
如何使用Vue创建无头WordPress网站
wp_embed_handler_youtube ( $matches, $attr, $url, $rawattr )
wp_embed_handler_youtube: 这个函数是一个回调函数,用于处理WordPress中的YouTube视频嵌入: 当用户在一个文章或页面中嵌入YouTube视频时,这个函数被调用来处理嵌入代码。
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 ); }