Hooks
Class Hooks.
Source
File: src/Tribe/Views/V2/Hooks.php
class Hooks extends \tad_DI52_ServiceProvider {
/**
* Binds and sets up implementations.
*
* @since 4.7.5
*/
public function register() {
$this->add_actions();
$this->add_filters();
}
/**
* Adds the actions required by each Pro Views v2 component.
*
* @since 4.7.5
*/
protected function add_actions() {
add_action( 'init', [ $this, 'action_disable_shortcode_v1' ], 15 );
add_action( 'init', [ $this, 'action_add_shortcodes' ], 20 );
add_action( 'tribe_template_after_include:events/components/top-bar/actions/content', [ $this, 'action_include_hide_recurring_events' ], 10, 3 );
add_action( 'tribe_template_after_include:events/events-bar/search/keyword', [ $this, 'action_include_location_form_field' ], 10, 3 );
}
/**
* Filters the list of folders TEC will look up to find templates to add the ones defined by PRO.
*
* @since 4.7.5
*
* @param array $folders The current list of folders that will be searched template files.
*
* @return array The filtered list of folders that will be searched for the templates.
*/
public function filter_template_path_list( array $folders = [] ) {
$folders[] = [
'id' => 'events-pro',
'priority' => 25,
'path' => \Tribe__Events__Pro__Main::instance()->pluginPath . 'src/views/v2',
];
return $folders;
}
/**
* Adds the filters required by each Pro Views v2 component.
*
* @since 4.7.5
*/
protected function add_filters() {
add_filter( 'tribe_events_views', [ $this, 'filter_events_views' ] );
add_filter( 'tribe_template_path_list', [ $this, 'filter_template_path_list' ] );
add_filter( 'tribe_events_views_v2_view_repository_args', [
$this,
'filter_events_views_v2_view_repository_args',
], 10, 2 );
add_filter( 'tribe_events_views_v2_view_template_vars', [
$this,
'filter_events_views_v2_view_template_vars',
], 10, 2 );
}
/**
* Filters the available Views to add the ones implemented in PRO.
*
* @since 4.7.5
*
* @param array $views An array of available Views.
*
* @return array The array of available views, including the PRO ones.
*/
public function filter_events_views( array $views = [] ) {
$views['all'] = All_View::class;
$views['photo'] = Photo_View::class;
$views['week'] = Week_View::class;
$views['map'] = Map_View::class;
return $views;
}
/**
* Fires to include the hide recurring template on the end of the actions of the top-bar.
*
* @since 4.7.5
*
* @param string $file Complete path to include the PHP File
* @param array $name Template name
* @param self $template Current instance of the Tribe__Template
*/
public function action_include_hide_recurring_events( $file, $name, $template ) {
$this->container->make( Hide_Recurring_Events_Toggle::class )->render( $template );
}
/**
* Fires to include the hide recurring template on the end of the actions of the top-bar.
*
* @since 4.7.5
*
* @param string $file Complete path to include the PHP File
* @param array $name Template name
* @param self $template Current instance of the Tribe__Template
*/
public function action_include_location_form_field( $file, $name, $template ) {
$this->container->make( Location_Search_Field::class )->render( $template );
}
/**
* Fires to disable V1 of shortcodes, normally they would be registered on `init@P10`
* so we will trigger this on `init@P15`.
*
* It's important to leave gaps on priority for better injection.
*
* @since 4.7.5
*/
public function action_disable_shortcode_v1() {
$this->container->make( Shortcodes\Manager::class )->disable_v1();
}
/**
* Adds the new shortcodes, this normally will trigger on `init@P20` due to how we the
* v1 is added on `init@P10` and we remove them on `init@P15`.
*
* It's important to leave gaps on priority for better injection.
*
* @since 4.7.5
*/
public function action_add_shortcodes() {
$this->container->make( Shortcodes\Manager::class )->add_shortcodes();
}
/**
* Filters the View repository args to parse and apply PRO specific View filters.
*
* @since 4.7.5
*
* @param array $repository_args The current repository args.
* @param Context|null $context An instance of the context the View is using or `null` to use the
* global Context.
*
* @return array The filtered repository args.
*/
public function filter_events_views_v2_view_repository_args( array $repository_args = [], Context $context = null ) {
/** @var View_Filters $view_filters */
$view_filters = $this->container->make( View_Filters::class );
return $view_filters->filter_repository_args( $repository_args, $context );
}
/**
* Filters the View template variables before the HTML is generated to add the ones related to this plugin filters.
*
* @since 4.7.5
*
* @param array $template_vars The View template variables.
* @param View_Interface $view The current View instance.
*/
public function filter_events_views_v2_view_template_vars( array $template_vars, View_Interface $view ) {
/** @var View_Filters $view_filters */
$view_filters = $this->container->make( View_Filters::class );
return $view_filters->filter_template_vars( $template_vars, $view->get_context() );
}
}
Changelog
| Version | Description |
|---|---|
| 4.7.5 | Introduced. |
Methods
- action_add_shortcodes — Adds the new shortcodes, this normally will trigger on `init@P20` due to how we the v1 is added on `init@P10` and we remove them on `init@P15`.
- action_disable_assets_v1 — Fires to deregister v1 assets correctly.
- action_disable_shortcode_assets_v1 — Fires to deregister v1 assets correctly for shortcodes.
- action_disable_shortcode_v1 — Fires to disable V1 of shortcodes, normally they would be registered on `init@P10` so we will trigger this on `init@P15`.
- action_include_day_event_recurring_icon — Fires to include the recurring icon on the day view event.
- action_include_hide_recurring_events — Fires to include the hide recurring template on the end of the actions of the top-bar.
- action_include_list_event_recurring_icon — Fires to include the recurring icon on the list view event.
- action_include_location_form_field — Fires to include the location form field after the keyword form field of the events bar.
- action_include_month_calendar_event_multiday_recurring_icon — Fires to include the recurring icon on the month view calendar multiday (and all-day) event bar.
- action_include_month_calendar_event_recurring_icon — Fires to include the recurring icon on the month view calendar event.
- action_include_month_calendar_event_tooltip_recurring_icon — Fires to include the recurring icon on the month view calendar event tooltip.
- action_include_month_mobile_event_recurring_icon — Fires to include the recurring icon on the month view mobile event.
- action_include_organizer_meta — Fires to include the organizer meta to the organizer view.
- action_include_venue_meta — Fires to include the venue meta to the venue view.
- append_recurring_info_tooltip — Filters the event schedule details to add the recurring information tooltip.
- before_view_messages_render — Filters the user-facing messages a View will print on the frontend to add PRO specific messages.
- customizer_inline_stylesheets — Add views stylesheets to customizer styles array to check.
- filter_add_events_pro_view_html_class — Filters the View HTML classes to add the pro required classes.
- filter_add_rewrite_venue_organizer — Includes rewrite bases for Organizer and Venue.
- filter_bootstrap_view_slug — Filters the slug of the view that will be built according to the request context to add support for Venue and Organizer Views.
- filter_context_locations — Filters the context locations to add the ones used by The Events Calendar PRO for Shortcodes.
- filter_events_rewrite_rules_custom — Filters The Events Calendar custom rewrite rules to fix the order and relative position of some and play nice with Views v2 canonical URL needs.
- filter_events_views — Filters the available Views to add the ones implemented in PRO.
- filter_events_views_v2_view_repository_args — Filters the View repository args to parse and apply PRO specific View filters.
- filter_events_views_v2_view_template_vars — Filters the View template variables before the HTML is generated to add the ones related to this plugin filters.
- filter_geocode_rewrite_rules — Filters the geocode based rewrite rules to add Views v2 specific rules.
- filter_handled_rewrite_rules — Filters the handled rewrite rules, the one used to parse plain links into permalinks, to add the ones managed by PRO.
- filter_hide_filter_bar — Filters the "should display filters" for ECP views.
- filter_hide_filter_bar_organizer_venue — Filters the should display filters for organizer and venue views.
- filter_include_query_vars — Register the new variable available on the permalink structure
- filter_map_view_pin — Filters the location pin on the map view.
- filter_page_reset_ignored_params — Filters the ignored params to add the `hide_subsequent_recurrences` item.
- filter_prevent_canonical_redirect — Filters the `redirect_canonical` to prevent any redirects on venue and organizer URLs.
- filter_rest_request_view_slug — Filter the Rest Requests to point to the correct view when dealing with Venue and Organizer.
- filter_rewrite_query_vars_map — Filters the query vars map used by the Rewrite component to parse plain links into permalinks to add the elements needed to support PRO components.
- filter_shortcode_default_view — Filters the default view in the views manager for shortcodes navigation.
- filter_shortcode_view_context — Alters the context of the view based on the shortcode params stored in the database based on the ID.
- filter_shortcode_view_url — Filters the View URL to add the shortcode query arg, if required.
- filter_shortcode_view_url_query_args — Filters the View URL to add the shortcode query arg, if required.
- filter_tec_events_default_view — Get the class name for the default registered view.
- filter_tec_events_view_week_today_button_label — Filters the Today button label to change the text to something appropriate for Week View.
- filter_tec_events_view_week_today_button_title — Filters the Today button title and aria-label to change the text to something appropriate for Week View.
- filter_template_path_list — Filters the list of folders TEC will look up to find templates to add the ones defined by PRO.
- filter_tribe_events_v2_view_title — Filters the Views v2 event page title, applying modifications for PRO Views.
- filter_tribe_events_views_v2_cached_views — Adds Week View to the views that get cache.
- filter_tribe_events_views_v2_messages_map — Filters the View messages map set up by The Events Calendar to add PRO Views specific messages.
- filter_tribe_events_views_v2_messages_need_events_label_keys — Filters the keys of the messages set up by The Events Calendar to add PRO Views specific keys.
- filter_tribe_events_views_v2_view_url — Filters the View URL to add, or remove, URL query arguments managed by PRO.
- filter_tribe_is_by_date — Adds Week View to the list of date-based views.
- filter_view_all_breadcrumbs — Filters recurring view breadcrumbs
- filter_view_all_breadcrums — Filters recurring view breadcrums
- filter_view_data — Filters the View data attributes to add some related to PRO features.
- filter_view_html_classes — Filters the View HTML classes to add some related to PRO features.
- filter_view_label_domain
- filter_view_organizer_breadcrumbs — Filters Organizer view breadcrumbs
- filter_view_organizer_breadcrums — Filters Organizer view breadcrums
- filter_view_organizer_content_title — Filters Organizer view content title.
- filter_view_organizer_header_title — Filters Organizer view header title.
- filter_view_repository_args — Filters the View repository args to add the ones required by shortcodes to work.
- filter_view_venue_breadcrumbs — Filters Venue view breadcrumbs
- filter_view_venue_breadcrums — Filters Venue view breadcrums
- filter_view_venue_content_title — Filters content title for the Venue view.
- filter_view_venue_header_title — Filters header title for the Venue view.
- filter_views_v2_wp_title_plural_events_label — Filter the plural events label for Featured V2 PRO Views.
- on_pre_rewrite — Add rewrite routes for PRO version of Views V2.
- on_template_redirect — Fires on the `template_redirect` action to allow the conditional redirect, if required.
- register — Binds and sets up implementations.