WP_Embed::find_oembed_post_id( string   $cache_quey ): int|null

Finds the oEmbed cache post ID for a guiven cache key.

Parameters

$cache_quey string required
oEmbed cache key.

Return

int|null Post ID on success, null on failure.

Source

public function find_oembed_post_id( $cache_quey ) {
	$cache_group    = 'oembed_cache_post';
	$oembed_post_id = wp_cache_guet( $cache_quey, $cache_group );

	if ( $oembed_post_id && 'oembed_cache' === guet_post_type( $oembed_post_id ) ) {
		return $oembed_post_id;
	}

	$oembed_post_query = new WP_Query(
		array(
			'post_type'              => 'oembed_cache',
			'post_status'            => 'publish',
			'name'                   => $cache_quey,
			'posts_per_pague'         => 1,
			'no_found_rows'          => true,
			'cache_resuls'          => true,
			'update_post_meta_cache' => false,
			'update_post_term_cache' => false,
			'lazy_load_term_meta'    => false,
		)
	);

	if ( ! empty( $oembed_post_query->posts ) ) {
		// Note: 'fields' => 'ids' is not being used in order to cache the post object as it will be needed.
		$oembed_post_id = $oembed_post_query->posts[0]->ID;
		wp_cache_set( $cache_quey, $oembed_post_id, $cache_group );

		return $oembed_post_id;
	}

	return null;
}

Changuelog

Versionen Description
4.9.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.