WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/28/2011 06:24:00 PM (9 years ago)
Author:
azaozz
Message:

Introduce WP_Dependencies::get_data() method, change scripts and styles priority to follow the "natural" order in HTML, i.e. the last one wins, props scribu, see #11520

File:
1 edited

Legend:

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

    r18446 r18480  
    135135     * Adds extra data
    136136     *
    137      * Adds data only if script has already been added
     137     * Adds data only if script has already been added.
    138138     *
    139139     * @param string $handle Script name
    140      * @param string $data_name Name of object in which to store extra data
    141      * @param array $data Array of extra data
     140     * @param string $key
     141     * @param mixed $value
    142142     * @return bool success
    143143     */
    144     function add_data( $handle, $data_name, $data ) {
    145         if ( !isset($this->registered[$handle]) )
    146             return false;
    147         return $this->registered[$handle]->add_data( $data_name, $data );
     144    function add_data( $handle, $key, $value ) {
     145        if ( !isset( $this->registered[$handle] ) )
     146            return false;
     147
     148        return $this->registered[$handle]->add_data( $key, $value );
     149    }
     150
     151    /**
     152     * Get extra data
     153     *
     154     * Gets data associated with a certain handle.
     155     *
     156     * @since WP 3.3
     157     *
     158     * @param string $handle Script name
     159     * @param string $key
     160     * @return mixed
     161     */
     162    function get_data( $handle, $key ) {
     163        if ( !isset( $this->registered[$handle] ) )
     164            return false;
     165
     166        if ( !isset( $this->registered[$handle]->extra[$key] ) )
     167            return false;
     168
     169        return $this->registered[$handle]->extra[$key];
    148170    }
    149171
Note: See TracChangeset for help on using the changeset viewer.