WooCommerce Code Reference

WC_Frontend_Scripts
in package

Frontend scripts class.

Table of Contents

$scripts  : array
Contains an array of script handles registered by WC.
$styles  : array
Contains an array of script handles registered by WC.
$wp_localize_scripts  : array
Contains an array of script handles localized by WC.
get_styles()  : array
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|bool
Return data for script handles.
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 sty;es.

Properties

Methods

enqueue_script()

Register and enqueue a script for use.

private static enqueue_script(string $handle[, string $path = '' ][, string[] $deps = array('jquery') ][, string $version = WC_VERSION ][, bool $in_footer = true ]) : 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 : 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 = true

Whether to enqueue the script before </body> instead of in the <head>. Default 'false'.

Tags
uses
wp_enqueue_script()
Return values
mixed

enqueue_style()

Register and enqueue a styles for use.

private static enqueue_style(string $handle[, string $path = '' ][, string[] $deps = array() ][, string $version = WC_VERSION ][, string $media = 'all' ][, bool $has_rtl = false ]) : mixed
Parameters
$handle : string

Name of the stylesheet. Should be unique.

$path : string = ''

Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.

$deps : string[] = array()

An array of registered stylesheet handles this stylesheet depends on.

$version : string = WC_VERSION

String specifying stylesheet 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.

$media : string = 'all'

The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.

$has_rtl : bool = false

If has RTL version to load too.

Tags
uses
wp_enqueue_style()
Return values
mixed

get_asset_url()

Return asset URL.

private static get_asset_url(string $path) : string
Parameters
$path : string

Assets path.

Return values
string

get_script_data()

Return data for script handles.

private static get_script_data(string $handle) : array|bool
Parameters
$handle : string

Script handle the data will be attached to.

Return values
array|bool

register_script()

Register a script for use.

private static register_script(string $handle, string $path[, string[] $deps = array('jquery') ][, string $version = WC_VERSION ][, bool $in_footer = true ]) : 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 : 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 = true

Whether to enqueue the script before </body> instead of in the <head>. Default 'false'.

Tags
uses
wp_register_script()
Return values
mixed

register_style()

Register a style for use.

private static register_style(string $handle, string $path[, string[] $deps = array() ][, string $version = WC_VERSION ][, string $media = 'all' ][, bool $has_rtl = false ]) : mixed
Parameters
$handle : string

Name of the stylesheet. Should be unique.

$path : string

Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.

$deps : string[] = array()

An array of registered stylesheet handles this stylesheet depends on.

$version : string = WC_VERSION

String specifying stylesheet 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.

$media : string = 'all'

The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.

$has_rtl : bool = false

If has RTL version to load too.

Tags
uses
wp_register_style()
Return values
mixed