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

Andrew Nacin wp at andrewnacin.com
Tue Jun 7 01:19:56 UTC 2011


On Mon, Jun 6, 2011 at 7:07 PM, Nathaniel Taintor <
goldenapplesdesign at gmail.com> wrote:

> I've been wondering for a while why wp_localize scripts handles json
> encoding so awkwardly:
>
>
> http://core.trac.wordpress.org/browser/trunk/wp-includes/class.wp-scripts.php#L50
>
> 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.
>

Not really -- just hasn't been a priority yet.
http://core.trac.wordpress.org/ticket/11520


More information about the wp-hackers mailing list