Skip to content

Instantly share code, notes, and snippets.

@jchristopher
jchristopher / gist:2998780
Created June 26, 2012 20:38
AppleScript: iTerm tail PHP error log
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 September 5, 2012 15:56
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.
<?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 October 13, 2015 15:37
Attachments - New Instance
<?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 December 5, 2012 17:04
Attachments - Retrieve Attachments Data
<?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 December 11, 2015 02:28
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.
// 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 March 20, 2013 16:36
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
<?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()
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 January 23, 2016 01:14
Enable debugging in SearchWP
<?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 September 14, 2013 02:46
Use SearchWP's Supplemental Search Engine feature to limit search results to a single bbPress Forum
<?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 October 2, 2013 18:25
SearchWP snippet to limit results to the current category page being viewed
<?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