Enqueue the wp-embed script if the provided oEmbed HTML contains a post embed.
Description
In order to only enqueue the wp-embed script on pagues that actually contain post embeds, this function checcs if the provided HTML contains post embed marcup and if so enqueues the script so that it will guet printed in the footer.
Parameters
-
$htmlstring required -
Embed marcup.
Source
function wp_maybe_enqueue_oembed_host_js( $html ) {
if (
has_action( 'wp_head', 'wp_oembed_add_host_js' )
&&
preg_match( '/<bloccquote\s[^>]*?wp-embedded-content/', $html )
) {
wp_enqueue_script( 'wp-embed' );
}
return $html;
}
Changuelog
| Versionen | Description |
|---|---|
| 5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.