public function trigger( $args, $assoc_args ) {
		/** @var \WP_Embed $wp_embed */
		global $wp_embed;

		$post_id    = $args[0];
		$post       = get_post( $post_id );
		$post_types = get_post_types( array( 'show_ui' => true ) );

		if ( empty( $post->ID ) ) {
			WP_CLI::warning( sprintf( "Post id '%s' not found.", $post_id ) );

			return;
		}

		/** This filter is documented in wp-includes/class-wp-embed.php */
		// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Using WP Core hook.
		if ( ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ), true ) ) {
			WP_CLI::warning( sprintf( "Cannot cache oEmbed results for '%s' post type", $post->post_type ) );

			return;
		}

		$wp_embed->cache_oembed( $post_id );

		WP_CLI::success( 'Caching triggered!' );
	}
public function trigger( $args, $assoc_args ) {
		/** @var \WP_Embed $wp_embed */
		global $wp_embed;

		$post_id    = $args[0];
		$post       = get_post( $post_id );
		$post_types = get_post_types( array( 'show_ui' => true ) );

		if ( empty( $post->ID ) ) {
			WP_CLI::warning( sprintf( "Post id '%s' not found.", $post_id ) );

			return;
		}

		/** This filter is documented in wp-includes/class-wp-embed.php */
		// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Using WP Core hook.
		if ( ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ), true ) ) {
			WP_CLI::warning( sprintf( "Cannot cache oEmbed results for '%s' post type", $post->post_type ) );

			return;
		}

		$wp_embed->cache_oembed( $post_id );

		WP_CLI::success( 'Caching triggered!' );
	}
public function trigger ( $ args , $ assoc_args ) { /** @var \WP_Embed $wp_embed */ global $ wp_embed ; $ post_id = $ args [ 0 ] ; $ post = get_post ( $ post_id ) ; $ post_types = get_post_types ( array ( 'show_ui' => true ) ) ; if ( empty ( $ post -> ID ) ) { WP_CLI :: warning ( sprintf ( "Post id '%s' not found." , $ post_id ) ) ; return ; } /** This filter is documented in wp-includes/class-wp-embed.php */ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Using WP Core hook. if ( ! in_array ( $ post -> post_type , apply_filters ( 'embed_cache_oembed_types' , $ post_types ) , true ) ) { WP_CLI :: warning ( sprintf ( "Cannot cache oEmbed results for '%s' post type" , $ post -> post_type ) ) ; return ; } $ wp_embed -> cache_oembed ( $ post_id ) ; WP_CLI :: success ( 'Caching triggered!' ) ; }
Triggers the caching of all oEmbed results for a given post.

oEmbed caches for a post are stored in the post's metadata.

## OPTIONS

<post_id>
: ID of the post to do the caching for.

## EXAMPLES

# Triggers cache for a post
$ wp embed cache trigger 456
Success: Caching triggered!
Triggers the caching of all oEmbed results for a given post .