Provider::register()

Registers the implementations and filters required by the plugin to integrate with Custom Tables Queries.

Contents


Source

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

	public function register() {
		$this->container->singleton( self::class, self::class );
		$this->container->singleton( Condense_Events_Series::class, Condense_Events_Series::class );
		$this->container->singleton( Replace_Results::class, Replace_Results::class );
		$this->container->singleton( Provisional_Post::class, function () {
			remove_filter( 'query', [ $this, 'hydrate_provisional_post' ], 200 );
			$provisional_post = new Provisional_Post(
				$this->container->make( Provisional_Post_Cache::class ),
				$this,
				$this->container->make( 'cache' )
			);
			add_filter( 'query', [ $this, 'hydrate_provisional_post' ], 200 );
			add_filter( 'get_post_metadata', [ $this, 'hydrate_tec_occurrence_meta' ], 10, 3 );

			return $provisional_post;
		} );
		$this->container->singleton( Custom_Query_Filters::class, function () {
			$base = tribe( Provisional_ID_Generator::class )->current();

			return new Custom_Query_Filters( $base, $this->container->make( Provisional_Post::class ) );
		} );

		if ( ! has_filter( 'query', [ $this, 'hydrate_provisional_post' ] ) ) {
			add_filter( 'query', [ $this, 'hydrate_provisional_post' ], 200 );
		}

		if ( ! has_action(
			'tec_events_custom_tables_v1_custom_tables_query_results',
			[ $this, 'hydrate_provisional_post_caches' ] )
		) {
			add_action(
				'tec_events_custom_tables_v1_custom_tables_query_results',
				[ $this, 'hydrate_provisional_post_caches' ]
			);
		}

		if ( ! has_filter( 'update_post_metadata_cache', [ $this, 'hydrate_provisional_meta_cache' ] ) ) {
			add_filter( 'update_post_metadata_cache', [ $this, 'hydrate_provisional_meta_cache' ], 10, 2 );
		}

		if ( ! has_filter( 'get_post_metadata', [ $this, 'hydrate_cache_on_occurrence' ] ) ) {
			add_filter( 'get_post_metadata', [ $this, 'hydrate_cache_on_occurrence' ], 10, 4 );
		}

		if ( ! has_filter( 'posts_results', [ $this, 'replace_posts_results' ] ) ) {
			add_filter( 'posts_results', [ $this, 'replace_posts_results' ], 10, 2 );
		}

		if ( ! has_filter( 'tec_events_custom_tables_v1_occurrence_select_fields', [ $this, 'filter_occurrence_fields' ] ) ) {
			add_filter( 'tec_events_custom_tables_v1_occurrence_select_fields', [ $this, 'filter_occurrence_fields' ], 10, 1 );
		}

		if ( ! has_action( 'tec_events_custom_tables_v1_custom_tables_query_pre_get_posts', [ $this, 'register_custom_tables_filters' ] ) ) {
			add_action(
				'tec_events_custom_tables_v1_custom_tables_query_pre_get_posts',
				[ $this, 'register_custom_tables_filters' ]
			);
		}

		if ( ! has_filter( 'tec_events_custom_tables_v1_custom_tables_query_vars', [ $this, 'filter_query_vars' ] ) ) {
			add_filter( 'tec_events_custom_tables_v1_custom_tables_query_vars', [ $this, 'filter_query_vars' ] );
		}

		if ( ! has_filter( 'tec_events_custom_tables_v1_custom_tables_query_where', [ $this, 'filter_where' ] ) ) {
			add_filter( 'tec_events_custom_tables_v1_custom_tables_query_where', [ $this, 'filter_where' ], 10, 2 );
		}

		if ( ! has_filter( 'tec_events_custom_tables_v1_custom_tables_query_hydrate_posts', [
			$this,
			'hydrate_query_posts'
		] ) ) {
			add_filter( 'tec_events_custom_tables_v1_custom_tables_query_hydrate_posts', [
				$this,
				'hydrate_query_posts'
			], 10, 2 );
		}

		if ( ! has_filter( 'tec_events_custom_tables_v1_query_modifier_implementations', [
			$this,
			'filter_query_modifier_implementations'
		] ) ) {
			add_filter( 'tec_events_custom_tables_v1_query_modifier_implementations', [
				$this,
				'filter_query_modifier_implementations'
			], 10, 2 );
		}

		if ( ! has_filter( 'tec_events_custom_tables_v1_query_modifier_applies_to_query', [
			$this,
			'filter_should_modify_query'
		] ) ) {
			add_filter( 'tec_events_custom_tables_v1_query_modifier_applies_to_query', [
				$this,
				'filter_should_modify_query'
			], 10, 3 );
		}

		if ( ! has_filter( 'tec_events_pro_tribe_repository_event_series_filter_override', [
			$this,
			'tribe_event_series_filter_override'
		] ) ) {
			add_filter( 'tec_events_pro_tribe_repository_event_series_filter_override', [
				$this,
				'tribe_event_series_filter_override'
			], 10, 3 );
		}

		$this->handle_collapse_recurring_event_instances();
	}

Top ↑

Changelog

Changelog
Version Description
6.0.0 Introduced.