<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[30055] trunk: Add `wp_json_encode()`, a wrapper for `json_encode()` that ensures everything is converted to UTF-8.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/30055">30055</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/30055","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>pento</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2014-10-28 18:34:16 +0000 (Tue, 28 Oct 2014)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Add `wp_json_encode()`, a wrapper for `json_encode()` that ensures everything is converted to UTF-8.
Change all core calls from `json_encode()` to `wp_json_encode()`.
Fixes <a href="https://core.trac.wordpress.org/ticket/28786">#28786</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincustomizephp">trunk/src/wp-admin/customize.php</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswplisttablephp">trunk/src/wp-admin/includes/class-wp-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpthemeslisttablephp">trunk/src/wp-admin/includes/class-wp-themes-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesmediaphp">trunk/src/wp-admin/includes/media.php</a></li>
<li><a href="#trunksrcwpadminincludesmiscphp">trunk/src/wp-admin/includes/misc.php</a></li>
<li><a href="#trunksrcwpadminincludesnavmenuphp">trunk/src/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunksrcwpadminincludestemplatephp">trunk/src/wp-admin/includes/template.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizewidgetsphp">trunk/src/wp-includes/class-wp-customize-widgets.php</a></li>
<li><a href="#trunksrcwpincludesclasswpeditorphp">trunk/src/wp-includes/class-wp-editor.php</a></li>
<li><a href="#trunksrcwpincludesclasswpscriptsphp">trunk/src/wp-includes/class.wp-scripts.php</a></li>
<li><a href="#trunksrcwpincludesfunctionsphp">trunk/src/wp-includes/functions.php</a></li>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
<li><a href="#trunksrcwpincludesthemephp">trunk/src/wp-includes/theme.php</a></li>
<li><a href="#trunksrcwpincludesupdatephp">trunk/src/wp-includes/update.php</a></li>
<li><a href="#trunktestsphpunittestsfunctionsphp">trunk/tests/phpunit/tests/functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincustomizephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/customize.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/customize.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/customize.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -274,7 +274,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script type="text/javascript">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
</ins><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </body>
</span></span></pre></div>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/ajax-actions.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -286,7 +286,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_die( json_encode( $return ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_die( wp_json_encode( $return ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1365,7 +1365,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $markup = ob_get_clean();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode(array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode(array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'replace-id' => $type . '-' . $item->name,
</span><span class="cx" style="display: block; padding: 0 10px"> 'markup' => $markup,
</span><span class="cx" style="display: block; padding: 0 10px"> ));
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1394,7 +1394,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $results ) )
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode( $results );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode( $results );
</ins><span class="cx" style="display: block; padding: 0 10px"> echo "\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1840,7 +1840,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'success' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'data' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1855,7 +1855,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $attachment_id ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'success' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> 'data' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'message' => $attachment_id->get_error_message(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1877,7 +1877,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'success' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'data' => $attachment,
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1902,7 +1902,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $_POST['do'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'save' :
</span><span class="cx" style="display: block; padding: 0 10px"> $msg = wp_save_image($attachment_id);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $msg = json_encode($msg);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $msg = wp_json_encode($msg);
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( $msg );
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'scale' :
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswplisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-list-table.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/class-wp-list-table.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1058,7 +1058,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- die( json_encode( $response ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ die( wp_json_encode( $response ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1075,6 +1075,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpthemeslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-themes-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-themes-list-table.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/class-wp-themes-list-table.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -273,7 +273,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $extra_args ) )
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array_merge( $args, $extra_args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", json_encode( $args ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> parent::_js_vars();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludesmediaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/media.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/media.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/media.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1826,7 +1826,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $large_size_w = 1024;
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-wpUploaderInit = <?php echo json_encode($plupload_init); ?>;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
</ins><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="plupload-upload-ui" class="hide-if-no-js">
</span></span></pre></div>
<a id="trunksrcwpadminincludesmiscphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/misc.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/misc.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/misc.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -621,7 +621,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
</span><span class="cx" style="display: block; padding: 0 10px"> <input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <input type="hidden" class="icon_colors" value="<?php echo esc_attr( json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
</ins><span class="cx" style="display: block; padding: 0 10px"> <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
</span><span class="cx" style="display: block; padding: 0 10px"> <table class="color-palette">
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -665,7 +665,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $icon_colors = array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_head', 'wp_color_scheme_settings' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/nav-menu.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/nav-menu.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/nav-menu.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -356,7 +356,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'markup' == $response_format ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'json' == $response_format ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $object_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => get_the_title( $object_id ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -373,7 +373,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'json' == $response_format ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_obj = get_term( $object_id, $object_type );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $object_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => $post_obj->name,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,7 +401,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $var_by_ref = get_the_ID();
</span><span class="cx" style="display: block; padding: 0 10px"> echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'json' == $response_format ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => get_the_ID(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => get_the_title(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -422,7 +422,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'markup' == $response_format ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'json' == $response_format ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $term->term_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => $term->name,
</span></span></pre></div>
<a id="trunksrcwpadminincludestemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/template.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-admin/includes/template.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1952,7 +1952,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <script type="text/javascript">
</span><span class="cx" style="display: block; padding: 0 10px"> //<![CDATA[
</span><span class="cx" style="display: block; padding: 0 10px"> (function($){
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var options = <?php echo json_encode( $args ); ?>, setup;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var options = <?php echo wp_json_encode( $args ); ?>, setup;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! options )
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-manager.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/class-wp-customize-manager.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -517,7 +517,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script type="text/javascript">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
</ins><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizewidgetsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-widgets.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-widgets.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/class-wp-customize-widgets.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -740,7 +740,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_scripts->add_data(
</span><span class="cx" style="display: block; padding: 0 10px"> 'customize-widgets',
</span><span class="cx" style="display: block; padding: 0 10px"> 'data',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- sprintf( 'var _wpCustomizeWidgetsSettings = %s;', json_encode( $settings ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ sprintf( 'var _wpCustomizeWidgetsSettings = %s;', wp_json_encode( $settings ) )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1055,7 +1055,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script type="text/javascript">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var _wpWidgetCustomizerPreviewSettings = <?php echo json_encode( $settings ); ?>;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode( $settings ); ?>;
</ins><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-editor.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/class-wp-editor.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -500,7 +500,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $mce_external_plugins ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$first_init['external_plugins'] = json_encode( $mce_external_plugins );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$first_init['external_plugins'] = wp_json_encode( $mce_external_plugins );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -986,7 +986,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $mce_translation['_dir'] = 'rtl';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return "tinymce.addI18n( '$mce_locale', " . json_encode( $mce_translation ) . ");\n" .
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" .
</ins><span class="cx" style="display: block; padding: 0 10px"> "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpscriptsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class.wp-scripts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class.wp-scripts.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/class.wp-scripts.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -167,7 +167,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $script = "var $object_name = " . json_encode($l10n) . ';';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !empty($after) )
</span><span class="cx" style="display: block; padding: 0 10px"> $script .= "\n$after;";
</span></span></pre></div>
<a id="trunksrcwpincludesfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/functions.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/functions.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2613,6 +2613,119 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Encode a variable into JSON, with some sanity checks
+ *
+ * @since 4.1.0
+ *
+ * @param mixed $data Variable (usually an array or object) to encode as JSON
+ * @param int $options Options to be passed to json_encode(). Default 0.
+ * @param int $depth Maximum depth to walk through $data. Must be greater than 0, default 512.t
+ *
+ * @return bool|string The JSON encoded string, or false if it cannot be encoded
+ */
+function wp_json_encode( $data, $options = 0, $depth = 512 ) {
+ // json_encode has had extra params added over the years.
+ // $options was added in 5.3, and $depth in 5.5.
+ // We need to make sure we call it with the correct arguments.
+ if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
+ $args = array( $data, $options, $depth );
+ } else if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
+ $args = array( $data, $options );
+ } else {
+ $args = array( $data );
+ }
+
+ $json = call_user_func_array( 'json_encode', $args );
+
+ if ( false !== $json ) {
+ // If json_encode was successful, no need to do more sanity checking
+ return $json;
+ }
+
+ try {
+ $args[0] = _wp_json_sanity_check( $data, $depth );
+ } catch ( Exception $e ) {
+ return false;
+ }
+
+ return call_user_func_array( 'json_encode', $args );
+}
+
+/**
+ * @ignore
+ */
+function _wp_json_sanity_check( $data, $depth ) {
+ if ( $depth < 0 ) {
+ throw new Exception( 'Reached depth limit' );
+ }
+
+ if ( is_array( $data ) ) {
+ $output = array();
+ foreach ( $data as $id => $el ) {
+ // Don't forget to sanitize the ID!
+ if ( is_string( $id ) ) {
+ $clean_id = _wp_json_convert_string( $id );
+ } else {
+ $clean_id = $id;
+ }
+
+ // Check the element type, so that we're only recursing if we really have to
+ if ( is_array( $el ) || is_object( $el ) ) {
+ $output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 );
+ } else if ( is_string( $el ) ) {
+ $output[ $clean_id ] = _wp_json_convert_string( $el );
+ } else {
+ $output[ $clean_id ] = $el;
+ }
+ }
+ } else if ( is_object( $data ) ) {
+ $output = new stdClass;
+ foreach ( $data as $id => $el ) {
+ if ( is_string( $id ) ) {
+ $clean_id = _wp_json_convert_string( $id );
+ } else {
+ $clean_id = $id;
+ }
+
+ if ( is_array( $el ) || is_object( $el ) ) {
+ $output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 );
+ } else if ( is_string( $el ) ) {
+ $output->$clean_id = _wp_json_convert_string( $el );
+ } else {
+ $output->$clean_id = $el;
+ }
+ }
+ } else if ( is_string( $data ) ) {
+ return _wp_json_convert_string( $data );
+ } else {
+ return $data;
+ }
+
+ return $output;
+}
+
+/**
+ * @ignore
+ */
+function _wp_json_convert_string( $string ) {
+ static $use_mb = null;
+ if ( is_null( $use_mb ) ) {
+ $use_mb = function_exists( 'mb_convert_encoding' );
+ }
+
+ if ( $use_mb ) {
+ $encoding = mb_detect_encoding( $string, mb_detect_order(), true );
+ if ( $encoding ) {
+ return mb_convert_encoding( $string, 'UTF-8', $encoding );
+ } else {
+ return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' );
+ }
+ } else {
+ return wp_check_invalid_utf8( $data, true );
+ }
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Send a JSON response back to an Ajax request.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.5.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2622,7 +2735,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_send_json( $response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo json_encode( $response );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo wp_json_encode( $response );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> else
</span></span></pre></div>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/media.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/media.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/media.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1398,7 +1398,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ?></ol>
</span><span class="cx" style="display: block; padding: 0 10px"> </noscript>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="application/json" class="wp-playlist-script"><?php echo json_encode( $data ) ?></script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ) ?></script>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> return ob_get_clean();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2582,7 +2582,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'limitExceeded' => is_multisite() && ! is_upload_space_available()
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $script = 'var _wpPluploadSettings = ' . json_encode( $settings ) . ';';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $data )
</span><span class="cx" style="display: block; padding: 0 10px"> $script = "$data\n$script";
</span></span></pre></div>
<a id="trunksrcwpincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/theme.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1939,7 +1939,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $script = 'var _wpCustomizeLoaderSettings = ' . json_encode( $settings ) . ';';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings ) . ';';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $wp_scripts->get_data( 'customize-loader', 'data' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $data )
</span></span></pre></div>
<a id="trunksrcwpincludesupdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/update.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/src/wp-includes/update.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +94,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_body = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'translations' => json_encode( $translations ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'translations' => wp_json_encode( $translations ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $extra_stats ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -274,16 +274,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $options = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => $timeout,
</span><span class="cx" style="display: block; padding: 0 10px"> 'body' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'plugins' => json_encode( $to_send ),
- 'translations' => json_encode( $translations ),
- 'locale' => json_encode( $locales ),
- 'all' => json_encode( true ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'plugins' => wp_json_encode( $to_send ),
+ 'translations' => wp_json_encode( $translations ),
+ 'locale' => wp_json_encode( $locales ),
+ 'all' => wp_json_encode( true ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $extra_stats ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $options['body']['update_stats'] = json_encode( $extra_stats );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options['body']['update_stats'] = wp_json_encode( $extra_stats );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -437,15 +437,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $options = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => $timeout,
</span><span class="cx" style="display: block; padding: 0 10px"> 'body' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'themes' => json_encode( $request ),
- 'translations' => json_encode( $translations ),
- 'locale' => json_encode( $locales ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'themes' => wp_json_encode( $request ),
+ 'translations' => wp_json_encode( $translations ),
+ 'locale' => wp_json_encode( $locales ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $extra_stats ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $options['body']['update_stats'] = json_encode( $extra_stats );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options['body']['update_stats'] = wp_json_encode( $extra_stats );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
</span></span></pre></div>
<a id="trunktestsphpunittestsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/functions.php 2014-10-28 18:31:19 UTC (rev 30054)
+++ trunk/tests/phpunit/tests/functions.php 2014-10-28 18:34:16 UTC (rev 30055)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -529,4 +529,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 8, $urls );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @ticket 28786
+ */
+ function test_wp_json_encode() {
+ $this->assertEquals( wp_json_encode( 'a' ), '"a"' );
+ $this->assertEquals( wp_json_encode( '这' ), '"\u8fd9"' );
+
+ $old_charsets = $charsets = mb_detect_order();
+ if ( ! in_array( 'EUC-JP', $charsets ) ) {
+ $charsets[] = 'EUC-JP';
+ mb_detect_order( $charsets );
+ }
+
+ $eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' );
+ $utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
+
+ $this->assertEquals( 'aあb', $utf8 );
+
+ $this->assertEquals( wp_json_encode( $eucjp ), '"a\u3042b"' );
+
+ $this->assertEquals( wp_json_encode( array( 'a' ) ), '["a"]' );
+
+ $object = new stdClass;
+ $object->a = 'b';
+ $this->assertEquals( wp_json_encode( $object ), '{"a":"b"}' );
+
+ mb_detect_order( $old_charsets );
+ }
+
+ /**
+ * @ticket 28786
+ */
+ function test_wp_json_encode_depth() {
+ $data = array( array( array( 1, 2, 3 ) ) );
+ $json = wp_json_encode( $data, 0, 1 );
+ $this->assertFalse( $json );
+
+ $data = array( 'あ', array( array( 1, 2, 3 ) ) );
+ $json = wp_json_encode( $data, 0, 1 );
+ $this->assertFalse( $json );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>