Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #51108, comment 2


Ignore:
Timestamp:
09/10/2020 01:44:22 PM (4 years ago)
Author:
azaozz
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #51108, comment 2

    initial v1  
    11Right, using `wp_add_inline_script()` is better in this case.
    22
    3 However, where is that warning coming from? For back-compat reasons `$wp_scripts->localize()` does `foreach ( (array) $l10n as $key => $value )`, i.e. it supports passing a string as mentioned in the ticket, and the string should be cast to array.
     3However, where is that warning coming from? For back-compat reasons `$wp_scripts->localize()` does:
     4
     5
     6{{{
     7if ( is_array( $l10n ) ...
     8...
     9foreach ( (array) $l10n as $key => $value )
     10...
     11}}}
     12
     13I.e. it supports passing a string as mentioned in the ticket, and the string should be cast to array.
    414
    515Does casting to array work in PHP 8.0?