Ticket #45933: 45933.diff
| File 45933.diff, 5.0 KB (added by , 7 years ago) |
|---|
-
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_doing_rest() ) { 2974 /** 2975 * Filters the callback for killing WordPress execution for REST API requests. 2976 * 2977 * @since 5.1.0 2978 * 2979 * @param callable $function Callback function name. 2980 */ 2981 $function = apply_filters( 'wp_die_rest_handler', '_rest_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. … … 3228 3237 die(); 3229 3238 } 3230 3239 3240 /** 3241 * Kill WordPress execution and display JSON message with error message. 3242 * 3243 * This is the handler for wp_die when processing REST API 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 _rest_wp_die_handler( $message, $title = '', $args = array() ) { 3254 $defaults = array( 'response' => 500, 'code' => 'wp_die_rest_handler' ); 3255 3256 $r = wp_parse_args( $args, $defaults ); 3257 3258 if ( ! headers_sent() ) { 3259 $content_type = isset( $_GET['_jsonp'] ) ? 'application/javascript' : 'application/json'; 3260 $blog_charset = 'utf-8'; 3261 if ( function_exists( 'get_option' ) ) { 3262 $blog_charset = get_option( 'blog_charset', 'utf-8' ); 3263 } 3264 header( 'Content-Type: ' . $content_type . '; charset=' . $blog_charset ); 3265 if ( null !== $r['response'] ) { 3266 status_header( $r['response'] ); 3267 } 3268 } 3269 3270 $return = array( 3271 'code' => $r['code'], 3272 'message' => $message, 3273 'data' => array( 3274 'status' => $r['response'], 3275 ) 3276 ); 3277 3278 $result = wp_json_encode($return); 3279 $jsonp_callback = $_GET['_jsonp']; 3280 if ( $jsonp_callback ) { 3281 // Prepend '/**/' to mitigate possible JSONP Flash attacks. 3282 // https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ 3283 echo '/**/' . $jsonp_callback . '(' . $result . ')'; 3284 } else { 3285 echo $result; 3286 } 3287 die(); 3288 } 3289 3231 3290 /** 3232 3291 * Kill WordPress ajax execution. 3233 3292 * … … 5073 5132 $exists[4] = ( $exists[1] && $exists[3] ); 5074 5133 $exists[5] = ( $exists[2] && $exists[3] ); 5075 5134 5076 // phpcs:disable WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText5077 5135 $zonen[] = array( 5078 5136 'continent' => ( $exists[0] ? $zone[0] : '' ), 5079 5137 'city' => ( $exists[1] ? $zone[1] : '' ), … … 5082 5140 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), 5083 5141 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ), 5084 5142 ); 5085 // phpcs:enable5086 5143 } 5087 5144 usort( $zonen, '_wp_timezone_choice_usort_callback' ); 5088 5145 -
src/wp-includes/load.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1271 1271 return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); 1272 1272 } 1273 1273 1274 1275 /** 1276 * Determines whether the current request is a WordPress REST API request. 1277 * 1278 * @since 5.1.0 1279 * 1280 * @return bool True if it's a WordPress REST API request, false otherwise. 1281 */ 1282 function wp_doing_rest() { 1283 1284 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 1285 return true; 1286 } 1287 if ( ! function_exists( 'rest_get_url_prefix' ) ) { 1288 return false; 1289 } 1290 $prefix = rest_get_url_prefix(); 1291 if ( isset( $_GET['rest_route'] ) && strpos( trim( $_GET['rest_route'], '\\/' ), $prefix, 0 ) === 0 ) { 1292 return true; 1293 } 1294 1295 $rest_url = wp_parse_url( site_url( $prefix ) ); 1296 $current_url = wp_parse_url( add_query_arg( array() ) ); 1297 1298 $wp_doing_rest = strpos( $current_url['path'], $rest_url['path'], 0 ) === 0; 1299 1300 /** 1301 * Filters whether the current request is a WordPress REST API request. 1302 * 1303 * @since 5.1.0 1304 * 1305 * @param bool $wp_doing_rest Whether the current request is a WordPress REST API request. 1306 */ 1307 return apply_filters( 'wp_doing_rest', $wp_doing_rest ); 1308 } 1309 1274 1310 /** 1275 1311 * Determines whether the current request should use themes. 1276 1312 * -
src/wp-includes/rest-api.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
301 301 $server->serve_request( $route ); 302 302 303 303 // We're done. 304 die();304 exit(); 305 305 } 306 306 307 307 /**