[wp-hackers] best way to remove oembed provider

Pascal Birchler pascal.birchler at gmail.com
Wed Feb 5 11:36:23 UTC 2014


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.


2014-02-01 Chris McCoy <chris at lod.com>:

> 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
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list