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_Scripts::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_Scripts::add() For parameter information.
43 function wp_register_script( $handle, $src, $deps = array(), $ver = false ) {
45 if ( !is_a($wp_scripts, 'WP_Scripts') )
46 $wp_scripts = new WP_Scripts();
48 $wp_scripts->add( $handle, $src, $deps, $ver );
54 * Localizes only if script has already been added.
57 * @see WP_Script::localize()
59 function wp_localize_script( $handle, $object_name, $l10n ) {
61 if ( !is_a($wp_scripts, 'WP_Scripts') )
64 return $wp_scripts->localize( $handle, $object_name, $l10n );
68 * Remove a registered script.
71 * @see WP_Scripts::remove() For parameter information.
73 function wp_deregister_script( $handle ) {
75 if ( !is_a($wp_scripts, 'WP_Scripts') )
76 $wp_scripts = new WP_Scripts();
78 $wp_scripts->remove( $handle );
84 * Registers the script if src provided (does NOT overwrite) and enqueues.
87 * @see WP_Script::add(), WP_Script::enqueue()
89 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false ) {
91 if ( !is_a($wp_scripts, 'WP_Scripts') )
92 $wp_scripts = new WP_Scripts();
95 $_handle = explode('?', $handle);
96 $wp_scripts->add( $_handle[0], $src, $deps, $ver );
98 $wp_scripts->enqueue( $handle );