Automattic\WooCommerce\StoreApi
Authentication::has_store_api_route_as_get_parameter
Checks if the request has a store API route as a GET rest_route parameter.
Method of the class: Authentication{}
No Hooks.
Returns
true|false.
Usage
// protected - for code of main (parent) or child class $result = $this->has_store_api_route_as_get_parameter(): bool;
Changelog
| Since 10.6.0 | Introduced. |
Authentication::has_store_api_route_as_get_parameter() Authentication::has store api route as get parameter code WC 10.7.0
protected function has_store_api_route_as_get_parameter(): bool {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Store API
if ( ! isset( $_GET['rest_route'] ) || ! is_string( $_GET['rest_route'] ) ) {
return false;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Store API context check.
$rest_route = rawurldecode( esc_url_raw( wp_unslash( $_GET['rest_route'] ) ) );
return 0 === strpos( $rest_route, '/wc/store/' );
}