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.

Built from https://develop.svn.wordpress.org/trunk@38361


git-svn-id: http://core.svn.wordpress.org/trunk@38302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor
2016-08-26 09:49:28 +00:00
parent ac6c22c392
commit ff59281441
5 changed files with 21 additions and 27 deletions

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.