Make WordPress Core


Ignore:
Timestamp:
06/26/2014 02:29:20 AM (11 years ago)
Author:
wonderboymusic
Message:

When wp_oembed_add_provider() or wp_oembed_remove_provider() is called before the plugins_loaded hook has, store the values statically on the WP_oEmbed object and add them just-in-time when the object is instantiated.

This ensures that all plugins have an accurate provider list when apply_filters( 'oembed_providers', $providers ) is called.

Props kovshenin.
Fixes #28284.

File:
1 edited

Legend:

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

    r28834 r28846  
    2020class WP_oEmbed {
    2121    public $providers = array();
     22    public static $early_providers = array();
    2223
    2324    /**
     
    6667        );
    6768
     69        if ( ! empty( self::$early_providers['add'] ) ) {
     70            foreach ( self::$early_providers['add'] as $format => $data ) {
     71                $providers[ $format ] = $data;
     72            }
     73        }
     74
     75        if ( ! empty( self::$early_providers['remove'] ) ) {
     76            foreach ( self::$early_providers['remove'] as $format ) {
     77                unset( $providers[ $format ] );
     78            }
     79        }
     80
     81        self::$early_providers = array();
     82
    6883        /**
    6984         * Filter the list of oEmbed providers.
     
    132147
    133148        return $provider;
     149    }
     150
     151    public static function _add_provider_early( $format, $provider, $regex = false ) {
     152        if ( empty( self::$early_providers['add'] ) ) {
     153            self::$early_providers['add'] = array();
     154        }
     155
     156        self::$early_providers['add'][ $format ] = array( $provider, $regex );
     157    }
     158
     159    public static function _remove_provider_early( $format ) {
     160        if ( empty( self::$early_providers['remove'] ) ) {
     161            self::$early_providers['remove'] = array();
     162        }
     163
     164        self::$early_providers['remove'][] = $format;
    134165    }
    135166
Note: See TracChangeset for help on using the changeset viewer.