Ticket #45933: 45933.1.diff
| File 45933.1.diff, 5.4 KB (added by , 7 years ago) |
|---|
-
src/wp-includes/class-wp-shutdown-handler.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
129 129 $message = substr( $message, 3, -4 ); 130 130 } 131 131 132 wp_die( $message, '', 500 ); 132 $status = 500; 133 134 if ( class_exists( 'WP_Error', false ) ) { 135 $error_code = 'php_fatal_error'; 136 $message = new WP_Error( $error_code, $message, array( 'status' => $status ) ); 137 } 138 139 wp_die( $message, '', $status ); 133 140 } 134 141 135 142 /** -
src/wp-includes/functions.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
2970 2970 * @param callable $function Callback function name. 2971 2971 */ 2972 2972 $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); 2973 } else if ( wp_is_json_request() ) { 2974 /** 2975 * Filters the callback for killing WordPress execution for JSON requests. 2976 * 2977 * @since 5.1.0 2978 * 2979 * @param callable $function Callback function name. 2980 */ 2981 $function = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); 2973 2982 } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { 2974 2983 /** 2975 2984 * Filters the callback for killing WordPress execution for XML-RPC requests. … … 3227 3236 } 3228 3237 die(); 3229 3238 } 3239 3240 /** 3241 * Kill WordPress execution and display JSON message with error message. 3242 * 3243 * This is the handler for wp_die when processing JSON requests. 3244 * 3245 * @since 5.1.0 3246 * @access private 3247 * 3248 * @param string $message Error message. 3249 * @param string $title Optional. Error title. Default empty. 3250 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 3251 */ 3252 3253 function _json_wp_die_handler( $message, $title = '', $args = array() ) { 3254 $defaults = array( 'response' => 500, 'code' => '_json_wp_die_handler' ); 3255 3256 $r = wp_parse_args( $args, $defaults ); 3257 3258 $data = array(); 3259 if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { 3260 $errors = array(); 3261 foreach ( (array) $message->errors as $code => $messages ) { 3262 foreach ( (array) $messages as $display_message ) { 3263 $errors[] = array( 3264 'code' => $code, 3265 'message' => strip_tags( $display_message ), 3266 'data' => $message->get_error_data( $code ), 3267 ); 3268 } 3269 } 3270 3271 $data = $errors[0]; 3272 if ( count( $errors ) > 1 ) { 3273 // Remove the primary error. 3274 array_shift( $errors ); 3275 $data['additional_errors'] = $errors; 3276 } 3277 } else { 3278 $data = array( 3279 'code' => $r['code'], 3280 'message' => strip_tags( $message ), 3281 ); 3282 } 3283 3284 if ( ! isset( $data['data']['status'] ) ) { 3285 $data['data']['status'] = $r['response']; 3286 } 3287 3288 if ( isset( $_GET['_jsonp'] ) ) { 3289 $jsonp_callback = $_GET['_jsonp']; 3290 $content_type = 'application/javascript'; 3291 } else { 3292 $jsonp_callback = false; 3293 $content_type = 'application/json'; 3294 } 3295 3296 if ( ! headers_sent() ) { 3297 $blog_charset = 'utf-8'; 3298 header( 'Content-Type: ' . $content_type . '; charset=' . $blog_charset ); 3299 status_header( $data['data']['status'] ); 3300 nocache_headers(); 3301 } 3302 3303 $result = wp_json_encode( $data ); 3304 if ( $jsonp_callback ) { 3305 echo '/**/' . $jsonp_callback . '(' . $result . ')'; 3306 } else { 3307 echo $result; 3308 } 3309 die(); 3310 } 3230 3311 3231 3312 /** 3232 3313 * Kill WordPress ajax execution. … … 5073 5154 $exists[4] = ( $exists[1] && $exists[3] ); 5074 5155 $exists[5] = ( $exists[2] && $exists[3] ); 5075 5156 5076 // phpcs:disable WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText5077 5157 $zonen[] = array( 5078 5158 'continent' => ( $exists[0] ? $zone[0] : '' ), 5079 5159 'city' => ( $exists[1] ? $zone[1] : '' ), … … 5082 5162 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), 5083 5163 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ), 5084 5164 ); 5085 // phpcs:enable5086 5165 } 5087 5166 usort( $zonen, '_wp_timezone_choice_usort_callback' ); 5088 5167 -
src/wp-includes/load.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1473 1473 * 1474 1474 * @since 5.0.0 1475 1475 * 1476 * @return bool True if Accepts or Content-Type headers contain application/json , false otherwise.1476 * @return bool True if Accepts or Content-Type headers contain application/json or 'application/javascript', false otherwise. 1477 1477 */ 1478 1478 function wp_is_json_request() { 1479 1479 1480 if ( isset( $_SERVER['HTTP_ACCEPT'] ) && false !== strpos( $_SERVER['HTTP_ACCEPT'], 'application/json' ) ) { 1481 return true; 1480 $accepted = array( 'application/json', 'application/javascript' ); 1481 1482 if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { 1483 foreach ( $accepted as $type ) { 1484 if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { 1485 return true; 1486 } 1487 } 1482 1488 } 1483 1489 1484 if ( isset( $_SERVER['CONTENT_TYPE'] ) && 'application/json' === $_SERVER['CONTENT_TYPE']) {1490 if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { 1485 1491 return true; 1486 1492 } 1487 1493