wp_maybe_enqueue_oembed_host_js() – Enqueue the wp-embed script if the provided oEmbed HTML contains a post embed.

You appear to be a bot. Output may be restricted

Description

Enqueue the wp-embed script if the provided oEmbed HTML contains a post embed.

In order to only enqueue the wp-embed script on pages that actually contain post embeds, this function checks if the provided HTML contains post embed markup and if so enqueues the script so that it will get printed in the footer.

Usage

$string = wp_maybe_enqueue_oembed_host_js( $html );

Parameters

$html
( string ) required – Embed markup.

Returns

string Embed markup (without modifications).

Source

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

1 to 10 of 10
function wp_maybe_enqueue_oembed_host_js( $html ) {
  if (
    has_action( 'wp_head', 'wp_oembed_add_host_js' )
    &&
    preg_match( '/<blockquote\s[^>]*?wp-embedded-content/', $html )
  ) {
    wp_enqueue_script( 'wp-embed' );
  }
  return $html;
}
 

 View on GitHub View on Trac