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.

Top ↑

See also


Top ↑

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.


Top ↑

Return

(bool) True on success, false on failure.


Top ↑

Source

File: wp-includes/functions.wp-scripts.php

function wp_script_add_data( $handle, $key, $value ) {
	return wp_scripts()->add_data( $handle, $key, $value );
}


Top ↑

Changelog

Changelog
VersionDescription
4.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.