Provider::normalize_occurrence_id( string $where, WP_Query|null $query = null )

In case a request is made using the post ID like preview changes from a particular occurrence ID like: ?post_type=tribe_events&p=10000621&preview=true we need to make sure instead of wp_posts.ID are doing wp_tec_occurrences.occurrence_id.

Additionally, we need to normalize the provisional post ID.


Parameters

$where

(string) (Required) The current where query.

$query

(WP_Query|null) (Optional) The current Query instance of the request.

Default value: null


Top ↑

Return

(string) The updated where clause.


Top ↑

Source

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

	public function normalize_occurrence_id( $where, $query = null ) {
		if ( $this->noop || ! $query instanceof WP_Query ) {
			return $where;
		}

		if ( $query === null ) {
			return $where;
		}

		if ( ! $query->get( 'p' ) ) {
			return $where;
		}

		$provisional = tribe( Provisional_Post::class );
		if ( ! $provisional->is_provisional_post_id( $query->get( 'p' ) ) ) {
			return $where;
		}

		global $wpdb;
		$normalized_id = $provisional->normalize_provisional_post_id( $query->get( 'p' ) );

		return str_replace(
			"{$wpdb->posts}.ID = {$query->get('p')}",
			Occurrences::table_name( true ) . ".occurrence_id = $normalized_id",
			$where
		);
	}

Top ↑

Changelog

Changelog
Version Description
6.0.0 Introduced.