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

git-svn-id: http://svn.automattic.com/wordpress/trunk@10572 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-02-15 11:04:42 +00:00
parent b6a97077f1
commit 788ba1ea2a
2 changed files with 52 additions and 2 deletions

View File

@ -16,7 +16,7 @@
* register/enqueue new scripts. * register/enqueue new scripts.
* *
* @since r16 * @since r16
* @see WP_Scripts::print_scripts() * @see WP_Dependencies::print_scripts()
*/ */
function wp_print_scripts( $handles = false ) { function wp_print_scripts( $handles = false ) {
do_action( 'wp_print_scripts' ); do_action( 'wp_print_scripts' );
@ -38,7 +38,7 @@ function wp_print_scripts( $handles = false ) {
* Register new JavaScript file. * Register new JavaScript file.
* *
* @since r16 * @since r16
* @see WP_Scripts::add() For parameter information. * @see WP_Dependencies::add() For parameter information.
*/ */
function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
global $wp_scripts; global $wp_scripts;
@ -101,3 +101,28 @@ function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false
} }
$wp_scripts->enqueue( $handle ); $wp_scripts->enqueue( $handle );
} }
/**
* Check whether script has been added to WordPress Scripts.
*
* The values for list defaults to 'queue', which is the same as enqueue for
* scripts.
*
* @since WP unknown; BP unknown
*
* @param string $handle Handle used to add script.
* @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do'
* @return bool
*/
function wp_script_is( $handle, $list = 'queue' ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
$wp_scripts = new WP_Scripts();
$query = $wp_scripts->query( $handle, $list );
if ( is_object( $query ) )
return true;
return $query;
}

View File

@ -77,3 +77,28 @@ function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false,
} }
$wp_styles->enqueue( $handle ); $wp_styles->enqueue( $handle );
} }
/**
* Check whether style has been added to WordPress Styles.
*
* The values for list defaults to 'queue', which is the same as enqueue for
* styles.
*
* @since WP unknown; BP unknown
*
* @param string $handle Handle used to add style.
* @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do'
* @return bool
*/
function wp_style_is( $handle, $list = 'queue' ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Scripts') )
$wp_styles = new WP_Styles();
$query = $wp_styles->query( $handle, $list );
if ( is_object( $query ) )
return true;
return $query;
}