wp_maybe_enqueue_oembed_host_js()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_maybe_enqueue_oembed_host_js( string $html ): string
Описание
Чтобы ставить в очередь подключения скрипт wp-embed только на страницах, действительно содержащих встраивания записей, функция проверяет, содержит ли переданный HTML разметку встраивания записи, и если да, ставит скрипт в очередь, чтобы он был выведен в подвале.
Оригинал (английский)
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.
Параметры
$html
string
обязательный
Возвращаемое значение
string
Исходный код
wp-includes/embed.php:400
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;
}
История изменений
| Версия | Описание |
|---|---|
| 5.9.0 | Introduced. |

