Make WordPress Core


Ignore:
Timestamp:
03/26/2019 10:25:47 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Bootstrap/Load: Add support for JSONP requests to wp_die().

In addition to AJAX, XML-RPC, and JSON requests, wp_die() now handles JSONP requests correctly, returning information in the expected content type.

Props spacedmonkey, TimothyBlynJacobs.
Fixes #46025. See #44458.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r44973 r45015  
    15021502
    15031503}
     1504
     1505/**
     1506 * Checks whether current request is a JSONP request, or is expecting a JSONP response.
     1507 *
     1508 * @since 5.2.0
     1509 *
     1510 * @return bool True if JSONP request, false otherwise.
     1511 */
     1512function wp_is_jsonp_request() {
     1513    if ( ! isset( $_GET['_jsonp'] ) ) {
     1514        return false;
     1515    }
     1516
     1517    if ( ! function_exists( 'wp_check_jsonp_callback' ) ) {
     1518        require_once ABSPATH . WPINC . '/functions.php';
     1519    }
     1520
     1521    $jsonp_callback = $_GET['_jsonp'];
     1522    if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
     1523        return false;
     1524    }
     1525
     1526    /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
     1527    $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true );
     1528
     1529    return $jsonp_enabled;
     1530
     1531}
Note: See TracChangeset for help on using the changeset viewer.