Skip to content

Instantly share code, notes, and snippets.

View jo-snips's full-sized avatar

Jonah West jo-snips

View GitHub Profile
@jo-snips
jo-snips / search-post-type.php
Created March 9, 2012 17:49
Wordpress: Include Post Types in Search
// Define what post types to include in search
function include_in_search( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', array( 'post', 'page', 'feed', 'tribe_events' ));
}
return $query;
}
add_filter( 'the_search_query', 'include_in_search' );
@jo-snips
jo-snips / event-category-list.php
Created March 12, 2012 03:21
The Events Calendar: List Event Categories
<?php
$terms = get_terms("tribe_events_cat");
$count = count($terms);
if ( $count > 0 ){
echo '<ul class="events-cat-menu">';
foreach ( $terms as $term ) {
echo '<li class="cat_'. $term->slug .'"><a href="'. get_term_link($term->slug, 'tribe_events_cat') .'">' . $term->name . '</a></li>';
}
echo '</ul>';
}
@jo-snips
jo-snips / deregister-register.php
Created March 13, 2012 03:46
The Events Calendar: Deregister/Register Scripts
add_action('wp_enqueue_scripts', 'example_enqueue_scripts');
function example_enqueue_scripts() {
wp_dequeue_script('tribe-events-calendar-script');
}
add_action('wp_footer', 'custom_events_script');
function custom_events_script() {
wp_register_script('tribe-custom-calendar-script', get_bloginfo('stylesheet_directory') .'/events/events.js', array('jquery'), '1.0', true); // see http://codex.wordpress.org/Function_Reference/wp_enqueue_script for full details
wp_print_scripts('tribe-custom-calendar-script');
}
@jo-snips
jo-snips / alternate-date-display.php
Created March 13, 2012 04:14
The Events Calendar: Alternate Single Event Date Display
<?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?>
<dt class="event-label event-label-date"><?php _e('Date:', 'tribe-events-calendar') ?></dt>
<dd class="event-meta event-meta-date"><meta itemprop="startDate" content="<?php echo tribe_get_start_date(null, false, 'Y-m-d'); ?>"/><?php echo tribe_get_start_date(null, false, 'F j, Y'); ?></dd>
<dt class="event-label event-label-start"><?php _e('Time:', 'tribe-events-calendar') ?></dt>
<dd class="event-meta event-meta-start"><meta itemprop="startDate" content="<?php echo tribe_get_start_date(null, false, 'h:i:s'); ?>"/><?php echo tribe_get_start_date(null, false, 'g:ia'); ?> to <meta itemprop="endDate" content="<?php echo tribe_get_end_date( null, false, 'h:i:s' ); ?>"/><?php echo tribe_get_end_date(null, false, 'g:ia'); ?></dd>
<?php } else { ?>
<dt class="event-label event-label-date"><?php _e('Date:', 'tribe-events-calendar') ?></dt>
<dd class="event-meta event-meta-date"><meta itemprop="startDate" content="<?php echo tribe_get_start_dat
@jo-snips
jo-snips / gist:2026901
Created March 13, 2012 05:00 — forked from luetkemj/wp-query-ref.php
WordPress: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@jo-snips
jo-snips / genesis-search-inpute-text.php
Created March 14, 2012 04:24
Genesis: Filter Search Input Text
/*-------------------------------------------------------------------------------
Filter Search Box Text
-------------------------------------------------------------------------------*/
add_filter( 'genesis_search_text', 'custom_search_text' );
function custom_search_text($text) {
return esc_attr('Enter keywords, hit enter;');
}
@jo-snips
jo-snips / alternate-page-title.php
Created March 15, 2012 16:53
The Events Calendar: Alternate Page Title
<h2>
<?php
if(tribe_is_month()) {
echo 'Calendar Grid';
} else if(tribe_is_event() && !tribe_is_day() && !is_single()) {
echo 'Event List';
} else if(tribe_is_event() && !tribe_is_day() && is_single()) {
echo 'Single Event';
} else if(tribe_is_day()) {
@jo-snips
jo-snips / thesis-body-classes.php
Created March 19, 2012 21:04
Thesis: Filter Body Classes
// Add a class for styling
function add_classes($classes) {
if('tribe_events' == get_post_type()) {
if ( is_single() && !tribe_is_showing_all() ) { // single event
$classes[] = 'single-event';
} elseif ( tribe_is_upcoming() || tribe_is_past() || tribe_is_day() || (is_single() && tribe_is_showing_all()) ) { // list view
$classes[] = 'list';
} else { // grid view
@jo-snips
jo-snips / exclude-categories-from-calendar.php
Created March 20, 2012 22:50
The Events Calendar: Exclude Category Events from Calendar
add_action( 'pre_get_posts', 'exclude_events_category' );
function exclude_events_category( $query ) {
if ( $query->query_vars['eventDisplay'] == 'month' && $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'tax_query', array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
'terms' => array('2012'),
'operator' => 'IN'
@jo-snips
jo-snips / private-events-patch.php
Created March 21, 2012 16:24
The Events Calendar: Patch for Private Events
public function getEvents( $args = '' ) {
$tribe_ecp = TribeEvents::instance();
// Determine if user can read private events. If so, pass private events by default, otherwise hide them.
global $current_user;
if (user_can( $current_user->ID, 'read_private_tribe_events' )) {
$defaults = array(
'posts_per_page' => tribe_get_option( 'postsPerPage', 10 ),
'post_type' => TribeEvents::POSTTYPE,
'orderby' => 'event_date',