Ticket #20876: 20876.3.patch
| File 20876.3.patch, 2.7 KB (added by , 14 years ago) |
|---|
-
wp-includes/class-wp-customize-manager.php
31 31 require( ABSPATH . WPINC . '/class-wp-customize-section.php' ); 32 32 require( ABSPATH . WPINC . '/class-wp-customize-control.php' ); 33 33 34 add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) ); 35 34 36 add_action( 'setup_theme', array( $this, 'setup_theme' ) ); 35 37 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); 36 38 … … 53 55 } 54 56 55 57 /** 58 * Return true if it's an AJAX request. 59 * 60 * @since 3.4.0 61 */ 62 public function doing_ajax() { 63 return isset( $_POST['customized'] ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ); 64 } 65 66 /** 67 * Custom wp_die wrapper. Returns either the standard message for UI 68 * or the AJAX message. 69 * 70 * @param mixed $ajax_message AJAX return 71 * @param mixed $message UI message 72 * 73 * @since 3.4.0 74 */ 75 private function wp_die( $ajax_message, $message ) { 76 if ( $this->doing_ajax() ) 77 wp_die( $ajax_message ); 78 79 wp_die( $message ); 80 } 81 82 /** 83 * Return the AJAX wp_die() handler if it's a customized request. 84 * 85 * @since 3.4.0 86 */ 87 public function wp_die_handler() { 88 if ( $this->doing_ajax() ) 89 return '_ajax_wp_die_handler'; 90 91 return '_default_wp_die_handler'; 92 } 93 94 /** 56 95 * Update theme modifications for the current theme. 57 96 * Note: Candidate core function. 58 97 * http://core.trac.wordpress.org/ticket/20091 … … 78 117 * @since 3.4.0 79 118 */ 80 119 public function setup_theme() { 81 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) 82 auth_redirect(); 120 if ( is_admin() && ! $this->doing_ajax() ) 121 auth_redirect(); 122 elseif ( $this->doing_ajax() && ! is_user_logged_in()) 123 wp_die( 0 ); 83 124 84 125 send_origin_headers(); 85 126 … … 89 130 90 131 // You can't preview a theme if it doesn't exist, or if it is not allowed (unless active). 91 132 if ( ! $this->theme->exists() ) 92 wp_die(__( 'Cheatin’ uh?' ) );133 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 93 134 94 135 if ( $this->theme->get_stylesheet() != get_stylesheet() && ( ! $this->theme()->is_allowed() || ! current_user_can( 'switch_themes' ) ) ) 95 wp_die(__( 'Cheatin’ uh?' ) );136 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 96 137 97 138 if ( ! current_user_can( 'edit_theme_options' ) ) 98 wp_die(__( 'Cheatin’ uh?' ) );139 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 99 140 100 141 $this->start_previewing_theme(); 101 142 show_admin_bar( false ); … … 967 1008 return '#' . $unhashed; 968 1009 969 1010 return $color; 970 } 971 No newline at end of file 1011 }