Skip to content

Instantly share code, notes, and snippets.

View jeremyclark13's full-sized avatar

Jeremy Clark jeremyclark13

View GitHub Profile
@jeremyclark13
jeremyclark13 / gist:6617363
Created September 18, 2013 23:49
Plugin update file with namespaced variables and functions. This assumes your namespace slug is 'my_cool_plugin'. There are two variables at the top of the file to namespace, and the two functions.
<?php
/*
Plugin Name: Test Plugin Update
Plugin URI: http://clark-technet.com
Description: Test plugin updates
Version: 0.9
Author: Jeremy Clark
Author URI: http://clark-technet.com
*/
@jeremyclark13
jeremyclark13 / gist:5554820
Created May 10, 2013 14:40
Calling a filter with an additional parameter.
<?php
/**
* Stores a value and calls any existing function with this value.
*/
class Filter_Storage
{
/**
* Filled by __construct(). Used by __call().
*
* @type mixed Any type you need.
@jeremyclark13
jeremyclark13 / twitter-functions.php
Last active December 14, 2015 15:49
Newly updated WordPress Twitter functions to work with API v1.1
<?php
/**
* Example of use. Create array with auth tokens from application created from https://dev.twitter.com/apps/new
*
*/
$twitter_auth = array(
'consumer_key' => 'pHUfo9zXAtCVjXrsfaetatA',
'consumer_secret' => '0oddga08872ptXqajjpqld6iVbHziaBHKLTzdq1o18c',
@jeremyclark13
jeremyclark13 / helpful-404.php
Created March 4, 2013 19:16
Display a helpful 404 page. With links to posts/pages/CPT related to url keywords.
<?php
/*
Plugin Name: Helpful 404 Page
Plugin URI: http://clark-technet.com/
Description: Displays helpful list of post/pages releated to the url on a 404 page. Simply edit 404 page and use echo helpful_404().
Author: Jeremy Clark
Author URI: http://clark-technet.com
Version: 1.0
Author URI:
*/
@jeremyclark13
jeremyclark13 / gist:4170117
Created November 29, 2012 16:21
Jetpack Infinite Scroll replace credit link on footer
add_filter( 'infinite_scroll_credit', 'your_footer_text' );
function your_footer_text() {
return '<a href="http://link_to_site">Credit Link</a>';
}
@jeremyclark13
jeremyclark13 / gist:4090632
Created November 16, 2012 20:29
Options Framework theme customizer
/**
* Front End Customizer
*
* WordPress 3.4 Required
*
* Search and replace theme_slug with your own theme slug.
*
*/
add_action( 'customize_register', 'theme_slug_customizer_register' );
@jeremyclark13
jeremyclark13 / plugin.php
Created November 16, 2012 19:26
Include templates from plugin
define( 'PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
//Template fallback
add_filter( "template_include", 'ps_theme_redirect' );
function ps_theme_redirect( $template ) {
//cpt is the slug of the custom post type registered
if ( get_post_type() == 'cpt' ) {
if ( is_single() ) {
//looks in the current theme directory for the template if so it is returned otherwise the template from the plugin directory is returned.
@jeremyclark13
jeremyclark13 / gist:2481191
Created April 24, 2012 16:25
WordPress simple twitter follower count function
<?php
/**
* Simple twitter feed
*
* @param string $user user of twitter feed to retrieve.
*
* @return string of formatted API data
*/
function twitter_followers($user = 'clarktechnet'){
@jeremyclark13
jeremyclark13 / gist:2471214
Created April 23, 2012 14:21
WordPress simple twitter feed function
<?php
/**
* Simple WordPress Twitter feed
*
*
* @param string $user user of twitter feed to retrieve.
* @param string $count number of tweets to retrive.
*
* Inspiration for code:
* Chip Bennet's oenology theme https://github.com/chipbennett/oenology
@jeremyclark13
jeremyclark13 / gist:2470972
Created April 23, 2012 13:36
New function wp_get_theme for WordPress 3.4
<?php
$theme_data;
if (function_exists('wp_get_theme')){
$theme_data = wp_get_theme('theme-name');
$theme_uri = $theme_data->ThemeURI;
$author_uri = $theme_data->Author_URI;
} else {
$theme_data = (object) get_theme_data(get_template_directory() . '/style.css');
$theme_uri = $theme_data->URI;
$author_uri = $theme_data->AuthorURI;