3 * BackPress script procedural API.
10 * Prints script tags in document head.
12 * Called by admin-header.php and by wp_head hook. Since it is called by wp_head
13 * on every page load, the function does not instantiate the WP_Scripts object
14 * unless script names are explicitly passed. Does make use of already
15 * instantiated $wp_scripts if present. Use provided wp_print_scripts hook to
16 * register/enqueue new scripts.
19 * @see WP_Dependencies::print_scripts()
21 function wp_print_scripts( $handles = false ) {
22 do_action( 'wp_print_scripts' );
23 if ( '' === $handles ) // for wp_head
27 if ( !is_a($wp_scripts, 'WP_Scripts') ) {
29 return array(); // No need to instantiate if nothing's there.
31 $wp_scripts = new WP_Scripts();
34 return $wp_scripts->do_items( $handles );
38 * Register new JavaScript file.
41 * @see WP_Dependencies::add() For parameter information.
43 function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
45 if ( !is_a($wp_scripts, 'WP_Scripts') )
46 $wp_scripts = new WP_Scripts();
48 $wp_scripts->add( $handle, $src, $deps, $ver );
50 $wp_scripts->add_data( $handle, 'group', 1 );
56 * Localizes only if script has already been added.
59 * @see WP_Script::localize()
61 function wp_localize_script( $handle, $object_name, $l10n ) {
63 if ( !is_a($wp_scripts, 'WP_Scripts') )
66 return $wp_scripts->localize( $handle, $object_name, $l10n );
70 * Remove a registered script.
73 * @see WP_Scripts::remove() For parameter information.
75 function wp_deregister_script( $handle ) {
77 if ( !is_a($wp_scripts, 'WP_Scripts') )
78 $wp_scripts = new WP_Scripts();
80 $wp_scripts->remove( $handle );
86 * Registers the script if src provided (does NOT overwrite) and enqueues.
89 * @see WP_Script::add(), WP_Script::enqueue()
91 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
93 if ( !is_a($wp_scripts, 'WP_Scripts') )
94 $wp_scripts = new WP_Scripts();
97 $_handle = explode('?', $handle);
98 $wp_scripts->add( $_handle[0], $src, $deps, $ver );
100 $wp_scripts->add_data( $_handle[0], 'group', 1 );
102 $wp_scripts->enqueue( $handle );
106 * Check whether script has been added to WordPress Scripts.
108 * The values for list defaults to 'queue', which is the same as enqueue for
111 * @since WP unknown; BP unknown
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'
117 function wp_script_is( $handle, $list = 'queue' ) {
119 if ( !is_a($wp_scripts, 'WP_Scripts') )
120 $wp_scripts = new WP_Scripts();
122 $query = $wp_scripts->query( $handle, $list );
124 if ( is_object( $query ) )