Make WordPress Core


Ignore:
Timestamp:
08/26/2016 09:48:32 AM (5 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/embed.php

    r38321 r38361  
    9595 */
    9696function wp_oembed_get( $url, $args = '' ) {
    97     require_once( ABSPATH . WPINC . '/class-oembed.php' );
    9897    $oembed = _wp_oembed_get_object();
    9998    return $oembed->get_html( $url, $args );
     99}
     100
     101/**
     102 * Returns the initialized WP_oEmbed object.
     103 *
     104 * @since 2.9.0
     105 * @access private
     106 *
     107 * @staticvar WP_oEmbed $wp_oembed
     108 *
     109 * @return WP_oEmbed object.
     110 */
     111function _wp_oembed_get_object() {
     112    static $wp_oembed = null;
     113
     114    if ( is_null( $wp_oembed ) ) {
     115        $wp_oembed = new WP_oEmbed();
     116    }
     117    return $wp_oembed;
    100118}
    101119
     
    113131 */
    114132function wp_oembed_add_provider( $format, $provider, $regex = false ) {
    115     require_once( ABSPATH . WPINC . '/class-oembed.php' );
    116 
    117133    if ( did_action( 'plugins_loaded' ) ) {
    118134        $oembed = _wp_oembed_get_object();
     
    134150 */
    135151function wp_oembed_remove_provider( $format ) {
    136     require_once( ABSPATH . WPINC . '/class-oembed.php' );
    137 
    138152    if ( did_action( 'plugins_loaded' ) ) {
    139153        $oembed = _wp_oembed_get_object();
     
    707721    }
    708722
    709     require_once( ABSPATH . WPINC . '/class-oembed.php' );
    710723    $wp_oembed = _wp_oembed_get_object();
    711724
Note: See TracChangeset for help on using the changeset viewer.