WP_Embed::cache_oembed() – Triggers a caching of all oEmbed results.

You appear to be a bot. Output may be restricted

Description

Triggers a caching of all oEmbed results.

Usage

WP_Embed::cache_oembed( $post_id );

Parameters

$post_id
( int ) required – Post ID to do the caching for.

Returns

void

Source

File name: wordpress/wp-includes/class-wp-embed.php
Lines:

1 to 29 of 29
  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->WP_Embed::run_shortcode( $post->post_content );
      $this->WP_Embed::autoembed( $content );

      $this->usecache = true;
    }
  }
 

 View on GitHub View on Trac