Discussion:
best way to remove oembed provider
Chris McCoy
2014-02-01 20:36:22 UTC
Permalink
Which way is the best, to use remove provider, or unset the value through
the oembed_providers filter?

function remove_youtube_oembed( $providers ) {
unset($providers['#https?://(www\.)?youtube\.com/watch.*#i']);
return $providers;
}

add_filter( 'oembed_providers', 'remove_youtube_oembed' , 10, 1);

function remove_embeds() {
wp_oembed_remove_provider(
'#https?://(www\.)?youtube\.com/watch.*#i' );
}

add_action( 'init', 'remove_embeds' );
Pascal Birchler
2014-02-05 11:36:23 UTC
Permalink
Since wp_oembed_remove_provider() is basically a wrapper function for the
first example, my choice would be this function.

There was a similar question on WordPress SE (
http://stackoverflow.com/questions/19466374/filtering-wordpress-oembed-provider-list)
where the filter was recommended because the user wanted to only allow a
couple of providers.
Post by Chris McCoy
Which way is the best, to use remove provider, or unset the value through
the oembed_providers filter?
function remove_youtube_oembed( $providers ) {
unset($providers['#https?://(www\.)?youtube\.com/watch.*#i']);
return $providers;
}
add_filter( 'oembed_providers', 'remove_youtube_oembed' , 10, 1);
function remove_embeds() {
wp_oembed_remove_provider(
'#https?://(www\.)?youtube\.com/watch.*#i' );
}
add_action( 'init', 'remove_embeds' );
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Chris McCoy
2014-02-05 14:45:52 UTC
Permalink
Ya my example is for only youtube videos.

I eneded up using the 1st one, as I saw the other one was a wrapper.
Post by Pascal Birchler
Since wp_oembed_remove_provider() is basically a wrapper function for the
first example, my choice would be this function.
There was a similar question on WordPress SE (
http://stackoverflow.com/questions/19466374/filtering-wordpress-oembed-pro
vider-list)
where the filter was recommended because the user wanted to only allow a
couple of providers.
Post by Chris McCoy
Which way is the best, to use remove provider, or unset the value through
the oembed_providers filter?
function remove_youtube_oembed( $providers ) {
unset($providers['#https?://(www\.)?youtube\.com/watch.*#i']);
return $providers;
}
add_filter( 'oembed_providers', 'remove_youtube_oembed' , 10, 1);
function remove_embeds() {
wp_oembed_remove_provider(
'#https?://(www\.)?youtube\.com/watch.*#i' );
}
add_action( 'init', 'remove_embeds' );
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...