bbp_enqueue_script( string $handle = '', string|bool $file = '', array $deps = array(), string|bool $ver = false, bool $in_footer = false )
Enqueue a script from the highest priority location in the template stack.
Description Description
Registers the style if file provided (does NOT overwrite) and enqueues.
Parameters Parameters
- $handle
-
(Optional) Name of the script.
Default value: ''
- $file
-
(Optional) Relative path to the script. Example: '/js/myscript.js'.
Default value: ''
- $deps
-
(Optional) An array of registered handles this script depends on.
Default value: array()
- $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.
Default value: false
- $in_footer
-
(Optional) Whether to enqueue the script before </head> or before </body>. Default 'false'. Accepts 'false' or 'true'.
Default value: false
Return Return
(mixed) The script filename if one is located. False if not.
Source Source
File: includes/core/template-functions.php
function bbp_enqueue_script( $handle = '', $file = '', $deps = array(), $ver = false, $in_footer = false ) { // Attempt to locate an enqueueable $located = bbp_locate_enqueueable( $file ); // Enqueue if located if ( ! empty( $located ) ) { // Make sure there is always a version if ( empty( $ver ) ) { $ver = bbp_get_version(); } // Make path to file relative to site URL $located = bbp_urlize_enqueueable( $located ); // Register the style wp_register_script( $handle, $located, $deps, $ver, $in_footer ); // Enqueue the style wp_enqueue_script( $handle ); } return $located; }
Changelog Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |