Make WordPress Core


Ignore:
Timestamp:
09/29/2011 06:43:46 AM (13 years ago)
Author:
azaozz
Message:

Recursively convert html entities in script localization strings, see #11520

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class.wp-scripts.php

    r18810 r18813  
    6363                unset($data['l10n_print_after']);
    6464            }
    65             $output = "var $name = " . json_encode($data) . "; $after\n";
     65
     66            $data = $this->decode_html_entities($data);
     67            $output = "var $name = " . json_encode( $data ) . "; $after\n";
    6668        } else {
    6769            $data = $this->get_data( $handle, 'data' );
     
    7072                return false;
    7173
    72             foreach ( (array) $data as $name => $data ) {
    73                 $output = "var $name = " . json_encode($data) . ";\n";
     74            foreach ( (array) $data as $name => $value ) {
     75                $value = $this->decode_html_entities($value);
     76                $output = "var $name = " . json_encode( $value ) . ";\n";
    7477            }
    7578        }
     
    217220    }
    218221
     222    function decode_html_entities($data) {
     223        foreach ( (array) $data as $key => $value ) {
     224            if ( is_array($value) )
     225                $data[$key] = $this->decode_html_entities($value);
     226            elseif ( is_string($value) )
     227                $data[$key] = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
     228        }
     229        return $data;
     230    }
     231
    219232    function reset() {
    220233        $this->do_concat = false;
Note: See TracChangeset for help on using the changeset viewer.