WordPress.org

Make WordPress Core

Ticket #6197: 6197.r10258.diff

File 6197.r10258.diff, 2.3 KB (added by jacobsantos, 9 years ago)

Adds new functions based off of r10258

  • functions.wp-scripts.php

     
    1616 * register/enqueue new scripts.
    1717 *
    1818 * @since r16
    19  * @see WP_Scripts::print_scripts()
     19 * @see WP_Dependencies::print_scripts()
    2020 */
    2121function wp_print_scripts( $handles = false ) {
    2222        do_action( 'wp_print_scripts' );
     
    3838 * Register new JavaScript file.
    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 ) {
    4444        global $wp_scripts;
     
    9797        }
    9898        $wp_scripts->enqueue( $handle );
    9999}
     100
     101/**
     102 * Check whether script has been added to WordPress Scripts.
     103 *
     104 * The values for list defaults to 'queue', which is the same as enqueue for
     105 * scripts.
     106 *
     107 * @since WP unknown; BP unknown
     108 *
     109 * @param string $handle Handle used to add script.
     110 * @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do'
     111 * @return bool
     112 */
     113function wp_script_is( $handle, $list = 'queue' ) {
     114        global $wp_scripts;
     115        if ( !is_a($wp_scripts, 'WP_Scripts') )
     116                $wp_scripts = new WP_Scripts();
     117
     118        $query = $wp_scripts->query( $handle, $list );
     119
     120        if ( is_object( $query ) )
     121                return true;
     122
     123        return $query;
     124}
  • functions.wp-styles.php

     
    7777        }
    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}