[wp-hackers] Is there a reason wp_localize_scripts doesn't handle multi-dimensional arrays?

Nathaniel Taintor goldenapplesdesign at gmail.com
Mon Jun 6 23:07:03 UTC 2011

I've been wondering for a while why wp_localize scripts handles json
encoding so awkwardly:


Since WP3.2 now requires PHP 5.2 or higher, could this be rewritten to use
json_encode, and thus allow localization of multi-dimensional arrays? Each
value could still be mapped through esc_js, if necessary.

I'd be happy to submit a patch for it, just wondered if there was a reason
it hadn't been done yet.

And, cheers to whoever added the "Source File" section on the Codex page for
wp_localize_scripts. You've made me laugh on more than one occasion when
I've looked up that page.

Nathaniel Taintor

Nathaniel Taintor, Designer/Developer
*Golden Apples Design*

@GoldenApples | 503.877.2880
goldenapplesdesign at gmail.com

More information about the wp-hackers mailing list