Title::build_title( string $title = '', boolean $depth = true, null|string $separator = ' › ' )

Builds the PRO View title based on context.


Parameters

$title

(string) (Optional) The input title.

Default value: ''

$cat

(WP_Term) (Required) The category term to use to build the title.

$depth

(boolean) (Optional) Whether to display the taxonomy hierarchy as part of the title.

Default value: true

$separator

(null|string) (Optional) The separator sequence to separate the title components.

Default value: ' › '


Top ↑

Return

(string) The View title, or an empty string if the rendering View is not a PRO one.


Top ↑

Source

File: src/Tribe/Views/V2/Template/Title.php

	public function build_title( $depth = true ) {
		$context = $this->context ?: tribe_context();
		$posts   = $this->get_posts();

		$title = '';

		if ( 'all' === $context->get( 'event_display_mode' ) ) {
			$title = sprintf(
				__( 'All %1$s for %2$s', 'tribe-events-calendar-pro' ),
				tribe_get_event_label_plural_lowercase(),
				get_the_title( $context->get( 'post_id' ) )
			);
		} elseif ( 'week' === $context->get( 'event_display' ) ) {
			/**
			 * Filters the date format that should be used to render PRO views title.
			 *
			 * @since 4.7.9
			 *
			 * @param string $date_format The date format, as read from the options.
			 */
			$date_format = apply_filters(
				'tribe_events_pro_page_title_date_format',
				tribe_get_date_format( true )
			);

			$title = sprintf(
				__( '%1$s for week of %2$s', 'tribe-events-calendar-pro' ),
				$this->events_label_plural,
				date_i18n( $date_format, strtotime( tribe_get_first_week_day( $context->get( 'event_date' ) ) ) )
			);
		}

		/**
		 * Filters the view title, specific to PRO Views V2.
		 *
		 * @since 4.7.9
		 *
		 * @param string  $title   The "Events" page title as it's been generated thus far.
		 * @param bool    $depth   Whether to include the linked title or not.
		 * @param Context $context The context used to build the title, it could be the global one, or one externally
		 *                         set.
		 * @param array   $posts   An array of posts fetched by the View.
		 */
		return apply_filters( 'tribe_events_pro_views_v2_view_title', $title, $depth, $context, $posts );
	}

Top ↑

Changelog

Changelog
Version Description
5.1.4 - Add filter for plural events label.
4.7.9 Introduced.