WordPress at a glance
function is not described

WooCommerce::is_rest_api_request() public WC 1.0

Returns true if the request is a non-legacy REST API request.

Legacy REST requests should still run some extra code for backwards compatibility.

{} It's a method of the class: WooCommerce{}

Hooks from the method

true|false. Nothing.


$WooCommerce = new WooCommerce();

Code of WooCommerce::is_rest_api_request() WC 5.3.0

public function is_rest_api_request() {
	if ( empty( $_SERVER['REQUEST_URI'] ) ) {
		return false;

	$rest_prefix         = trailingslashit( rest_get_url_prefix() );
	$is_rest_api_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) ); // phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

	return apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request );