wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_localize_script › WordPress Function

Since2.2.0
Deprecatedn/a
wp_localize_script ( $handle, $object_name, $l10n )
Parameters: (3)
  • (string) $handle Script handle the data will be attached to.
    Required: Yes
  • (string) $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable. Example: '/[a-zA-Z0-9_]+/'.
    Required: Yes
  • (array) $l10n The data itself. The data can be either a single or multi-dimensional array.
    Required: Yes
Links:
See:
  • WP_Scripts::localize()
Returns:
  • (bool) True if the script was successfully localized, false otherwise.
Defined at:
Codex:

Localizes a script.

Works only if the script has already been registered. Accepts an associative array $l10n and creates a JavaScript object: "$object_name": { key: value, key: value, ... }


Source

function wp_localize_script( $handle, $object_name, $l10n ) {
	$wp_scripts = wp_scripts();

	return $wp_scripts->localize( $handle, $object_name, $l10n );
}