IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
2989 | 2989 | * @param callable $function Callback function name. |
2990 | 2990 | */ |
2991 | 2991 | $function = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); |
| 2992 | } elseif ( wp_is_jsonp_request() ) { |
| 2993 | /** |
| 2994 | * Filters the callback for killing WordPress execution for JSONP requests. |
| 2995 | * |
| 2996 | * @since 5.1.0 |
| 2997 | * |
| 2998 | * @param callable $function Callback function name. |
| 2999 | */ |
| 3000 | $function = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' ); |
2992 | 3001 | } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { |
2993 | 3002 | /** |
2994 | 3003 | * Filters the callback for killing WordPress execution for XML-RPC requests. |
… |
… |
|
4271 | 4280 | <?php |
4272 | 4281 | die(); |
4273 | 4282 | } |
| 4283 | |
| 4284 | /** |
| 4285 | * Kill WordPress execution and display JSONP message with error message. |
| 4286 | * |
| 4287 | * This is the handler for wp_die when processing JSONP requests. |
| 4288 | * |
| 4289 | * @since 5.1.0 |
| 4290 | * @access private |
| 4291 | * |
| 4292 | * @param string $message Error message. |
| 4293 | * @param string $title Optional. Error title. Default empty. |
| 4294 | * @param string|array $args Optional. Arguments to control behavior. Default empty array. |
| 4295 | */ |
| 4296 | function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) { |
| 4297 | list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); |
| 4298 | |
| 4299 | $data = array( |
| 4300 | 'code' => $r['code'], |
| 4301 | 'message' => $message, |
| 4302 | 'data' => array( |
| 4303 | 'status' => $r['response'], |
| 4304 | ), |
| 4305 | 'additional_errors' => $r['additional_errors'], |
| 4306 | ); |
| 4307 | |
| 4308 | if ( ! headers_sent() ) { |
| 4309 | header( 'Content-Type: application/javascript; charset=utf-8' ); |
| 4310 | if ( null !== $r['response'] ) { |
| 4311 | status_header( $r['response'] ); |
| 4312 | } |
| 4313 | nocache_headers(); |
| 4314 | } |
| 4315 | |
| 4316 | $result = wp_json_encode( $data ); |
| 4317 | $jsonp_callback = $_GET['_jsonp']; |
| 4318 | echo '/**/' . $jsonp_callback . '(' . $result . ')'; |
| 4319 | if ( $r['exit'] ) { |
| 4320 | die(); |
| 4321 | } |
| 4322 | } |
4274 | 4323 | |
4275 | 4324 | /** |
4276 | 4325 | * Convert a value to non-negative integer. |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
1488 | 1488 | return false; |
1489 | 1489 | |
1490 | 1490 | } |
| 1491 | |
| 1492 | |
| 1493 | /** |
| 1494 | * Checks whether current request is a JSONP request, or is expecting a JSONP response. |
| 1495 | * |
| 1496 | * @since 5.1.0 |
| 1497 | * |
| 1498 | * @return bool True if JSONP Request |
| 1499 | */ |
| 1500 | function wp_is_jsonp_request() { |
| 1501 | if ( ! isset( $_GET['_jsonp'] ) ) { |
| 1502 | return false; |
| 1503 | } |
| 1504 | |
| 1505 | if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { |
| 1506 | require_once ABSPATH . WPINC . '/functions.php'; |
| 1507 | } |
| 1508 | |
| 1509 | $jsonp_callback = $_GET['_jsonp']; |
| 1510 | if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { |
| 1511 | return false; |
| 1512 | } |
| 1513 | |
| 1514 | $jsonp_enabled = true; |
| 1515 | /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ |
| 1516 | $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', $jsonp_enabled ); |
| 1517 | |
| 1518 | return $jsonp_enabled; |
| 1519 | |
| 1520 | } |
| 1521 | No newline at end of file |