Skip to content

Instantly share code, notes, and snippets.

@nathanrice
nathanrice / gist:9399581
Created March 6, 2014 21:03
Debug rogue redirects in WordPress
<?php
//* Debug redirect
add_filter( 'wp_redirect', function( $location ) {
if ( home_url() == $location ) {
print_r( debug_backtrace() );
return false;
}
@nathanrice
nathanrice / functions.php
Created August 2, 2013 20:05
Unit test for HTML5 support in WordPress 3.6
<?php
//* Only turn on HTML5 for comment list
add_theme_support( 'html5', array( 'comment-list' ) );
@nathanrice
nathanrice / .profile
Last active December 17, 2015 22:09
Convert GitHub issue into a Pull Request
# Replace [username] with your GitHub username (in both places).
# Replace [project]/[repository] with the project and repository where the issue resides.
# Replace [base] with the destination branch you wish to PR to (usually master or develop)
# And obviously, don't leave the [] brackets in there.
# Usage:
# @git-pr 999 features/999
@nathanrice
nathanrice / single-recipe.php
Created May 16, 2013 14:36
A sample single template for a Recipe CPT with Genesis
<?php
/**
* This file controls the single view of the Recipe CPT
*/
/**
* This is where you would put your custom mods. Just hook them (or unhook) to the proper location.
*/
genesis(); //* <-- Just make sure this is at the END of the file.
<?php
//** Redirect if not logged in
if ( ! is_user_logged_in() && 'wp-login.php' !== $pagenow ) {
wp_redirect( wp_login_url() );
exit;
}
@nathanrice
nathanrice / jetpack-open-graph-tags.php
Last active December 12, 2015 00:28
Use Genesis Doctitle and Meta Description with Jetpack's Open Graph tags on entry pages.
<?php
add_filter( 'jetpack_open_graph_tags', 'nr_jetpack_open_graph_tags_filter' );
/**
* Filter open graph tags to use Genesis doctitle and meta description instead.
*
* @author Nathan Rice
* @link https://gist.github.com/4683845
*/
function nr_jetpack_open_graph_tags_filter( $tags ) {