wp_script_add_data

Add metadata to a script.

Description

wp_script_add_data( (string) $handle, (string) $key, (mixed) $value ); 

Works only if the script has already been added.

Possible values for $key and $value: 'conditional' string Comments for IE 6, lte IE 7, etc.

Parameters (3)

0. $handle (string)
Name of the script.
1. $key (string)
Name of data point for which we're storing a value.
2. $value (mixed)
String containing the data to be added.

Usage

  1. if ( !function_exists( 'wp_script_add_data' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.wp-scripts.php'; 
  3.  
  4. // Name of the script. 
  5. $handle = ''; 
  6.  
  7. // Name of data point for which we're storing a value. 
  8. $key = ''; 
  9.  
  10. // String containing the data to be added. 
  11. $value = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_script_add_data($handle, $key, $value); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.wp-scripts.php  
  1. function wp_script_add_data( $handle, $key, $value ) { 
  2. returnwp_scripts)->add_data( $handle, $key, $value );