wp_localize_script [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Wrapper for $wp_scripts->localize().
Used to localizes a script. Works only if the script has already been added. Accepts an associative array $l10n and creates JS object: "$object_name" = { key: value, key: value, ... } See http://core.trac.wordpress.org/ticket/11520 for more information.
Source
<?php
function wp_localize_script( $handle, $object_name, $l10n ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
return false;
}
return $wp_scripts->localize( $handle, $object_name, $l10n );
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/wp localize script « WordPress Codex
Description. Localizes a script, but only if script has already been added. Can also be used to include arbitrary Javascript data in a page.
codex.wordpress.org - jQuery extend is not working with wp_localize_script ... - WordPress
May 15, 2012 ... Hi, while outputting json with wp_localize_script but jquery extend is not working at all. Is there any issue with wp_localize_script json out put?
wordpress.org - wp_localize_script » Otto on WordPress
Aug 14, 2010 ... The wp_localize_script function was made in order to allow for WordPress translations to be able to also translate some of the JS files inside ...
ottopress.com - Best practice for adding JavaScript code to WordPress plugins ...
wp-wall.js', array('jquery', 'jquery-form')); wp_localize_script( 'wp_wall_script', ' WPWallSettings', array( 'refreshtime' => 5, 'mode' => "auto" )); } } ...
www.prelovac.com