WordPress.org

Make WordPress Core

Ticket #27992: 27992.diff

File 27992.diff, 1.1 KB (added by westonruter, 6 years ago)

Prevent sending a 404 status when returning the response for the customize preview, since it causes the jQuery Ajax to fail. Send 200 instead. Also pushed to GitHub: https://github.com/x-team/wordpress-develop/pull/19

  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 42977cb..5323c32 100644
    final class WP_Customize_Manager { 
    394394                $this->prepare_controls();
    395395
    396396                wp_enqueue_script( 'customize-preview' );
     397                add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) );
    397398                add_action( 'wp_head', array( $this, 'customize_preview_base' ) );
    398399                add_action( 'wp_head', array( $this, 'customize_preview_html5' ) );
    399400                add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 );
    final class WP_Customize_Manager { 
    416417        }
    417418
    418419        /**
     420         * Prevent sending a 404 status when returning the response for the customize
     421         * preview, since it causes the jQuery Ajax to fail. Send 200 instead.
     422         *
     423         * @since 4.0.0
     424         */
     425        public function customize_preview_override_404_status() {
     426                if ( is_404() ) {
     427                        status_header( 200 );
     428                }
     429        }
     430
     431        /**
    419432         * Print base element for preview frame.
    420433         *
    421434         * @since 3.4.0