WordPress.org

Make WordPress Core

Changeset 10572


Ignore:
Timestamp:
02/15/09 11:04:42 (7 years ago)
Author:
westi
Message:

Expose the ability to find out if styles, scripts have already been queued. Fixes #6197 props jacobsantos

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r10367 r10572  
    1717 * 
    1818 * @since r16 
    19  * @see WP_Scripts::print_scripts() 
     19 * @see WP_Dependencies::print_scripts() 
    2020 */ 
    2121function wp_print_scripts( $handles = false ) { 
     
    3939 * 
    4040 * @since r16 
    41  * @see WP_Scripts::add() For parameter information. 
     41 * @see WP_Dependencies::add() For parameter information. 
    4242 */ 
    4343function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { 
     
    102102    $wp_scripts->enqueue( $handle ); 
    103103} 
     104 
     105/** 
     106 * Check whether script has been added to WordPress Scripts. 
     107 * 
     108 * The values for list defaults to 'queue', which is the same as enqueue for 
     109 * scripts. 
     110 * 
     111 * @since WP unknown; BP unknown 
     112 * 
     113 * @param string $handle Handle used to add script. 
     114 * @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do' 
     115 * @return bool 
     116 */ 
     117function wp_script_is( $handle, $list = 'queue' ) { 
     118    global $wp_scripts; 
     119    if ( !is_a($wp_scripts, 'WP_Scripts') ) 
     120        $wp_scripts = new WP_Scripts(); 
     121 
     122    $query = $wp_scripts->query( $handle, $list ); 
     123 
     124    if ( is_object( $query ) ) 
     125        return true; 
     126 
     127    return $query; 
     128} 
  • trunk/wp-includes/functions.wp-styles.php

    r9404 r10572  
    7878    $wp_styles->enqueue( $handle ); 
    7979} 
     80 
     81/** 
     82 * Check whether style has been added to WordPress Styles. 
     83 * 
     84 * The values for list defaults to 'queue', which is the same as enqueue for 
     85 * styles. 
     86 * 
     87 * @since WP unknown; BP unknown 
     88 * 
     89 * @param string $handle Handle used to add style. 
     90 * @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do' 
     91 * @return bool 
     92 */ 
     93function wp_style_is( $handle, $list = 'queue' ) { 
     94    global $wp_styles; 
     95    if ( !is_a($wp_styles, 'WP_Scripts') ) 
     96        $wp_styles = new WP_Styles(); 
     97 
     98    $query = $wp_styles->query( $handle, $list ); 
     99 
     100    if ( is_object( $query ) ) 
     101        return true; 
     102 
     103    return $query; 
     104} 
Note: See TracChangeset for help on using the changeset viewer.