le` template tag.
*
* This is the template tag introduced in WP 4.4 to get the page title.
*
* @since 4.9.10
*
* @param string $title The page title.
*
* @return string The modified page title, if required.
*/
public function filter_document_title_parts( $title ) {
$bootstrap = $this->container->make( Template_Bootstrap::class );
if ( ! $bootstrap->should_load() || $bootstrap->is_single_event() ) {
return $title;
}
return $this->container->make( Title::class )->filter_document_title_parts( $title );
}
/**
* Filters the `excerpt_length`.
*
* @since 4.9.10
*
* @param int $length The excerpt length.
*
* @return int The modified excerpt length, if required.
*/
public function filter_excerpt_length( $length ) {
return $this->container->make( Template\Excerpt::class )->maybe_filter_excerpt_length( $length );
}
/**
* Filters the `excerpt_more`.
*
* @since 4.9.10
*
* @param string $link The excerpt read more link.
*
* @return string The modified excerpt read more link, if required.
*/
public function filter_excerpt_more( $link ) {
return $this->container->make( Template\Excerpt::class )->maybe_filter_excerpt_more( $link );
}
/**
* Filters the `admin_post_thumbnail_html` to add image aspect ratio recommendation.
*
* @since 4.9.11
*
* @param string $html The HTML for the featured image box.
*
* @return string The modified html, if required.
*/
public function filter_admin_post_thumbnail_html( $html ) {
$screen = get_current_screen();
if ( ! $screen instanceof \WP_Screen ) {
return $html;
}
if ( TEC::POSTTYPE !== $screen->post_type ) {
return $html;
}
return $html . '
' . __( 'We recommend a 16:9 aspect ratio for featured images.', 'the-events-calendar' ) . '
';
}
/**
* Filters the `redirect_canonical` to prevent any redirects on embed URLs.
*
* @since 4.9.13
*
* @param mixed $redirect_url URL which we will redirect to.
* @param string|int $original_url The original URL if this method runs on the `redirect_canonical` filter, else
* the redirect status (e.g. `301`) if this method runs in the context of the
* `wp_redirect` filter.
*
* @return string A redirection URL, or `false` to prevent redirection.
*/
public function filter_redirect_canonical( $redirect_url = null, $original_url = null ) {
if ( doing_filter( 'redirect_canonical' ) ) {
/*
* If we're not running in the context of the `redirect_canonical` filter, skip this check
* as it would happen between a string (`$redirect_url`) and an integer (the redirect HTTP
* status code).
*/
if ( trailingslashit( $original_url ) === trailingslashit( $redirect_url ) ) {
return $redirect_url;
}
}
$context = tribe_context();
// Bail with the original redirect if we are not dealing with a CPT from TEC.
if ( ! $context->is( 'tec_post_type' ) ) {
return $redirect_url;
}
$view = $context->get( 'view_request', null );
if ( 'embed' === $view ) {
// Do not redirect embedded Views.
return false;
}
if ( empty( $view ) || 'single-event' === $view ) {
// Let the redirection go on.
return $redirect_url;
}
$parsed = \Tribe__Events__Rewrite::instance()->parse_request( $redirect_url );
if (
empty( $parsed['tribe_redirected'] )
&& $view !== Arr::get( (array) $parsed, 'eventDisplay' )
) {
/*
* If we're here we know we should be looking at a View URL.
* If the proposed URL does not resolve to a View, do not redirect.
*/
return false;
}
return $redirect_url;
}
/**
* Modifies the Live update tooltip properly.
*
* @since 4.9.13
*
* @param array $fields Fields that were passed for the Settings tab.
*
* @return array Fields after changing the tooltip.
*/
public function filter_general_settings_tab_live_update( $fields ) {
if ( empty( $fields['liveFiltersUpdate'] ) ) {
return $fields;
}
$fields['liveFiltersUpdate']['tooltip'] .= '
' . esc_html__( 'Recommended for all sites using the updated calendar views.', 'the-events-calendar' );
return $fields;
}
/**
* Registers The Events Calendar with the views/overrides update checker.
*
* @since 4.9.13
*
* @param array $plugins List of plugins to be checked.
*
* @return array
*/
public function filter_register_template_updates( array $plugins = [] ) {
$plugins[ __( 'The Events Calendar - View V2', 'the-events-calendar' ) ] = [
TEC::VERSION,
TEC::instance()->pluginPath . 'src/views/v2',
trailingslashit( get_stylesheet_directory() ) . 'tribe/events',
];
return $plugins;
}
/**
* Suppress v1 query filters on a per-query basis, if required.
*
* @since 4.9.11
*
* @param \WP_Query $query The current WordPress query object.
*/
public function parse_query( $query ) {
if ( ! $query instanceof \WP_Query ) {
return;
}
$event_query = $this->container->make( Event_Query_Controller::class );
$event_query->parse_query( $query );
}
/**
* Adds the period repository to the map of available repositories.
*
* @since 4.9.13
*
* @param array $repository_map The current repository map.
*
* @return array The filtered repository map.
*/
public function add_period_repository( array $repository_map, $repository, array $args = [] ) {
if ( 'period' === $repository ) {
// This is a new instance on each run, by design. Making this a singleton would create dangerous dependencies.
$event_period_repository = $this->container->make( Event_Period::class );
$event_period_repository->cache_results = in_array( 'caching', $args, true );
$repository_map['period'] = $event_period_repository;
}
return $repository_map;
}
/**
* Flush rewrite rules after the site language setting changes.
*
* @since 4.9.13
*
* @param string $option The option name that was updated.
* @param string $old The option old value.
* @param string $new The option updated value.
*/
public function action_save_wplang( $option, $old, $new ) {
if ( 'WPLANG' !== $option ) {
return;
}
// Deleting `rewrite_rules` given that this is being executed after `init`
// And `flush_rewrite_rules()` doesn't take effect.
delete_option( 'rewrite_rules' );
}
/**
* Filters rewrite rules to modify and update them for Views V2.
*
* @since 5.0.0
*
* @param array $bases An array of rewrite bases that have been generated.
* @param string $method The method that's being used to generate the bases; defaults to `regex`.
*
* @return array An array of rewrite rules. Modified, if required, to support Views V2.
*/
public function filter_rewrite_i18n_slugs_raw( $bases, $method ) {
if ( ! is_array( $bases ) ) {
return $bases;
}
return $this->container->make( Rewrite::class )->filter_raw_i18n_slugs( $bases, $method );
}
/**
* Fires to manage sensitive information on password protected posts.
*
* @since 5.0.0
*
* @param \WP_Post|int $post The event post ID or object currently being decorated.
*/
public function manage_sensitive_info( $post ) {
if ( $this->container->make( Template_Bootstrap::class )->is_single_event() ) {
$this->container->make( Template\Event::class )->manage_sensitive_info( $post );
}
}
/**
* Include the promo banner after the after component.
*
* @since 5.1.5
*
* @param string $file Complete path to include the PHP File.
* @param array $name Template name.
* @param Template $template Current instance of the Template.
*
* @return void Template render has no return.
*/
public function action_add_promo_banner( $file, $name, $template ) {
$this->container->make( Template\Promo::class )->action_add_promo_banner( $file, $name, $template );
}
/**
* Updates and modifies the properties added to the event post object by the `tribe_get_event` function to
* hide some sensitive information, if required.
*
* @since 5.0.0
*
* @param \WP_Post $event The event post object, decorated w/ properties added by the `tribe_get_event` function.
*
* @return \WP_Post The event post object, decorated w/ properties added by the `tribe_get_event` function, some of
* them updated to hide sensitive information, if required.
*/
public function filter_events_properties( $event ) {
if ( ! $event instanceof \WP_Post ) {
return $event;
}
return $this->container->make( Template\Event::class )->filter_event_properties( $event );
}
/**
* Filter the template file in case we're in single event
* and we need to use the theme overrides.
*
* @see tribe_template_file
*
* @since 5.0.0
*
* @param string $file Complete path to include the PHP File
* @param array $name Template name
* @param object $template Instance of the Tribe__Template
*
* @return string
*/
public function filter_template_file( $file, $name, $template ) {
return $this->container->make( Template_Bootstrap::class )->filter_template_file( $file, $name, $template );
}
/**
* Filter the stylesheet option to do some switching for V2
*
* @since 5.0.2
*
* @param string $value The option value.
* @param string $key The option key.
*
* @return string Which value we are converting to.
*/
public function filter_get_stylesheet_option( $value, $key ) {
// Bail early if possible. No need to do the shuffle below if
if (
'stylesheetOption' !== $key
&& ( 'stylesheet_mode' !== $key )
) {
return $value;
}
// Remove this filter so we don't loop infinitely.
remove_filter( 'tribe_get_option', [ $this, 'filter_get_stylesheet_option' ], 10 );
$default = 'tribe';
if ( 'stylesheetOption' === $key ) {
$value = tribe_get_option( 'stylesheet_mode', $default );
} else if ( 'stylesheet_mode' === $key && empty( $value ) ) {
$value = tribe_get_option( 'stylesheetOption', $default );
if ( 'full' === $value ) {
$value = $default;
}
}
// Add the filter back
add_filter( 'tribe_get_option', [ $this, 'filter_get_stylesheet_option' ], 10, 2 );
return $value;
}
/**
* Filter the liveFiltersUpdate option to do some switching for V2.
* Note: this triggers on option_liveFiltersUpdate, tribe_get_option, AND tribe_field_value. We
* don't have to add/remove filters because we don't need to get the value - it's already provided.
*
* @since 5.0.3
*
* @param string $value The option value.
* @param string $key The option key.
*
* @return string Converted value of the Live Filters string.
*/
public function filter_live_filters_option_value( $value, $key ) {
if ( 'liveFiltersUpdate' !== $key ) {
return $value;
}
return $this->live_filters_maybe_convert( $value );
}
/**
* Converts old (boolean) values to the new string values.
*
* @since 5.0.3
*
* @param mixed $value The value to maybe convert.
*
* @return string Modified value of Live filters Update.
*/
public function live_filters_maybe_convert( $value ) {
$return_value = 'automatic';
if ( empty( $value ) || 'manual' === $value ) {
$return_value = 'manual';
}
/**
* Allow filtering of the new value for Live Filters.
*
* @since 5.0.3
*
* @param string $return_value Which value we are going to return as the conversion.
* @param string $value Which value was previously used.
*/
$return_value = apply_filters( 'tribe_events_option_convert_live_filters', $return_value, $value );
return $return_value;
}
/**
* Print Single Event JSON-LD.
*
* @since 5.0.3
*/
public function print_single_json_ld() {
$this->container->make( Template\JSON_LD::class )->print_single_json_ld();
}
/**
* Add views stylesheets to customizer styles array to check.
* Remove unused legacy stylesheets.
*
* @since 5.1.1
*
* @param array $sheets Array of sheets to search for.
* @param string $css_template String containing the inline css to add.
*
* @return array Modified array of sheets to search for.
*/
public function customizer_inline_stylesheets( $sheets, $css_template ) {
$v2_sheets = [ 'tribe-events-views-v2-full' ];
// Dequeue legacy sheets.
$keys = array_keys( $sheets, 'tribe-events-calendar-style' );
if ( ! empty( $keys ) ) {
foreach ( $keys as $key ) {
unset( $sheets[ $key ] );
}
}
return array_merge( $sheets, $v2_sheets );
}
/**
* Changes the action the Customizer should use to try and print inline styles to print the inline
* styles in the footer.
*
* @since 5.3.1
*
* @return string The action the Customizer should use to print inline styles.
*/
public function print_inline_styles_in_footer() {
return 'wp_print_footer_scripts';
}
/**
* Adds new Global Elements settings via the hook in common.
*
* @since 5.3.1
*
* @param \Tribe__Customizer__Section $section The Global Elements Customizer section.
* @param WP_Customize_Manager $manager The settings manager.
* @param \Tribe__Customizer $customizer The Customizer object.
*/
public function action_include_global_elements_settings( $section, $manager, $customizer ) {
$this->container->make( Customizer::class )->include_global_elements_settings( $section, $manager, $customizer );
}
/**
* Adds new Single Event settings via the hook in common.
*
* @since 5.3.1
*
* @param \Tribe__Customizer__Section $section The Single Event Customizer section.
* @param WP_Customize_Manager $manager The settings manager.
* @param \Tribe__Customizer $customizer The Customizer object.
*/
public function action_include_single_event_settings( $section, $manager, $customizer ) {
$this->container->make( Customizer::class )->include_single_event_settings( $section, $manager, $customizer );
}
/**
* Filters the Global Elements section CSS template to add Views v2 related style templates to it.
*
* @since 5.3.1
*
* @param string $css_template The CSS template, as produced by the Global Elements.
* @param \Tribe__Customizer__Section $section The Global Elements section.
* @param \Tribe__Customizer $customizer The current Customizer instance.
*
* @return string The filtered CSS template.
*/
public function filter_global_elements_css_template( $css_template, $section ) {
if ( ! ( is_string( $css_template ) && $section instanceof Customizer_Section ) ) {
return $css_template;
}
return $this->container->make( Customizer::class )->filter_global_elements_css_template( $css_template, $section );
}
/**
* Filters the Single Event section CSS template to add Views v2 related style templates to it.
*
* @since 5.3.1
*
* @param string $css_template The CSS template, as produced by the Global Elements.
* @param \Tribe__Customizer__Section $section The Single Event section.
* @param \Tribe__Customizer $customizer The current Customizer instance.
*
* @return string The filtered CSS template.
*/
public function filter_single_event_css_template( $css_template, $section ) {
if ( ! ( is_string( $css_template ) && $section instanceof Customizer_Section ) ) {
return $css_template;
}
return $this->container->make( Customizer::class )->filter_single_event_css_template( $css_template, $section );
}
/**
* Enqueues Customizer controls styles specific to Views v2 components.
*
* @since 5.4.0
*/
public function enqueue_customizer_controls_styles() {
return $this->container->make( Customizer::class )->enqueue_customizer_controls_styles();
}
/**
* Filter the website link label and change it for Single Event Classic Editor.
* Use the following in functions.php to disable:
* remove_filter( 'tribe_get_venue_website_link_label', [ tribe( 'events.views.v2.hooks' ), 'filter_single_event_details_website_label' ] );
*
* @since 5.5.0
*
* @param string $label The filtered label.
* @param null|string|int $post_id The current post ID.
*
* @return string
*/
public function filter_single_event_details_event_website_label( $label, $post_id = null ) {
// If not V2 or not Classic Editor, return the website url.
if ( $this->is_v1_or_blocks( $post_id ) ) {
return $label;
}
return sprintf(
_x(
'View %s Website',
'Capitalized label for the event website link.',
'the-events-calendar'
),
tribe_get_event_label_singular()
);
}
/**
* Filter the website link label and change it for Single Event Classic Editor.
* Use the following in functions.php to disable:
* remove_filter( 'tribe_get_venue_website_link_label', [ tribe( 'events.views.v2.hooks' ), 'filter_single_event_details_venue_website_label' ] );
*
* @since 5.5.0
*
* @param string $label The filtered label.
* @param null|string|int $post_id The current post ID.
*
* @return string
*/
public function filter_single_event_details_venue_website_label( $label, $post_id = null ) {
// If not V2 or not Classic Editor, return the website url.
if ( $this->is_v1_or_blocks( $post_id ) ) {
return $label;
}
return sprintf(
_x(
'View %s Website',
'Capitalized label for the venue website link.',
'the-events-calendar'
),
tribe_get_venue_label_singular()
);
}
/**
* Filter the website link label and change it for Single Event Classic Editor.
* Use the following in functions.php to disable:
* remove_filter( 'tribe_get_organizer_website_link_label', [ tribe( 'events.views.v2.hooks' ), 'filter_single_event_details_organizer_website_label' ] );
*
* @since 5.5.0
*
* @param string $label The filtered label.
* @param null|string|int $post_id The current post ID.
*
* @return string
*/
public function filter_single_event_details_organizer_website_label( $label, $post_id = null ) {
// If not V2 or not Classic Editor, return the website url.
if ( $this->is_v1_or_blocks( $post_id ) ) {
return $label;
}
return sprintf(
_x(
'View %s Website',
'Capitalized label for the organizer website link.',
'the-events-calendar'
),
tribe_get_organizer_label_singular()
);
}
/**
* Sugar function for the above that determines if the labels should be filtered.
*
* @since 4.6.0
*
* @param null|string|int $post_id The current post ID.
*
* @return boolean
*/
public function is_v1_or_blocks( $post_id = null ) {
return is_null( $post_id )
|| ! tribe_events_single_view_v2_is_enabled()
|| has_blocks( $post_id );
}
/**
* Overrides the default iCalendar export link logic to inject a list of event
* post IDs fitting the Views V2 criteria.
*
* @since 4.6.0
*
* @param array|false $event_ids Either a list of event post IDs that has been
* explicitly requested or `false` to indicate the
* iCalendar export link did not indicate a specific
* set of event post IDs.
*
* @return array Either the original input value if a specific set of event post IDs
* was requested as part of the iCalendar export link, or a filtered
* set of event post IDs compiled depending on the current View context
* and request arguments.
*/
public function inject_ical_event_ids( $event_ids = null ) {
if ( false !== $event_ids ) {
// The request already specifies a set of Event post IDs to return, bail.
return $event_ids;
}
return $this->container->make( iCalendar\Request::class )->get_event_ids();
}
}
Fatal error: Uncaught Error: Class 'Tribe\Events\Views\V2\Hooks' not found in /home/ocb/public_html/wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/Service_Provider.php:77
Stack trace:
#0 /home/ocb/public_html/wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/Service_Provider.php(47): Tribe\Events\Views\V2\Service_Provider->register_hooks()
#1 /home/ocb/public_html/wp-content/plugins/the-events-calendar/common/vendor/lucatume/di52/src/tad/DI52/Container.php(484): Tribe\Events\Views\V2\Service_Provider->register()
#2 /home/ocb/public_html/wp-content/plugins/the-events-calendar/common/src/Tribe/Container.php(288): tad_DI52_Container->register('Tribe\\Events\\Vi...')
#3 /home/ocb/public_html/wp-content/plugins/the-events-calendar/src/Tribe/Main.php(616): tribe_register_provider('Tribe\\Events\\Vi...')
#4 /home/ocb/public_html/wp-content/plugins/the-events-calendar/src/Tribe/Main.php(483): Tribe__Events__Main->bind_implementations()
#5 /home/ocb/public_html/wp-includes/class-wp-hook.php(324): Tribe__Events__ in /home/ocb/public_html/wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/Service_Provider.php on line 77