Make WordPress Core

Ticket #25280: 25280.diff

File 25280.diff, 682 bytes (added by adamsilverstein, 11 years ago)

correct wp_localize_script encoding numbers as strings

  • wp-includes/class.wp-scripts.php

     
    148148                        $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
    149149                }
    150150
    151                 $script = "var $object_name = " . json_encode($l10n) . ';';
     151                // Add JSON_NUMERIC_CHECK (introduced in PHP 5.3.3) if available so numbers are passed properly.
     152                $script = "var $object_name = " . ( defined( 'JSON_NUMERIC_CHECK' ) ? json_encode( $l10n, JSON_NUMERIC_CHECK ) : json_encode( $l10n ) ) . ';';
    152153
    153154                if ( !empty($after) )
    154155                        $script .= "\n$after;";