确定是否应加载默认嵌入处理程序。

原型

wp_maybe_load_embeds()

描述

检查以确保尚未加载嵌入库。如果没有,那么它将加载嵌入库。

参考:

  • wp_embed_register_handler()

源文件

路径:wp-includes/embed.php

<?php
...
function wp_maybe_load_embeds() {
	/**
	 * Filters whether to load the default embed handlers.
	 *
	 * Returning a falsey value will prevent loading the default embed handlers.
	 *
	 * @since 2.9.0
	 *
	 * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
	 */
	if ( ! apply_filters( 'load_default_embeds', true ) ) {
		return;
	}
	wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' );
	/**
	 * Filters the audio embed handler callback.
	 *
	 * @since 3.6.0
	 *
	 * @param callable $handler Audio embed handler callback function.
	 */
	wp_embed_register_handler( 'audio', '#^https?://.+?.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 );
	/**
	 * Filters the video embed handler callback.
	 *
	 * @since 3.6.0
	 *
	 * @param callable $handler Video embed handler callback function.
	 */
	wp_embed_register_handler( 'video', '#^https?://.+?.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_maybe_load_embeds/