wp_oembed_add_host_js

函式
wp_oembed_add_host_js ( No parameters )

wp_oembed_add_host_js: 這個函式將oEmbed主機的一個JavaScript檔案新增到頁面上。這可以用來定製頁面上oEmbed內容的行為。

新增必要的JavaScript,以便與嵌入的iframes通訊。

這個函式不再被直接使用。對於back-compat來說,它只作為一種指示oEmbed主機JS_應該被新增的方式而存在。在`default-filters.php`中,仍然有這樣的程式碼。

add_action( ‘wp_head’, ‘wp_oembed_add_host_js’ )

歷史上,一個網站可以通過以下方式禁止新增oEmbed主機指令碼。

remove_action( ‘wp_head’, ‘wp_oembed_add_host_js’ )

為了確保這樣的程式碼仍能按預期工作,這個函式仍然存在。現在`wp_maybe_enqueue_oembed_host_js()`中有一個`has_action()`的檢查,以檢視`wp_oembed_add_host_js()`是否沒有在`wp_head`動作處解除鉤子執行。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_oembed_add_host_js() {}
/**
* 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.
*
* @since 5.9.0
*
* @param string $html Embed markup.
* @return string Embed markup (without modifications).
*/
function wp_oembed_add_host_js() {} /** * 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. * * @since 5.9.0 * * @param string $html Embed markup. * @return string Embed markup (without modifications). */
function wp_oembed_add_host_js() {}

/**
 * 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.
 *
 * @since 5.9.0
 *
 * @param string $html Embed markup.
 * @return string Embed markup (without modifications).
 */

常見問題

FAQs
檢視更多 >