When wp_oembed_add_provider() or wp_oembed_remove_provider() is called before the plugins_loaded hook has, store the values statically on the WP_oEmbed object and add them just-in-time when the object is instantiated.
This ensures that all plugins have an accurate provider list when `apply_filters( 'oembed_providers', $providers )` is called. Props kovshenin. Fixes #28284. Built from https://develop.svn.wordpress.org/trunk@28846 git-svn-id: http://core.svn.wordpress.org/trunk@28650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
class WP_oEmbed {
|
||||
public $providers = array();
|
||||
public static $early_providers = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -65,6 +66,20 @@ class WP_oEmbed {
|
||||
'#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'http://animoto.com/oembeds/create', true ),
|
||||
);
|
||||
|
||||
if ( ! empty( self::$early_providers['add'] ) ) {
|
||||
foreach ( self::$early_providers['add'] as $format => $data ) {
|
||||
$providers[ $format ] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( self::$early_providers['remove'] ) ) {
|
||||
foreach ( self::$early_providers['remove'] as $format ) {
|
||||
unset( $providers[ $format ] );
|
||||
}
|
||||
}
|
||||
|
||||
self::$early_providers = array();
|
||||
|
||||
/**
|
||||
* Filter the list of oEmbed providers.
|
||||
*
|
||||
@@ -133,6 +148,22 @@ class WP_oEmbed {
|
||||
return $provider;
|
||||
}
|
||||
|
||||
public static function _add_provider_early( $format, $provider, $regex = false ) {
|
||||
if ( empty( self::$early_providers['add'] ) ) {
|
||||
self::$early_providers['add'] = array();
|
||||
}
|
||||
|
||||
self::$early_providers['add'][ $format ] = array( $provider, $regex );
|
||||
}
|
||||
|
||||
public static function _remove_provider_early( $format ) {
|
||||
if ( empty( self::$early_providers['remove'] ) ) {
|
||||
self::$early_providers['remove'] = array();
|
||||
}
|
||||
|
||||
self::$early_providers['remove'][] = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* The do-it-all function that takes a URL and attempts to return the HTML.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user