wp_embed_handler_youtube

函数


wp_embed_handler_youtube ( $matches, $attr, $url, $rawattr )
参数
  • (array)
    $matches
    The RegEx matches from the provided regex when calling wp_embed_register_handler().
    Required:
  • (array)
    $attr
    Embed attributes.
    Required:
  • (string)
    $url
    The original URL that was matched by the regex.
    Required:
  • (array)
    $rawattr
    The original unmodified attributes.
    Required:
返回值
  • (string) The embed HTML.
定义位置
  • wp-includes/embed.php
    , line 242
引入
4.0.0
弃用

YouTube iframe嵌入处理回调。

捕捉那些不能被oEmbed解析的YouTube iframe嵌入的URL,但可以被翻译成一个可以解析的URL。

function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
	global $wp_embed;
	$embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) );

	/**
	 * Filters the YoutTube embed output.
	 *
	 * @since 4.0.0
	 *
	 * @see wp_embed_handler_youtube()
	 *
	 * @param string $embed   YouTube embed output.
	 * @param array  $attr    An array of embed attributes.
	 * @param string $url     The original URL that was matched by the regex.
	 * @param array  $rawattr The original unmodified attributes.
	 */
	return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr );
}