Skip to content

Instantly share code, notes, and snippets.

View wilsonwc's full-sized avatar

Ross Wilson wilsonwc

View GitHub Profile
@wilsonwc
wilsonwc / functions.php
Created December 21, 2012 07:37
Wordpress shortcode for simply setting font size and color usage: [font size="20px" color="#333"]Some text[/font]
<?php
function font_shortcode( $atts, $content = null ) {
extract(shortcode_atts(array(
'size' => '',
'color' => '',
), $atts));
$size = ($size) ? ' font-size:'.$size : '';
$color = ($color) ? ' color:'.$color : '';
$out = '<span' .$target. ' style="' .$size.$color. '">' .do_shortcode($content). '</span>';
return $out;
@wilsonwc
wilsonwc / gist:4631605
Created January 25, 2013 03:49
This is a simple filter modification that allows you to have an index.html landing page for a wordpress site while you are developing the full site in the same directory.
remove_filter('template_redirect', 'redirect_canonical');
@wilsonwc
wilsonwc / main.js
Created April 30, 2013 23:50
Little hack to disable click events for non touch-enabled devices
if(!Modernizr.touch){
$('a[href^="tel"]').click(function(){return false;});
}
@wilsonwc
wilsonwc / social-count.php
Last active December 18, 2015 10:49
Get and cache twitter follower count in php and wordpress
<?php
function update_facebook_count() {
$name = 'giantsydney';
$optionName = $name . '_facebook_followers';
$url = 'https://graph.facebook.com/'.$name;
$fb = @json_decode(file_get_contents($url));
$count = number_format($fb->likes);
add_option($optionName);
update_option($optionName, $count);
}
@wilsonwc
wilsonwc / stateMock.js
Created January 10, 2014 17:24
Angular Mock for properly resolving ui-router $state in Karma unit tests
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
@wilsonwc
wilsonwc / functions.php
Created October 20, 2014 17:07
Put Yoast SEO metabox below all other boxes
add_filter( 'wpseo_metabox_prio', 'filter_yoast_seo_metabox' );
function filter_yoast_seo_metabox() {
return 'low';
}