WP_Embed::cache_oembed()publicWP 1.0

Triggers a caching of all oEmbed results.

Метод класса: WP_Embed{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

global $wp_embed;
$wp_embed->cache_oembed( $post_id );
$post_id(int) (обязательный)
Post ID to do the caching for.

Код WP_Embed::cache_oembed() WP 6.7.1

public function cache_oembed( $post_id ) {
	$post = get_post( $post_id );

	$post_types = get_post_types( array( 'show_ui' => true ) );

	/**
	 * Filters the array of post types to cache oEmbed results for.
	 *
	 * @since 2.9.0
	 *
	 * @param string[] $post_types Array of post type names to cache oEmbed results for. Defaults to post types with `show_ui` set to true.
	 */
	$cache_oembed_types = apply_filters( 'embed_cache_oembed_types', $post_types );

	if ( empty( $post->ID ) || ! in_array( $post->post_type, $cache_oembed_types, true ) ) {
		return;
	}

	// Trigger a caching.
	if ( ! empty( $post->post_content ) ) {
		$this->post_ID  = $post->ID;
		$this->usecache = false;

		$content = $this->run_shortcode( $post->post_content );
		$this->autoembed( $content );

		$this->usecache = true;
	}
}