diff --git a/src/wp-admin/includes/class-wp-press-this.php b/src/wp-admin/includes/class-wp-press-this.php index a00bbaa40e..2ac4255107 100644 --- a/src/wp-admin/includes/class-wp-press-this.php +++ b/src/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/src/wp-includes/class-oembed.php b/src/wp-includes/class-oembed.php index a6f98749cf..6490b1719f 100644 --- a/src/wp-includes/class-oembed.php +++ b/src/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/src/wp-includes/embed.php b/src/wp-includes/embed.php index a15ef8e7ed..ac62f5ecfd 100644 --- a/src/wp-includes/embed.php +++ b/src/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/src/wp-settings.php b/src/wp-settings.php index 4a03e0aa63..abde178b6e 100644 --- a/src/wp-settings.php +++ b/src/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' );