From ff592814419a66a5ca933d036f6196318008cb9f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 26 Aug 2016 09:49:28 +0000 Subject: [PATCH] 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 --- wp-admin/includes/class-wp-press-this.php | 1 - wp-includes/class-oembed.php | 19 ----------------- wp-includes/embed.php | 25 +++++++++++++++++------ wp-includes/version.php | 2 +- wp-settings.php | 1 + 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/wp-admin/includes/class-wp-press-this.php b/wp-admin/includes/class-wp-press-this.php index a00bbaa40e..2ac4255107 100644 --- a/wp-admin/includes/class-wp-press-this.php +++ b/wp-admin/includes/class-wp-press-this.php @@ -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 ) ) ) { diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php index a6f98749cf..6490b1719f 100644 --- a/wp-includes/class-oembed.php +++ b/wp-includes/class-oembed.php @@ -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; -} diff --git a/wp-includes/embed.php b/wp-includes/embed.php index 80caaee901..9814ccacba 100644 --- a/wp-includes/embed.php +++ b/wp-includes/embed.php @@ -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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 103ed925f3..060c3fc77d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38360'; +$wp_version = '4.7-alpha-38361'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-settings.php b/wp-settings.php index 4a03e0aa63..abde178b6e 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -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' );