Ticket #25280: 25280.2.diff
File 25280.2.diff, 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_s calar($value) )164 if ( !is_string($value) ) 165 165 continue; 166 166 167 $l10n[$key] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8');167 $l10n[$key] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8'); 168 168 } 169 169 170 170 $script = "var $object_name = " . json_encode($l10n) . ';'; -
tests/phpunit/tests/functions.php
524 524 $this->assertCount( 8, $urls ); 525 525 $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls ); 526 526 } 527 528 /** 529 * @ticket 25280 530 */ 531 function test_wp_localize_doesnt_convert_types_unexpectedly() { 532 global $wp_scripts; 533 534 $array_to_localize = array( 535 'a_string' => __( 'Some String' ), 536 'a_number' => 10, 537 'a_boolean' => true, 538 ); 539 540 wp_enqueue_script( 'localize_test','localize_script.js', array(), '1.0.0', true ); 541 $localized = wp_localize_script( 'localize_test', 'localized_variable', $array_to_localize ); 542 543 $this->assertEquals( 544 'var localized_variable = {"a_string":"Some String","a_number":10,"a_boolean":true};', 545 $wp_scripts->print_extra_script( 'localize_test', false ) 546 ); 547 } 548 527 549 }