From 1884ec383cb8175d5cf24e3e639cb65b0206de96 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Wed, 11 Feb 2015 22:13:25 +0000 Subject: [PATCH] Customizer: Restore showing a login form inside the previewer if an user is logged out. Broken since [31370]. props westonruter. see #31294. Built from https://develop.svn.wordpress.org/trunk@31421 git-svn-id: http://core.svn.wordpress.org/trunk@31402 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 37 ++++++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 4a776beb63..6f19c498ca 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -140,11 +140,13 @@ final class WP_Customize_Manager { * @param mixed $message UI message */ protected function wp_die( $ajax_message, $message = null ) { - if ( $this->doing_ajax() ) + if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) { wp_die( $ajax_message ); + } - if ( ! $message ) + if ( ! $message ) { $message = __( 'Cheatin’ uh?' ); + } wp_die( $message ); } @@ -157,8 +159,9 @@ final class WP_Customize_Manager { * @return string */ public function wp_die_handler() { - if ( $this->doing_ajax() ) + if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) { return '_ajax_wp_die_handler'; + } return '_default_wp_die_handler'; } @@ -173,10 +176,12 @@ final class WP_Customize_Manager { public function setup_theme() { send_origin_headers(); - if ( is_admin() && ! $this->doing_ajax() ) - auth_redirect(); - elseif ( $this->doing_ajax() && ! is_user_logged_in() ) - $this->wp_die( 0 ); + $doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_POST['customized'] ) ); + if ( is_admin() && ! $doing_ajax_or_is_customized ) { + auth_redirect(); + } elseif ( $doing_ajax_or_is_customized && ! is_user_logged_in() ) { + $this->wp_die( 0 ); + } show_admin_bar( false ); @@ -194,16 +199,19 @@ final class WP_Customize_Manager { } else { // If the requested theme is not the active theme and the user doesn't have the // switch_themes cap, bail. - if ( ! current_user_can( 'switch_themes' ) ) + if ( ! current_user_can( 'switch_themes' ) ) { $this->wp_die( -1 ); + } // If the theme has errors while loading, bail. - if ( $this->theme()->errors() ) + if ( $this->theme()->errors() ) { $this->wp_die( -1 ); + } // If the theme isn't allowed per multisite settings, bail. - if ( ! $this->theme()->is_allowed() ) + if ( ! $this->theme()->is_allowed() ) { $this->wp_die( -1 ); + } } $this->start_previewing_theme(); @@ -215,7 +223,8 @@ final class WP_Customize_Manager { * @since 3.4.0 */ public function after_setup_theme() { - if ( ! $this->doing_ajax() && ! validate_current_theme() ) { + $doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_SERVER['customized'] ) ); + if ( ! $doing_ajax_or_is_customized && ! validate_current_theme() ) { wp_redirect( 'themes.php?broken=true' ); exit; } @@ -229,8 +238,9 @@ final class WP_Customize_Manager { */ public function start_previewing_theme() { // Bail if we're already previewing. - if ( $this->is_preview() ) + if ( $this->is_preview() ) { return; + } $this->previewing = true; @@ -266,8 +276,9 @@ final class WP_Customize_Manager { * @since 3.4.0 */ public function stop_previewing_theme() { - if ( ! $this->is_preview() ) + if ( ! $this->is_preview() ) { return; + } $this->previewing = false; diff --git a/wp-includes/version.php b/wp-includes/version.php index eb55f2a9db..94475fa7cf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31420'; +$wp_version = '4.2-alpha-31421'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.