Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
@Pross
Pross / functions.php
Last active December 14, 2015 10:19
Delete transients older than 7 days.
<?php
class PurgeTransients {
var $expire = '7 days';
function __construct(){
add_action( 'admin_init', array( &$this, 'init' ) );
}
function init(){
$this->purge( $this->expire );
@Pross
Pross / gist:5081498
Created March 4, 2013 10:53
Simple continue reading filter
add_filter( 'continue_reading_link_text', 'add_my_continue' );
function add_my_continue() {
return 'Continue Reading <i class="icon-beer"></i>';
}
@Pross
Pross / functions.php
Created March 4, 2013 10:58
Add signature to post/pages with the_content filter
add_filter( 'the_content', 'add_my_signature' );
function add_my_signature( $content ){
if( ! is_single() ) // if were not on a post/page just return the content.
return $content;
$sig = '<br />Thanks for reading!'; // Add a sig to the post/page content and return.
return $content . $sig;
}
@Pross
Pross / functions.php
Created March 4, 2013 11:02
Add some shortcode to footer.
add_action( 'wp_footer', 'add_my_footer_shortcode' );
function add_my_footer_shortcode(){
echo do_shortcode( '[some_shortcode]' );
}
@Pross
Pross / functions.php
Created March 4, 2013 11:07
Remove fixed nav logo with a filter.
add_action( 'navbar_brand', 'remove_fixed_navbar_logo' );
function remove_fixed_navbar_logo(){
return '';
}
@Pross
Pross / functions.php
Created March 4, 2013 11:13
Change logo image for one post/page with filter.
add_action( 'pagelines_logo_url', 'change_logo_url' );
function change_logo_url( $url ){
// $url contains original image url.
// lets change the image for one page.
global $post;
if( 96 == $post->ID )
$url = 'http://placekitten.com/g/200/300';
return $url;
}
@Pross
Pross / justcss_functions.php
Created March 7, 2013 16:38
fixed header image
<?php
/**
* Include all the theme support
*/
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
add_theme_support( 'post-thumbnails' );
add_custom_background();
add_editor_style( 'css/editor-style.css' );
add_image_size( 'random-thumb', 125, 125 );
@Pross
Pross / gist:5111864
Created March 7, 2013 21:16
You MUST add this to cron.php: define( 'CRMCRON', true );
<?php
// Add this to wp-content/mu-plugins/crm.php
if( class_exists( 'CRM_Utils_System_WordPress' ) ) {
class Fix_CRM_Cron extends CRM_Utils_System_WordPress {
function __construct() {
if( ! defined( 'CRMCRON' ) )
return;
add_filter('template', array( &$this, 'change_theme') );
@Pross
Pross / functions.php
Created March 8, 2013 11:23
open features in new window
add_filter( 'pagelines_features_target', create_function('', "return 'target=\"_blank\"';") );
@Pross
Pross / cache.php
Created March 19, 2013 22:45
Simple file cache
<?php
class Cache {
function __construct( $format = '' ) {
$this->format = $format;
$this->cache_life = '1200';
$this->cache_file = 'cache/' . md5( $_SERVER['REQUEST_URI'] );;
// check exists....