Skip to content

Instantly share code, notes, and snippets.

@jchristopher
jchristopher / gist:2998780
Created Jun 26, 2012
AppleScript: iTerm tail PHP error log
View gist:2998780
tell application "iTerm"
activate
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
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
<?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
jchristopher / gist:4217475
Last active Oct 13, 2015
Attachments - New Instance
View gist:4217475
<?php
function my_attachments( $attachments )
{
$args = array(
// title of the meta box (string)
'label' => 'My Attachments',
// all post types to utilize (string|array)
@jchristopher
jchristopher / gist:4217483
Created Dec 5, 2012
Attachments - Retrieve Attachments Data
View gist:4217483
<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
<ul>
<?php while( $attachments->get() ) : ?>
<li>
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
jchristopher / terra-nova-location-snippet.scss
Last active Dec 11, 2015
This is a snippet referenced in http://mondaybynoon.com/20130114/css3-pseudo-elements-box-shadows-hidpi-retina-geometric-shapes/ 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: http://mondaybynoon.com/20130114/css3-pseudo-elements-box-shadows-hidpi-retina-geometric-shapes/
// for project: http://terranovachurch.org
.locations .wrapper {
height:210px;
&:after {
// implement the brackets
content:' ';
@jchristopher
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
<?php
/**
* 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
jQuery(document).ready(function($){
if(location.hash){
if($(location.hash)){
setTimeout(function(){
var targetTop = $('#content').offset().top;
targetTop -= $('#header').height() + $('#nav').height() - 23;
$('body,html').scrollTop(targetTop);
@jchristopher
jchristopher / gist:6524511
Last active Jan 23, 2016
Enable debugging in SearchWP
View gist:6524511
<?php
/**
* Enable debugging in SearchWP
* Messages are logged to searchwp-debug.txt in your uploads folder
*/
add_filter( 'searchwp_debug', '__return_true' );
@jchristopher
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
<?php
function myForumIncludeIds( $ids, $engine, $terms )
{
if( $engine != 'my_forum_supplemental_engine' )
return $ids;
// set your forum ID
$forumID = 900;
@jchristopher
jchristopher / gist:6798262
Created Oct 2, 2013
SearchWP snippet to limit results to the current category page being viewed
View gist:6798262
<?php
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