[wp-trac] [WordPress Trac] #25280: wp_localize_script unexpectedly convert numbers to strings

WordPress Trac noreply at wordpress.org
Wed Sep 11 16:48:38 UTC 2013


#25280: wp_localize_script unexpectedly convert numbers to strings
-----------------------------+------------------------------
 Reporter:  adamsilverstein  |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  I18N             |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |
-----------------------------+------------------------------
Changes (by c3mdigital):

 * keywords:  has-patch dev-feedback => has-patch close


Comment:

 It also converts booleans to strings as well and if you don't have control
 of the javascript reading the vars you can't use numbers or booleans.

 I know the general accepted practice is to use wp_localize_script to pass
 variables to javascript but that is not what the function was intended for
 (it's a bonus feature and I blame Otto's awesome blog post). It's for
 string translations and I don't think it should be changed because numbers
 don't need to be translated.

 Also we can't rely on PHP 5.3.x when over 58% of our user base is still on
 5.2.x

 I'm thinking wontfix.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25280#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list