WC_REST_Authentication::is_request_to_rest_api │ protected │ WC 1.0

Check if is request to our REST API.

Метод класса: WC_REST_Authentication{}

Хуки из метода

Возвращает

bool.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->is_request_to_rest_api();

Код WC_REST_Authentication::is_request_to_rest_api() WC 11.2.2

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

	// Only treat this as a WooCommerce REST API request once WordPress is actually dispatching one.
	if ( ! wp_is_rest_endpoint() ) {
		return false;
	}

	$resolved_route = $this->resolved_route();
	$is_wc_route    = $this->is_wc_namespace( $this->route_from_request_uri() )
		|| ( 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 );
}