Skip to content

Instantly share code, notes, and snippets.

Avatar

Ross Wilson wilsonwc

View GitHub Profile
@wilsonwc
wilsonwc / functions.php
Created Oct 20, 2014
Put Yoast SEO metabox below all other boxes
View functions.php
add_filter( 'wpseo_metabox_prio', 'filter_yoast_seo_metabox' );
function filter_yoast_seo_metabox() {
return 'low';
}
@wilsonwc
wilsonwc / stateMock.js
Created Jan 10, 2014
Angular Mock for properly resolving ui-router $state in Karma unit tests
View stateMock.js
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 / social-count.php
Last active Dec 18, 2015
Get and cache twitter follower count in php and wordpress
View social-count.php
<?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 / main.js
Created Apr 30, 2013
Little hack to disable click events for non touch-enabled devices
View main.js
if(!Modernizr.touch){
$('a[href^="tel"]').click(function(){return false;});
}
@wilsonwc
wilsonwc / gist:4631605
Created Jan 25, 2013
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.
View gist:4631605
remove_filter('template_redirect', 'redirect_canonical');
@wilsonwc
wilsonwc / functions.php
Created Dec 21, 2012
Wordpress shortcode for simply setting font size and color usage: [font size="20px" color="#333"]Some text[/font]
View functions.php
<?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;