[wp-trac] [WordPress Trac] #20558: allow wp_localize_script data to be added to existing objects
WordPress Trac
wp-trac at lists.automattic.com
Fri Apr 27 17:12:07 UTC 2012
#20558: allow wp_localize_script data to be added to existing objects
-------------------------------------------------+-------------------------
Reporter: ryanve | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
Component: Performance | Review
Severity: minor | Version: 3.3
Keywords: dev-feedback reporter-feedback 2nd- | Resolution:
opinion |
-------------------------------------------------+-------------------------
Comment (by ryanve):
Another future consideration would be if an `$object_name` is not
provided, then expose the data to a single global object called wordpress:
{{{
window.wordpress = {};
}}}
so that `wp_localize_script($handle, false, $object)` would do
{{{
$script = 'wordpress["' . $handle . '"] = ' . json_encode($object) . ';';
}}}
You'd have to use bracket notation to accomodate stuff like
{{{
wordpress["jquery-ui-core"] = { ... };
}}}
Should probably do `sanitize_key($handle)` first to be safe.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20558#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list