WPDev.one
Core Function
View Source on Trac ↗

wp_register_script()

wp_register_script( mixed $handle, mixed $src, mixed $deps = array(), mixed $ver = false, mixed $args = array() )

Registers a new script.

Parameters 4 required

Name / Type Description
$handle
string

Name of the script. Should be unique.

Required
mixed

(string | false) $src Full URL of the script, or path of the script relative to the WordPress root directory. If source is set to false, script is an alias of other scripts it depends on.

Required
$deps
string[]

Optional. An array of registered script handles this script depends on. Default empty array.

mixed

(string | bool | null) $ver Optional. String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.

Required
mixed

(array | bool) $args { Optional. An array of additional script loading strategies. Default empty array. Otherwise, it may be a boolean in which case it determines whether the script is printed in the footer. Default false.

Required

Return Value

(bool)
Whether the script has been registered. True on success, false on failure.

Function Information

Since Version
2.1.0
Source File
wp-includes/functions.wp-scripts.php
Advertisement