<!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>[36414] trunk: Customizer: Export `nonce`, `theme`, and `url` app settings in preview as exported in pane.</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/36414">36414</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/36414","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-01-27 17:54:39 +0000 (Wed, 27 Jan 2016)</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'>Customizer: Export `nonce`, `theme`, and `url` app settings in preview as exported in pane.
* Introduce `WP_Customize_Manager::get_nonces()` to consolidate logic for retrieving nonces.
* Export nonces centrally in `wp.customize.settings.nonce` with each request and update nav menus preview to utilize.
* Send updated nonces to preview upon `nonce-refresh`.
* Request full preview refresh if Nav Menu selective refresh request fails (e.g. due to bad nonce).
* Update nav menus and widgets in Customizer to utilize `customize_refresh_nonces` for exporting nonces and keeping them up to date.
See <a href="https://core.trac.wordpress.org/ticket/27355">#27355</a>.
Fixes <a href="https://core.trac.wordpress.org/ticket/35617">#35617</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjscustomizecontrolsjs">trunk/src/wp-admin/js/customize-controls.js</a></li>
<li><a href="#trunksrcwpadminjscustomizenavmenusjs">trunk/src/wp-admin/js/customize-nav-menus.js</a></li>
<li><a href="#trunksrcwpadminjscustomizewidgetsjs">trunk/src/wp-admin/js/customize-widgets.js</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizenavmenusphp">trunk/src/wp-includes/class-wp-customize-nav-menus.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizewidgetsphp">trunk/src/wp-includes/class-wp-customize-widgets.php</a></li>
<li><a href="#trunksrcwpincludesjscustomizepreviewnavmenusjs">trunk/src/wp-includes/js/customize-preview-nav-menus.js</a></li>
<li><a href="#trunksrcwpincludesjscustomizepreviewjs">trunk/src/wp-includes/js/customize-preview.js</a></li>
<li><a href="#trunktestsphpunittestscustomizemanagerphp">trunk/tests/phpunit/tests/customize/manager.php</a></li>
<li><a href="#trunktestsphpunittestscustomizenavmenusphp">trunk/tests/phpunit/tests/customize/nav-menus.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjscustomizecontrolsjs"></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/js/customize-controls.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-controls.js 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-admin/js/customize-controls.js 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3375,6 +3375,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> api.bind( 'nonce-refresh', function( nonce ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $.extend( api.settings.nonce, nonce );
</span><span class="cx" style="display: block; padding: 0 10px"> $.extend( api.previewer.nonce, nonce );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.previewer.send( 'nonce-refresh', nonce );
</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"> // Create Settings
</span></span></pre></div>
<a id="trunksrcwpadminjscustomizenavmenusjs"></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/js/customize-nav-menus.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-nav-menus.js 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-admin/js/customize-nav-menus.js 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -323,7 +323,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> availableMenuItemContainer.find( '.accordion-section-title' ).addClass( 'loading' );
</span><span class="cx" style="display: block; padding: 0 10px"> self.loading = true;
</span><span class="cx" style="display: block; padding: 0 10px"> params = {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'customize-menus-nonce': api.Menus.data.nonce,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'customize-menus-nonce': api.settings.nonce['customize-menus'],
</ins><span class="cx" style="display: block; padding: 0 10px"> 'wp_customize': 'on',
</span><span class="cx" style="display: block; padding: 0 10px"> 'type': type,
</span><span class="cx" style="display: block; padding: 0 10px"> 'object': object,
</span></span></pre></div>
<a id="trunksrcwpadminjscustomizewidgetsjs"></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/js/customize-widgets.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-widgets.js 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-admin/js/customize-widgets.js 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1107,7 +1107,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> params = {};
</span><span class="cx" style="display: block; padding: 0 10px"> params.action = 'update-widget';
</span><span class="cx" style="display: block; padding: 0 10px"> params.wp_customize = 'on';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- params.nonce = api.Widgets.data.nonce;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ params.nonce = api.settings.nonce['update-widget'];
</ins><span class="cx" style="display: block; padding: 0 10px"> params.theme = api.settings.theme.stylesheet;
</span><span class="cx" style="display: block; padding: 0 10px"> params.customized = wp.customize.previewer.query().customized;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2058,11 +2058,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> sidebar_widgets: api.Widgets.SidebarControl
</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">- // Refresh the nonce if login sends updated nonces over.
- api.bind( 'nonce-refresh', function( nonces ) {
- api.Widgets.data.nonce = nonces['update-widget'];
- });
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Init Customizer for widgets.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</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 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-includes/class-wp-customize-manager.php 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -801,20 +801,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function customize_preview_settings() {
</span><span class="cx" style="display: block; padding: 0 10px"> $settings = array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'theme' => array(
+ 'stylesheet' => $this->get_stylesheet(),
+ 'active' => $this->is_theme_active(),
+ ),
+ 'url' => array(
+ 'self' => empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'channel' => wp_unslash( $_POST['customize_messenger_channel'] ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'activePanels' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'activeSections' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'activeControls' => array(),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'nonce' => $this->get_nonces(),
</ins><span class="cx" style="display: block; padding: 0 10px"> '_dirty' => array_keys( $this->unsanitized_post_values() ),
</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">- if ( 2 == $this->nonce_tick ) {
- $settings['nonce'] = array(
- 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
- 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() )
- );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> foreach ( $this->panels as $panel_id => $panel ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $panel->check_capabilities() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $settings['activePanels'][ $panel_id ] = $panel->active();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1025,22 +1026,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( 'not_preview' );
</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">- $nonces = array(
- 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
- 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
- );
-
- /**
- * Filter nonces for a customize_refresh_nonces AJAX request.
- *
- * @since 4.2.0
- *
- * @param array $nonces Array of refreshed nonces for save and
- * preview actions.
- * @param WP_Customize_Manager $this WP_Customize_Manager instance.
- */
- $nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this );
- wp_send_json_success( $nonces );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_send_json_success( $this->get_nonces() );
</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">@@ -1636,6 +1622,32 @@
</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">+ * Get nonces for the Customizer.
+ *
+ * @since 4.5.0
+ * @return array Nonces.
+ */
+ public function get_nonces() {
+ $nonces = array(
+ 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
+ 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
+ );
+
+ /**
+ * Filter nonces for Customizer.
+ *
+ * @since 4.2.0
+ *
+ * @param array $nonces Array of refreshed nonces for save and
+ * preview actions.
+ * @param WP_Customize_Manager $this WP_Customize_Manager instance.
+ */
+ $nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this );
+
+ return $nonces;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Print JavaScript settings for parent window.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.4.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1695,10 +1707,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'panels' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'sections' => array(),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'nonce' => array(
- 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
- 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'nonce' => $this->get_nonces(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'autofocus' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'documentTitleTmpl' => $this->get_document_title_template(),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizenavmenusphp"></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-nav-menus.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-nav-menus.php 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-includes/class-wp-customize-nav-menus.php 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,6 +48,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->previewed_menus = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->manager = $manager;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,6 +64,20 @@
</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">+ * Add nonce for customizing menus.
+ *
+ * @since 4.5.0
+ * @access public
+ *
+ * @param array $nonces Array of nonces.
+ * @return array $nonces Array of nonces.
+ */
+ public function filter_nonces( $nonces ) {
+ $nonces['customize-menus'] = wp_create_nonce( 'customize-menus' );
+ return $nonces;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Ajax handler for loading available menu items.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.3.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -329,7 +344,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Pass data to JS.
</span><span class="cx" style="display: block; padding: 0 10px"> $settings = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'nonce' => wp_create_nonce( 'customize-menus' ),
</del><span class="cx" style="display: block; padding: 0 10px"> 'allMenus' => wp_get_nav_menus(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'itemTypes' => $this->available_item_types(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'l10n' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -939,12 +953,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'renderQueryVar' => self::RENDER_QUERY_VAR,
</span><span class="cx" style="display: block; padding: 0 10px"> 'renderNonceValue' => wp_create_nonce( self::RENDER_AJAX_ACTION ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'renderNoncePostKey' => self::RENDER_NONCE_POST_KEY,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'requestUri' => empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
- 'theme' => array(
- 'stylesheet' => $this->manager->get_stylesheet(),
- 'active' => $this->manager->is_theme_active(),
- ),
- 'previewCustomizeNonce' => wp_create_nonce( 'preview-customize_' . $this->manager->get_stylesheet() ),
</del><span class="cx" style="display: block; padding: 0 10px"> 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args,
</span><span class="cx" style="display: block; padding: 0 10px"> 'l10n' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'editNavMenuItemTooltip' => __( 'Shift-click to edit this menu item.' ),
</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 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-includes/class-wp-customize-widgets.php 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -661,7 +661,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"> $settings = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'nonce' => wp_create_nonce( 'update-widget' ),
</del><span class="cx" style="display: block; padding: 0 10px"> 'registeredSidebars' => array_values( $wp_registered_sidebars ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'registeredWidgets' => $wp_registered_widgets,
</span><span class="cx" style="display: block; padding: 0 10px"> 'availableWidgets' => $available_widgets, // @todo Merge this with registered_widgets
</span></span></pre></div>
<a id="trunksrcwpincludesjscustomizepreviewnavmenusjs"></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/js/customize-preview-nav-menus.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/customize-preview-nav-menus.js 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-includes/js/customize-preview-nav-menus.js 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,12 +13,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> renderQueryVar: null,
</span><span class="cx" style="display: block; padding: 0 10px"> renderNonceValue: null,
</span><span class="cx" style="display: block; padding: 0 10px"> renderNoncePostKey: null,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- previewCustomizeNonce: null,
</del><span class="cx" style="display: block; padding: 0 10px"> requestUri: '/',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- theme: {
- active: false,
- stylesheet: ''
- },
</del><span class="cx" style="display: block; padding: 0 10px"> navMenuInstanceArgs: {},
</span><span class="cx" style="display: block; padding: 0 10px"> l10n: {}
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,11 +195,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> menuId = parseInt( menuId, 10 );
</span><span class="cx" style="display: block; padding: 0 10px">
</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">- nonce: settings.previewCustomizeNonce, // for Customize Preview
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ nonce: wp.customize.settings.nonce.preview,
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_customize: 'on'
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! settings.theme.active ) {
- data.theme = settings.theme.stylesheet;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp.customize.settings.theme.active ) {
+ data.theme = wp.customize.settings.theme.stylesheet;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> data[ settings.renderQueryVar ] = '1';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -239,7 +234,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> request = wp.ajax.send( null, {
</span><span class="cx" style="display: block; padding: 0 10px"> data: data,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- url: settings.requestUri
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ url: api.settings.url.self
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> request.done( function( data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // If the menu is now not visible, refresh since the page layout may have changed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,6 +258,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> container.removeClass( 'customize-partial-refreshing' );
</span><span class="cx" style="display: block; padding: 0 10px"> $( document ).trigger( 'customize-preview-menu-refreshed', [ eventParam ] );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ request.fail( function() {
+ api.preview.send( 'refresh' );
+ } );
</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"> refreshMenuInstanceDebounced : function( instanceNumber ) {
</span></span></pre></div>
<a id="trunksrcwpincludesjscustomizepreviewjs"></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/js/customize-preview.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/customize-preview.js 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/src/wp-includes/js/customize-preview.js 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,9 +146,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"> api.preview.bind( 'active', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( api.settings.nonce ) {
- api.preview.send( 'nonce', api.settings.nonce );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.preview.send( 'nonce', api.settings.nonce );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> api.preview.send( 'documentTitle', document.title );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,6 +161,10 @@
</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">+ api.preview.bind( 'nonce-refresh', function( nonce ) {
+ $.extend( api.settings.nonce, nonce );
+ } );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Send a message to the parent customize frame with a list of which
</span><span class="cx" style="display: block; padding: 0 10px"> * containers and controls are active.
</span></span></pre></div>
<a id="trunktestsphpunittestscustomizemanagerphp"></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/customize/manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/customize/manager.php 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/tests/phpunit/tests/customize/manager.php 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -369,6 +369,36 @@
</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">+ * Test get_nonces() method.
+ *
+ * @see WP_Customize_Manager::get_nonces()
+ */
+ function test_nonces() {
+ $nonces = $this->manager->get_nonces();
+ $this->assertInternalType( 'array', $nonces );
+ $this->assertArrayHasKey( 'save', $nonces );
+ $this->assertArrayHasKey( 'preview', $nonces );
+
+ add_filter( 'customize_refresh_nonces', array( $this, 'filter_customize_refresh_nonces' ), 10, 2 );
+ $nonces = $this->manager->get_nonces();
+ $this->assertArrayHasKey( 'foo', $nonces );
+ $this->assertEquals( wp_create_nonce( 'foo' ), $nonces['foo'] );
+ }
+
+ /**
+ * Filter for customize_refresh_nonces.
+ *
+ * @param array $nonces Nonces.
+ * @param WP_Customize_Manager $manager Manager.
+ * @return array Nonces.
+ */
+ function filter_customize_refresh_nonces( $nonces, $manager ) {
+ $this->assertInstanceOf( 'WP_Customize_Manager', $manager );
+ $nonces['foo'] = wp_create_nonce( 'foo' );
+ return $nonces;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Test customize_pane_settings() method.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see WP_Customize_Manager::customize_pane_settings()
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,6 +432,38 @@
</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">+ * Test customize_preview_settings() method.
+ *
+ * @see WP_Customize_Manager::customize_preview_settings()
+ */
+ function test_customize_preview_settings() {
+ wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ $this->manager->register_controls();
+ $this->manager->prepare_controls();
+ $this->manager->set_post_value( 'foo', 'bar' );
+ $_POST['customize_messenger_channel'] = 'preview-0';
+
+ ob_start();
+ $this->manager->customize_preview_settings();
+ $content = ob_get_clean();
+
+ $this->assertEquals( 1, preg_match( '/var _wpCustomizeSettings = ({.+});/', $content, $matches ) );
+ $settings = json_decode( $matches[1], true );
+
+ $this->assertArrayHasKey( 'theme', $settings );
+ $this->assertArrayHasKey( 'url', $settings );
+ $this->assertArrayHasKey( 'channel', $settings );
+ $this->assertArrayHasKey( 'activePanels', $settings );
+ $this->assertArrayHasKey( 'activeSections', $settings );
+ $this->assertArrayHasKey( 'activeControls', $settings );
+ $this->assertArrayHasKey( 'nonce', $settings );
+ $this->assertArrayHasKey( '_dirty', $settings );
+
+ $this->assertArrayHasKey( 'preview', $settings['nonce'] );
+ $this->assertEquals( array( 'foo' ), $settings['_dirty'] );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 33552
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_customize_loaded_components_filter() {
</span></span></pre></div>
<a id="trunktestsphpunittestscustomizenavmenusphp"></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/customize/nav-menus.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/customize/nav-menus.php 2016-01-27 13:50:11 UTC (rev 36413)
+++ trunk/tests/phpunit/tests/customize/nav-menus.php 2016-01-27 17:54:39 UTC (rev 36414)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -647,12 +647,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'renderQueryVar', $data );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'renderNonceValue', $data );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'renderNoncePostKey', $data );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'requestUri', $data );
- $this->assertContains( 'theme', $data );
- $this->assertContains( 'previewCustomizeNonce', $data );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'navMenuInstanceArgs', $data );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'requestUri', $data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>