Make WordPress Core


Ignore:
Timestamp:
05/24/2012 01:48:32 AM (12 years ago)
Author:
koopersmith
Message:

Theme Customizer: Properly handle redirects in the preview by setting wp_redirect_status to 200. props nacin, see #20507, #19910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize-manager.php

    r20860 r20861  
    3535        add_action( 'wp_loaded',    array( $this, 'wp_loaded' ) );
    3636
     37        // Run wp_redirect_status late to make sure we override the status last.
     38        add_action( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 );
     39
    3740        add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
    3841
     
    209212        if ( $this->is_preview() && ! is_admin() )
    210213            $this->customize_preview_init();
     214    }
     215
     216    /**
     217     * Prevents AJAX requests from following redirects when previewing a theme
     218     * by issuing a 200 response instead of a 30x.
     219     *
     220     * Instead, the JS will sniff out the location header.
     221     *
     222     * @since 3.4.0
     223     */
     224    public function wp_redirect_status( $status ) {
     225        if ( $this->is_preview() && ! is_admin() )
     226            return 200;
     227
     228        return $status;
    211229    }
    212230
Note: See TracChangeset for help on using the changeset viewer.