WC_Frontend_Scripts::enqueue_script()
Register and enqueue a script for use.
Method of the class: WC_Frontend_Scripts{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WC_Frontend_Scripts::enqueue_script( $handle, $path, $deps, $version, $in_footer );
- $handle(string) (required)
- Name of the script. Should be unique.
- $path(string)
- Full URL of the script, or path of the script relative to the WordPress root directory.
Default: '' - $deps(string[])
- An array of registered script handles this script depends on.
Default: array( fooo ) - $version(string)
- 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.
Default: WC_VERSION - $in_footer(true|false)
- Whether to enqueue the script before </body> instead of in the <head>.
Default: 'false'
WC_Frontend_Scripts::enqueue_script() WC Frontend Scripts::enqueue script code WC 9.8.2
private static function enqueue_script( $handle, $path = '', $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = array( 'strategy' => 'defer' ) ) { if ( ! in_array( $handle, self::$scripts, true ) && $path ) { self::register_script( $handle, $path, $deps, $version, $in_footer ); } wp_enqueue_script( $handle ); }