WP_Embed::cache_oembed() WordPress Method

The WP_Embed::cache_oembed() method is used to cache oEmbed requests. It accepts an oEmbed response object and stores it in the cache. This method is used internally by the WP_Embed class.

WP_Embed::cache_oembed( int $post_ID ) #

Triggers a caching of all oEmbed results.


Parameters

$post_ID

(int)(Required)Post ID to do the caching for.


Top ↑

Source

File: wp-includes/class-wp-embed.php

	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;
		}
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.