wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_localize_script › WordPress Function

Od2.2.0
Przestarzałyn/a
wp_localize_script ( $handle, $object_name, $l10n )
Parametry: (3)
  • (string) $handle Script handle the data will be attached to.
    Wymagane: Tak
  • (string) $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable. Example: '/[a-zA-Z0-9_]+/'.
    Wymagane: Tak
  • (array) $l10n The data itself. The data can be either a single or multi-dimensional array.
    Wymagane: Tak
Linki:
Zobacz:
  • WP_Scripts::localize()
Powrót:
  • (bool) True if the script was successfully localized, false otherwise.
Zdefiniowane na:
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, ... }


Źródło

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

	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
		_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
		return false;
	}

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