Last active
September 5, 2018 07:30
-
-
Save jo-snips/4074168 to your computer and use it in GitHub Desktop.
The Events Calendar: Filter Tribe Events Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('tribe_get_events_title','custom_get_events_title'); | |
function custom_get_events_title( $depth=true ) { | |
global $wp_query; | |
$tribe_ecp = TribeEvents::instance(); | |
$title = __('Class Schedule', 'tribe-events-calendar'); | |
// TODO: Use the displayed dates for the title | |
/* | |
if ( tribe_is_upcoming() || isset( $_REQUEST['tribe-bar-date'] ) ) { | |
$start_date = date( 'Y-m-d', strtotime( $wp_query->get( 'start_date' ) ) ); | |
if ( $wp_query->get( 'start_date' ) && $start_date != date('Y-m-d') ) { | |
if ( get_query_var('paged') > 1 ) { | |
// get the date of the first post | |
$first_post = reset($wp_query->posts); | |
$start_date = date('Y-m-d', strtotime($first_post->EventStartDate)); | |
} | |
$format = __('Events for %1$s', 'tribe-events-calendar'); | |
$args = array(date_i18n( get_option( 'date_format', 'Y-m-d' ), strtotime($start_date) )); | |
// Get the date of the last post | |
if ( count($wp_query->posts) > 1 ) { | |
$last_post = end($wp_query->posts); | |
$last_post_date = date('Y-m-d', strtotime($last_post->EventStartDate)); | |
if ( $last_post_date != $start_date ) { | |
$format = __('Events for %1$s through %2$s', 'tribe-events-calendar'); | |
$args[] = date_i18n( get_option( 'date_format', 'Y-m-d' ), strtotime($last_post_date) ); | |
} | |
} | |
$title = vsprintf($format, $args); | |
} | |
} else */ | |
if ( tribe_is_past() ) { | |
$title = __( 'Past Classes', 'tribe-events-calendar' ); | |
} | |
if( tribe_is_month() ){ | |
$title = sprintf( __( 'Classes for %s', 'tribe-events-calendar' ), | |
date_i18n( tribe_get_option( 'monthAndYearFormat', 'F Y' ), strtotime( tribe_get_month_view_date() ) ) | |
); | |
} | |
// day view title | |
if( tribe_is_day() ) { | |
$title = __( 'Classes for', 'tribe-events-calendar' ) . ' ' . | |
date_i18n( tribe_get_date_format(true), strtotime( $wp_query->get('start_date') ) ); | |
} | |
if ( is_tax( $tribe_ecp->get_event_taxonomy() ) ) { | |
$cat = get_queried_object(); | |
if ( $depth ) { | |
$title = '<a href="'.tribe_get_events_link().'">'.$title.'</a>'; | |
$title .= ' › ' . $cat->name; | |
} else { | |
$title = $cat->name; | |
} | |
} | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment