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

git-svn-id: https://develop.svn.wordpress.org/trunk@18813 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2011-09-29 06:43:46 +00:00
parent bb89b80c5b
commit 03375fa844
1 changed files with 16 additions and 3 deletions

View File

@ -62,6 +62,8 @@ class WP_Scripts extends WP_Dependencies {
$after = $data['l10n_print_after']; $after = $data['l10n_print_after'];
unset($data['l10n_print_after']); unset($data['l10n_print_after']);
} }
$data = $this->decode_html_entities($data);
$output = "var $name = " . json_encode( $data ) . "; $after\n"; $output = "var $name = " . json_encode( $data ) . "; $after\n";
} else { } else {
$data = $this->get_data( $handle, 'data' ); $data = $this->get_data( $handle, 'data' );
@ -69,8 +71,9 @@ class WP_Scripts extends WP_Dependencies {
if ( empty( $data ) ) if ( empty( $data ) )
return false; return false;
foreach ( (array) $data as $name => $data ) { foreach ( (array) $data as $name => $value ) {
$output = "var $name = " . json_encode($data) . ";\n"; $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; 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() { function reset() {
$this->do_concat = false; $this->do_concat = false;
$this->print_code = ''; $this->print_code = '';