Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
@GaryJones
GaryJones / functions.php
Last active December 23, 2021 23:10
Wrap the last Genesis breadcrumb in a span for styling.
<?php
add_filter( 'genesis_build_crumbs', 'gj_wrap_last_breadcrumb', 10, 2 );
/**
* Wrap the last Genesis breadcrumb in a span for styling.
*
* @author Gary Jones
*
* @param array $crumbs Existing HTML markup for the breadcrumbs.
*
@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',
<?php
/**
* Get post image.
*/
function wds_get_post_image( $size = 'thumbnail' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $size );
@GaryJones
GaryJones / en_GB.po
Created November 14, 2014 23:11
WP Rocket en_GB.po
# Copyright (C) 2014 WP Rocket
# This file is distributed under the same license as the WP Rocket package.
msgid ""
msgstr ""
"Project-Id-Version: WP Rocket 2.3.6\n"
"Report-Msgid-Bugs-To: http://wp-rocket.me/\n"
"POT-Creation-Date: 2014-10-06 14:18:51+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
<?php
// Add a post signature for multiple authors.
// All signature divs will have a class of .signature for common styling
// then .signature-cat as the default and .signature-tracey for the guest
// as class modifiers (different background image, or background position
// if using sprites etc.)
// If it's not a single entry of any post type, return.
if ( is_single() ) {
return;
@GaryJones
GaryJones / big-brother.php
Created October 2, 2014 10:31
Big Brother eviction of @tarendai's Davina swear.
<?php
// Solution for https://github.com/Tarendai/davina
/**
* Remove filter or action method added from an unassigned object.
*
* Solves the immediate case. Not bothered to generalise it.
*
* @global array $wp_filter Storage for all of the filters and actions.
@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" />
@GaryJones
GaryJones / gist:cfe0f917f144da8c908e
Last active August 29, 2015 14:06
Gamajo Accessible Menu plugin
/**
* Gamajo Accessible Menu.
*
* Improves menu accessibility in two ways:
* * Adds a delay to submenus disappearing when moving the mouse away.
* * Makes submenus appear when tabbing through menu items with the keyboard.
*
* Kudos to Rian Rietveld for the code on which this plugin is based.
*
* After enqueueing this file (or concatenating it with your theme JS file),
@GaryJones
GaryJones / gist:635b1aaea8a45f6c8833
Created August 21, 2014 23:13
Can this SCSS be optimised to avoid the position static / left auto / opacity 1 duplication?
.genesis-nav-menu {
// ... other styles
.menu-item:hover,
.menu-item-hover {
position: static;
> .sub-menu { // Note the >
left: auto;
opacity: 1;
@GaryJones
GaryJones / gist:258eaa3eb74aa263d0c3
Created August 14, 2014 22:17
Example _site-navigation.scss for Genesis Sample. Only a starting point, so customise as needed!
// Navigation (.genesis-nav-menu)
$navigation-font-size: 16px !default;
$navigation-line-height: 1 !default;
$navigation-link-color: #000 !default;
$navigation-link-color-hover: #e5554e !default;
$navigation-link-padding: 30px 24px;
// Navigation submenus
$navigation-submenu-width: 200px;
$navigation-submenu-link-font-size: 14px !default;