Changeset 44625
- Timestamp:
- 01/16/2019 03:21:49 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r44624 r44625 2976 2976 */ 2977 2977 $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); 2978 } elseif ( wp_is_json_request() ) { 2979 /** 2980 * Filters the callback for killing WordPress execution for JSON requests. 2981 * 2982 * @since 5.1.0 2983 * 2984 * @param callable $function Callback function name. 2985 */ 2986 $function = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); 2978 2987 } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { 2979 2988 /** … … 3213 3222 </html> 3214 3223 <?php 3224 die(); 3225 } 3226 3227 /** 3228 * Kill WordPress execution and display JSON message with error message. 3229 * 3230 * This is the handler for wp_die when processing JSON requests. 3231 * 3232 * @since 5.1.0 3233 * @access private 3234 * 3235 * @param string $message Error message. 3236 * @param string $title Optional. Error title. Default empty. 3237 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 3238 */ 3239 function _json_wp_die_handler( $message, $title = '', $args = array() ) { 3240 $defaults = array( 'response' => 500 ); 3241 3242 $r = wp_parse_args( $args, $defaults ); 3243 3244 $data = array( 3245 'code' => 'wp_die', 3246 'message' => $message, 3247 'status' => $r['response'], 3248 ); 3249 3250 if ( ! headers_sent() ) { 3251 header( 'Content-Type: application/json; charset=utf-8' ); 3252 if ( null !== $r['response'] ) { 3253 status_header( $r['response'] ); 3254 } 3255 } 3256 3257 echo wp_json_encode( $data ); 3215 3258 die(); 3216 3259 }
Note: See TracChangeset
for help on using the changeset viewer.