OEmbed: move _wp_oembed_get_object() to embed.php, where all of the other embed functions live. WP_oEmbed is then in a file by itself. Load class-oembed.php in wp-settings.php and remove extraneous include calls.

See #37827.


git-svn-id: https://develop.svn.wordpress.org/trunk@38361 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2016-08-26 09:48:32 +00:00
parent 05cd65dd82
commit 1ff3356d22
4 changed files with 20 additions and 26 deletions

View File

@ -479,7 +479,6 @@ class WP_Press_This {
// Embedded Daily Motion videos
$src = 'https://www.dailymotion.com/video/' . $src_matches[2];
} else {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
$oembed = _wp_oembed_get_object();
if ( ! $oembed->get_provider( $src, array( 'discover' => false ) ) ) {

View File

@ -677,22 +677,3 @@ class WP_oEmbed {
return str_replace( $tokens, $pre, $stripped );
}
}
/**
* Returns the initialized WP_oEmbed object.
*
* @since 2.9.0
* @access private
*
* @staticvar WP_oEmbed $wp_oembed
*
* @return WP_oEmbed object.
*/
function _wp_oembed_get_object() {
static $wp_oembed = null;
if ( is_null( $wp_oembed ) ) {
$wp_oembed = new WP_oEmbed();
}
return $wp_oembed;
}

View File

@ -94,11 +94,29 @@ function wp_embed_defaults( $url = '' ) {
* @return false|string False on failure or the embed HTML on success.
*/
function wp_oembed_get( $url, $args = '' ) {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
$oembed = _wp_oembed_get_object();
return $oembed->get_html( $url, $args );
}
/**
* Returns the initialized WP_oEmbed object.
*
* @since 2.9.0
* @access private
*
* @staticvar WP_oEmbed $wp_oembed
*
* @return WP_oEmbed object.
*/
function _wp_oembed_get_object() {
static $wp_oembed = null;
if ( is_null( $wp_oembed ) ) {
$wp_oembed = new WP_oEmbed();
}
return $wp_oembed;
}
/**
* Adds a URL format and oEmbed provider URL pair.
*
@ -112,8 +130,6 @@ function wp_oembed_get( $url, $args = '' ) {
* @param boolean $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false.
*/
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
if ( did_action( 'plugins_loaded' ) ) {
$oembed = _wp_oembed_get_object();
$oembed->providers[$format] = array( $provider, $regex );
@ -133,8 +149,6 @@ function wp_oembed_add_provider( $format, $provider, $regex = false ) {
* @return bool Was the provider removed successfully?
*/
function wp_oembed_remove_provider( $format ) {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
if ( did_action( 'plugins_loaded' ) ) {
$oembed = _wp_oembed_get_object();
@ -706,7 +720,6 @@ function wp_filter_oembed_result( $result, $data, $url ) {
return $result;
}
require_once( ABSPATH . WPINC . '/class-oembed.php' );
$wp_oembed = _wp_oembed_get_object();
// Don't modify the HTML for trusted providers.

View File

@ -191,6 +191,7 @@ require( ABSPATH . WPINC . '/canonical.php' );
require( ABSPATH . WPINC . '/shortcodes.php' );
require( ABSPATH . WPINC . '/embed.php' );
require( ABSPATH . WPINC . '/class-wp-embed.php' );
require( ABSPATH . WPINC . '/class-oembed.php' );
require( ABSPATH . WPINC . '/class-wp-oembed-controller.php' );
require( ABSPATH . WPINC . '/media.php' );
require( ABSPATH . WPINC . '/http.php' );