Changeset 45016
- Timestamp:
- 03/26/2019 11:10:21 PM (5 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r45015 r45016 3008 3008 */ 3009 3009 $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); 3010 } elseif ( wp_is_xml_request() 3011 || function_exists( 'is_feed' ) && is_feed() 3012 || function_exists( 'is_comment_feed' ) && is_comment_feed() 3013 || function_exists( 'is_trackback' ) && is_trackback() ) { 3014 /** 3015 * Filters the callback for killing WordPress execution for XML requests. 3016 * 3017 * @since 5.2.0 3018 * 3019 * @param callable $function Callback function name. 3020 */ 3021 $function = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' ); 3010 3022 } else { 3011 3023 /** 3012 * Filters the callback for killing WordPress execution for all non-Ajax, non- XML-RPCrequests.3024 * Filters the callback for killing WordPress execution for all non-Ajax, non-JSON, non-XML requests. 3013 3025 * 3014 3026 * @since 3.0.0 … … 3220 3232 3221 3233 /** 3234 * Kills WordPress execution and displays Ajax response with an error message. 3235 * 3236 * This is the handler for wp_die() when processing Ajax requests. 3237 * 3238 * @since 3.4.0 3239 * @access private 3240 * 3241 * @param string $message Error message. 3242 * @param string $title Optional. Error title (unused). Default empty. 3243 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 3244 */ 3245 function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { 3246 // Set default 'response' to 200 for AJAX requests. 3247 $args = wp_parse_args( 3248 $args, 3249 array( 'response' => 200 ) 3250 ); 3251 3252 list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); 3253 3254 if ( ! headers_sent() ) { 3255 // This is intentional. For backward-compatibility, support passing null here. 3256 if ( null !== $args['response'] ) { 3257 status_header( $r['response'] ); 3258 } 3259 nocache_headers(); 3260 } 3261 3262 if ( is_scalar( $message ) ) { 3263 $message = (string) $message; 3264 } else { 3265 $message = '0'; 3266 } 3267 3268 if ( $r['exit'] ) { 3269 die( $message ); 3270 } 3271 3272 echo $message; 3273 } 3274 3275 /** 3222 3276 * Kills WordPress execution and displays JSON response with an error message. 3223 3277 * … … 3332 3386 3333 3387 /** 3334 * Kill s WordPress execution and displays Ajax response with anerror message.3335 * 3336 * This is the handler for wp_die () when processing Ajaxrequests.3337 * 3338 * @since 3.4.03388 * Kill WordPress execution and display XML message with error message. 3389 * 3390 * This is the handler for wp_die when processing XML requests. 3391 * 3392 * @since 5.2.0 3339 3393 * @access private 3340 3394 * 3341 3395 * @param string $message Error message. 3342 * @param string $title Optional. Error title (unused). Default empty.3396 * @param string $title Optional. Error title. Default empty. 3343 3397 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 3344 3398 */ 3345 function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { 3346 // Set default 'response' to 200 for AJAX requests. 3347 $args = wp_parse_args( 3348 $args, 3349 array( 'response' => 200 ) 3350 ); 3351 3399 function _xml_wp_die_handler( $message, $title = '', $args = array() ) { 3352 3400 list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); 3353 3401 3402 $message = htmlspecialchars( $message ); 3403 $title = htmlspecialchars( $title ); 3404 3405 $xml = <<<EOD 3406 <error> 3407 <code>{$r['code']}</code> 3408 <title><![CDATA[{$title}]]></title> 3409 <message><![CDATA[{$message}]]></message> 3410 <data> 3411 <status>{$r['response']}</status> 3412 </data> 3413 </error> 3414 3415 EOD; 3416 3354 3417 if ( ! headers_sent() ) { 3355 // This is intentional. For backward-compatibility, support passing null here.3356 if ( null !== $ args['response'] ) {3418 header( 'Content-Type: text/xml; charset=utf-8' ); 3419 if ( null !== $r['response'] ) { 3357 3420 status_header( $r['response'] ); 3358 3421 } … … 3360 3423 } 3361 3424 3362 if ( is_scalar( $message ) ) { 3363 $message = (string) $message; 3364 } else { 3365 $message = '0'; 3366 } 3367 3425 echo $xml; 3368 3426 if ( $r['exit'] ) { 3369 die( $message ); 3370 } 3371 3372 echo $message; 3427 die(); 3428 } 3373 3429 } 3374 3430 -
trunk/src/wp-includes/load.php
r45015 r45016 1530 1530 1531 1531 } 1532 1533 /** 1534 * 1535 * Checks whether current request is a XML request, or is expecting a XML response. 1536 * 1537 * @since 5.2.0 1538 * 1539 * @return bool True if Accepts or Content-Type headers contain xml, false otherwise. 1540 */ 1541 function wp_is_xml_request() { 1542 $accepted = array( 1543 'text/xml', 1544 'application/rss+xml', 1545 'application/atom+xml', 1546 'application/rdf+xml', 1547 'text/xml+oembed', 1548 'application/xml+oembed', 1549 ); 1550 1551 if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { 1552 foreach ( $accepted as $type ) { 1553 if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { 1554 return true; 1555 } 1556 } 1557 } 1558 1559 if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { 1560 return true; 1561 } 1562 1563 return false; 1564 }
Note: See TracChangeset
for help on using the changeset viewer.