Ticket #24169: 24169.patch
File 24169.patch, 2.6 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-customize-manager.php
34 34 35 35 add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) ); 36 36 37 add_action( 'init', array( $this, 'init' ) ); 37 38 add_action( 'setup_theme', array( $this, 'setup_theme' ) ); 38 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );39 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); 39 40 40 41 // Run wp_redirect_status late to make sure we override the status last. 41 42 add_action( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 ); … … 111 112 112 113 if ( is_admin() && ! $this->doing_ajax() ) 113 114 auth_redirect(); 114 elseif ( $this->doing_ajax() && ! is_user_logged_in() )115 $this->wp_die( 0 );116 115 117 116 show_admin_bar( false ); 118 117 119 if ( ! current_user_can( 'edit_theme_options' ) )120 $this->wp_die( -1 );121 122 118 $this->original_stylesheet = get_stylesheet(); 119 $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null ); 123 120 124 $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null ); 125 121 // Once the theme is loaded, we'll validate it. 126 122 if ( $this->is_theme_active() ) { 127 // Once the theme is loaded, we'll validate it.128 123 add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); 129 124 } else { 130 if ( ! current_user_can( 'switch_themes' ) )131 $this->wp_die( -1 );132 125 133 // If the theme isn't active, you can't preview it if it is not allowed or has errors.126 // Bail if theme has errors 134 127 if ( $this->theme()->errors() ) 135 128 $this->wp_die( -1 ); 136 129 137 if ( ! $this->theme()->is_allowed() ) 130 // Bail if theme is not allowed 131 if ( !$this->theme()->is_allowed() ) 138 132 $this->wp_die( -1 ); 139 133 } 140 134 135 141 136 $this->start_previewing_theme(); 142 137 } 143 138 … … 154 149 } 155 150 156 151 /** 152 * Callback to perform capability checks on the current user, once 153 * wp_get_current_user() has been called. 154 * 155 * @since 3.6 156 */ 157 function init() { 158 159 // Bail if user is not logged in 160 if ( $this->doing_ajax() && ! is_user_logged_in() ) { 161 $this->wp_die( 0 ); 162 } 163 164 // Bail if user cannot edit theme options 165 if ( ! current_user_can( 'edit_theme_options' ) ) { 166 $this->wp_die( -1 ); 167 } 168 169 // Previewing a new theme 170 if ( ! $this->is_theme_active() ) { 171 172 // Bail if user cannot switch themes 173 if ( ! current_user_can( 'switch_themes' ) ) { 174 $this->wp_die( -1 ); 175 } 176 } 177 } 178 179 /** 157 180 * Start previewing the selected theme. 158 181 * 159 182 * Adds filters to change the current theme.