WordPress.org

Make WordPress Core

Changeset 38576


Ignore:
Timestamp:
09/08/2016 01:44:32 PM (21 months ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r38518 r38576  
    31023102 * @param int   $status_code The HTTP status code to output.
    31033103 */
    3104 function wp_send_json( $response, $status_code = 200 ) {
     3104function wp_send_json( $response, $status_code = null ) {
    31053105    @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
    3106     status_header( $status_code );
     3106    if ( null !== $status_code ) {
     3107        status_header( $status_code );
     3108    }
    31073109    echo wp_json_encode( $response );
    31083110    if ( wp_doing_ajax() )
     
    31213123 * @param int   $status_code The HTTP status code to output.
    31223124 */
    3123 function wp_send_json_success( $data = null, $status_code = 200 ) {
     3125function wp_send_json_success( $data = null, $status_code = null ) {
    31243126    $response = array( 'success' => true );
    31253127
     
    31453147 * @param int   $status_code The HTTP status code to output.
    31463148 */
    3147 function wp_send_json_error( $data = null, $status_code = 200 ) {
     3149function wp_send_json_error( $data = null, $status_code = null ) {
    31483150    $response = array( 'success' => false );
    31493151
Note: See TracChangeset for help on using the changeset viewer.