Make WordPress Core

Ticket #20876: 20876.3.patch

File 20876.3.patch, 2.7 KB (added by ocean90, 14 years ago)
  • wp-includes/class-wp-customize-manager.php

     
    3131                require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
    3232                require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
    3333
     34                add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
     35
    3436                add_action( 'setup_theme',  array( $this, 'setup_theme' ) );
    3537                add_action( 'wp_loaded',    array( $this, 'wp_loaded' ) );
    3638
     
    5355        }
    5456
    5557        /**
     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        /**
    5695         * Update theme modifications for the current theme.
    5796         * Note: Candidate core function.
    5897         * http://core.trac.wordpress.org/ticket/20091
     
    78117         * @since 3.4.0
    79118         */
    80119        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 );
    83124
    84125                send_origin_headers();
    85126
     
    89130
    90131                // You can't preview a theme if it doesn't exist, or if it is not allowed (unless active).
    91132                if ( ! $this->theme->exists() )
    92                         wp_die( __( 'Cheatin’ uh?' ) );
     133                        $this->wp_die( -1, __( 'Cheatin’ uh?' ) );
    93134
    94135                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?' ) );
    96137
    97138                if ( ! current_user_can( 'edit_theme_options' ) )
    98                         wp_die( __( 'Cheatin’ uh?' ) );
     139                        $this->wp_die( -1, __( 'Cheatin’ uh?' ) );
    99140
    100141                $this->start_previewing_theme();
    101142                show_admin_bar( false );
     
    9671008                return '#' . $unhashed;
    9681009
    9691010        return $color;
    970 }
    971  No newline at end of file
     1011}