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

WordPress Trac noreply at wordpress.org
Wed Sep 17 19:11:43 UTC 2014


#25280: wp_localize_script unexpectedly converts numbers to strings
----------------------------------------------+----------------------------
 Reporter:  adamsilverstein                   |       Owner:
     Type:  enhancement                       |      Status:  new
 Priority:  normal                            |   Milestone:  Future
Component:  I18N                              |  Release
 Severity:  normal                            |     Version:  3.2
 Keywords:  has-patch dev-feedback 4.1-early  |  Resolution:
                                              |     Focuses:  javascript
----------------------------------------------+----------------------------

Comment (by adamsilverstein):

 I agree this would be a nice feature to add, however its outside the scope
 of the issue I am trying to address with this ticket.

 Could you please open up a new ticket for this enhancement and post your
 patch there?

 Thanks!

 Replying to [comment:21 Fab1en]:
 > I thinks that another behavior is to be fixed at the same time : using a
 scalar variable.
 > We should be able to do this :
 >
 > {{{
 > wp_localize_script( 'main', 'localized_variable', 'a scalar value' );
 > }}}
 >
 > As of version 3.9.1, this is working : it generates a JavaScript scalar
 value, but a PHP Warning is thrown :
 > {{{
 > Warning: Cannot use a scalar value as an array in
 > /server/projects/other/quatreheures/esope/htdocs/wp-includes/class.wp-
 scripts.php on line 167
 > }}}
 >
 > I suggest to add another test to avoid this issue.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/25280#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list