Skip to content

Instantly share code, notes, and snippets.

View peterchester's full-sized avatar

Peter Chester peterchester

View GitHub Profile
@peterchester
peterchester / gist:7504965aae068513b8c8
Created June 25, 2014 23:48
MvcImageResize - Mat's Fabulous WordPress Image Resizer
<?php
/*
Plugin Name: Mat's Fabulous Image Resizer
Description: Peter has hacked Mat's image resizer a bit to make it a stand alone plugin for the sake of team testing & inspection.
*/
/**
* Manage Image resizing on the fly to prevent a bunch of uneeded image sizes for every image uploaded
* Includes support for the Wp Smush.it plugin and will run the smush on all image sizes when generating the thumbnails. This also allow for smushing image larger than 1mb when
* using cropped sizes less than 1MB
@peterchester
peterchester / gdoc-backup.sh
Created July 16, 2014 23:54
Bash script for backing up selected google docs on a mounted google drive. Copies the files to new files with "BACKUP YYYY-MM-DD" added to the file name.
#! /bin/bash
# Google Drive path
BASEDIR='/Users/xxxx/Google Drive/'
# Files to backup
FILES=(
'Some Folder on Your Drive/Some Spreadsheet.gsheet'
'Some Other Folder on Your Drive/Some Doc.gdoc'
)
@peterchester
peterchester / gist:6bcbae502dc946bc8a63
Created February 3, 2015 20:51
show-blog-belongs-to.php
<?php
/*
Plugin Name: Show User's Blogs
Description: Adds a list of what blogs a user belongs to to the user table.
Version: 1.0
Author: Modern Tribe, Inc.
*/
if(!class_exists('Show_Blog_Belongs')) {
class Show_Blog_Belongs {
public function __construct() {
@peterchester
peterchester / gist:d2833d354e2af5d8dca4
Last active August 29, 2015 14:17
Git Info WP Plugin
<?php
/*
Plugin Name: Git Info
Plugin URI: https://github.com/jbrinley/wp-git-deploy
Description: Git info (abstracted from jbrinley's git deploy plugin)
Author: Modern Tribe, Inc.
Author URI: http://tri.be
Contributors: jbrinley
Version: 1.0
*/
@peterchester
peterchester / tribe-common-libraries.class.php
Created March 20, 2012 11:47
WordPress library management
<?php
/**
* Class for managing overlapping helper plugins. This ensures that we use the latest versions of common code.
*
* Usage: include this file on any plugin that may have shared code BEFORE the 'plugins_loaded' action is completed.
* After including this file, register the helper files using the TribeCommonLibraries::register() instead of including the files directly.
*
* @author Peter Chester
* @version 1.0
*/
@peterchester
peterchester / object-cache.php.diff
Created May 27, 2012 23:49
Xcache Object Cache update to account for versions of Xcache prior to 1.3
Index: object-cache.php
===================================================================
--- object-cache.php (revision 548800)
+++ object-cache.php (working copy)
@@ -92,8 +92,8 @@
public function __construct() {
global $table_prefix;
- if ( !function_exists( 'xcache_get' ) ) {
- wp_die( 'You do not have XCache installed, so you cannot use the XCache object cache backend. Please remove the <code>object-cache.php</code> file from your content directory.' );
@peterchester
peterchester / wp-supercache.diff
Created May 28, 2012 06:02
Wp-supercache fixes to various PHP Notices
diff --git a/wp-content/plugins/wp-super-cache/plugins/badbehaviour.php b/wp-content/plugins/wp-super-cache/plugins/badbehaviour.php
index 6c07488..478dd85 100644
--- a/wp-content/plugins/wp-super-cache/plugins/badbehaviour.php
+++ b/wp-content/plugins/wp-super-cache/plugins/badbehaviour.php
@@ -66,7 +66,7 @@ function wp_supercache_badbehaviour_admin() {
<label><input type="radio" name="cache_badbehaviour" value="0" <?php if( !$cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<p><?php _e( '', 'wp-super-cache' ); ?></p><?php
echo '<p>' . sprintf( __( '(Only legacy caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p>';
- if ($changed) {
+ if ( isset( $changed ) && $changed ) {
@peterchester
peterchester / wp-cache-phase2.php.diff
Created May 29, 2012 23:21
More wp-super-cache notice fixes
diff --git a/wp-content/plugins/wp-super-cache/wp-cache-phase2.php b/wp-content/plugins/wp-super-cache/wp-cache-phase2.php
index 739512e..86f6086 100644
--- a/wp-content/plugins/wp-super-cache/wp-cache-phase2.php
+++ b/wp-content/plugins/wp-super-cache/wp-cache-phase2.php
@@ -59,7 +59,7 @@ function wp_cache_phase2() {
return false;
}
- if ( $wp_cache_object_cache && !empty( $_GET ) ) {
+ if ( isset( $wp_cache_object_cache ) && $wp_cache_object_cache && !empty( $_GET ) ) {
@peterchester
peterchester / hyper-cache-php-notice-fix.diff
Created June 6, 2012 04:49
Fix php notices in WordPress Hyper Cache
diff --git a/wp-content/plugins/hyper-cache/cache.php b/wp-content/plugins/hyper-cache/cache.php
index e3e1dbf..647fa55 100644
--- a/wp-content/plugins/hyper-cache/cache.php
+++ b/wp-content/plugins/hyper-cache/cache.php
@@ -125,7 +125,7 @@ if ($hyper_data['type'] == 'home' || $hyper_data['type'] == 'archive') {
// Valid cache file check ends here
-if ($hyper_data['location']) {
+if (isset($hyper_data['location']) && $hyper_data['location']) {
@peterchester
peterchester / hyper-cache-site-option.diff
Created June 6, 2012 08:47
Hyper Cache Site Option
diff --git a/wp-content/plugins/hyper-cache/options.php b/wp-content/plugins/hyper-cache/options.php
index 9daa572..cbc1e7e 100644
--- a/wp-content/plugins/hyper-cache/options.php
+++ b/wp-content/plugins/hyper-cache/options.php
@@ -1,6 +1,6 @@
<?php
-$options = get_option('hyper');
+$options = hyper_get_options();