Tribe__Events__Aggregator__Records::find_by_data_hash( string $source, string $data_hash )

Filter records by source and data hash.


Parameters

$source

(string) (Required) Source value.

$data_hash

(string) (Required) Data hash.


Top ↑

Return

(Tribe__Events__Aggregator__Record__Abstract|false) Record object or false if not found.


Top ↑

Source

File: src/Tribe/Aggregator/Records.php

	public function find_by_data_hash( $source, $data_hash ) {
		/** @var WP_Query $matches */
		$matches = $this->query( array(
			'post_status' => $this->get_status( 'schedule' )->name,
			'meta_query'  => array(
				array(
					'key'   => $this->prefix_meta( 'source' ),
					'value' => $source,
				),
			),
			'fields'      => 'ids',
		) );

		if ( empty( $matches->posts ) ) {
			return false;
		}

		foreach ( $matches->posts as $post_id ) {
			$this_record = $this->get_by_post_id( $post_id );

			if ( ! $this_record instanceof Tribe__Events__Aggregator__Record__Abstract ) {
				continue;
			}

			if ( $data_hash === $this_record->get_data_hash() ) {
				return $this_record;
			}
		}

		return false;
	}

Top ↑

Changelog

Changelog
Version Description
4.6.25 Introduced.