wp_maybe_load_embeds() - WordPress 函数参考中文文档

返回介绍

wp_maybe_load_embeds()

发布于 2017-09-11 字数 2375 浏览 912 评论 0

wp_maybe_load_embeds()

Determines if default embed handlers should be loaded.


描述

Checks to make sure that the embeds library hasn’t already been loaded. If it hasn’t, then it will load the embeds library.


源代码

File: wp-includes/embed.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 );
}

更新日志

Version 描述
2.9.0 Introduced.

相关函数

Uses

  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/embed.php:
    wp_embed_register_handler()
  • wp-includes/embed.php:
    load_default_embeds
  • wp-includes/embed.php:
    wp_audio_embed_handler
  • wp-includes/embed.php:
    wp_video_embed_handler
  • wp-includes/media.php:
    wp_get_video_extensions()
  • wp-includes/media.php:
    wp_get_audio_extensions()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!