Changeset 49235
- Timestamp:
- 10/20/2020 03:54:43 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r49225 r49235 4079 4079 * @since 3.5.0 4080 4080 * @since 4.7.0 The `$status_code` parameter was added. 4081 * @since 5.6.0 The `$options` parameter was added. 4081 4082 * 4082 4083 * @param mixed $response Variable (usually an array or object) to encode as JSON, 4083 4084 * then print and die. 4084 * @param int $status_code The HTTP status code to output. 4085 */ 4086 function wp_send_json( $response, $status_code = null ) { 4085 * @param int $status_code Optional. The HTTP status code to output. Default null. 4086 * @param int $options Optional. Options to be passed to json_encode(). Default 0. 4087 */ 4088 function wp_send_json( $response, $status_code = null, $options = 0 ) { 4087 4089 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 4088 4090 _doing_it_wrong( … … 4105 4107 } 4106 4108 4107 echo wp_json_encode( $response );4109 echo wp_json_encode( $response, $options ); 4108 4110 4109 4111 if ( wp_doing_ajax() ) { … … 4125 4127 * @since 3.5.0 4126 4128 * @since 4.7.0 The `$status_code` parameter was added. 4127 * 4128 * @param mixed $data Data to encode as JSON, then print and die. 4129 * @param int $status_code The HTTP status code to output. 4130 */ 4131 function wp_send_json_success( $data = null, $status_code = null ) { 4129 * @since 5.6.0 The `$options` parameter was added. 4130 * 4131 * @param mixed $data Optional. Data to encode as JSON, then print and die. Default null. 4132 * @param int $status_code Optional. The HTTP status code to output. Default null. 4133 * @param int $options Optional. Options to be passed to json_encode(). Default 0. 4134 */ 4135 function wp_send_json_success( $data = null, $status_code = null, $options = 0 ) { 4132 4136 $response = array( 'success' => true ); 4133 4137 … … 4136 4140 } 4137 4141 4138 wp_send_json( $response, $status_code );4142 wp_send_json( $response, $status_code, $options ); 4139 4143 } 4140 4144 … … 4150 4154 * @since 4.1.0 The `$data` parameter is now processed if a WP_Error object is passed in. 4151 4155 * @since 4.7.0 The `$status_code` parameter was added. 4152 * 4153 * @param mixed $data Data to encode as JSON, then print and die. 4154 * @param int $status_code The HTTP status code to output. 4155 */ 4156 function wp_send_json_error( $data = null, $status_code = null ) { 4156 * @since 5.6.0 The `$options` parameter was added. 4157 * 4158 * @param mixed $data Optional. Data to encode as JSON, then print and die. Default null. 4159 * @param int $status_code Optional. The HTTP status code to output. Default null. 4160 * @param int $options Optional. Options to be passed to json_encode(). Default 0. 4161 */ 4162 function wp_send_json_error( $data = null, $status_code = null, $options = 0 ) { 4157 4163 $response = array( 'success' => false ); 4158 4164 … … 4175 4181 } 4176 4182 4177 wp_send_json( $response, $status_code );4183 wp_send_json( $response, $status_code, $options ); 4178 4184 } 4179 4185
Note: See TracChangeset
for help on using the changeset viewer.