[wp-trac] [WordPress Trac] #11520: print_scripts_l10n() should use json_encode()
WordPress Trac
wp-trac at lists.automattic.com
Fri Sep 30 21:16:37 UTC 2011
#11520: print_scripts_l10n() should use json_encode()
-------------------------+------------------------
Reporter: scribu | Owner: azaozz
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 3.3
Component: JavaScript | Version:
Severity: critical | Resolution:
Keywords: |
-------------------------+------------------------
Comment (by azaozz):
Replying to [comment:72 westi]:
The current implementation has two (major) improvements:
1. json_encode() properly encodes all characters. This was a long standing
shortcoming masked by the fact that WordPress sets UTF-8 as default
charset in the browser. But as long as we support other charsets, we need
to make sure all JS strings containing non ASCII chars are properly
encoded (JS expects UFT-8). For example using English sets most browsers
to ISO-8859-1 and any non ASCII chars in the JS localization scripts are
garbled.
2. Replaces the (hacky) HTML entities decoding in JS with
html_entity_decode(). Not sure why we didn't use that the first time (in
WP 2.7), but seems to work well now (PHP 5.2).
We still can split the functions and revert localize_script but will need
to use html_entity_decode() and json_encode() for it. Can even make
add_script_data() to accept one string only leaving the encoding to the
plugins that would use it (that would actually allow passing of JS
functions, not just data).
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11520#comment:76>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list