Skip to content

Instantly share code, notes, and snippets.

View tomjn's full-sized avatar
🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
View GitHub Profile
@tomjn
tomjn / gist:4148899
Created November 26, 2012 15:51 — forked from jmdodd/gist:4055427
Set Twitter language for WordPress oEmbeds
global $wp_version;
if ( version_compare( $wp_version, '3.5', 'ge' ) ) {
if ( !function_exists( 'ucc_oembed_twitter_lang' ) ) {
function ucc_oembed_twitter_lang( $provider, $url, $args ) {
if ( stripos( $url, 'twitter.com' ) ) {
if ( defined( 'WPLANG' ) )
$lang = strtolower( WPLANG );
if ( empty( $lang ) )
$lang = 'en';
@tomjn
tomjn / remove_jetpack_menu_order.php
Last active December 9, 2015 22:18
Disables Jetpacks menu reordering code
<?php
/*
Plugin Name: Jetpack Menu Weight
Plugin URI: http://tomjn.com
Description: Fixes the broken Jetpack menu reordering by removing it
Author: Tom J Nowell
Contributors: TJNowell
Version: 1.0
Author URI: http://tomjn.com
*/
@tomjn
tomjn / gist:4551786
Last active December 11, 2015 05:19
hmmm initialise in the loop start, loop_end shouldn't ever be called without loop_start
<?php
add_action( 'loop_start', 'qd_loop_start' );
add_action( 'loop_end', 'qd_loop_end' );
function qd_loop_start( $query ) {
global $query_depth;
if(!isset($query_depth)){
$query_depth = 0;
}
@tomjn
tomjn / gist:4593910
Created January 22, 2013 11:21
Displaying html5 audio controls in WordPress
<audio controls>
<source src="<?php echo wp_get_attachment_url(); ?>" type="<?php echo get_post_mime_type(); ?>">
Your browser does not support the audio tag.
</audio>
@tomjn
tomjn / gist:4996601
Last active December 14, 2015 00:09 — forked from anonymous/gist:4996553
<?php
if ( function_exists( 'contact_detail' ) ) {
$chair = contact_detail( 'chair' );
$address = contact_detail( 'address' );
}
@tomjn
tomjn / gist:5005743
Created February 21, 2013 16:05
csswizardry-grids example
<div class="grid">
<div class="grid__item one-whole lap-one-half desk-two-thirds">
...
</div>
<div class="grid__item one-whole lap-one-half desk-one-third">
...
</div>
@tomjn
tomjn / gist:5151708
Created March 13, 2013 12:41
Change the text of the local indicator
<?php
function indicator_helloworld( $indicator_text ) {
return 'Hello World!!!';
}
add_action( 'tomjn_indicator_text', 'indicator_helloworld' );
@tomjn
tomjn / gist:5151718
Created March 13, 2013 12:42
Change the local indicator colour
<?php
function indicator_colour( $indicator_colour ) {
return 'yellow';
}
add_action( 'tomjn_indicator_colour', 'indicator_colour' );
Have you tried using git to do that?
@tomjn
tomjn / shortcode.php
Last active December 16, 2015 09:09 — forked from r-a-y/shortcode.php
Always ommit trailing php close tags, indent correctly, and remove the IDE unfriendly shorthand
<?php
if ( ! function_exists( 'shortcode_exists' ) ) {
/**
* Check if a shortcode is registered in WordPress.
*
* Examples: shortcode_exists( 'caption' ) - will return true.
* shortcode_exists( 'blah' ) - will return false.
*/
function shortcode_exists( $shortcode = false ) {
global $shortcode_tags;