wp_localize_script


wp_localize_script ( $handle, $object_name, $l10n )

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

Description

Localize a script.

Works only if the script has already been added.

Accepts an associative array $l10n and creates a JavaScript object:

"$object_name" = {
    key: value,
    key: value,
    ...
}

Related Functions

wp_playlist_scripts, wp_add_inline_script, wp_normalize_path, wp_initialize_site, _wp_footer_scripts

Top Google Results

User discussions

wpseek mobile