Ticket #25280: 25280.5.patch
File 25280.5.patch, 1.5 KB (added by , 10 years ago) |
---|
-
src/wp-includes/class.wp-scripts.php
161 161 } 162 162 163 163 foreach ( (array) $l10n as $key => $value ) { 164 if ( ! is_scalar($value) )164 if ( ! is_string( $value ) ) { 165 165 continue; 166 } 166 167 167 $l10n[ $key] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8');168 $l10n[ $key ] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8'); 168 169 } 169 170 170 171 $script = "var $object_name = " . json_encode($l10n) . ';'; -
tests/phpunit/tests/functions.php
529 529 $this->assertCount( 8, $urls ); 530 530 $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls ); 531 531 } 532 533 /** 534 * @ticket 25280 535 */ 536 function test_wp_localize_doesnt_convert_types_unexpectedly() { 537 global $wp_scripts; 538 539 $array_to_localize = array( 540 'a_string' => __( 'Some String' ), 541 'a_number' => 10, 542 'a_boolean' => true, 543 ); 544 545 wp_enqueue_script( 'localize_test','localize_script.js', array(), '1.0.0', true ); 546 $localized = wp_localize_script( 'localize_test', 'localized_variable', $array_to_localize ); 547 548 $this->assertEquals( 549 'var localized_variable = {"a_string":"Some String","a_number":10,"a_boolean":true};', 550 $wp_scripts->print_extra_script( 'localize_test', false ) 551 ); 552 } 553 532 554 }