Changeset 21031 for trunk/wp-includes/class-wp-customize-manager.php
- Timestamp:
- 06/08/2012 07:22:11 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/class-wp-customize-manager.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-customize-manager.php
r21027 r21031 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' ) ); … … 53 55 } 54 56 55 /** 56 * Start preview and customize theme. 57 * 58 * Check if customize query variable exist. Init filters to filter the current theme. 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 * Start preview and customize theme. 95 * 96 * Check if customize query variable exist. Init filters to filter the current theme. 59 97 * 60 98 * @since 3.4.0 61 99 */ 62 100 public function setup_theme() { 63 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) 64 auth_redirect(); 101 if ( is_admin() && ! $this->doing_ajax() ) 102 auth_redirect(); 103 elseif ( $this->doing_ajax() && ! is_user_logged_in()) 104 wp_die( 0 ); 65 105 66 106 send_origin_headers(); … … 72 112 // You can't preview a theme if it doesn't exist, or if it is not allowed (unless active). 73 113 if ( ! $this->theme->exists() ) 74 wp_die(__( 'Cheatin’ uh?' ) );114 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 75 115 76 116 if ( $this->theme->get_stylesheet() != get_stylesheet() && ( ! $this->theme()->is_allowed() || ! current_user_can( 'switch_themes' ) ) ) 77 wp_die(__( 'Cheatin’ uh?' ) );117 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 78 118 79 119 if ( ! current_user_can( 'edit_theme_options' ) ) 80 wp_die(__( 'Cheatin’ uh?' ) );120 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 81 121 82 122 $this->start_previewing_theme();
Note: See TracChangeset
for help on using the changeset viewer.