WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/30/2012 06:57:57 PM (9 years ago)
Author:
nacin
Message:

Have wp_script_is() and wp_style_is() accept 'enqueued', as it reads better than 'queue' and is consistent with 'registered'. fixes #21741.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.wp-scripts.php

    r19687 r21672  
    162162 * Check whether script has been added to WordPress Scripts.
    163163 *
    164  * The values for list defaults to 'queue', which is the same as enqueue for
    165  * scripts.
     164 * By default, checks if the script has been enqueued. You can also
     165 * pass 'registered' to $list, to see if the script is registered,
     166 * and you can check processing statuses with 'to_do' and 'done'.
    166167 *
    167168 * @since WP unknown; BP unknown
    168169 *
    169  * @param string $handle Handle used to add script.
    170  * @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do'
    171  * @return bool
     170 * @param string $handle Name of the script.
     171 * @param string $list Optional. Defaults to 'enqueued'. Values are
     172 *  'registered', 'enqueued' (or 'queue'), 'to_do', and 'done'.
     173 * @return bool Whether script is in the list.
    172174 */
    173 function wp_script_is( $handle, $list = 'queue' ) {
     175function wp_script_is( $handle, $list = 'enqueued' ) {
    174176    global $wp_scripts;
    175177    if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     
    180182    }
    181183
    182     $query = $wp_scripts->query( $handle, $list );
    183 
    184     if ( is_object( $query ) )
    185         return true;
    186 
    187     return $query;
     184    return (bool) $wp_scripts->query( $handle, $list );
    188185}
Note: See TracChangeset for help on using the changeset viewer.