wp_script_add_data() WordPress Function
The wp_script_add_data() function allows you to add data to a registered script. The function takes two arguments: the handle of the script to which you want to add data, and the key of the data you want to add. The value of the data you add will be available to the script via the global object.
wp_script_add_data( string $handle, string $key, mixed $value ) #
Add metadata to a script.
Description
Works only if the script has already been registered.
Possible values for $key and $value: ‘conditional’ string Comments for IE 6, lte IE 7, etc.
See also
Parameters
- $handle
(string)(Required)Name of the script.
- $key
(string)(Required)Name of data point for which we're storing a value.
- $value
(mixed)(Required)String containing the data to be added.
Return
(bool) True on success, false on failure.
Source
File: wp-includes/functions.wp-scripts.php
function wp_script_add_data( $handle, $key, $value ) { return wp_scripts()->add_data( $handle, $key, $value ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.2.0 | Introduced. |