Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
@GaryJones
GaryJones / distributor-post-modifier.php
Created March 30, 2026 10:58
Distributor Post Modifier plugin for WordPress VIP
<?php
/**
* Plugin Name: Distributor Post Modifier
* Description: Modifies pulled posts to show excerpts and link to original sources.
* Version: 1.0.0
* Author: Automattic
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
@GaryJones
GaryJones / distributor-auto-pull.php
Created March 30, 2026 10:58
Distributor Auto Pull plugin for WordPress VIP
<?php
/**
* Plugin Name: Distributor Auto Pull
* Description: Automatically pulls posts from external sites using the Distributor plugin.
* Version: 1.0.0
* Author: Automattic
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
@GaryJones
GaryJones / distributor-auto-pull.php
Last active June 12, 2025 23:08
Custom plugins for the Distributor WordPress plugin to automatically fetch and publish posts every 5 minutes, and modify the created post as a link post format with the original URL has the post link.
<?php
/**
* Plugin Name: Distributor Auto Pull
* Description: Automatically pulls posts from external sites using the Distributor plugin.
* Version: 1.0.0
* Author: Automattic
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
@GaryJones
GaryJones / js.js
Created January 5, 2015 12:54
Gravity Forms Countries dropdown with country codes
var countryCodes = {
'Afghanistan': '93',
'Albania': '355',
'Algeria': '213',
'American Samoa': '684',
'Andorra': '376',
'Angola': '244',
'Antigua and Barbuda': '1-268',
'Argentina': '54',
'Armenia': '374',
@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 / gist:5271998
Created March 29, 2013 16:41
Genesis workflow using GitFlow.

Genesis Framework workflow on GitHub

General procedure is to follow the established GitFlow model.

Initial Setup

Assuming the move happens right after 2.0.0 is released.

  • All SVN tags moved in as Git Tags.
  • Code SVN tagged as 2.0.0 moved to Git master branch
  • Git master branch is branched to develop.

If work after 2.0.0 has already been committed to SVN trunk, then SVN trunk is moved to Git develop branch instead.

<?php
/**
* Plugin Name: Day-of-the-Month Filter
* Description: Adds a day-of-the-month filter to the posts list table in wp-admin.
* Version: 1.0.0
* Author: Gary Jones
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
@GaryJones
GaryJones / notes.md
Last active October 24, 2023 19:12
Add PHPCS + WPCS to Sublime Text 3

Install PHP_CodeSniffer (PHPCS) via git

You can use the .phar for PHPCS, but it's easier to pull the repo down from git to then choose what version to use.

cd ~
mkdir -p code
cd code
git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs
@GaryJones
GaryJones / .htaccess
Last active October 6, 2023 08:35
Security Headers
<IfModule mod_headers.c>
# HSTS - force redirect to HTTPS at the browser level.
# Submit for Chrome preload list at https://hstspreload.appspot.com/
# Header always set Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload" env=HTTPS
# X-Xss-Protection
Header always set X-XSS-Protection "1; mode=block"
# Stop clickjacking by only allowing us to frame our own site
Header always set X-Frame-Options "SAMEORIGIN"
@GaryJones
GaryJones / phpmd.xml
Created September 12, 2014 15:04
PHPMD Ruleset for a WordPress Theme
<?xml version="1.0"?>
<ruleset name="phpmd.xml"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHPMD Ruleset for a WordPress Theme</description>
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/StaticAccess" />