class-woo-detect.php

Woo_Detect boundary — WooCommerce detection, excluded paths, and self-test.

Source includes/Integrations/class-woo-detect.php4 min readPart of Performance Optimisation

includes/Integrations/class-woo-detect.php

Woo_Detect boundary — WooCommerce detection, excluded paths, and self-test.

Namespace: PerformanceOptimise\\Inc · Lines: 1016

Class Woo_Detect

Class Woo_Detect

Source: includes/Integrations/class-woo-detect.php, line 57

final class Woo_Detect

Tags: @since 2.4.0

publicstatic is_woo_safe_mode_enabled()

public static function is_woo_safe_mode_enabled(?array=null $settings): bool

Whether WooCommerce safe mode is enabled.

ParameterTypeDefaultDescription
$settings?array=null—Optional settings array (defaults to get_settings()).

Return: bool — True when safe mode is enabled.

Tags: @since 2.0.0

Source: includes/Integrations/class-woo-detect.php, line 69

publicstatic is_woo_store_api_path()

public static function is_woo_store_api_path(string $path): bool

Whether a normalized request path is a WooCommerce Store API route.

ParameterTypeDefaultDescription
$pathstring—Request path (leading slash optional) or a `rest_route` value.

Return: bool — True when the path is a Store API route.

Tags: @since 2.0.0

Source: includes/Integrations/class-woo-detect.php, line 104

publicstatic is_woo_store_api_request()

public static function is_woo_store_api_request(string=\'\' $path, ?string=null $query_string, ?string=null $rest_route): bool

Whether the current request targets a WooCommerce Store API route.

ParameterTypeDefaultDescription
$pathstring=\'\'—Request path (leading slash optional).
$query_string?string=null—Optional raw query string (defaults to `$_SERVER[\’QUERY_STRING\’]`).
$rest_route?string=null—Optional `rest_route` value (defaults to `$_GET[\’rest_route\’]`).

Return: bool — True when the request is a Store API request.

Tags: @since 2.0.0

Source: includes/Integrations/class-woo-detect.php, line 141

publicstatic is_woo_dynamic_path()

public static function is_woo_dynamic_path(string $path): bool

Whether a request path belongs to a WooCommerce dynamic page.

ParameterTypeDefaultDescription
$pathstring—Request path (leading slash optional).

Return: bool — True when the path is Woo-dynamic.

Tags: @since 2.0.0

Source: includes/Integrations/class-woo-detect.php, line 183

publicstatic get_woo_excluded_paths()

public static function get_woo_excluded_paths(): array

Relative paths treated as WooCommerce endpoints for static-cache bypass.

Return: string[] — Relative paths (e.g. `cart`, `shop/basket`), unique, lowercased.

Tags: @since 2.0.0

Source: includes/Integrations/class-woo-detect.php, line 229

publicstatic is_woo_active()

public static function is_woo_active(): bool

Whether WooCommerce is active on the current site.

Return: bool — True when any WooCommerce symbol is available.

Tags: @since 2.0.0

Source: includes/Integrations/class-woo-detect.php, line 295

publicstatic is_woo_faceted_query()

public static function is_woo_faceted_query(?string=null $query_string): bool

Whether a query string carries WooCommerce layered-nav / faceted-filter params.

ParameterTypeDefaultDescription
$query_string?string=null—Raw query string. Defaults to `$_SERVER[\’QUERY_STRING\’]`.

Return: bool — True when faceted params are present.

Tags: @since 2.2.0

Source: includes/Integrations/class-woo-detect.php, line 325

publicstatic is_woo_ajax_request()

public static function is_woo_ajax_request(string=\'\' $path, string=\'\' $query_string): bool

Whether path/query values indicate a WooCommerce AJAX endpoint.

ParameterTypeDefaultDescription
$pathstring=\'\'—Request path (leading slash optional).
$query_stringstring=\'\'—Raw query string (without leading `?`).

Return: bool — True when the values indicate a wc-ajax request.

Tags: @since 2.3.0

Source: includes/Integrations/class-woo-detect.php, line 415

publicstatic is_woo_add_to_cart_request()

public static function is_woo_add_to_cart_request(string=\'\' $query_string): bool

Whether a query string carries a WooCommerce add-to-cart action.

ParameterTypeDefaultDescription
$query_stringstring=\'\'—Raw query string (without leading `?`).

Return: bool — True when the query carries an add-to-cart action.

Tags: @since 2.3.0

Source: includes/Integrations/class-woo-detect.php, line 458

publicstatic is_woo_excluded_url()

public static function is_woo_excluded_url(string $url, string=\'\' $query, string=\'\' $rest_route): bool

Whether an absolute URL targets a WooCommerce dynamic route.

ParameterTypeDefaultDescription
$urlstring—Absolute URL.
$querystring=\'\'—Optional pre-parsed query string (parsed from $url when \’\’).
$rest_routestring=\'\'—Optional pre-parsed rest_route value.

Return: bool — True when the URL must not be cached/preloaded.

Tags: @since 2.2.0

Source: includes/Integrations/class-woo-detect.php, line 498

publicstatic woo_cache_self_test()

public static function woo_cache_self_test(): array

Verifiable WooCommerce cart/checkout cache-exclusion self-test.

Return: array{woo_active: — bool, safe_mode: bool, runnable: bool, excluded_paths: string[], donotcachepage_honored: bool, checks: array<int, array{url: string, path: string, is_dynamic: bool, cacheable: bool, donotcachepage_honored: bool, pass: bool, error?: string}>, fragment_checks: array<int, array{url: string, path: string, is_dynamic: bool, cacheable: bool, donotcachepage_honored: bool, pass: bool, error?: string}>, editor_checks: array<int, array{url: string, bypass: bool, cacheable: bool, donotcachepage_honored: bool, pass: bool, error?: string}>, preload_checks: array<int, array{url: string, path: string, skipped: bool, pass: bool, error?: string}>, cart_checks: array<int, array{key: string, url: string, bypass: bool, cacheable: bool, donotcachepage_honored: bool, pass: bool, error?: string}>, force_exclude: bool, all_pass: bool} Structured self-test result.

Tags: @since 2.0.0 · @since 2.2.0 Added additive `editor_checks` (wp-admin + builder/core preview bypass probes). · @since 2.2.0 Added additive `fragment_checks` (wc-ajax / add-to-cart / plain-permalink Store API fragment probes, issue #1197). · @since 2.2.0 Added additive `preload_checks` (faceted-URL preload-skip probes), `cart_checks` (guest-cart survival probes) and `force_exclude` (fail-closed recommendation, issue #1256).

Source: includes/Integrations/class-woo-detect.php, line 628

Hooks

Hooks referenced in includes/Integrations/class-woo-detect.php:

HookTypeLineNotes
wppo_woo_faceted_query_paramsfilter348—