Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
@GaryJones
GaryJones / envira-gallery-tweak.php
Created February 11, 2014 09:01
Envira Gallery tweak
@GaryJones
GaryJones / gist:8430080
Created January 15, 2014 03:08
References for Why Not to Use Singleton Design Pattern
http://www.youtube.com/watch?v=-FRm3VPhseI Google's Clean Code Talks
http://blog.gordon-oheim.biz/2011-01-17-Why-Singletons-have-no-use-in-PHP/
http://sebastian-bergmann.de/archives/882-Testing-Code-That-Uses-Singletons.html
http://eamann.com/tech/making-singletons-safe-in-php/
http://hakre.wordpress.com/2012/06/10/the-missing-patterns-of-the-php-manual/#p2
http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140827.aspx
http://www.phptherightway.com/pages/Design-Patterns.html ("You should be wary when using the singleton pattern, as by its very nature it introduces global state into your application, reducing testability.")
http://www.practicaldesignpatternsinphp.com/ ("The Singleton Pattern is perhaps the most well known - and most often misused - pattern in all of PHP design pattern development. Its simplicity, combined with its seeming benefits makes it a widely-used (and overused) pattern. The Singleton is not so much a recommended pattern, as a pattern I recommend you shy away from.")
http://www.sli
@GaryJones
GaryJones / gravity-au.php
Last active April 27, 2016 15:54 — forked from thewebprincess/gravity-au.php
Australian address format for Gravity Forms.
<?php
add_filter( 'gform_address_types', 'your_plugin_slug_australian_address' );
/**
* Set Gravity Forms custom addresses for Australia.
*
* @since 1.0.0
*
* @param array $address_types Existing address formats.
* @param int $form_id Form ID.
@GaryJones
GaryJones / my-plugin1.php
Last active January 1, 2016 10:49
Usage examples for Gamajo_Dashboard_Glancer
<?php
// Require the new class (change to your correct path)
if ( ! class_exists( 'Gamajo_Dashboard_Glancer' ) ) {
require plugin_dir_path( 'includes/class-gamajo-dashboard-glancer.php' );
}
// Hook into the widget (or any hook before it!) to register your items.
add_action( 'dashboard_glance_items', 'prefix_add_dashboard_counts' );
function prefix_add_dashboard_counts() {
@GaryJones
GaryJones / class-gamajo-template-loader.php
Created December 9, 2013 16:17
Separate out the template loader class into a generic class for all plugins, and a specific one for this plugin.
<?php
/**
* Template Loader for Plugins
*
* @package Template_Loader_For_Plugins
* @author Gary Jones
* @link http://gamajo.com/template-loader
* @copyright 2013 Gary Jones
* @license GPL-2.0+
*/
<?php
/**
* Add Extra Code to Any Menu
* @author Bill Erickson
* @link http://www.billerickson.net/customizing-wordpress-menus/
*
* @param string $menu
* @param object $args
* @return string modified menu
*/
@GaryJones
GaryJones / gist:7183071
Last active December 26, 2015 16:49 — forked from salcode/gist:7164690
<?php
/*
* Examples to add custom classes to Genesis WordPress Framework Markup when using HTML5 output
*/
add_action( 'genesis_setup', 'srf_add_cust_classes', 15 ); // Priority 15 ensures it runs after Genesis itself has setup.
function srf_add_cust_classes() {
add_filter( 'genesis_attr_site-inner', 'srf_attr_site_inner' );
add_filter( 'genesis_attr_content-sidebar-wrap', 'srf_attr_content_sidebar_wrap' );
add_filter( 'genesis_attr_content', 'srf_attr_content' );
add_filter( 'genesis_attr_sidebar-primary', 'srf_attr_sidebar_primary' );
@GaryJones
GaryJones / functions.php
Last active May 27, 2017 18:13
Genesis: Stop archives from using first attached image as fallback when no featured image is set.
<?php
// Don't include the above.
add_filter( 'genesis_get_image_default_args', 'prefix_stop_auto_featured_image' );
/**
* Stop Genesis archives from using first attached image as fallback when no featured image is set.
*
* @param array $args Default image arguments.
*
@GaryJones
GaryJones / gist:7057100
Last active December 25, 2015 23:29
WordPress: Allow anchor target attribute in user biography field.
<?php
// Don't include the above
add_filter( 'wp_kses_allowed_html', 'georgef_allow_anchor_target_attribute_in_biography', 20, 2 );
/**
* Allow links to have a target attribute in user biographical information.
*
* @author Gary Jones
* @link http://www.studiopress.com/forums/topic/about-the-author-box-can-open-links-in-new-window/