mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@45015 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1501,3 +1501,31 @@ function wp_is_json_request() {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether current request is a JSONP request, or is expecting a JSONP response.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return bool True if JSONP request, false otherwise.
|
||||
*/
|
||||
function wp_is_jsonp_request() {
|
||||
if ( ! isset( $_GET['_jsonp'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_check_jsonp_callback' ) ) {
|
||||
require_once ABSPATH . WPINC . '/functions.php';
|
||||
}
|
||||
|
||||
$jsonp_callback = $_GET['_jsonp'];
|
||||
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
|
||||
$jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true );
|
||||
|
||||
return $jsonp_enabled;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user