From 83b0f3f681ad12dbf1c5929762bd11429baa74c8 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 15 Oct 2014 17:49:36 +0000 Subject: [PATCH] Customizer: Only POST dirty settings to preview to improve performance. props westonruter. fixes #29983. git-svn-id: https://develop.svn.wordpress.org/trunk@29905 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 13 ++++++++++++- src/wp-includes/js/customize-base.js | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 30d1bd91bf..fad223ee4a 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -1021,10 +1021,17 @@ nonce: api.settings.nonce, query: function() { + var dirtyCustomized = {}; + api.each( function ( value, key ) { + if ( value._dirty ) { + dirtyCustomized[ key ] = value(); + } + } ); + return { wp_customize: 'on', theme: api.settings.theme.stylesheet, - customized: JSON.stringify( api.get() ), + customized: JSON.stringify( dirtyCustomized ), nonce: this.nonce.preview }; }, @@ -1067,6 +1074,10 @@ return; } + // Clear setting dirty states + api.each( function ( value ) { + value._dirty = false; + } ); api.trigger( 'saved' ); } ); }; diff --git a/src/wp-includes/js/customize-base.js b/src/wp-includes/js/customize-base.js index 6c41b40c43..765c59505d 100644 --- a/src/wp-includes/js/customize-base.js +++ b/src/wp-includes/js/customize-base.js @@ -158,6 +158,7 @@ window.wp = window.wp || {}; initialize: function( initial, options ) { this._value = initial; // @todo: potentially change this to a this.set() call. this.callbacks = $.Callbacks(); + this._dirty = false; $.extend( this, options || {} ); @@ -187,6 +188,7 @@ window.wp = window.wp || {}; return this; this._value = to; + this._dirty = true; this.callbacks.fireWith( this, [ to, from ] );