Provider::register()

Registers the bindings and hooks required by the plugin template redirection.

Contents


Source

File: src/Events_Pro/Custom_Tables/V1/Templates/Provider.php

	public function register() {
		$this->container->singleton( Series_Filters::class, Series_Filters::class );
		$this->container->singleton( Templates_Loader::class, Templates_Loader::class );
		$this->container->singleton( Single_Event_Modifications::class, Single_Event_Modifications::class );

		$this->register_assets();

		$filters = function ( $method ) {
			return $this->container->callback( Series_Filters::class, $method );
		};

		add_filter(
			'tribe_events_single_meta_details_section_after_datetime',
			$this->container->callback( Single_Event_Modifications::class, 'include_series_meta_details' )
		);

		add_filter( 'query_vars', $filters( 'filter_query_vars' ) );
		add_filter( 'tec_events_views_v2_view_global_repository_args', $filters( 'filter_repository_args' ), 10, 2 );
		add_action( 'tribe_views_v2_after_setup_loop', $filters( 'replace_view_url_object' ) );
		add_filter( 'tribe_events_views_v2_url_query_args', $filters( 'filter_query_args' ), 10, 2 );

		add_filter( 'tribe_context_locations', $filters( 'update_tribe_context' ), 10, 2 );

		add_filter(
			'get_the_terms',
			$this->container->callback( Single_Event_Modifications::class, 'redirect_get_the_terms' ),
			10,
			3
		);

		add_filter(
			'get_terms',
			$this->container->callback( Single_Event_Modifications::class, 'redirect_get_terms' ),
			10,
			3
		);

		$this->hook_series_markers();

		if ( is_admin() || wp_doing_ajax() || wp_doing_cron() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
			// Only register this on front-end of PHP initial state.
			return;
		}

		// We're in PHP initial state land here.

		add_filter( 'template_include', $filters( 'redirect_series_template' ) );
		add_filter( 'redirect_canonical', $filters( 'redirect_series_requests' ), 10, 2 );
		add_action( 'template_redirect', $filters( 'redirect_to_single_series' ) );
		add_filter( 'tribe_events_views_v2_view_html_classes', $filters( 'alter_container_classes' ), 10, 3 );

		/**
		 * Allows redirecting the event links for events in a series so that they point to the series,
		 * rather than the event.
		 *
		 * @since 6.0.0
		 *
		 * @param boolean $filter_event_url Default false. Whether we redirect event links to the associated series.
		 */
		$filter_event_url = apply_filters( 'tec_events_pro_custom_tables_v1_redirect_event_link_to_series', false );
		if ( $filter_event_url ) {
			foreach( $this->template_series_link_hooks as $hook_name ) {
				add_filter( "tribe_template_include_html:{$hook_name}", [ $this, 'redirect_event_link_to_series' ], 10, 4 );
			}
		}
	}

Top ↑

Changelog

Changelog
Version Description
6.0.0 Introduced.