wp_is_jsonp_request() WordPress Function

The wp_is_jsonp_request() function is used to check whether the current request is a JSONP (JavaScript Object Notation with Padding) request. A JSONP request is a type of AJAX (Asynchronous JavaScript and XML) request that uses a callback function to receive data from a server. JSONP requests are used to bypass the same-origin policy that is enforced by web browsers. The wp_is_jsonp_request() function can be used to check if a JSONP request is being made from a given URL. It can also be used to verify that the callback function specified in the request is valid.

wp_is_jsonp_request() #

Checks whether current request is a JSONP request, or is expecting a JSONP response.


Return

(bool) True if JSONP request, false otherwise.


Top ↑

Source

File: wp-includes/load.php

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;

}


Top ↑

Changelog

Changelog
VersionDescription
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.