WC_Frontend_Scripts
in package
Frontend scripts class.
These scripts are enqueued in the frontend of the store. The registered script handles in this class can be used to enqueue the scripts in the frontend by third party plugins and the handles will follow WooCommerce's L-1 support policy. Scripts registered outside of this class do not guarantee support and can be removed in future versions of WooCommerce.
Table of Contents
- $registered_scripts : array<string|int, mixed>
- Contains an array of script handles registered by WC.
- $styles : array<string|int, mixed>
- Contains an array of script handles registered by WC.
- $wp_localize_scripts : array<string|int, mixed>
- Contains an array of script handles localized by WC.
- add_legacy_script_warnings() : mixed
- Add warnings for deprecated script handles.
- get_styles() : array<string|int, mixed>
- Get styles for the frontend.
- init() : mixed
- Hook in methods.
- load_scripts() : mixed
- Register/queue frontend scripts.
- localize_printed_scripts() : mixed
- Localize scripts only when enqueued.
- enqueue_script() : mixed
- Register and enqueue a script for use.
- enqueue_style() : mixed
- Register and enqueue a styles for use.
- get_asset_url() : string
- Return asset URL.
- get_script_data() : array<string|int, mixed>|bool
- Return data for script handles.
- get_scripts() : array<string|int, mixed>
- Get scripts for the frontend.
- localize_script() : mixed
- Localize a WC script once.
- register_script() : mixed
- Register a script for use.
- register_scripts() : mixed
- Register all WC scripts.
- register_style() : mixed
- Register a style for use.
- register_styles() : mixed
- Register all WC styles.
Properties
$registered_scripts
Contains an array of script handles registered by WC.
private
static array<string|int, mixed>
$registered_scripts
= array()
$styles
Contains an array of script handles registered by WC.
private
static array<string|int, mixed>
$styles
= array()
$wp_localize_scripts
Contains an array of script handles localized by WC.
private
static array<string|int, mixed>
$wp_localize_scripts
= array()
Methods
add_legacy_script_warnings()
Add warnings for deprecated script handles.
public
static add_legacy_script_warnings() : mixed
Return values
mixed —get_styles()
Get styles for the frontend.
public
static get_styles() : array<string|int, mixed>
Return values
array<string|int, mixed> —init()
Hook in methods.
public
static init() : mixed
Return values
mixed —load_scripts()
Register/queue frontend scripts.
public
static load_scripts() : mixed
Return values
mixed —localize_printed_scripts()
Localize scripts only when enqueued.
public
static localize_printed_scripts() : mixed
Return values
mixed —enqueue_script()
Register and enqueue a script for use.
private
static enqueue_script(string $handle[, string $path = '' ][, array<string|int, string> $deps = array('jquery') ][, string $version = WC_VERSION ][, bool $in_footer = array('strategy' => 'defer') ]) : mixed
Parameters
- $handle : string
-
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.
- $deps : array<string|int, string> = array('jquery')
-
An array of registered script handles this script depends on.
- $version : string = WC_VERSION
-
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.
- $in_footer : bool = array('strategy' => 'defer')
-
Whether to enqueue the script before
