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

git-svn-id: http://svn.automattic.com/wordpress/trunk@18813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-09-29 06:43:46 +00:00
parent ccf47d55c4
commit b26dcf5ce6
1 changed files with 16 additions and 3 deletions

View File

@ -62,15 +62,18 @@ class WP_Scripts extends WP_Dependencies {
$after = $data['l10n_print_after'];
unset($data['l10n_print_after']);
}
$output = "var $name = " . json_encode($data) . "; $after\n";
$data = $this->decode_html_entities($data);
$output = "var $name = " . json_encode( $data ) . "; $after\n";
} else {
$data = $this->get_data( $handle, 'data' );
if ( empty( $data ) )
return false;
foreach ( (array) $data as $name => $data ) {
$output = "var $name = " . json_encode($data) . ";\n";
foreach ( (array) $data as $name => $value ) {
$value = $this->decode_html_entities($value);
$output = "var $name = " . json_encode( $value ) . ";\n";
}
}
@ -216,6 +219,16 @@ class WP_Scripts extends WP_Dependencies {
return false;
}
function decode_html_entities($data) {
foreach ( (array) $data as $key => $value ) {
if ( is_array($value) )
$data[$key] = $this->decode_html_entities($value);
elseif ( is_string($value) )
$data[$key] = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
}
return $data;
}
function reset() {
$this->do_concat = false;
$this->print_code = '';