WordPress Version: 3.7
/**
* Enqueue a script.
*
* Registers the script if $src provided (does NOT overwrite), and enqueues it.
*
* @see WP_Dependencies::add(), WP_Dependencies::add_data(), WP_Dependencies::enqueue()
* @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
*
* @since 2.6.0
* @param string $handle Name of the script.
* @param string|bool $src Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
* @param array $deps An array of registered handles this script depends on. Default empty array.
* @param string|bool $ver Optional. String specifying the script version number, if it has one. This parameter
* is used to ensure that the correct version is sent to the client regardless of caching,
* and so should be included if a version number is available and makes sense for the script.
* @param bool $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
* Default 'false'. Accepts 'false' or 'true'.
*/
function wp_enqueue_script($handle, $src = false, $deps = array(), $ver = false, $in_footer = false)
{
global $wp_scripts;
if (!is_a($wp_scripts, 'WP_Scripts')) {
if (!did_action('init')) {
_doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>'), '3.3');
}
$wp_scripts = new WP_Scripts();
}
if ($src) {
$_handle = explode('?', $handle);
$wp_scripts->add($_handle[0], $src, $deps, $ver);
if ($in_footer) {
$wp_scripts->add_data($_handle[0], 'group', 1);
}
}
$wp_scripts->enqueue($handle);
}