IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 2993 | 2993 | * @param callable $function Callback function name. |
| 2994 | 2994 | */ |
| 2995 | 2995 | $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); |
| 2996 | | } else { |
| | 2996 | } elseif ( wp_is_xml_request() ) { |
| | 2997 | /** |
| | 2998 | * Filters the callback for killing WordPress execution for XML requests. |
| | 2999 | * |
| | 3000 | * @since 5.1.0 |
| | 3001 | * |
| | 3002 | * @param callable $function Callback function name. |
| | 3003 | */ |
| | 3004 | $function = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' ); |
| | 3005 | }else { |
| 2997 | 3006 | /** |
| 2998 | 3007 | * Filters the callback for killing WordPress execution for all non-Ajax, non-XML-RPC requests. |
| 2999 | 3008 | * |
| … |
… |
|
| 3258 | 3267 | die(); |
| 3259 | 3268 | } |
| 3260 | 3269 | |
| | 3270 | /** |
| | 3271 | * Kill WordPress execution and display XML message with error message. |
| | 3272 | * |
| | 3273 | * This is the handler for wp_die when processing XML requests. |
| | 3274 | * |
| | 3275 | * @since 5.1.0 |
| | 3276 | * @access private |
| | 3277 | * |
| | 3278 | * @param string $message Error message. |
| | 3279 | * @param string $title Optional. Error title. Default empty. |
| | 3280 | * @param string|array $args Optional. Arguments to control behavior. Default empty array. |
| | 3281 | */ |
| | 3282 | function _xml_wp_die_handler( $message, $title = '', $args = array() ) { |
| | 3283 | $defaults = array( 'response' => 500 ); |
| | 3284 | |
| | 3285 | $r = wp_parse_args( $args, $defaults ); |
| | 3286 | |
| | 3287 | $data = array( |
| | 3288 | 'error' => array( |
| | 3289 | 'code' => 'wp_die', |
| | 3290 | 'message' => $message, |
| | 3291 | 'status' => $r['response'], |
| | 3292 | ) |
| | 3293 | ); |
| | 3294 | |
| | 3295 | if ( ! headers_sent() ) { |
| | 3296 | header( 'Content-Type: text/xml; charset=utf-8' ); |
| | 3297 | if ( null !== $r['response'] ) { |
| | 3298 | status_header( $r['response'] ); |
| | 3299 | } |
| | 3300 | nocache_headers(); |
| | 3301 | } |
| | 3302 | echo '<?xml version="1.0" encoding="UTF-8"?>'; |
| | 3303 | array_walk( $data, '_wp_wrap_xml' ); |
| | 3304 | die(); |
| | 3305 | } |
| | 3306 | |
| | 3307 | |
| 3261 | 3308 | /** |
| 3262 | 3309 | * Kill WordPress execution and display XML message with error message. |
| 3263 | 3310 | * |
| … |
… |
|
| 3330 | 3377 | die(); |
| 3331 | 3378 | } |
| 3332 | 3379 | |
| | 3380 | /** |
| | 3381 | * Helper function to walk through array and echo xml elements |
| | 3382 | * |
| | 3383 | * @since 5.1.0 |
| | 3384 | * @access private |
| | 3385 | * |
| | 3386 | * @param $value |
| | 3387 | * @param $element |
| | 3388 | */ |
| | 3389 | function _wp_wrap_xml( $value, $element ) { |
| | 3390 | |
| | 3391 | if ( ! is_string( $element ) ) { |
| | 3392 | $element = 'item'; |
| | 3393 | } |
| | 3394 | if ( is_object( $value ) ) { |
| | 3395 | $value = (array) $value; |
| | 3396 | } |
| | 3397 | |
| | 3398 | echo "<$element>"; |
| | 3399 | if ( is_array( $value ) ) { |
| | 3400 | array_walk( $value, '_wp_wrap_xml' ); |
| | 3401 | } elseif ( is_scalar( $value ) ) { |
| | 3402 | echo $value; |
| | 3403 | } |
| | 3404 | echo "</$element>"; |
| | 3405 | } |
| | 3406 | |
| 3333 | 3407 | /** |
| 3334 | 3408 | * Encode a variable into JSON, with some sanity checks. |
| 3335 | 3409 | * |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 1488 | 1488 | return false; |
| 1489 | 1489 | |
| 1490 | 1490 | } |
| | 1491 | |
| | 1492 | /** |
| | 1493 | * Checks whether current request is a XML request, or is expecting a XML response. |
| | 1494 | * |
| | 1495 | * @since 5.1.0 |
| | 1496 | * |
| | 1497 | * @return bool True if Accepts or Content-Type headers contain xml, false otherwise. |
| | 1498 | */ |
| | 1499 | function wp_is_xml_request() { |
| | 1500 | |
| | 1501 | $accepted = array( |
| | 1502 | 'application/rss+xml', |
| | 1503 | 'application/rss+xml', |
| | 1504 | 'text/xml', |
| | 1505 | 'application/atom+xml', |
| | 1506 | 'application/rdf+xml', |
| | 1507 | ); |
| | 1508 | |
| | 1509 | if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { |
| | 1510 | foreach ( $accepted as $type ) { |
| | 1511 | if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { |
| | 1512 | return true; |
| | 1513 | } |
| | 1514 | } |
| | 1515 | } |
| | 1516 | |
| | 1517 | if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { |
| | 1518 | return true; |
| | 1519 | } |
| | 1520 | |
| | 1521 | return false; |
| | 1522 | } |