includes/Integrations/class-litespeed-esi.php
LiteSpeed ESI bridge (P5).
Class LiteSpeed_ESI
Class LiteSpeed_ESI
final class LiteSpeed_ESIProperties
| Property | Visibility | Type | Default | Line |
|---|---|---|---|---|
$asset_cache | private static | mixed | null | 38 |
$asset_cache_set | private static | bool | false | 49 |
$nonce_wildcard_memo | private static | array<string,bool> | array() | 75 |
publicstatic reset_asset_cache_for_tests()
public static function reset_asset_cache_for_tests(): voidReset the memoized asset lookup (tests / long-lived workers).
Return: void.
publicstatic is_esi_available()
public static function is_esi_available(): boolWhether ESI is available (Enterprise only).
Return: bool.
publicstatic is_setting_enabled()
public static function is_setting_enabled(): boolWhether the ESI bridge setting is enabled.
Return: bool.
publicstatic is_enabled()
public static function is_enabled(): boolWhether ESI is enabled via settings AND available (Enterprise).
Return: bool.
privatestatic has_header_emitter()
private static function has_header_emitter(): boolWhether the Header_Emitter bridge is loaded.
Return: bool — True when Header_Emitter can be called safely.
privatestatic is_fragment_throttled()
private static function is_fragment_throttled(string=\'\' $block, int=60 $limit, int=60 $window): boolPer-IP-per-block fixed-window throttle for the public fragment endpoint. Parameter Type Default Description $blockstring=\'\'— Block name scoping the bucket (\’\’ for legacy callers). $limitint=60— Max hits per window. $windowint=60— Window in seconds.
Return: bool — True when throttled.
privatestatic has_nonce_receipt_proof()
private static function has_nonce_receipt_proof(string $nonce): boolWhether a presented nonce value proves prior page receipt. Parameter Type Default Description $noncestring— The presented nonce value (may be empty).
Return: bool — True when the value is structurally a WP nonce.
privatestatic log_refresh_mint_burst()
private static function log_refresh_mint_burst(string $block): voidLog a throttled nonce-refresh burst (at most once per hour per source). Parameter Type Default Description $blockstring— Block name scoping the throttle bucket.
Return: void.
privatestatic emit_private_fail_closed()
private static function emit_private_fail_closed(): voidEmit the private pair, fail-closed when the emitter is unavailable.
Return: void.
privatestatic emit_nocache_fail_closed()
private static function emit_nocache_fail_closed(): voidEmit the no-cache pair, fail-closed when the emitter is unavailable.
Return: void.
privatestatic fallback_nonce_seed()
private static function fallback_nonce_seed(string $context): stringFallback nonce seed when pluggable functions are unavailable. Parameter Type Default Description $contextstring— Nonce context (block name).
Return: string — MD5 seed for the fallback nonce, or \’\’ when no secret exists.
privatestatic supports_script_strategy()
private static function supports_script_strategy(): boolWhether core supports the native `strategy` script args (WP 6.3+).
Return: bool.
publicstatic enqueue_hydration_client()
public static function enqueue_hydration_client(): voidEnqueue the ESI hydration client (build/esi.js) for OLS placeholder mode.
Return: void.
publicstatic should_punch_hole()
public static function should_punch_hole(string $context): boolWhether a given context should punch hole via AJAX/ESI. Parameter Type Default Description $contextstring— Context: cart|checkout|account|adminbar|nonce etc.
Return: bool.
publicstatic render_esi_placeholder()
public static function render_esi_placeholder(string $block, array=array() $attrs): stringRender ESI placeholder. Parameter Type Default Description $blockstring— Block name (cart, adminbar, nonce). $attrsarray=array()— Optional attributes.
Return: string.
privatestatic get_esi_placeholder_aria()
private static function get_esi_placeholder_aria(string $block): arrayARIA attributes for the OLS ESI placeholder. Parameter Type Default Description $blockstring— Block name.
Return: array<string,?string> — Attribute => value map (null skips the attribute).
publicstatic register_ajax_handlers()
public static function register_ajax_handlers(): voidRegister AJAX handlers for ESI fragments.
Return: void.
publicstatic get_allowed_fragment_html()
public static function get_allowed_fragment_html(): arrayAllowlist of HTML tags/attributes permitted in ESI fragment HTML.
Return: array — Allowed tags => attributes map, in wp_kses() shape.
publicstatic get_woo_fragment_guidance()
public static function get_woo_fragment_guidance(): arrayWooCommerce fragment-caching guidance for dynamic commerce.
Return: array{esi_available: — string, bypass_routes: string[], fragment_blocks: string[], cookie_vary: string[], fallback: string} Structured ESI guidance.
publicstatic render_woo_cart_fragment()
public static function render_woo_cart_fragment(): stringRender the WooCommerce cart fragment (mini-cart count + cart hash).
Return: string — Kses-safe cart fragment HTML.
publicstatic handle_ajax_fragment()
public static function handle_ajax_fragment(): voidHandle AJAX fragment request.
Return: void.
publicstatic inject_nonce_replacement()
public static function inject_nonce_replacement($content)Inject nonce replacement into content. Parameter Type Default Description $contentmixed— Content to inject.
Return: mixed — The rewritten content, or the input unchanged.
publicstatic handle_send_headers()
public static function handle_send_headers(): voidHandle send_headers — emit private/no-vary for cart/checkout/account, no-cache for admin.
Return: void.
publicstatic init()
public static function init(): voidRegister ESI nonce/widget hooks.
Return: void.
privatestatic register_nonce_injector()
private static function register_nonce_injector(): voidAttach the ESI nonce injector to the fragment-content filter.
Return: void.
privatestatic sanitize_esi_tag_value()
private static function sanitize_esi_tag_value(string $action): stringSanitize an ESI tag value through the canonical sanitizer when available, with a local fallback otherwise. Parameter Type Default Description $actionstring— Raw ESI action name.
Return: string — Sanitized tag value (max 1024 chars).
publicstatic handle_nonce()
public static function handle_nonce($action): voidHandle litespeed_nonce action for widget/cart hole-punching. Parameter Type Default Description $actionstring— Nonce action.
Return: void.
publicstatic filter_esi_nonces()
public static function filter_esi_nonces($nonces): arrayFilter litespeed_esi_nonces for hole-punch list. Parameter Type Default Description $noncesarray— Nonce list.
Return: array.
publicstatic ajax_fallback()
public static function ajax_fallback(string $fragment): stringAJAX fallback fragment for OLS (no ESI). Parameter Type Default Description $fragmentstring— Fragment HTML.
Return: string.
Hooks
Hooks referenced in includes/Integrations/class-litespeed-esi.php: Hook Type Line Notes wppo_litespeed_esi_availablefilter 105 @param ×1 wppo_esi_availablefilter 115 @param ×1 wppo_esi_enabledfilter 139 @param ×1 wppo_esi_should_punch_holefilter 590 @param ×2 wppo_esi_blockfilter 745 @param ×2 wppo_esi_placeholderfilter 815 @param ×3 wppo_litespeed_esi_placeholderfilter 823 @param ×2 wppo_esi_placeholderfilter 853 @param ×3 wppo_litespeed_esi_placeholderfilter 854 @param ×3 wppo_esi_block_labelfilter 901 @param ×2 wppo_esi_allowed_htmlfilter 1058 @param ×1 wppo_esi_fragment_htmlfilter 1345 @param ×2 wppo_litespeed_esi_fragment_htmlfilter 1346 @param ×2 wppo_esi_nonce_contentfilter 1460 @param ×2 wppo_litespeed_esi_nonce_contentfilter 1461 @param ×2 wppo_esi_private_headers_sentaction 1527 @param ×1 wppo_esi_private_headers_sentaction 1534 — wppo_esi_private_headers_sentaction 1560 — wppo_esi_fragment_htmlfilter registration 1650 — wppo_litespeed_esi_fragment_htmlfilter registration 1651 — wppo_esi_noncesfilter 1737 @param ×1 wppo_litespeed_esi_noncesfilter 1738 @param ×1 wppo_esi_fallbackfilter 1760 @param ×2