Skip to content

Instantly share code, notes, and snippets.

jchristopher / gist:2998780
Created Jun 26, 2012
AppleScript: iTerm tail PHP error log
View gist:2998780
tell application "iTerm"
set t to (make new terminal)
tell t
tell (make new session at the end of sessions)
exec command "tail -f /Applications/MAMP/logs/php_error.log"
end tell
end tell
end tell
jchristopher / class.Iti_Walker_Flag_Parents.php
Created Sep 5, 2012
WordPress Menu items that have children are not flagged as such until visiting the permalink of a child link. This gist forces a custom Walker on all calls to wp_nav_menu that adds a class to parents out of the box.
View class.Iti_Walker_Flag_Parents.php
* Iti_Walker_Flag_Parents
* Adds a class of 'menu-item-parent' to all WordPress Menu items that have children
class Iti_Walker_Flag_Parents extends Walker_Nav_Menu
function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output)
jchristopher / gist:4217475
Last active Oct 13, 2015
Attachments - New Instance
View gist:4217475
function my_attachments( $attachments )
$args = array(
// title of the meta box (string)
'label' => 'My Attachments',
// all post types to utilize (string|array)
jchristopher / gist:4217483
Created Dec 5, 2012
Attachments - Retrieve Attachments Data
View gist:4217483
<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<?php while( $attachments->get() ) : ?>
ID: <?php echo $attachments->id(); ?><br />
Type: <?php echo $attachments->type(); ?><br />
Subtype: <?php echo $attachments->subtype(); ?><br />
URL: <?php echo $attachments->url(); ?><br />
jchristopher / terra-nova-location-snippet.scss
Last active Dec 11, 2015
This is a snippet referenced in that outlines how we can utilize pseudo-elements and box-shadows to get HiDPI-friendly geometic shapes into our designs without using images or extra markup.
View terra-nova-location-snippet.scss
// snippet referenced in:
// for project:
.locations .wrapper {
&:after {
// implement the brackets
content:' ';
jchristopher / gist:5206136
Created Mar 20, 2013
In an ideal world I'd love to be able to 'nest' meta_query arguments in WP_Query, but I realize the limitation in the structure of this gist being too loose to implement programmatically, but I'd like to think about ways to possibly accomplish something like this in a more efficient way than filtering posts_join
View gist:5206136
* My events have two Custom Fields, one for a start date and one for an end
* date. Start dates are required, but end dates are optional. That's because
* some events are one day only, while others might span multiple dates
* (e.g. conferences). Dates are stored in MySQL format.
* I want to pull events that meet these criteria:
* - Event has only a start date, and it's after NOW()
View gist:5877424
var targetTop = $('#content').offset().top;
targetTop -= $('#header').height() + $('#nav').height() - 23;
jchristopher / gist:6524511
Last active Jan 23, 2016
Enable debugging in SearchWP
View gist:6524511
* Enable debugging in SearchWP
* Messages are logged to searchwp-debug.txt in your uploads folder
add_filter( 'searchwp_debug', '__return_true' );
jchristopher / gist:6558425
Created Sep 14, 2013
Use SearchWP's Supplemental Search Engine feature to limit search results to a single bbPress Forum
View gist:6558425
function myForumIncludeIds( $ids, $engine, $terms )
if( $engine != 'my_forum_supplemental_engine' )
return $ids;
// set your forum ID
$forumID = 900;
jchristopher / gist:6798262
Created Oct 2, 2013
SearchWP snippet to limit results to the current category page being viewed
View gist:6798262
function mySearchIncludeIds( $ids, $engine, $terms )
// if we're viewing a category page and the SearchWP engine is the default engine
if( is_category() && $engine == 'default' ) {
$termID = get_queried_object_id(); // determine which category we're viewing
// get the IDs of all the posts in this category