Skip to content

Instantly share code, notes, and snippets.

@MZAWeb
Created Aug 1, 2012
Embed
What would you like to do?
The Events Calendar: maybeAddEventTitle
<?php
public function maybeAddEventTitle( $title, $sep = NULL ) {
if ( get_query_var( 'eventDisplay' ) == 'upcoming' ) {
$new_title = apply_filters( 'tribe_upcoming_events_title', __( "Upcoming Events", 'tribe-events-calendar' ) . ' ' . $sep . ' ' . $title, $sep );
} elseif ( get_query_var( 'eventDisplay' ) == 'past' ) {
$new_title = apply_filters( 'tribe_past_events_title', __( "Past Events", 'tribe-events-calendar' ) . ' ' . $sep . ' ' . $title, $sep );
} elseif ( get_query_var( 'eventDisplay' ) == 'month' ) {
if ( get_query_var( 'eventDate' ) ) {
$title_date = date_i18n( "F, Y", strtotime( get_query_var( 'eventDate' ) ) );
$new_title = apply_filters( 'tribe_month_grid_view_title', sprintf( __( "Events for %s", 'tribe-events-calendar' ), $title_date ) . ' ' . $sep . ' ' . $title, $sep, $title_date );
} else {
$new_title = apply_filters( 'tribe_events_this_month_title', sprintf( __( "Events this month", 'tribe-events-calendar' ), get_query_var( 'eventDate' ) ) . ' ' . $sep . ' ' . $title, $sep );
}
} elseif ( get_query_var( 'eventDisplay' ) == 'day' ) {
$title_date = date_i18n( "F d, Y", strtotime( get_query_var( 'eventDate' ) ) );
$new_title = apply_filters( 'tribe_events_day_view_title', sprintf( __( "Events for %s", 'tribe-events-calendar' ), $title_date ) . ' ' . $sep . ' ' . $title, $sep, $title_date );
} elseif ( get_query_var( 'post_type' ) == self::POSTTYPE && is_single() && $this->getOption( 'tribeEventsTemplate' ) != '' ) {
global $post;
$new_title = $post->post_title . ' ' . $sep . ' ' . $title;
} elseif ( get_query_var( 'post_type' ) == self::VENUE_POST_TYPE && $this->getOption( 'tribeEventsTemplate' ) != '' ) {
global $post;
$new_title = apply_filters( 'tribe_events_venue_view_title', sprintf( __( "Events at %s", 'tribe-events-calendar' ), $post->post_title ) . ' ' . $sep . ' ' . $title, $sep );
} else {
return $title;
}
return $new_title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment