WordPress – Getting the oEmbed whitelist providers

Posted by & filed under , , .

I wanted to get the list of providers from the oembed whitelist to use in the NFB Video Plugin’s next update for WordPress 3.0.

The global $OEMBED is the variable that stores all my other variables in the plugin, that’s why it’s there.

There’s probably a function somewhere that does this, but I didn’t find it. So, if there’s anyone else who was having difficulty with it, as a temporary solution you could go with something like this:

$INCLUDE_EXTERNAL_BASE_PATH = dirname(dirname(dirname(dirname(__FILE__))));
require_once($INCLUDE_EXTERNAL_BASE_PATH . ‘/wp-includes/class-oembed.php’);

function populate_list_from_wp_oembed_whitelist(){

global $OEMBED;
$wp_oembed = new WP_oEmbed();

$OEMBED->whitelist = array();

foreach($wp_oembed->providers as $provider=>$oembed_url):
array_push($OEMBED->whitelist, $provider);
endforeach;

return $OEMBED->whitelist;
}

$providers = populate_list_from_wp_oembed_whitelist();

** I would have put it in code tags, but apparently it’s not working correctly at the moment.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>