[wp-trac] [WordPress Trac] #25280: wp_localize_script unexpectedly convert numbers to strings
WordPress Trac
noreply at wordpress.org
Tue Jan 14 21:09:25 UTC 2014
#25280: wp_localize_script unexpectedly convert numbers to strings
-------------------------------------------------+-------------------------
Reporter: adamsilverstein | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
Component: I18N | Review
Severity: normal | Version: 3.2
Keywords: has-patch dev-feedback needs- | Resolution:
testing |
-------------------------------------------------+-------------------------
Comment (by adamsilverstein):
Replying to [comment:8 tomauger]:
> I'm liking this fix, but actually agree with adam that it might be good
to have an entirely new way of passing object dependencies into our JS.
Right now I'm using a lot of JSDoc to document the "localize" global JS
var, but it certainly would be nice to have something a little more
robust.
>
> Forking wp_localize_script() to wp_pass_vars_to_script() (for lack of a
better name) seems like a pretty good (and backward-compatible) way to go.
I agree a new function probably makes the most sense, that would leave
backward compatibility with what we have while allowing a more robust
design. i believe this function was originally built with translation in
mind and has obviously been used for other purposes to the point where it
has become the recommended way to pass variables from PHP->JS in
WordPress.
The attached patch corrects some unexpected behavior and might still be
worth getting in - what would you envision a new function doing other than
having a new name and passing numbers/booleans correctly? If you have some
ideas, please respond or go ahead an open a new ticket proposing the new
function!
Thanks :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/25280#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list