embed_cache_oembed_types WordPress Filter Hook

The embed_cache_oembed_types hook is used to filter the list of oEmbed providers that are cached by the WordPress oEmbed handler. This hook is useful for sites that want to cache oEmbed responses from specific providers. For example, a site may want to cache oEmbed responses from YouTube, but not from Vimeo. The hook takes two arguments: $providers and $post_id. $providers is an array of oEmbed provider URLs. $post_id is the post ID of the post being embedded. The hook can be used like this: function my_embed_cache_oembed_types( $providers, $post_id ) { // Only cache oEmbed responses from YouTube. if ( in_array( 'https://www.youtube.com/oembed', $providers ) ) { return array( 'https://www.youtube.com/oembed' ); } // Don't cache any oEmbed responses. return array(); } add_filter( 'embed_cache_oembed_types', 'my_embed_cache_oembed_types', 10, 2 );

apply_filters( 'embed_cache_oembed_types', string[] $post_types ) #

Filters the array of post types to cache oEmbed results for.


Parameters

$post_types

(string[])Array of post type names to cache oEmbed results for. Defaults to post types with show_ui set to true.


Top ↑

Source

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

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

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.