'#373737',
'default-image' => get_template_directory_uri() . '/img/bg-main.png',
) );
/**
* Enable support for automatic feed links.
*/
add_theme_support( 'automatic-feed-links' );
/**
* Enable support for Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
/**
* Register our two theme menus.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'eventbrite-event' ),
'secondary' => __( 'Secondary Menu', 'eventbrite-event' ),
) );
}
add_action( 'after_setup_theme', 'eventbrite_single_setup' );
/**
* Global theme script enqueing
*
*/
if ( ! function_exists( 'eventbrite_single_enqueue_scripts' ) ) {
function eventbrite_single_enqueue_scripts() {
// Main theme stylesheet
wp_enqueue_style( 'eventbrite-event-style', get_stylesheet_uri() );
// Google Fonts
wp_enqueue_style( 'eventbrite-event-cutive' );
wp_enqueue_style( 'eventbrite-event-raleway' );
// Main theme script
wp_enqueue_script( 'eventbrite-event-main', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), '20130915', true );
// Bootstrap scripts
wp_enqueue_script( 'eventbrite-event-carousel', get_template_directory_uri() . '/js/bootstrap/bootstrap-carousel.js', array(), '20130915', true );
wp_enqueue_script( 'eventbrite-event-collapse', get_template_directory_uri() . '/js/bootstrap/bootstrap-collapse.js', array(), '20130915', true );
wp_enqueue_script( 'eventbrite-event-tooltip', get_template_directory_uri() . '/js/bootstrap/bootstrap-tooltip.js', array(), '20130915', true );
wp_enqueue_script( 'eventbrite-event-popover', get_template_directory_uri() . '/js/bootstrap/bootstrap-popover.js', array(), '20130915', true );
// Modernizr
wp_enqueue_script( 'eventbrite-event-modernizr', get_template_directory_uri() . '/js/libs/modernizr.min.js', array(), '20140304', false );
// Inline reply script for comments
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'eventbrite_single_enqueue_scripts' );
}
/**
* Register Google Fonts
*/
function eventbrite_single_google_fonts() {
/* translators: If there are characters in your language that are not supported
by Raleway, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Raleway font: on or off', 'eventbrite-event' ) ) {
wp_register_style( 'eventbrite-event-raleway', "https://fonts.googleapis.com/css?family=Raleway:400,800" );
}
/* translators: If there are characters in your language that are not supported
by Cutive, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Cutive font: on or off', 'eventbrite-event' ) ) {
wp_register_style( 'eventbrite-event-cutive', "https://fonts.googleapis.com/css?family=Cutive" );
}
}
add_action( 'init', 'eventbrite_single_google_fonts' );
//sidebars
function eventbrite_single_register_sidebars() {
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'eventbrite-event' ),
'id' => 'sidebar-1',
'description' => __( 'Appears on posts and pages in the sidebar.', 'eventbrite-event' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'eventbrite_single_register_sidebars' );
/**
* Custom comment callback template
*
* @param type $comment
* @param type $args
* @param type $depth
*/
function eventbrite_single_comment_template( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
?>
id="div-comment-">
format( $date_format );
}
/**
* Get the formatted price and name for tickets of an event
*
* @param array $tickets
* @return array ticket price/name information
*/
function eventbrite_single_get_event_tickets( $tickets ) {
$prices = array();
foreach ( $tickets as $ticket ) {
$price = $ticket->ticket->display_price;
$name = $ticket->ticket->name;
if ( '0.00' == $price )
$price = _x( 'free', 'ticket price', 'eventbrite-event' );
else
$price = sprintf( _x( '$%01.2f', 'ticket price', 'eventbrite-event' ), $price );
$prices[] = compact( 'price', 'name' );
}
return $prices;
}
/**
* Get a string describing the price for an event's ticket(s)
*
* @param array $tickets
* @return string ticket price. or events with multiple tickets, the lowest
* price followed by text noting higher priced tickets.
*/
function eventbrite_single_get_event_ticket_price_string( $tickets ) {
// Bail if we don't have proper ticket info.
if ( ! is_array( $tickets ) || empty( $tickets ) ) {
return false;
}
$prices = array();
$lowest_price_key = 0;
$price_description = '';
// Build an array of ticket prices for this event.
foreach ( $tickets as $ticket ) {
if ( true === $ticket->free ) {
$prices[] = array(
'value' => 0,
'display' => 'Free',
);
} else {
$prices[] = array(
'value' => $ticket->cost->value,
'display' => $ticket->cost->display,
);
}
}
// Determine our pricing description.
if ( 1 == count( $prices ) ) {
// Check if the only ticket is free.
if ( 0 === $prices[0]['value'] ) {
$price_description = _x( 'Free', 'ticket price', 'eventbrite-parent' );
} else {
$price_description = $prices[0]['display'];
}
}
// We've got multiple ticket prices.
else {
// Find the lowest priced ticket.
foreach ( $prices as $key => $price ) {
if ( $price['value'] < $prices[$lowest_price_key]['value'] ) {
$lowest_price_key = $key;
}
}
// Set the description according to the lowest priced ticket.
$price_description = sprintf( _x( '%s and up', 'ticket price', 'eventbrite-parent' ),
$prices[$lowest_price_key]['display']
);
}
return $price_description;
}
/**
* Get a string representing the timespan of an event
*
* @param object $event
* @return string
*/
function eventbrite_single_get_event_date_timespan( $event, $occurrence = 0 ) {
if ( ! is_object( $event ) )
return new WP_Error( 'event_not_set', esc_html__( "The event variable is expected to be an object." ) );
try {
$tz = new DateTimeZone( $event->start->timezone );
} catch( Exception $e ) {
return new WP_Error( 'bad_datetimezone', $e->getMessage() );
}
if ( 0 < (int) $occurrence && is_array( $event->repeat_schedule ) && isset( $event->repeat_schedule[$occurrence] ) ) {
$event_occurrence = $event->repeat_schedule[$occurrence];
$event_start_date = $event_occurrence->start_date;
$event_end_date = $event_occurrence->end_date;
} else {
$event_start_date = $event->start->local;
$event_end_date = $event->end->local;
}
try {
$start_date = new DateTime( $event_start_date, $tz );
} catch( Exception $e ) {
return new WP_Error( 'bad_datetime', $e->getMessage() );
}
try {
$end_date = new DateTime( $event_end_date, $tz );
} catch( Exception $e ) {
return new WP_Error( 'bad_datetime', $e->getMessage() );
}
if ( $start_date->format( 'mdY' ) === $end_date->format( 'mdY' ) ) {
$date_format_start = 'l, F j, Y \f\r\o\m g:i A';
$date_format_end = '\t\o g:i A';
} else {
$date_format_start = 'l, F j, Y \a\t g:i A';
$date_format_end = '- l, F j, Y \a\t g:i A';
}
$time_zone_transitions = $tz->getTransitions();
$time_zone_string = $time_zone_transitions[0]['abbr'];
return sprintf( _x( '%s %s (%s)', 'event timespan: statdate, end date, (time zone)', 'eventbrite-event' ), $start_date->format( $date_format_start ), $end_date->format( $date_format_end ), $time_zone_string );
}
/**
* Get the events for month and year of the venue set in the admin
*
* @param int $month numeric value of the month
* @param int $year year
* @return type
*/
function eventbrite_single_get_monthly_events( $month, $year ) {
$venue_id = eventbrite_services_get_setting( 'venue-id', 'all' );
$organizer_id = eventbrite_services_get_setting( 'organizer-id', 'all' );
$venue_events = Voce_Eventbrite_API::get_user_events( array(
'venue' => $venue_id,
'organizer' => $organizer_id
) );
$calendar_events = eventbrite_single_filter_events_by_month($month, $year, $venue_events);
return $calendar_events;
}
/**
* Builds the calendar control for the specified month and year
*
* @param int $month numeric value of the month
* @param int $year year
* @return type
*/
function eventbrite_single_get_calendar_of_events( $month, $year ) {
$month_events = eventbrite_single_get_monthly_events( $month, $year );
$calendar = Calendar::factory( $month, $year );
$calendar->standard( 'today' )->standard( 'prev-next' );
foreach ( $month_events as $month_event ) {
$start_date = new DateTime( $month_event->event->start_date );
$end_date = new DateTime( $month_event->event->end_date );
$start_time = $start_date->format( 'g:ia' );
$end_time = $end_date->format( 'g:ia' );
$eb_event_url = eventbrite_single_get_eventbrite_single_event_url( $month_event->event, 'wpcalendar' );
$wp_event_url = eventbrite_single_get_wp_event_url( $month_event->event );
$event_popover_url = $eb_event_url;
if ( $wp_event_url )
$event_popover_url = $wp_event_url;
$format_string = '%1$s - %2$s%4$s';
$output = sprintf( $format_string,
esc_html( $start_time ),
esc_html( $end_time ),
esc_url( $event_popover_url ),
esc_html( $month_event->event->title ),
esc_html( eventbrite_single_get_event_ticket_price_string( $month_event->event->tickets ) ),
esc_html( eventbrite_single_get_event_excerpt( $month_event->event->description, 20 ) ),
esc_html( $month_event->event->title ),
esc_url( $eventbrite_single_event_url ),
__( 'Buy', 'eventbrite-event' )
);
$event = $calendar->event()
->condition( 'timestamp', $start_date->format( 'U' ) )
->title( esc_html( $month_event->event->title ) )
->output ( $output );
$calendar->attach( $event );
$diff = date_diff( $start_date, $end_date );
$days_diff = (int) $diff->format( '%a' );
if ( $days_diff ) {
$start_day = (int) $start_date->format( 'Ymd' );
$event_title = $month_event->event->title . _x( ' - cont.', 'calendar', 'eventbrite-event' );
$output = sprintf( $format_string,
esc_html( $start_time ),
esc_html( $end_time ),
esc_url( $event_popover_url ),
esc_html( $event_title ),
esc_html( eventbrite_single_get_event_ticket_price_string( $month_event->event->tickets ) ),
esc_html( eventbrite_single_get_event_excerpt( $month_event->event->description, 20 ) ),
esc_html( $month_event->event->title ),
esc_url( eventbrite_single_get_eventbrite_single_event_url( $month_event->event, 'wpcalendar' ) ),
__( 'Buy', 'eventbrite-event' )
);
$counter = 0;
while ( $counter < $days_diff ) {
$counter += 1;
$event = $calendar->event()
->condition( 'timestamp', strtotime( $start_day + $counter ) )
->title( esc_html( $month_event->event->title ) )
->output( $output );
$calendar->attach( $event );
}
}
}
return $calendar;
}
/**
* Retrieve the event's Eventbrite URL, with the referrer value replaced
*
* @param object $event
* @return string
*/
function eventbrite_single_get_eb_event_url( $event, $refer = 'wplink' ) {
$url = '';
if ( empty( $event->url ) ) {
return $url;
} else {
$url = $event->url;
}
if ( $refer )
$url = add_query_arg( 'ref', $refer, $url );
return $url;
}
/**
* Get the page id set in the eventbrite settings
*
* @param string $type the type to get based on the setting name
* @return mixed false if the page isn't set or doesn't exist or the url
*/
function eventbrite_single_get_page_id( $type ) {
return eventbrite_services_get_setting( "{$type}-page-id", false );
}
/**
* Function to get the page link for pages set in the eventbrite settings,
* if a page is used with page_on_front we can still utilize the page's
* original url for a base.
*
* An important use for this function is if a user sets the "Events" page as the
* "page on front" to preserve the original link for use with single events.
*
* @param string $type the type to get based on the setting name
* @return string
*/
function eventbrite_single_get_eventbrite_page_link( $ebpage ) {
global $wp_rewrite;
if ( ! $ebpage )
return false;
$rewrite = $wp_rewrite->get_page_permastruct();
if ( ! empty( $rewrite ) && ( get_post_status( $ebpage ) == 'publish' ) ) {
$event_page_link = str_replace( '%pagename%', get_page_uri( $ebpage ), $rewrite );
$event_page_link = home_url( $event_page_link );
$event_page_link = user_trailingslashit( $event_page_link, 'page' );
} else {
$event_page_link = home_url( '?page_id=' . $ebpage->ID );
}
return $event_page_link;
}
/**
* Get the url for an Eventbrite selected page
*
* @param string $type the type to get based on the setting name
* @return mixed false if the page isn't set or doesn't exist or the url
*/
function eventbrite_single_get_page_url( $type ) {
$eb_page_id = eventbrite_single_get_page_id( $type );
if ( ! $eb_page_id )
return false;
$eb_page = get_post( $eb_page_id );
if ( ! $eb_page )
return false;
$eb_page_link = eventbrite_single_get_eventbrite_page_link( $eb_page );
return $eb_page_link;
}
/**
* Output a block of HTML like page-loop for a given page title
*/
function eventbrite_single_page_content_block( $page_title ) {
$page = get_page_by_title( $page_title );
if ( ! is_null( $page ) ) :
setup_postdata( $page );
?>
%2$s';
$update_time = '';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) )
$update_time = '';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
printf( __( 'Posted on %3$s', 'eventbrite-event' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
);
if ( !empty($update_time) ) {
$update_time = sprintf( $update_time,
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
printf( __( ' Updated on %3$s', 'eventbrite-event' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$update_time
);
}
}
function eventbrite_single_filter_events_by_month( $month, $year, $venue_events ) {
$filtered_events = array();
foreach( $venue_events as $venue_event ) {
$start_time = strtotime( $venue_event->event->start_date );
$date = getdate( $start_time );
if ( ( $date['mon'] == $month ) && ( $date['year'] == $year ) )
$filtered_events[] = $venue_event;
}
return $filtered_events;
}
/**
* Load the specified template if the currently queried object id matches the
* given page id
*
* @param int $page_id the ID of the page to match
* @param int $queried_object_id the currently queried object's id
* @param string $template template path relative to theme dir
*/
function eventbrite_single_maybe_include_template( $page_id, $queried_object_id, $template ) {
if ( $page_id && $page_id === $queried_object_id ) {
do_action( 'eventbrite_single_template_redirect', $page_id, $queried_object_id, $template );
include( get_stylesheet_directory() . '/' . $template );
die();
}
}
function eventbrite_single_the_attached_image() {
$next_id = null;
$post = get_post();
$attachment_size = apply_filters( 'eventbrite_single_attachment_size', array( 1200, 1200 ) );
$next_attachment_url = wp_get_attachment_url();
if ( $post->post_parent ) {
/**
* Grab the IDs of all the image attachments in a gallery so we can get the
* URL of the next adjacent image in a gallery, or the first image (if
* we're looking at the last image in a gallery), or, in a gallery of one,
* just the link to that image file.
*/
$attachment_ids = get_posts( array(
'post_parent' => $post->post_parent,
'fields' => 'ids',
'numberposts' => 999,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID'
) );
// If there is more than 1 attachment in a gallery...
if ( is_countable( $attachment_ids ) && 1 < count( $attachment_ids ) ) {
foreach ( $attachment_ids as $idx => $attachment_id ) {
if ( $attachment_id == $post->ID ) {
$next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ];
break;
}
}
// get the URL of the next image attachment...
if ( $next_id )
$next_attachment_url = get_attachment_link( $next_id );
// or get the URL of the first image attachment.
else
$next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
}
}
printf( '%3$s',
esc_url( $next_attachment_url ),
the_title_attribute( array( 'echo' => false ) ),
wp_get_attachment_image( $post->ID, $attachment_size )
);
}
function eventbrite_single_caption_shortcode( $val, $attr, $content = null ) {
$width = null;
$id = null;
$align = null;
$sc_atts = shortcode_atts( array(
'id' => '',
'align' => 'aligncenter',
'width' => '',
'caption' => ''
), $attr );
extract( $sc_atts );
if ( 1 > (int) $width || empty( $caption ) )
return $val;
$capid = '';
if ( $id ) {
$id = esc_attr( $id );
$capid = 'id="figcaption_'. $id . '" ';
$id = 'id="' . $id . '" aria-labelledby="figcaption_' . $id . '" ';
}
return '';
}
add_filter( 'img_caption_shortcode', 'eventbrite_single_caption_shortcode', 10, 3 );
/**
* Add eventbrite info to title
* @param string $title
* @return string
*/
function eventbrite_single_wp_title( $title ) {
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
return $title;
}
add_filter( 'wp_title', 'eventbrite_single_wp_title', 10, 2 );
/**
* Displays navigation to next/previous set of posts when applicable.
*/
function eventbrite_single_paging_nav( $args = array() ) {
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
$default = array(
'base' => $pagenum_link,
'format' => $format,
'total' => $GLOBALS['wp_query']->max_num_pages,
'current' => $paged,
'mid_size' => 1,
'add_args' => http_build_query( $query_args ),
'prev_text' => __( '← Previous', 'eventbrite-event' ),
'next_text' => __( 'Next →', 'eventbrite-event' ),
'type' => 'list'
);
$paginate_links_args = wp_parse_args( (array) $args, $default );
$paginate_links_args = array_intersect_key( $paginate_links_args, $default );
// Don't print empty markup if there's only one page.
if ( $paginate_links_args['total'] < 2 )
return;
$links = paginate_links( $paginate_links_args );
if ( $links ) :
?>
venue ) )
return false;
$venue = $event->venue;
$venue_info = array();
// formulate full address to easily output
$venue_full_add = array();
if ( ! empty( $venue->name ) )
$venue_full_add['line-1'] = $venue->name;
if ( ! empty( $venue->address->address_1 ) )
$venue_full_add['line-2'] = $venue->address->address_1;
if ( ! empty( $venue->address->address_2 ) )
$venue_full_add['line-3'] = $venue->address->address_2;
$venue_city_state = array();
if ( ! empty( $venue->city ) )
$venue_city_state[] = $venue->city;
if ( ! empty( $venue->region ) )
$venue_city_state[] = $venue->region;
// ZIP info is missing from the new (v3) API at this point (July 8, 2014)
// $venue_zip = ( ! empty( $venue->postal_code ) ) ? $venue->postal_code : '';
// if ( $venue_city_state || $venue_zip )
// $venue_full_add['line-4'] = implode( ', ', $venue_city_state ) . ' ' . $venue_zip;
$venue_info['mailing-address'] = $venue_full_add;
return $venue_info;
}
/**
* Get the Google Map URL for the venue.
*
* @param object $event
* @return string A valid Google Map URL for the venue
*/
function eventbrite_single_get_venue_google_map_url( $event = false ) {
// Bail if we have no event to work with, or can't check the user's API key.
if ( ! $event || empty( $event->venue ) || ! class_exists( 'Voce_Settings_API' ) ) {
return false;
}
$api_key = eventbrite_services_get_google_maps_api_key();
$venue = $event->venue;
$google_map = false;
if ( is_object( $venue ) && $api_key ) {
$lat = isset( $venue->latitude ) ? $venue->latitude : false;
$long = isset( $venue->longitude ) ? $venue->longitude : false;
$parameters = array();
if ( $lat && $long ) {
$parameters[] = $lat;
$parameters[] = $long;
} else {
if ( isset( $venue->address ) ) {
$address = ( ! empty( $venue->address->address_1 ) ) ? $venue->address->address_1 : '';
if ( isset( $venue->address->address_2 ) )
$address .= ' ' . $venue->address->address_2;
$parameters[] = $address;
}
if ( ! empty( $venue->address->city ) ) {
$parameters[] = $venue->address->city;
}
if ( ! empty( $venue->address->region ) ) {
$parameters[] = $venue->address->region;
}
if ( ! empty( $venue->address->country ) ) {
$parameters[] = $venue->address->country;
}
if ( ! empty( $venue->address->postal_code ) ) {
$parameters[] = $venue->address->postal_code;
}
}
if ( $parameters ) {
$google_map = 'https://www.google.com/maps/embed/v1/place';
$location = implode( ',', $parameters );
$google_map = add_query_arg( 'q', $location, $google_map );
$google_map = add_query_arg( 'zoom', 13, $google_map );
$google_map = add_query_arg( 'key', $api_key, $google_map );
}
}
return $google_map;
}
/**
* redirect to selected Eventbrite page templates
*/
function eventbrite_single_event_template_redirect() {
if ( class_exists( 'Voce_Eventbrite_API' ) && Voce_Eventbrite_API::get_auth_service() ) {
$dynamic_pages = eventbrite_single_get_dynamic_pages();
if ( $dynamic_pages ) {
foreach ( $dynamic_pages as $key => $template ) {
$queried_object_id = get_queried_object_id();
eventbrite_single_maybe_include_template( eventbrite_services_get_setting( "{$key}-page-id", false ), $queried_object_id, $template );
}
}
}
}
add_action( 'template_redirect', 'eventbrite_single_event_template_redirect' );
function eventbrite_single_set_theme_single_event() {
// Only allow a single featured event
add_filter( 'eventbrite-settings_single-featured-event' , '__return_true' );
}
add_action( 'admin_init', 'eventbrite_single_set_theme_single_event' );
/**
* Register the widgets used by the theme, if available in the activated Eventbrite plugin.
*/
function eventbrite_single_event_register_widgets() {
if ( class_exists( 'Eventbrite_Introduction_Widget' ) ) {
register_widget( 'Eventbrite_Introduction_Widget' );
}
if ( class_exists( 'Eventbrite_Register_Ticket_Widget' ) ) {
register_widget( 'Eventbrite_Register_Ticket_Widget' );
}
}
add_action( 'widgets_init', 'eventbrite_single_event_register_widgets' );
/**
* Suggested default pages for the event theme
* @param type $default_pages
* @return array
*/
function eventbrite_single_event_default_pages( $default_pages ) {
$event_pages = array(
'attend-event' => array(
'title' => __( 'Attend Event', 'eventbrite-event' )
),
'event-info' => array(
'title' => __( 'Event Info', 'eventbrite-event' )
),
);
$event_pages = array_merge( $default_pages, $event_pages );
return $event_pages;
}
add_filter( 'eventbrite_default_pages', 'eventbrite_single_event_default_pages' );
/**
* dynamic pages
*
* @return array
*/
function eventbrite_single_get_dynamic_pages() {
return array(
'event-info' => 'template-single-event.php',
'attend-event' => 'template-attend-event.php',
);
}
/**
* Get the WordPress event info URL
*
* @param object $event
* @return string
*/
function eventbrite_single_get_wp_event_url( $event ) {
$events_page_url = eventbrite_single_get_page_url( 'event-info' );
if ( ! $events_page_url )
return '';
return $events_page_url;
}
/**
* Filter to handle the customized (events/posts) search template query, forcing no paging when search "events" to allow
* "events" paging and halving posts_per_page when initial searching
* @global WP_Object $wp_query
* @param string $search
* @param WP_Object $query
* @return string
*/
function eventbrite_single_multi_event_search( $search, $query ) {
global $wp_query;
if ( is_search() && ! is_admin() ) {
if ( isset( $_REQUEST['type'] ) ) {
// Force no paging so a 404 does not occur when paging through "events"
if ( 'events' == $_REQUEST['type'] ) {
$wp_query->is_paged = false;
}
} else {
// Only display half the results on the initial search
$query->query_vars['posts_per_page'] = ceil( get_option( 'posts_per_page' ) / 2 );
}
}
return $search;
}
add_filter( 'posts_search', 'eventbrite_single_multi_event_search', 10 , 2 );
/**
* Set the content width global.
*/
if ( ! isset( $content_width ) ) {
$content_width = 705;
}
/**
* Adds support for a custom header image.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Load our Eventbrite theme options.
*/
require get_template_directory() . '/inc/theme-options.php';
/**
* Load Eventbrite widgets.
*/
require get_template_directory() . '/inc/widgets.php';