Skip to content

Instantly share code, notes, and snippets.

View invmatt's full-sized avatar

Matt Saxon invmatt

View GitHub Profile
@invmatt
invmatt / twitterauth.php
Last active June 21, 2018 16:56
Simple PHP Twitter AUTH. You'll need to include https://github.com/abraham/twitteroauth for OAuth
<?php
session_start();
require_once("twitteroauth/twitteroauth/twitteroauth.php"); //Path to twitteroauth library
$twitteruser = "twitterusername";
$notweets = 30;
$consumerkey = "12345";
$consumersecret = "123456789";
$accesstoken = "123456789";
$accesstokensecret = "12345";
@invmatt
invmatt / repeat_metabox.php
Created October 13, 2013 17:54
WP Custom repeatable metabox
<?php
echo '<ul class="iv-slider">';
$sliders = get_post_meta( get_the_id(), 'gp', false );
foreach ( $sliders as $slider ) {
echo '<li class="iv-slide">';
echo '<h3>'.$slider["iv-slider-title"].'</h3>';
echo '<p>'.$slider["iv-slider-desc"].'</p>';
echo wp_get_attachment_image(array_shift($slider["iv-slider-img"]));
@invmatt
invmatt / meta-slider.php
Created October 14, 2013 11:28
Metabox function for repeat_metabox.php
<?php
function iv_slider_metabox( array $meta_boxes ) {
$fields = array(
array( 'id' => 'iv-slider-title', 'name' => 'Text input field', 'type' => 'text' ),
array( 'id' => 'iv-slider-desc', 'name' => 'WYSIWYG field', 'type' => 'wysiwyg', 'options' => array( 'editor_height' => '100' ) ),
array( 'id' => 'iv-slider-img', 'name' => 'File field', 'type' => 'file', 'file_type' => 'image', 'repeatable' => 1, 'sortable' => 1 ),
);
@invmatt
invmatt / gitignore.txt
Created October 25, 2013 16:07
Base .gitignore file
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
(function($) {
$.rdCalendar = function(element, options) {
var plugin = this,
$element = $(element),
defaults = {
region : 'en',
monthNames: 'monthNamesShort',
dayNames: 'dayNamesShort',
template: '<h2><%= month %><%= year %> | <a class="navigate" href="#prev">prev</a> | <a class="navigate" href="#next">next</a></h2><table class="calendar"><thead><tr><% for (var i = 0, l = days.length; i < l; i++) { %><th><%= days[i] %></th><% } %></tr></thead><tbody><% var rows = dates.length/7, cols=7; for (var x = 0, d = 0; x < rows; x++) { %><tr><% for (var y = 0; y < cols; y++) { var date = dates[d++]; %><% if (date != null) { %><td><h3 class="day"><span class="num"><%= date.date %></span></h3><% if (date.events.length > 0) { %><ul><% for (var e = 0, l = date.events.length; e < l; e++) {%><li><a href=""><%= date.events[e].name %></a></li><% } %></ul><% } %></td><% } else { %><td></td><% } %><% } %></tr><% } %></tbody></table>',
@invmatt
invmatt / html5-starter.html
Last active December 26, 2015 17:08
Base starter html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="A description about your site" />
<meta name="keywords" content="keywords, separated, by, comma" />
<title>Untitled Document</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="css/style.css" media="screen" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
@invmatt
invmatt / quick_start.css
Last active December 29, 2015 15:29
A very basic reset, grid and layout helper, useful for rapid development / testing
/*------------------------------------*\
$RESET
\*------------------------------------*/
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
@invmatt
invmatt / match_twitter_handle.php
Last active December 30, 2015 05:49
Retrieve the JSON tweet text and replace all @username with links to profile. (using https://docs.google.com/file/d/0B6SP5Ft5Ty22SmJjSE9WOHh0RmM/edit?pli=1)
<?php
// Match Twitter handles and create a link to the profile
$string = $value["text"];
$input = preg_replace('/(?<=^|\s)@([a-z0-9_]+)/i', '<a href="http://www.twitter.com/$1">@$1</a>', $string);
echo $input;
?>
@invmatt
invmatt / wp-remove-howdy.php
Created December 20, 2013 14:34
Remove "Howdy" from Wordpress admin bar
<?
add_filter( 'gettext', 'change_howdy_text', 10, 2 );
function change_howdy_text( $translation, $original ) {
if( 'Howdy, %1$s' == $original )
$translation = 'Logged in as %1$s';
return $translation;
}
?>
@invmatt
invmatt / wp-check-sub-menu.php
Created February 8, 2014 22:52
Checks to see if the hierarchical submenu returns anything. If true output the left column else give the content a full width class.
<?php
$submenu = hierarchical_submenu($post);
if (!empty($submenu)) {
echo '
<div class="sidebar col-3-12">
'. $submenu .'
</div>
<section id="content" class="col-9-12" role="main">
';