WC_REST_Authentication::is_request_to_rest_api │ protected │ WC 1.0

Check if is request to our REST API.

Method of the class: WC_REST_Authentication{}

Returns

bool.

Usage

// protected - for code of main (parent) or child class
$result = $this->is_request_to_rest_api();

WC_REST_Authentication::is_request_to_rest_api() code WC 11.1.2

protected function is_request_to_rest_api() {
	if ( empty( $_SERVER['REQUEST_URI'] ) ) {
		return false;
	}

	$resolved_route = $this->resolved_route();
	$is_wc_route    = $this->is_wc_namespace( $this->route_from_request_uri() )
		|| ( wp_is_rest_endpoint() && null !== $resolved_route && $this->is_wc_namespace( $resolved_route ) );

	/**
	 * Filters whether the current request is a request to the WooCommerce REST API.
	 *
	 * @since 2.6.0
	 *
	 * @param bool $is_request_to_rest_api Whether the request is to a WooCommerce REST API endpoint.
	 */
	return apply_filters( 'woocommerce_rest_is_request_to_rest_api', $is_wc_route );
}