wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_maybe_enqueue_oembed_host_js › WordPress Function

Since5.9.0
已弃用n/a
wp_maybe_enqueue_oembed_host_js ( $html )
参数:
  • (string) $html Embed markup.
    Required: Yes
返回:
  • (string) Embed markup (without modifications).
定义在:
文档:

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.


源码

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;
}