[wp-trac] [WordPress Trac] #19825: Bugs and modifications to localize script

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 13 16:47:55 UTC 2012


#19825: Bugs and modifications to localize script
-------------------------+-----------------------------
 Reporter:  ssmathias    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 After working in trunk, I noted that I get a fatal error when trying to
 localize some objects with wp_localize_script informing me that I cannot
 use an object of that type as an array. For tests, I've done this with
 $wp, $wp_query, $wpdb, and $wp_scripts on a clean install with no plugins.

 I also have been working on sites that would like to compress all of their
 JS calls into a single request where possible, but in the past I was not
 able to keep localizations that certain scripts required, and had to leave
 them out.

 With the changes I've made in this patch file, the issues regarding
 pushing arbitrary objects for localization are addressed. It also stores
 those objects, rather than a string of JS with $wp_scripts. This allows me
 to pull the localizations used for some files, and attach them instead to
 another file using wp_localize_script.

 As a side benefit, by not processing the object into JS until output, we
 are able to preserve the data cleanly, and reduce process on any script
 that may be dequeued later that has such dependencies.

 I would like to submit this patch as a core patch for a future release.
 Its design is fully compatible with existing functionality in 3.3, with
 the exception of any code modifying the underlying data key in an enqueued
 script directly.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19825>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list