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 April 19, 2021 23:12
Apply superfish enhancement to usual Genesis menus with different settings.
<?php
// For Genesis 2.0.0 and later:
add_filter( 'genesis_superfish_args_url', 'prefix_superfish_args_url' );
/**
* Filter in URL for custom Superfish arguments.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/change-superfish-arguments
@GaryJones
GaryJones / functions.php
Created March 27, 2013 23:37
Insert ads or other content after specific paragraph in single post content. The second function here would be easily re-usable for inserting additional bits and pieces do whatever content under whatever conditions (e.g. Cinema tickets competition link after 3rd paragraph of Movie CPT).
<?php
add_filter( 'the_content', 'prefix_insert_post_ads' );
/**
* Insert code for ads after second paragraph of single post content.
*
* @param string $content Post content
*
* @return string Amended content
*/
@GaryJones
GaryJones / strip-image-meta-data-on-upload.php
Created November 3, 2020 11:09
WordPress: Strip image meta data (except ICC profile) on file upload
<?php
add_filter( 'wp_handle_upload', 'foo_strip_metadata_from_images_on_upload' );
/**
* Overwrite the uploaded image with a new version that has no metadata.
*
* @param array $upload Array containing:
* - file: The path to the image file.
* - url: The URL to the image.
* - type: The MIME type of the image.
@GaryJones
GaryJones / nav-extras.php
Last active April 30, 2020 15:14 — forked from studiopress/nav-extras.php
Add Genesis Primary Nav Extras features in manually.
<?php
// Don't include the above <?php when copying
add_filter( 'wp_nav_menu_items', 'prefix_primary_nav_extras', 10, 2 );
/**
* Filter menu items, appending either a search form or today's date.
*
* @param string $menu HTML string of list items.
* @param stdClass $args Menu arguments.
@GaryJones
GaryJones / functions.php
Created January 30, 2012 23:58
Add post_terms shortcode (Genesis pre-1.4.2)
<?php
add_shortcode( 'post_terms', 'child_post_terms_shortcode' );
/**
* Add linked post taxonomy terms via shortcode.
*
* Not needed since Genesis 1.4.2 as it exists in Genesis.
* @author Ade Walker and Gary Jones
* @link http://code.garyjones.co.uk/post-taxonomy-terms-shortcode/
*
@GaryJones
GaryJones / gist:3685285
Created September 9, 2012 16:04
Minimum ARIA accessible menu.
<div role="navigation">
<ul role="menubar" aria-label="Menu Bar">
<li role="presentation" tabindex="0">
<a href="item-1.html" role="menuitem" id="nav-item-1" aria-haspopup="true">Item 1</a>
<ul role="menu" aria-expanded="false" aria-hidden="true" aria-labelledby="nav-item-1">
<li role="presentation"><a href="item-1-1.html" role="menuitem">Item 1.1</a></li>
<li role="presentation"><a href="item-1-2.html" role="menuitem">Item 1.2</a></li>
<li role="presentation"><a href="item-1-3.html" role="menuitem">Item 1.3</a></li>
</ul>
</li>
@GaryJones
GaryJones / readme.md
Last active July 14, 2019 20:46
Custom Featured Post Widget plugin: Skeleton for amending the output of the Genesis Featured Post widget.
@GaryJones
GaryJones / RedirectsCept.php
Last active May 20, 2019 15:21
Codeception 301 Redirection Tests
<?php
$I = new RedirectsTester($scenario);
$I->wantTo('check 301 redirects are working');
// First, test /login/ page gets rewritten to https://
$I->seePermanentRedirectToHttpsFor('login/');
$I->seePermanentRedirectToHttpsFor('login/?redirect_to=foo');
@GaryJones
GaryJones / gist:5648951
Created May 25, 2013 12:46
Genesis 2.0b1 rtl.css. Add this file as rtl.css to root of child themes, then install RTL Tester plugin, and switch to RTL.
/* WARNING - Please read the notice below:
This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances. Please do all modifications in the form of a child theme.
Copy the contents of this file to the child theme. Do not use @import, as the CSS included with Genesis might change in the future.
*/
body {
direction: rtl;
unicode-bidi: embed;
<?php
// Create color style options
add_theme_support( 'genesis-style-selector', array(
'theme-blue' => __( 'Blue', 'your-child-theme-text-domain' ),
'theme-green' => __( 'Green', 'your-child-theme-text-domain' ),
'theme-orange' => __( 'Orange', 'your-child-theme-text-domain' ),
'theme-red' => __( 'Red', 'your-child-theme-text-domain' ),
) );