WPDev.one
Core Function
View Source on Trac ↗

wp_localize_script()

wp_localize_script( mixed $handle, mixed $object_name, mixed $l10n )

Localizes a script.

Parameters 3 required

Name / Type Description
$handle
string

Script handle the data will be attached to.

Required
string

$object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable. Example: '/[a-zA-Z0-9_]+/'.

Required
$l10n
array

The data itself. The data can be either a single or multi-dimensional array.

Required

Return Value

(bool)
True if the script was successfully localized, false otherwise.

Function Information

Since Version
2.2.0
Source File
wp-includes/functions.wp-scripts.php
Advertisement