name->text;
} else {
return '' . $event->name->text . '';
}
}
}
if ( ! function_exists( 'eventbrite_multi_event_meta' ) ) {
/**
* Output an event's date and price.
*
* @param object $event
* @return string
*/
function eventbrite_multi_event_meta( $event ) {
if ( ! is_object( $event ) ) {
return false;
}
/*
* Translators: %1$s = date, %2$s = price
*/
return sprintf( __( '%1$s | %2$s', 'eventbrite-venue' ),
'' . eventbrite_multi_get_event_date( $event->start->local, $event->start->timezone ) . '',
'' . eventbrite_multi_get_event_ticket_price_string( $event->ticket_classes ) . ''
);
}
}
if ( ! function_exists( 'eventbrite_multi_get_event_excerpt' ) ) {
/**
* Get an excerpt for an event description. Strips tags and trims words.
*
* @param string $text
* @param int $words number of words to return
* @return string
*/
function eventbrite_multi_get_event_excerpt( $text, $words = 40 ) {
return wp_trim_words( strip_tags( $text ), $words );
}
}
if ( ! function_exists( 'eventbrite_multi_get_event_date' ) ) {
/**
* Format an event date with the given timezone and optional format.
* Uses the blog's date format if $date_format is not specified.
*
* @param string $date Date string
* @param string $timezone Timezone in 'Americas/New York' format
* @param string $date_format
* @return string
*/
function eventbrite_multi_get_event_date( $date, $timezone, $date_format = '' ) {
if ( ! $date || ! $timezone ) {
return false;
}
if ( ! $date_format )
$date_format = get_option( 'date_format' );
$tz = new DateTimeZone( $timezone );
$dt = new DateTime( $date, $tz );
return $dt->format( $date_format );
}
}
/**
* 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_multi_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_multi_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() );
}
$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( $event_start_date, $event_end_date );
$time_zone_string = $time_zone_transitions[0]['abbr'];
return sprintf( _x( '%s %s (%s)', 'event timespan: statdate, end date, (time zone)', 'eventbrite-venue' ), $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_multi_get_monthly_events( $month, $year ) {
if ( ! class_exists( 'Voce_Eventbrite_API' ) ) {
return false;
}
$venue_id = eventbrite_services_get_setting( 'venue-id', 'all' );
$organizer_id = eventbrite_services_get_setting( 'organizer-id', 'all' );
$hide_private = eventbrite_services_get_setting( 'only-public-events' );
$venue_events = Voce_Eventbrite_API::get_user_events( array(
'venue' => $venue_id,
'organizer' => $organizer_id,
'hide_private' => $hide_private,
) );
$calendar_events = eventbrite_multi_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_multi_get_calendar_of_events( $month, $year ) {
$month_events = eventbrite_multi_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->start->local );
$end_date = new DateTime( $month_event->end->local );
$start_time = $start_date->format( 'g:ia' );
$end_time = $end_date->format( 'g:ia' );
$cta_text = eventbrite_services_get_setting( 'call-to-action' );
// if set to the 'Buy Tickets' option only use 'Buy' to preserve space in flyout
$cta_text = ( 'Buy Tickets' === $cta_text ) ? 'Buy' : $cta_text;
$eb_event_url = eventbrite_multi_get_eb_event_url( $month_event, 'wpcalendar' );
$wp_event_url = eventbrite_multi_get_wp_event_url( $month_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->name->text ),
esc_html( eventbrite_multi_get_event_ticket_price_string( $month_event->ticket_classes ) ),
esc_html( eventbrite_multi_get_event_excerpt( $month_event->description->text, 20 ) ),
esc_html( $month_event->name->text ),
esc_url( $eb_event_url ),
__( esc_html( $cta_text ), 'eventbrite-venue' )
);
$event = $calendar->event()
->condition( 'timestamp', $start_date->format( 'U' ) )
->title( esc_html( $month_event->name->text ) )
->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 = sprintf( _x( '%s - cont.', 'calendar', 'eventbrite-venue' ),
esc_html( $month_event->name->text )
);
$output = sprintf( $format_string,
esc_html( $start_time ),
esc_html( $end_time ),
esc_url( $event_popover_url ),
esc_html( $event_title ),
esc_html( eventbrite_multi_get_event_ticket_price_string( $month_event->ticket_classes ) ),
esc_html( eventbrite_multi_get_event_excerpt( $month_event->description->text, 20 ) ),
esc_html( $month_event->name->text ),
esc_url( eventbrite_multi_get_eb_event_url( $month_event, 'wpcalendar' ) ),
__( esc_html( $cta_text ), 'eventbrite-venue' )
);
$counter = 0;
while ( $counter < $days_diff ) {
$counter += 1;
$event = $calendar->event()
->condition( 'timestamp', strtotime( $start_day + $counter ) )
->title( esc_html( $month_event->name->text ) )
->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_multi_get_eb_event_url( $event, $refer = 'wplink' ) {
$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_multi_get_page_id( $type ) {
if ( class_exists( 'Voce_Eventbrite_API' ) ) {
return eventbrite_services_get_setting( "{$type}-page-id", false );
} else {
return 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_multi_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_multi_get_page_url( $type ) {
$eb_page_id = eventbrite_multi_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_multi_get_eventbrite_page_link( $eb_page );
return $eb_page_link;
}
/**
* Filter events by month and year
*
* @param string $month
* @param string $year
* @param object $venue_events
* @uses strtotime()
* @uses getdate()
* @return array
*/
function eventbrite_multi_filter_events_by_month( $month, $year, $venue_events ) {
$filtered_events = array();
foreach( $venue_events as $venue_event ) {
$start_time = strtotime( $venue_event->start->local );
$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_multi_maybe_include_template( $page_id, $queried_object_id, $template ) {
if ( $page_id && $page_id === $queried_object_id ) {
do_action( 'eventbrite_multi_template_redirect', $page_id, $queried_object_id, $template );
include( get_template_directory() . '/' . $template );
die();
}
}
/**
* Get the venue address elements.
*
* @param object $event
* @return array
*/
function eventbrite_multi_get_venue_address( $event ) {
if ( ! $event || empty( $event->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->address->city ) )
$venue_city_state[] = $venue->address->city;
if ( ! empty( $venue->address->region ) )
$venue_city_state[] = $venue->address->region;
// The Eventbrite API v3 might not have a ZIP data point yet (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_multi_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
*
* @uses Voce_Eventbrite_API::get_auth_service()
* @uses eventbrite_multi_get_dynamic_pages()
* @uses get_queried_object_id()
* @uses eventbrite_multi_maybe_include_template()
* @uses eventbrite_services_get_setting()
*/
function eventbrite_multi_event_template_redirect() {
if ( class_exists( 'Voce_Eventbrite_API' ) && Voce_Eventbrite_API::get_auth_service() ) {
$dynamic_pages = eventbrite_multi_get_dynamic_pages();
if ( $dynamic_pages ) {
foreach ( $dynamic_pages as $key => $template ) {
$queried_object_id = get_queried_object_id();
eventbrite_multi_maybe_include_template( eventbrite_services_get_setting( "{$key}-page-id", false ), $queried_object_id, $template );
}
}
}
}
add_action( 'template_redirect', 'eventbrite_multi_event_template_redirect' );
/**
* Register the widgets used by the theme, if available in the activated Eventbrite plugin.
*
* @uses register_widget()
*/
function eventbrite_multi_register_widgets() {
if ( class_exists( 'Eventbrite_Introduction_Widget' ) ) {
register_widget( 'Eventbrite_Introduction_Widget' );
}
if ( class_exists( 'Eventbrite_Multi_Just_Announced_Widget' ) ) {
register_widget( 'Eventbrite_Multi_Just_Announced_Widget' );
}
}
add_action( 'widgets_init', 'eventbrite_multi_register_widgets' );
/**
* Suggested default pages for the event theme
*
* @param array $default_pages
* @return array
*/
function eventbrite_multi_event_default_pages( $default_pages ) {
$venue_pages = array(
'events-list' => array(
'title' => __( 'Events List', 'eventbrite-venue' )
),
'featured-events-list' => array(
'title' => __( 'Featured Events List', 'eventbrite-venue' )
),
'calendar' => array(
'title' => __( 'Calendar', 'eventbrite-venue' )
),
'about' => array(
'title' => __( 'About', 'eventbrite-venue' )
)
);
$venue_pages = array_merge( $venue_pages, $default_pages );
return $venue_pages;
}
add_filter( 'eventbrite_default_pages', 'eventbrite_multi_event_default_pages' );
/**
* Get the theme's dynamic pages.
*
* @return array
*/
function eventbrite_multi_get_dynamic_pages() {
return array(
'events' => 'event.php',
'upcoming-events' => 'upcoming-events.php',
'calendar' => 'template-calendar.php',
);
}
/**
* Get the WordPress event URL.
*
* @param object $event
* @uses eventbrite_multi_get_page_url()
* @return string
*/
function eventbrite_multi_get_wp_event_url( $event ) {
$events_page_url = eventbrite_multi_get_page_url( 'events' );
if ( ! $events_page_url )
return '';
$event_url = sprintf( '%s%s/', $events_page_url, $event->id );
return $event_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
* @uses is_search()
* @uses is_admin()
* @uses is_paged()
* @uses query_vars()
* @uses get_option()
* @return string
*/
function eventbrite_multi_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_multi_multi_event_search', 10 , 2 );
/**
* Given a page url, removes the home url from it and the trailing slash.
*
* @param string $page_url
* @uses get_home_url()
* @return string base of the page
*/
function eventbrite_multi_get_page_base( $page_url ) {
return ltrim( str_replace( get_home_url(), '', $page_url ) , '/' );
}
/**
* Flush rewrite rules.
*
* @param string $service
* @uses flush_rewrite_rules()
*/
function eventbrite_multi_flush_rewrite_rules( $service ) {
if ( 'eventbrite' === $service )
flush_rewrite_rules( true );
}
add_action( 'keyring_connection_verified', 'eventbrite_multi_flush_rewrite_rules' );
/**
* Clean up rewrites when removing Eventbrite connection.
*
* @param string $service
* @uses remove_filter()
* @uses eventbrite_multi_flush_rewrite_rules()
*/
function eventbrite_multi_keyring_connection_deleted( $service ) {
// do not want to set the rewrites when we remove the eventbrite keyring connection
if ( 'eventbrite' === $service ) {
remove_filter( 'rewrite_rules_array', 'eventbrite_multi_add_rewrite_rules' );
eventbrite_multi_flush_rewrite_rules( $service );
}
}
add_action( 'keyring_connection_deleted', 'eventbrite_multi_keyring_connection_deleted' );
/**
* Add rewrite rules for events.
*
* @param array $rules
* @uses Voce_Eventbrite_API::get_auth_service()
* @uses eventbrite_multi_get_page_url()
* @uses get_home_url()
* @uses eventbrite_multi_get_dynamic_pages()
* @uses eventbrite_multi_get_page_url()
* @uses eventbrite_multi_get_page_base()
* @return array Rewrite rules
*/
function eventbrite_multi_add_rewrite_rules( $rules ) {
if ( class_exists( 'Voce_Eventbrite_API' ) && Voce_Eventbrite_API::get_auth_service() ) {
$events_page_url = eventbrite_multi_get_page_url( 'events' );
// single event rewrites
if ( $events_page_url ) {
$events_page_base = ltrim( str_replace( get_home_url(), '', $events_page_url ) , '/' );
$event_rules = array();
$event_rules_key = sprintf( '%s?(\d+)?/?$', $events_page_base );
$event_rules[$event_rules_key] = 'index.php?eb_event=1&eb_event_id=$matches[1]';
$event_rules_key = sprintf( '%s?(\d+)/(\d+)/?$', $events_page_base );
$event_rules[$event_rules_key] = 'index.php?eb_event=1&eb_event_id=$matches[1]&eb_occurrence=$matches[2]';
$rules = array_merge( $event_rules, $rules );
}
// add paging to dynamic pages
$dynamic_pages = eventbrite_multi_get_dynamic_pages();
if ( $dynamic_pages ) {
foreach ( $dynamic_pages as $key => $template ) {
$dynamic_page_url = eventbrite_multi_get_page_url( $key );
if ( ! $dynamic_page_url ) {
continue;
}
$dynamic_page_base = rtrim ( eventbrite_multi_get_page_base( $dynamic_page_url ), '/' );
$dynamic_rules = array();
// base page
$dynamic_rules_key = sprintf( '%s/?$', $dynamic_page_base );
$dynamic_rules[$dynamic_rules_key] = sprintf( 'index.php?pagename=%s&eb_dynamic_page=1&paged=1', $dynamic_page_base );
$new_rules = $dynamic_rules + $rules;
// paging on base page
$dynamic_rules_key = sprintf( '%s/page/?([0-9]{1,})/?$', $dynamic_page_base );
$dynamic_rules[$dynamic_rules_key] = sprintf( 'index.php?pagename=%s&eb_dynamic_page=1&paged=$matches[1]', $dynamic_page_base );
$rules = array_merge( $dynamic_rules + $rules );
}
}
}
return $rules;
}
/**
* Add query vars for events.
*
* @param array $query_vars
* @return array
*/
function eventbrite_multi_add_query_vars( $query_vars ) {
$query_vars[] = 'eb_event';
$query_vars[] = 'eb_event_id';
$query_vars[] = 'eb_dynamic_page';
$query_vars[] = 'eb_occurrence';
return $query_vars;
}
/**
* Redirect to event listing or single event template.
*
* @uses Voce_Eventbrite_API::get_auth_service()
* @uses eventbrite_multi_get_page_id()
* @uses is_front_page()
* @uses get_option()
* @uses set_query_var()
* @uses get_query_var()
* @uses get_template_directory()
* @uses eventbrite_services_get_event_by_id()
* @uses eventbrite_multi_maybe_include_template()
*/
function eventbrite_multi_template_redirect() {
if ( ! class_exists( 'Voce_Eventbrite_API' ) || ! Voce_Eventbrite_API::get_auth_service() )
return;
// handle case when reading settings, front page setting is set to upcoming events
$upcoming_events_page_id = eventbrite_multi_get_page_id( 'upcoming-events' );
if ( is_front_page() && $upcoming_events_page_id && $upcoming_events_page_id == get_option( 'page_on_front' ) ) {
// set paged variable
set_query_var( 'paged' , get_query_var( 'page' ) );
include( get_template_directory() . '/upcoming-events.php' );
die();
}
// handle case when reading settings, front page setting is set to events
$events_page_id = eventbrite_multi_get_page_id( 'events' );
if ( is_front_page() && $events_page_id && $events_page_id == get_option( 'page_on_front' ) ) {
// set paged variable
set_query_var( 'paged' , get_query_var( 'page' ) );
include( get_template_directory() . '/event.php' );
die();
}
if ( get_query_var( 'eb_event' ) && eventbrite_multi_get_page_url( 'events' ) ) {
$event_id = get_query_var( 'eb_event_id' );
if ( $event_id ) {
if ( ! eventbrite_services_get_event_by_id( $event_id ) ) {
global $wp_query;
$wp_query->is_404 = true;
return;
}
include( get_template_directory() . '/event-single.php' );
die();
}
include( get_template_directory() . '/event.php' );
die();
}
if ( get_query_var( 'eb_dynamic_page' ) ) {
// check currently queried object against Eventbrite pages to see if we
// need to load a different template
$dynamic_pages = eventbrite_multi_get_dynamic_pages();
if ( $dynamic_pages ) {
$queried_object_id = get_queried_object_id();
foreach ( $dynamic_pages as $key => $template ) {
eventbrite_multi_maybe_include_template( eventbrite_multi_get_page_id( $key ), $queried_object_id, $template );
}
}
}
}
/**
* Filter in body classes.
*
* @param array $classes
* @uses get_query_var()
* @uses eventbrite_multi_get_page_url()
* @uses eventbrite_multi_get_page_id()
* @return array Filtered body classes
*/
function eventbrite_multi_body_class( $classes ) {
if ( get_query_var( 'eb_event' ) && eventbrite_multi_get_page_url( 'events' ) )
$classes[] = 'eventbrite-venue-single-event';
global $post;
if ( isset( $post->ID ) && $post->ID == eventbrite_multi_get_page_id( 'calendar' ) )
$classes[] = 'template-calendar';
return $classes;
}
add_action( 'body_class', 'eventbrite_multi_body_class' );
function eventbrite_multi_plumbing_setup(){
add_filter( 'rewrite_rules_array', 'eventbrite_multi_add_rewrite_rules' );
add_filter( 'query_vars', 'eventbrite_multi_add_query_vars' );
add_action( 'template_redirect', 'eventbrite_multi_template_redirect' );
}
add_action( 'after_setup_theme', 'eventbrite_multi_plumbing_setup' );
/**
* Flush rewrite rules on theme activation.
*/
add_action( 'after_switch_theme', 'flush_rewrite_rules' );