Changeset 54142
- Timestamp:
- 09/13/2022 03:56:28 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class.wp-scripts.php
r53366 r54142 502 502 '5.7.0' 503 503 ); 504 505 if ( false === $l10n ) { 506 // This should really not be needed, but is necessary for backward compatibility. 507 $l10n = array( $l10n ); 508 } 504 509 } 505 510 506 511 if ( is_string( $l10n ) ) { 507 512 $l10n = html_entity_decode( $l10n, ENT_QUOTES, 'UTF-8' ); 508 } else {509 foreach ( (array)$l10n as $key => $value ) {513 } elseif ( is_array( $l10n ) ) { 514 foreach ( $l10n as $key => $value ) { 510 515 if ( ! is_scalar( $value ) ) { 511 516 continue; -
trunk/tests/phpunit/tests/dependencies/scripts.php
r53360 r54142 1429 1429 * @param mixed $l10n_data Localization data passed to wp_localize_script(). 1430 1430 * @param string $expected Expected transformation of localization data. 1431 * @param string $warning Optional. Whether a PHP native warning/error is expected. Default false. 1432 */ 1433 public function test_wp_localize_script_data_formats( $l10n_data, $expected, $warning = false ) { 1434 if ( $warning ) { 1435 if ( PHP_VERSION_ID < 80000 ) { 1436 $this->expectWarning(); 1437 } else { 1438 $this->expectError(); 1439 } 1440 } 1441 1431 */ 1432 public function test_wp_localize_script_data_formats( $l10n_data, $expected ) { 1442 1433 if ( ! is_array( $l10n_data ) ) { 1443 1434 $this->setExpectedIncorrectUsage( 'WP_Scripts::localize' ); … … 1461 1452 * @type mixed $l10n_data Localization data passed to wp_localize_script(). 1462 1453 * @type string $expected Expected transformation of localization data. 1463 * @type string $warning Optional. Whether a PHP native warning/error is expected.1464 1454 * } 1465 1455 */ … … 1472 1462 array( array( 'foo' => 6.6 ), '{"foo":"6.6"}' ), 1473 1463 array( array( 'foo' => 6 ), '{"foo":"6"}' ), 1464 array( array(), '[]' ), 1474 1465 1475 1466 // Unofficially supported format. … … 1477 1468 1478 1469 // Unsupported formats. 1479 array( 1.5, '1.5' , true),1480 array( 1, '1' , true),1470 array( 1.5, '1.5' ), 1471 array( 1, '1' ), 1481 1472 array( false, '[""]' ), 1473 array( null, 'null' ), 1482 1474 ); 1483 1475 }
Note: See TracChangeset
for help on using the changeset viewer.