IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
3247 | 3247 | 'status' => $r['response'], |
3248 | 3248 | ); |
3249 | 3249 | |
| 3250 | if ( isset( $_GET['_jsonp'] ) ) { |
| 3251 | $jsonp_callback = $_GET['_jsonp']; |
| 3252 | $content_type = 'application/javascript'; |
| 3253 | } else { |
| 3254 | $jsonp_callback = false; |
| 3255 | $content_type = 'application/json'; |
| 3256 | } |
| 3257 | |
3250 | 3258 | if ( ! headers_sent() ) { |
3251 | | header( 'Content-Type: application/json; charset=utf-8' ); |
| 3259 | header( 'Content-Type: ' . $content_type . '; charset=utf-8' ); |
3252 | 3260 | if ( null !== $r['response'] ) { |
3253 | 3261 | status_header( $r['response'] ); |
3254 | 3262 | } |
3255 | 3263 | } |
3256 | 3264 | |
3257 | | echo wp_json_encode( $data ); |
| 3265 | $result = wp_json_encode( $data ); |
| 3266 | if ( $jsonp_callback ) { |
| 3267 | echo '/**/' . $jsonp_callback . '(' . $result . ')'; |
| 3268 | } else { |
| 3269 | echo $result; |
| 3270 | } |
3258 | 3271 | die(); |
3259 | 3272 | } |
3260 | 3273 | |
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 | |
| 1491 | if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { |
1485 | 1492 | return true; |
1486 | 1493 | } |
1487 | 1494 | |