Refresh nonces in the customizer. props koopersmith. see #20876.

git-svn-id: https://develop.svn.wordpress.org/trunk@21135 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2012-06-26 18:48:18 +00:00
parent 5b9214124c
commit 26f8f3e504
5 changed files with 60 additions and 30 deletions
+12 -1
View File
@@ -17,6 +17,8 @@ final class WP_Customize_Manager {
protected $sections = array();
protected $controls = array();
protected $nonce_tick;
protected $customized;
private $_post_values;
@@ -308,6 +310,8 @@ final class WP_Customize_Manager {
* @since 3.4.0
*/
public function customize_preview_init() {
$this->nonce_tick = check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce' );
$this->prepare_controls();
wp_enqueue_script( 'customize-preview' );
@@ -362,6 +366,13 @@ final class WP_Customize_Manager {
'channel' => esc_js( $_POST['customize_messenger_channel'] ),
);
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() )
);
}
foreach ( $this->settings as $id => $setting ) {
$settings['values'][ $id ] = $setting->js_value();
}
@@ -468,7 +479,7 @@ final class WP_Customize_Manager {
if ( ! $this->is_preview() )
die;
check_ajax_referer( 'customize_controls-' . $this->get_stylesheet(), 'nonce' );
check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce' );
// Do we have to switch themes?
if ( ! $this->is_theme_active() ) {