Assets

Posted on November 25, 2016

The Assets config module is responsible to easily register/deregister your stylesheet and/or javascript files.

Default config path

{{ Project Name }}/app/config/assets.json

You can rewrite this path by lf_config_assets_path filter.

Keys:

deregister_scripts

Description: deregistering scripts from front end.

Value: array of names of the script handle to be removed.

Value item arguments:

$handle 

(string) (required) Name of the script handle to be removed.

Default: None

Based on:

wp_deregister_script( jquery );

 

admin_deregister_scripts

Description: deregistering scripts from back end.

Value: array of names of the script handle to be removed.

Value item arguments: 

$handle 

(string) (required) Name of the script handle to be removed.

Default: None

Based on:

wp_deregister_script( jquery );

login_deregister_scripts

Description: deregistering scripts from login page.

Value: array of names of the script handle to be removed.

Value item arguments:

$handle 

(string) (required) Name of the script handle to be removed.

Default: None

Based on:

wp_deregister_script( jquery );

 

deregister_scripts

scripts

Description: load scripts into front end.

Value: array of wp_enqueue_script functions.

Value item arguments: 

$handle

(string) (Required) Name of the script. Should be unique.

$src

(string) (Optional) Full URL of the script, or path of the script relative to the WordPress root directory.

Default value: false

$deps

(array) (Optional) An array of registered script handles this script depends on.

Default value: array()

$ver

(string|bool|null) (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.

Default value: false

$in_footer

(bool) (Optional) Whether to enqueue the script before </body> instead of in the <head>. Default ‘false’.

Default value: false

 

Based on:

wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );

admin_scripts

Description: load scripts into back end.

Value: array of wp_enqueue_script functions.

Value item arguments: 

$handle

(string) (Required) Name of the script. Should be unique.

$src

(string) (Optional) Full URL of the script, or path of the script relative to the WordPress root directory.

Default value: false

$deps

(array) (Optional) An array of registered script handles this script depends on.

Default value: array()

$ver

(string|bool|null) (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.

Default value: false

$in_footer

(bool) (Optional) Whether to enqueue the script before </body> instead of in the <head>. Default ‘false’.

Default value: false

 

Based on:

wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );

 

login_scripts

Description: load scripts into login page.

Value: array of wp_enqueue_script functions.

Value item arguments: 

$handle

(string) (Required) Name of the script. Should be unique.

$src

(string) (Optional) Full URL of the script, or path of the script relative to the WordPress root directory.

Default value: false

$deps

(array) (Optional) An array of registered script handles this script depends on.

Default value: array()

$ver

(string|bool|null) (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.

Default value: false

$in_footer

(bool) (Optional) Whether to enqueue the script before </body> instead of in the <head>. Default ‘false’.

Default value: false

 

Based on:

wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );

 

scripts

styles

Description: load styles into front end. Registers the style if source provided (does NOT overwrite) and enqueues.

Value: array of wp_enqueue_style functions.

Value item arguments: 

$handle

(string) (Required) Name of the stylesheet. Should be unique.

$src

(string) (Optional) Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
Default value: false

$deps

(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()

$ver

(string|bool|null) (Optional) 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.
Default value: false

$media

(string) (Optional) 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)’.
Default value: ‘all’

 

Based on:

wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media = all )

admin_styles

Description: load styles into back end. Registers the style if source provided (does NOT overwrite) and enqueues.

Value: array of wp_enqueue_style functions.

Value item arguments: 

$handle

(string) (Required) Name of the stylesheet. Should be unique.

$src

(string) (Optional) Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
Default value: false

$deps

(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()

$ver

(string|bool|null) (Optional) 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.
Default value: false

$media

(string) (Optional) 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)’.
Default value: ‘all’

 

Based on:

wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media = all )

login_styles

Description: load styles into back end. Registers the style if source provided (does NOT overwrite) and enqueues.

Value: array of wp_enqueue_style functions.

Value item arguments: 

$handle

(string) (Required) Name of the stylesheet. Should be unique.

$src

(string) (Optional) Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
Default value: false

$deps

(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()

$ver

(string|bool|null) (Optional) 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.
Default value: false

$media

(string) (Optional) 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)’.
Default value: ‘all’

 

Based on:

wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media = all )

styles

localize

Description: load localize script into front end. Localizes a registered script with data for a JavaScript variable.

Value: array of wp_localize_script functions.

Value item arguments: 

$handle

(string) (required) The registered script handle you are attaching the data for.
Default: None

$name

(string) (required) The name of the variable which will contain the data. Note that this should be unique to both the script and to the plugin or theme. Thus, the value here should be properly prefixed with the slug or another unique value, to prevent conflicts. However, as this is a JavaScript object name, it cannot contain dashes. Use underscores or camelCasing.
Default: None

$data

(array) (required) The data itself. The data can be either a single- or multi- (as of 3.3) dimensional array. Like json_encode(), the data will be a JavaScript object if the array is an associate array (a map), otherwise the array will be a JavaScript array.
Default: None

Based on:

wp_localize_script( $handle, $name, $data );

admin_localize

Description: load localize script into back end. Localizes a registered script with data for a JavaScript variable.

Value: array of wp_localize_script functions.

Value item arguments: 

$handle

(string) (required) The registered script handle you are attaching the data for.
Default: None

$name

(string) (required) The name of the variable which will contain the data. Note that this should be unique to both the script and to the plugin or theme. Thus, the value here should be properly prefixed with the slug or another unique value, to prevent conflicts. However, as this is a JavaScript object name, it cannot contain dashes. Use underscores or camelCasing.
Default: None

$data

(array) (required) The data itself. The data can be either a single- or multi- (as of 3.3) dimensional array. Like json_encode(), the data will be a JavaScript object if the array is an associate array (a map), otherwise the array will be a JavaScript array.
Default: None

Based on:

wp_localize_script( $handle, $name, $data );

login_localize

Description: load localize script into login page. Localizes a registered script with data for a JavaScript variable.

Value: array of wp_localize_script functions.

Value item arguments: 

$handle

(string) (required) The registered script handle you are attaching the data for.
Default: None

$name

(string) (required) The name of the variable which will contain the data. Note that this should be unique to both the script and to the plugin or theme. Thus, the value here should be properly prefixed with the slug or another unique value, to prevent conflicts. However, as this is a JavaScript object name, it cannot contain dashes. Use underscores or camelCasing.
Default: None

$data

(array) (required) The data itself. The data can be either a single- or multi- (as of 3.3) dimensional array. Like json_encode(), the data will be a JavaScript object if the array is an associate array (a map), otherwise the array will be a JavaScript array.
Default: None

Based on:

wp_localize_script( $handle, $name, $data );

 

localize

custom

Description: load custom assets stuff with certain conditions into front end.

Value: array of callable functions.

 

admin_custom

Description: load custom assets stuff with certain conditions into back end.

Value: array of callable functions.

 

login_custom

Description: load custom assets stuff with certain conditions into login page.

Value: array of callable functions.

custom

 

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *