admin管理员组

文章数量:1333201

I am using this code to replace youtube video:

add_filter('embed_oembed_html', 'foo_embed_oembed_html', 99, 4);
add_filter('video_embed_html', 'foo_embed_oembed_html');

function foo_embed_oembed_html( $cache, $url, $attr, $post_ID ) {

    if ( false !== strpos( $url, 'youtube' ) ) {
    
        if ( preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches)) {

               // return my shortcode

        }
}

This works well with this example:


But the function foo_embed_oembed_html is not even called if I use this:


What would be the reason?

本文标签: plugin developmentReplace youtube embed in wordpress