diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index 0e720ee..9634ed4 100644
|
|
|
function _wp_json_prepare_data( $data ) { |
| 3031 | 3031 | * Send a JSON response back to an Ajax request. |
| 3032 | 3032 | * |
| 3033 | 3033 | * @since 3.5.0 |
| | 3034 | * @since 4.6.0 The `$status_code` parameter was added |
| 3034 | 3035 | * |
| 3035 | 3036 | * @param mixed $response Variable (usually an array or object) to encode as JSON, |
| 3036 | 3037 | * then print and die. |
| 3037 | 3038 | */ |
| 3038 | | function wp_send_json( $response ) { |
| | 3039 | function wp_send_json( $response, $status_code = 200 ) { |
| 3039 | 3040 | @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
| | 3041 | status_header( (int) $status_code ); |
| 3040 | 3042 | echo wp_json_encode( $response ); |
| 3041 | 3043 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
| 3042 | 3044 | wp_die(); |
| … |
… |
function wp_send_json( $response ) { |
| 3048 | 3050 | * Send a JSON response back to an Ajax request, indicating success. |
| 3049 | 3051 | * |
| 3050 | 3052 | * @since 3.5.0 |
| | 3053 | * @since 4.6.0 The `$status_code` parameter was added |
| 3051 | 3054 | * |
| 3052 | 3055 | * @param mixed $data Data to encode as JSON, then print and die. |
| 3053 | 3056 | */ |
| 3054 | | function wp_send_json_success( $data = null ) { |
| | 3057 | function wp_send_json_success( $data = null, $status_code = 200 ) { |
| 3055 | 3058 | $response = array( 'success' => true ); |
| 3056 | 3059 | |
| 3057 | 3060 | if ( isset( $data ) ) |
| 3058 | 3061 | $response['data'] = $data; |
| 3059 | 3062 | |
| 3060 | | wp_send_json( $response ); |
| | 3063 | wp_send_json( $response, $status_code ); |
| 3061 | 3064 | } |
| 3062 | 3065 | |
| 3063 | 3066 | /** |
| … |
… |
function wp_send_json_success( $data = null ) { |
| 3071 | 3074 | * @since 3.5.0 |
| 3072 | 3075 | * @since 4.1.0 The `$data` parameter is now processed if a {@see WP_Error} |
| 3073 | 3076 | * object is passed in. |
| | 3077 | * @since 4.6.0 The `$status_code` parameter was added |
| 3074 | 3078 | * |
| 3075 | | * @param mixed $data Data to encode as JSON, then print and die. |
| | 3079 | * @param mixed $data Data to encode as JSON, then print and die. |
| | 3080 | * @param int $status_code HTTP status code. |
| 3076 | 3081 | */ |
| 3077 | | function wp_send_json_error( $data = null ) { |
| | 3082 | function wp_send_json_error( $data = null, $status_code = 200 ) { |
| 3078 | 3083 | $response = array( 'success' => false ); |
| 3079 | 3084 | |
| 3080 | 3085 | if ( isset( $data ) ) { |
| … |
… |
function wp_send_json_error( $data = null ) { |
| 3092 | 3097 | } |
| 3093 | 3098 | } |
| 3094 | 3099 | |
| 3095 | | wp_send_json( $response ); |
| | 3100 | wp_send_json( $response, $status_code ); |
| 3096 | 3101 | } |
| 3097 | 3102 | |
| 3098 | 3103 | /** |