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:
@@ -2135,8 +2135,13 @@ function wp_oembed_get( $url, $args = '' ) {
|
||||
*/
|
||||
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
|
||||
require_once( ABSPATH . WPINC . '/class-oembed.php' );
|
||||
$oembed = _wp_oembed_get_object();
|
||||
$oembed->providers[$format] = array( $provider, $regex );
|
||||
|
||||
if ( did_action( 'plugins_loaded' ) ) {
|
||||
$oembed = _wp_oembed_get_object();
|
||||
$oembed->providers[$format] = array( $provider, $regex );
|
||||
} else {
|
||||
WP_oEmbed::_add_provider_early( $format, $provider, $regex );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2152,11 +2157,15 @@ function wp_oembed_add_provider( $format, $provider, $regex = false ) {
|
||||
function wp_oembed_remove_provider( $format ) {
|
||||
require_once( ABSPATH . WPINC . '/class-oembed.php' );
|
||||
|
||||
$oembed = _wp_oembed_get_object();
|
||||
if ( did_action( 'plugins_loaded' ) ) {
|
||||
$oembed = _wp_oembed_get_object();
|
||||
|
||||
if ( isset( $oembed->providers[ $format ] ) ) {
|
||||
unset( $oembed->providers[ $format ] );
|
||||
return true;
|
||||
if ( isset( $oembed->providers[ $format ] ) ) {
|
||||
unset( $oembed->providers[ $format ] );
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
WP_oEmbed::_remove_provider_early( $format );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user