@@ 52-63 (lines=12) @@ | ||
49 | * |
|
50 | * @return bool |
|
51 | */ |
|
52 | protected function is_request_to_rest_api() { |
|
53 | if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
54 | return false; |
|
55 | } |
|
56 | ||
57 | $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
58 | ||
59 | // Allow third party plugins use our authentication methods. |
|
60 | $third_party = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc-' ) ); // @codingStandardsIgnoreLine |
|
61 | ||
62 | return apply_filters( 'woocommerce_rest_is_request_to_rest_api', WC()->is_rest_api_request() || $third_party ); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * Authenticate user. |
@@ 252-264 (lines=13) @@ | ||
249 | * |
|
250 | * @return bool |
|
251 | */ |
|
252 | public function is_rest_api_request() { |
|
253 | if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
254 | return false; |
|
255 | } |
|
256 | ||
257 | // REST API prefix. |
|
258 | $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
259 | ||
260 | // Check if this is a WC endpoint. |
|
261 | $is_woocommerce_endpoint = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc/' ) ); // phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
262 | ||
263 | return apply_filters( 'woocommerce_is_rest_api_request', $is_woocommerce_endpoint ); |
|
264 | } |
|
265 | ||
266 | /** |
|
267 | * What type of request is this? |