From 3afaf2147cefdca7faea0c4fee87216985d3d3a6 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 8 Sep 2016 13:45:34 +0000 Subject: [PATCH] Formatting: Don't send an HTTP status code in `wp_send_json()` by default. This avoids clobbering an HTTP status code that may have been set prior to calling this function. Props westonruter See #35666 Built from https://develop.svn.wordpress.org/trunk@38576 git-svn-id: http://core.svn.wordpress.org/trunk@38519 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index bcb930e183..11645a842a 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3101,9 +3101,11 @@ function _wp_json_prepare_data( $data ) { * then print and die. * @param int $status_code The HTTP status code to output. */ -function wp_send_json( $response, $status_code = 200 ) { +function wp_send_json( $response, $status_code = null ) { @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); - status_header( $status_code ); + if ( null !== $status_code ) { + status_header( $status_code ); + } echo wp_json_encode( $response ); if ( wp_doing_ajax() ) wp_die(); @@ -3120,7 +3122,7 @@ function wp_send_json( $response, $status_code = 200 ) { * @param mixed $data Data to encode as JSON, then print and die. * @param int $status_code The HTTP status code to output. */ -function wp_send_json_success( $data = null, $status_code = 200 ) { +function wp_send_json_success( $data = null, $status_code = null ) { $response = array( 'success' => true ); if ( isset( $data ) ) @@ -3144,7 +3146,7 @@ function wp_send_json_success( $data = null, $status_code = 200 ) { * @param mixed $data Data to encode as JSON, then print and die. * @param int $status_code The HTTP status code to output. */ -function wp_send_json_error( $data = null, $status_code = 200 ) { +function wp_send_json_error( $data = null, $status_code = null ) { $response = array( 'success' => false ); if ( isset( $data ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 638528d011..3ae1045844 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38575'; +$wp_version = '4.7-alpha-38576'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.