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

WordPress Trac noreply at wordpress.org
Tue Aug 5 09:58:54 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 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:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list