Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
View GitHub Profile
View junction-fix.php
<?php
/*
Plugin Name: Junction fixes for plugins
Plugin URI: http://interconnectit.com/
Description: Junctioning files into the WordPess plug-ins folder causes problems with php 5.3 for plugin_url, this tries to fix it. Place in the wp-content/mu-plugins folder so it loads before all other plugins.
Author: James R Whitehead
Version: 0.0.0.0.0.0.2
Author URI: http://interconnectit.com
*/
@tomjn
tomjn / gist:3425191
Created Aug 22, 2012
GDocs Spreadsheet Check WordPress Sites for Updates
View gist:3425191
function getWPVersion(url){
var newurl = url + "/readme.html";
var hdoc = null;
try{
hdoc = UrlFetchApp.fetch(newurl);
if(hdoc.getResponseCode() != 200){
return "Cannot retrieve version";
}
}catch(e){
return "Cannot retrieve version";
@tomjn
tomjn / typekit.editor.php
Created Sep 10, 2012
Typekit fonts for TinyMCE editor plugin
View typekit.editor.php
add_filter("mce_external_plugins", "tomjn_mce_external_plugins");
function tomjn_mce_external_plugins($plugin_array){
$plugin_array['typekit'] = get_template_directory_uri().'/typekit.tinymce.js';
return $plugin_array;
}
@tomjn
tomjn / gist:3871705
Created Oct 11, 2012
PHP Levenshtein distance methods
View gist:3871705
class Example {
public function length(){
return 5;
}
public function __call($name,$arguments){
$methods = get_class_methods($this);
$ldist = 9999;
$currmethod = $name;
foreach($methods as $m){
$distance = levenshtein($name,$m);
@tomjn
tomjn / notify-on-media.php
Created Oct 18, 2012
WP - Notify via Email on creation of Attachment
View notify-on-media.php
<?php
/*
Plugin Name: Notify on Attachment Creation
Plugin URI: http://www.tomjn.com
Description: Send a notification when an attachment is created
Version: 1.04
Author: Tom J Nowell
Author URI: http://www.tomjn.com
*/
@tomjn
tomjn / sellwirecsv.php
Last active Oct 13, 2015
Grab product orders from Sellwire in PHP
View sellwirecsv.php
require 'PHP-Browser/browser.class.php';
function get_sellwire_csv( $username, $password, $project_id ) {
$browser = new Browser( 'SellWire Browser' );
$browser->navigate( 'http://app.sellwire.net/logout' );
$browser->navigate( 'http://app.sellwire.net/login' );
$form = $browser->getForm( '//form[@method]' );
$form->setAction( 'http://app.sellwire.net/login' );
$form->setAttributeByName( 'username', $username )->setAttributeByName( 'password', $password );
@tomjn
tomjn / gist:4148899
Created Nov 26, 2012 — forked from jmdodd/gist:4055427
Set Twitter language for WordPress oEmbeds
View gist:4148899
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 Dec 9, 2015
Disables Jetpacks menu reordering code
View remove_jetpack_menu_order.php
<?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 Dec 11, 2015
hmmm initialise in the loop start, loop_end shouldn't ever be called without loop_start
View gist:4551786
<?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 Jan 22, 2013
Displaying html5 audio controls in WordPress
View gist:4593910
<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>