Ticket #20921: 20921.diff
File 20921.diff, 5.8 KB (added by , 13 years ago) |
---|
-
wp-includes/class-wp-customize-manager.php
72 72 * 73 73 * @since 3.4.0 74 74 */ 75 pr ivate function wp_die( $ajax_message, $message) {75 protected function wp_die( $ajax_message, $message = null ) { 76 76 if ( $this->doing_ajax() ) 77 77 wp_die( $ajax_message ); 78 78 79 if ( ! $message ) 80 $message = __( 'Cheatin’ uh?' ); 81 79 82 wp_die( $message ); 80 83 } 81 84 … … 100 103 public function setup_theme() { 101 104 if ( is_admin() && ! $this->doing_ajax() ) 102 105 auth_redirect(); 103 elseif ( $this->doing_ajax() && ! is_user_logged_in() )104 wp_die( 0 );106 elseif ( $this->doing_ajax() && ! is_user_logged_in() ) 107 $this->wp_die( 0 ); 105 108 106 109 send_origin_headers(); 107 110 … … 109 112 110 113 $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null ); 111 114 112 // You can't preview a theme if it doesn't exist, or if it is not allowed (unless active). 115 if ( $this->is_theme_active() && ! $this->doing_ajax() && ! validate_current_theme() ) { 116 wp_redirect( 'themes.php?broken=true' ); 117 exit; 118 } 119 113 120 if ( ! $this->theme->exists() ) 114 $this->wp_die( -1 , __( 'Cheatin’ uh?' ));121 $this->wp_die( -1 ); 115 122 116 if ( $this->theme->get_stylesheet() != get_stylesheet() && ( ! $this->theme()->is_allowed() || ! current_user_can( 'switch_themes' ) ) ) 117 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 123 // If the theme isn't active, you can't preview it if it is not allowed or has errors. 124 if ( ! $this->is_theme_active() ) { 125 if ( ! current_user_can( 'switch_themes' ) ) 126 $this->wp_die( -1 ); 118 127 128 if ( $this->theme()->errors() ) 129 $this->wp_die( -1 ); 130 131 if ( ! $this->theme()->is_allowed() ) 132 $this->wp_die( -1 ); 133 } 134 119 135 if ( ! current_user_can( 'edit_theme_options' ) ) 120 $this->wp_die( -1 , __( 'Cheatin’ uh?' ));136 $this->wp_die( -1 ); 121 137 122 138 $this->start_previewing_theme(); 123 139 show_admin_bar( false ); … … 137 153 138 154 $this->previewing = true; 139 155 140 add_filter( 'template', array( $this, 'get_template' ) ); 141 add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); 142 add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); 156 if ( ! $this->is_theme_active() ) { 157 add_filter( 'template', array( $this, 'get_template' ) ); 158 add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); 159 add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); 160 161 // @link: http://core.trac.wordpress.org/ticket/20027 162 add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); 163 add_filter( 'pre_option_template', array( $this, 'get_template' ) ); 164 165 // Handle custom theme roots. 166 add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); 167 add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); 168 } 143 169 144 // @link: http://core.trac.wordpress.org/ticket/20027145 add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );146 add_filter( 'pre_option_template', array( $this, 'get_template' ) );147 148 // Handle custom theme roots.149 add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );150 add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );151 152 170 do_action( 'start_previewing_theme', $this ); 153 171 } 154 172 … … 165 183 166 184 $this->previewing = false; 167 185 168 remove_filter( 'template', array( $this, 'get_template' ) ); 169 remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); 170 remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); 186 if ( ! $this->is_theme_active() ) { 187 remove_filter( 'template', array( $this, 'get_template' ) ); 188 remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); 189 remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); 190 191 // @link: http://core.trac.wordpress.org/ticket/20027 192 remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); 193 remove_filter( 'pre_option_template', array( $this, 'get_template' ) ); 194 195 // Handle custom theme roots. 196 remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); 197 remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); 198 } 171 199 172 // @link: http://core.trac.wordpress.org/ticket/20027173 remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );174 remove_filter( 'pre_option_template', array( $this, 'get_template' ) );175 176 // Handle custom theme roots.177 remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );178 remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );179 180 200 do_action( 'stop_previewing_theme', $this ); 181 201 } 182 202 … … 448 468 check_ajax_referer( 'customize_controls-' . $this->get_stylesheet(), 'nonce' ); 449 469 450 470 // Do we have to switch themes? 451 if ( $this->get_stylesheet() != $this->original_stylesheet) {471 if ( ! $this->is_theme_active() ) { 452 472 // Temporarily stop previewing the theme to allow switch_themes() 453 473 // to operate properly. 454 474 $this->stop_previewing_theme(); -
wp-admin/themes.php
92 92 require_once('./admin-header.php'); 93 93 ?> 94 94 95 <?php if ( ! validate_current_theme() ) : ?>95 <?php if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?> 96 96 <div id="message1" class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 97 97 <?php elseif ( isset($_GET['activated']) ) : 98 98 if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { ?>