[wp-trac] [WordPress Trac] #52534: PHP 8: wp_localize_script() throws a warning if third parameter is a string.

WordPress Trac noreply at wordpress.org
Mon Feb 22 23:22:10 UTC 2021


#52534: PHP 8: wp_localize_script() throws a warning if third parameter is a
string.
-------------------------------------------------+-------------------------
 Reporter:  peterwilsoncc                        |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  5.7
Component:  Script Loader                        |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  php8 has-patch has-unit-tests dev-   |     Focuses:
  reviewed commit                                |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50408" 50408]:
 {{{
 #!CommitTicketReference repository="" revision="50408"
 Script Loader: Prevent `wp_localize_script()` warnings.

 Prevent `wp_localize_script()` (via `WP_Scripts::localize()`) throwing
 warnings in PHP 8 when the translation data is passed as a string. This
 maintains backward compatibility with earlier versions of PHP.

 Introduce a `_doing_it_wrong()` notice to `WP_Scripts::localize()` if the
 translation data is not passed as an array.

 Props jrf, peterwilsoncc, SergeyBiryukov.
 Fixes #52534.
 }}}

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


More information about the wp-trac mailing list