wp_maybe_enqueue_oembed_host_js

函数
wp_maybe_enqueue_oembed_host_js ( $html )
参数
  • (string) $html Embed markup.
    Required:
返回值
  • (string) Embed markup (without modifications).
定义位置
相关方法
enqueue_embed_scriptswp_oembed_add_host_jswp_enqueue_stored_stylesenqueue_comment_hotkeys_jswp_maybe_load_embeds
引入
5.9.0
弃用
-

wp_maybe_enqueue_oembed_host_js: 这是一个函数,用于在必要时排队等待oEmbed主机JavaScript文件: 这个函数用于确保oEmbed内容的正常显示。

如果提供的oEmbed HTML包含一个post embed,那么就排队等待wp-embed脚本。

为了只在实际包含文章嵌入的页面上排队等候wp-embed脚本,这个函数检查所提供的HTML是否包含文章嵌入标记,如果是,就排队等候脚本,这样它就会被打印在页脚。

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

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: