From 2f344b9d3c475fee9ee479de1cd80feff5ea4181 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 3 Jul 2014 16:10:15 +0000 Subject: [PATCH] Prevent sending a 404 status when returning the response for the customize preview, since it causes the jQuery Ajax to fail. Send 200 instead. props westonruter. fixes #27992. Built from https://develop.svn.wordpress.org/trunk@28970 git-svn-id: http://core.svn.wordpress.org/trunk@28759 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 7ec89ee904..bdd79bab66 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -406,6 +406,7 @@ final class WP_Customize_Manager { $this->prepare_controls(); wp_enqueue_script( 'customize-preview' ); + add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) ); add_action( 'wp_head', array( $this, 'customize_preview_base' ) ); add_action( 'wp_head', array( $this, 'customize_preview_html5' ) ); add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); @@ -427,6 +428,18 @@ final class WP_Customize_Manager { do_action( 'customize_preview_init', $this ); } + /** + * Prevent sending a 404 status when returning the response for the customize + * preview, since it causes the jQuery Ajax to fail. Send 200 instead. + * + * @since 4.0.0 + */ + public function customize_preview_override_404_status() { + if ( is_404() ) { + status_header( 200 ); + } + } + /** * Print base element for preview frame. *