class-critical-css.php

Critical CSS Generation for above-the-fold optimization.

Source includes/CSS/class-critical-css.php32 min readPart of Performance Optimisation

includes/CSS/class-critical-css.php

Critical CSS Generation for above-the-fold optimization.

Namespace: PerformanceOptimise\\Inc · Lines: 6251

Class Critical_CSS

Class Critical_CSS

Source: includes/CSS/class-critical-css.php, line 28

class Critical_CSS

Tags: @since 2.0.0

Constants

ConstantVisibilityValueLine
ABOVE_FOLD_SELECTORSprivatearray( \'html\', \'body\', \'header\', \'.header\', \'#header\', \'.site-header\', \'#masthead\', \'nav\', \'.nav\', \'#nav\', \'.menu\', \'.primary-menu\', \'.main-navigation\', \'h1\', \'h2\', \'h3\', \'.hero\', \'.banner\', \'.page-title\', \'.entry-title\', \'.page-header\', \'.entry-header\', \'.logo\', \'.site-logo\', \'.site-branding\', \'img\', \'.wp-block-image\', \'figure\', \'main\', \'.main\', \'.content\', \'.site-content\', \'.container\', \'.wrapper\', \'.row\', \'.section\', \'.top-bar\', \'.topbar\', \'.skip-link\', \'.screen-reader-text\', \':root\', \'p\', \'a\', \'ul\', \'li\', \'button\', \'.btn\', \'.button\', )61
SKIP_DEFER_HANDLESprivatearray( \'wppo-combine-css\', \'dashicons\', \'admin-bar\', \'wp-block-library\', \'wc-block-style\', )118
MAX_IMPORT_DEPTHprivate3132
DEFAULT_CCSS_MAX_SIZEprivate20480144
DEFAULT_CCSS_QUEUE_CAPprivate5156
MAX_CCSS_QUEUE_CAPprivate100164
DEFAULT_CCSS_GEN_TIMEOUTprivate25179
MAX_CCSS_GEN_TIMEOUTprivate120190
DEFAULT_CCSS_INLINE_BUDGET_BYTESprivate14336204
MIN_CCSS_INLINE_BUDGET_BYTESprivate1024212
MAX_CCSS_INLINE_BUDGET_BYTESprivate102400223
MAX_CCSS_SOURCE_BYTESprivate2097152236
MAX_CCSS_FETCHESprivate30249
MAX_CCSS_FILE_BYTESprivate524288257
DEFAULT_EXCLUDED_POST_TYPESprivatearray( \'fl-builder-template\', \'elementor_library\' )269
LAST_FULL_REGEN_OPTIONpublic\'wppo_ccss_last_full_regen\'282
FULL_REGEN_COOLDOWN_SECONDSprivate18000293
TARGETED_REGEN_CAPprivate20305
TARGETED_REGEN_OPTIONpublic\'wppo_ccss_last_targeted_regen\'319
TARGETED_REGEN_COOLDOWN_SECONDSprivate3600331
VIEWPORT_VARIANTSpublicarray( \'mobile\', \'desktop\' )409
MIN_INLINE_SIZEprivate500420

Properties

PropertyVisibilityTypeDefaultLine
$lcp_preload_emittedprivate staticarrayarray()38
$ccss_defer_blockedprivate staticarrayarray()51
$has_microtimeprivate static?boolnull339
$excluded_memoprivate static?arraynull354
$gzip_size_memoprivate staticarrayarray()368
$commerce_context_memoprivate static?boolnull380
$commerce_excluded_context_memoprivate static?boolnull392
$stale_probe_memoprivate staticarrayarray()2656
$above_fold_matcherprivate static?arraynull4871
$ccss_presets_memoprivate static?arraynull4884

privatestatic get_ccss_dir()

private static function get_ccss_dir(): string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_dir}.

Return: string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 429

privatestatic get_ccss_url()

private static function get_ccss_url(): string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_url}.

Return: string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 440

publicstatic get_template_hash()

public static function get_template_hash(string=\'\' $template): string

Generate a unique template hash for a template slug + stylesheet.

ParameterTypeDefaultDescription
$templatestring=\'\'—Optional template slug. Defaults to current template via get_current_template_slug().

Return: string — MD5 hash.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 451

privatestatic get_current_template_slug()

private static function get_current_template_slug(): string

Get the current WordPress template slug based on conditional tags.

Return: string — Template slug: \’home\’, \’single\’, \’page\’, \’archive\’, or \’index\’.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 466

privatestatic get_ccss_file()

private static function get_ccss_file(string $template_hash): string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_file}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 490

privatestatic is_ccss_path_contained()

private static function is_ccss_path_contained(string $path): bool

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::is_ccss_path_contained}.

ParameterTypeDefaultDescription
$pathstring—Parameter (see Ccss_Store).

Return: bool — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 502

publicstatic stage_ccss_for_template()

public static function stage_ccss_for_template(string $template_hash, string $css): array

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::stage_ccss_for_template}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).
$cssstring—Parameter (see Ccss_Store).

Return: array — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 515

publicstatic promote_staged_ccss()

public static function promote_staged_ccss(string $template_hash): bool

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::promote_staged_ccss}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: bool — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 527

publicstatic rollback_ccss_to_fallback()

public static function rollback_ccss_to_fallback(string $template_hash, string=\'manual\' $reason): bool

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::rollback_ccss_to_fallback}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).
$reasonstring=\'manual\'—Parameter (see Ccss_Store).

Return: bool — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 540

publicstatic get_ccss_rollout_status()

public static function get_ccss_rollout_status(string $template_hash): array

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_rollout_status}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: array — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 552

publicstatic verify_ccss_health()

public static function verify_ccss_health(string $template_hash): array

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::verify_ccss_health}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: array — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 564

publicstatic generate_preview_for_template()

public static function generate_preview_for_template(string $template): array

Dry-run critical-CSS generation with staged preview (issue #1348).

ParameterTypeDefaultDescription
$templatestring—Template identifier.

Return: array{staged: — bool, reason: string, bytes: int, checksum: string, live_bytes: int, live_checksum: string, changed: bool, template: string} Preview metadata.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 581

publicstatic get_ccss_max_size()

public static function get_ccss_max_size(): int

Read the configured CCSS inline size cap in bytes.

Return: int — Cap in bytes.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 636

publicstatic truncate_to_cap()

public static function truncate_to_cap(string $css, int $cap): string

Truncate CSS to the cap without breaking a rule.

ParameterTypeDefaultDescription
$cssstring—CSS content.
$capint—Maximum bytes.

Return: string — Truncated CSS, or \’\’ when nothing fits.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 660

publicstatic get_full_regen_cooldown()

public static function get_full_regen_cooldown(): int

Effective full-regen cooldown in seconds (issue #1462).

Return: int — Cooldown in seconds.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 695

publicstatic get_ccss_inline_budget_bytes()

public static function get_ccss_inline_budget_bytes(): int

Read the configured gzipped inline budget in bytes (issue #1388).

Return: int — Budget in bytes, clamped to MIN..MAX_CCSS_INLINE_BUDGET_BYTES.

Tags: @since 2.3.0 · @see Critical_CSS::get_ccss_max_size()

Source: includes/CSS/class-critical-css.php, line 726

publicstatic is_full_regen_cooled_down()

public static function is_full_regen_cooled_down(): bool

Whether a non-forced full regeneration is inside the cooldown window (issue #1462).

Return: bool — True when the last full regen is newer than the cooldown.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 757

publicstatic mark_full_regen()

public static function mark_full_regen(): void

Record a completed full-regeneration scan (issue #1462).

Return: void.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 787

publicstatic get_targeted_regen_cooldown()

public static function get_targeted_regen_cooldown(): int

Effective targeted-regeneration cooldown in seconds (issue #1462).

Return: int — Cooldown in seconds (>= 0).

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 810

publicstatic is_targeted_regen_cooled_down()

public static function is_targeted_regen_cooled_down(): bool

Whether a targeted regeneration is inside the throttle window (issue #1462).

Return: bool — True when the last targeted regen is newer than the cooldown.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 845

publicstatic mark_targeted_regen()

public static function mark_targeted_regen(): void

Record a targeted-regeneration pass (issue #1462).

Return: void.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 871

publicstatic estimate_committed_inline_bytes()

public static function estimate_committed_inline_bytes(): int

Bytes already committed to inline output on this request (issue #1462).

Return: int — Committed inline bytes (>= 0).

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 899

publicstatic get_effective_ccss_budget()

public static function get_effective_ccss_budget(int=0 $already_inlined): int

Effective inline budget for critical CSS after prior commits (issue #1462).

ParameterTypeDefaultDescription
$already_inlinedint=0—Bytes already committed to inline output.

Return: int — Effective budget in bytes (>= 0).

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 939

publicstatic coordinate_inline_budgets()

public static function coordinate_inline_budgets(string $ccss, string|int=\'\' $used_css): array

Coordinate used CSS and critical CSS within one inline budget (issue #1462).

ParameterTypeDefaultDescription
$ccssstring—Critical CSS content for the current template.
$used_cssstring|int=\'\'—Used-CSS content already committed inline (\’\’ when file-delivered), or a byte count to avoid materialising a stub string.

Return: array{inline: — string, deferred: string} Budget-aware CCSS split.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 976

publicstatic request_targeted_regen()

public static function request_targeted_regen(string=\'\' $reason, int=20 $cap): int

Queue a bounded targeted regen after builder/theme updates (issue #1462).

ParameterTypeDefaultDescription
$reasonstring=\'\'—Short reason for logging (e.g. \’builder-update\’).
$capint=20—Maximum templates to requeue in this pass (0 = empty pass, no work; negatives clamp to 0).

Return: int — Number of jobs queued.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1035

publicstatic gzipped_size()

public static function gzipped_size(string $css): int

Measure the gzipped transfer size of CSS output (issue #1388).

ParameterTypeDefaultDescription
$cssstring—CSS content.

Return: int — Gzipped size in bytes, or raw size without zlib.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1121

publicstatic is_over_inline_budget()

public static function is_over_inline_budget(string $css): bool

Whether CSS output exceeds the gzipped inline budget (issue #1388).

ParameterTypeDefaultDescription
$cssstring—CSS content.

Return: bool — True when the gzipped size exceeds the inline budget.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1164

publicstatic is_commerce_excluded()

public static function is_commerce_excluded(): bool

Whether cart/checkout inline critical CSS is excluded (issue #1388).

Return: bool — True when commerce exclusion is active.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1186

publicstatic is_commerce_context()

public static function is_commerce_context(): bool

Whether the current request is a cart/checkout context (issue #1388).

Return: bool — True on cart/checkout pages.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1221

privatestatic is_commerce_excluded_context()

private static function is_commerce_excluded_context(): bool

Whether commerce exclusion applies to the current request (issue #1388 review).

Return: bool — True when inline/deferral must yield to normal stylesheets.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1296

publicstatic get_ccss_inline_budget_label()

public static function get_ccss_inline_budget_label(): string

Human-readable label for the configured gzipped inline budget (issue #1388 review).

Return: string — e.g. \”14 KB\” or \”2.5 KB\”.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1320

publicstatic is_checksum_regen_enabled()

public static function is_checksum_regen_enabled(): bool

Whether checksum-triggered CCSS regen on save is enabled (issue #1388).

Return: bool — True when checksum regen is active.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 1348

publicstatic get_css_queue_cap()

public static function get_css_queue_cap(): int

Read the configured per-run CCSS queue cap (issue #1164).

Return: int — Per-run cap, or PHP_INT_MAX when uncapped.

Tags: @since 2.2.0 Filterable via `wppo_ccss_queue_cap`. · @see Critical_CSS::get_ccss_gen_timeout() · @see Critical_CSS::get_ccss_queue_cap()

Source: includes/CSS/class-critical-css.php, line 1381

publicstatic get_ccss_queue_cap()

public static function get_ccss_queue_cap(): int

Canonical double-`s` spelling of the per-run CCSS queue cap (issue #1235).

Return: int — Per-run cap, or PHP_INT_MAX when uncapped.

Tags: @since 2.2.0 · @see Critical_CSS::get_css_queue_cap()

Source: includes/CSS/class-critical-css.php, line 1417

publicstatic get_ccss_gen_timeout()

public static function get_ccss_gen_timeout(): int

Read the configured wall-clock budget in seconds for one CCSS generation run (issue #1235).

Return: int — Budget in seconds, clamped to 1..MAX_CCSS_GEN_TIMEOUT.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1436

publicstatic parse_excluded_slugs()

public static function parse_excluded_slugs($raw): array

Normalize raw exclusion slugs (setting lines or filter output).

ParameterTypeDefaultDescription
$rawstring|string[]|mixed—Raw slugs.

Return: string[] — Validated lowercase slugs.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1476

publicstatic get_excluded_post_types()

public static function get_excluded_post_types(): array

Builder-template post types excluded from CSS generation (issue #1274).

Return: string[] — Excluded post type slugs.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1524

publicstatic reset_excluded_post_types_memo()

public static function reset_excluded_post_types_memo(): void

Reset the request-lifetime exclusion memo (unit tests).

Return: void.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1576

publicstatic resolve_template_slug()

public static function resolve_template_slug(string $template, ?array=null $templates): string

Resolve a template slug or hash to its canonical slug (issue #1274).

ParameterTypeDefaultDescription
$templatestring—Template slug or template hash.
$templates?array=null—Optional pre-enumerated template map (reuses the caller\’s scan).

Return: string — Canonical slug, or \’\’ when unknown.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1592

publicstatic is_known_template()

public static function is_known_template(string $template, ?array=null $templates): bool

Whether a template slug or hash is a known template (issue #1274 review).

ParameterTypeDefaultDescription
$templatestring—Template slug or template hash.
$templates?array=null—Optional pre-enumerated template map (reuses the caller\’s scan).

Return: bool — True when the slug or hash resolves to a template.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1628

publicstatic is_post_type_excluded()

public static function is_post_type_excluded(string $post_type): bool

Whether a post type is excluded from CSS generation (issue #1274).

ParameterTypeDefaultDescription
$post_typestring—Post type slug.

Return: bool — True when excluded.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1639

publicstatic is_excluded_post()

public static function is_excluded_post(int $post_id): bool

Whether a post ID belongs to an excluded builder-template type (issue #1274).

ParameterTypeDefaultDescription
$post_idint—Post ID.

Return: bool — True when the post should be skipped.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1662

publicstatic get_ccss_max_retries()

public static function get_ccss_max_retries(): int

Bounded-retry cap for generic generation failures (issue #1274).

Return: int — Retry cap, 0..5.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1691

privatestatic generation_now()

private static function generation_now(): float

Current wall-clock time in seconds with fractions.

Return: float — Now.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1707

privatestatic generation_deadline()

private static function generation_deadline(int $budget): float

Absolute deadline for a generation budget starting now.

ParameterTypeDefaultDescription
$budgetint—Budget in seconds.

Return: float — Unix timestamp (fractions) when the budget expires.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1727

privatestatic generation_expired()

private static function generation_expired(?float $deadline): bool

Whether a generation deadline has expired.

ParameterTypeDefaultDescription
$deadline?float—Absolute deadline, or null when uncapped.

Return: bool — True when the budget is exhausted.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1741

privatestatic request_timeout_for_deadline()

private static function request_timeout_for_deadline(?float $deadline, int $fallback): int

Per-request HTTP timeout bounded by the remaining budget.

ParameterTypeDefaultDescription
$deadline?float—Absolute deadline, or null for the default.
$fallbackint—Historical per-request timeout in seconds.

Return: int — Timeout in seconds, 0 when exhausted, otherwise 1..$fallback.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1764

privatestatic is_valid_template_hash()

private static function is_valid_template_hash($hash): bool

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::is_valid_template_hash}.

ParameterTypeDefaultDescription
$hashmixed—Parameter (see Ccss_Store).

Return: bool — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 1783

privatestatic resolve_generation_budget()

private static function resolve_generation_budget(?float=null $deadline): array

Resolve one generation budget + deadline pair (issue #1235 review).

ParameterTypeDefaultDescription
$deadline?float=null—Optional caller-supplied deadline.

Return: array{0:int,1:float|null} — Budget and absolute deadline.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1797

publicstatic generate_guarded()

public static function generate_guarded(string $template_hash, string $template, ?bool&=null $timed_out, bool=false $stage_only): bool

Guarded CCSS generation wrapper with a wall-clock timeout (issue #1235).

ParameterTypeDefaultDescription
$template_hashstring—Template hash to generate.
$templatestring—Template identifier for the sample URL.
$timed_out?bool&=null—Out-param: true when the run hit the timeout budget.
$stage_onlybool=false—When true (issue #1348 dry-run), the output lands on the staged sibling instead of going live.

Return: bool — True on success, false on failure or timeout.

Tags: @since 2.2.0 · @since 2.3.0 Added the $stage_only dry-run flag.

Source: includes/CSS/class-critical-css.php, line 1876

publicstatic is_viewport_variants_enabled()

public static function is_viewport_variants_enabled(): bool

Whether viewport-split CCSS variants are enabled (issue #1164).

Return: bool — True when split variants should be emitted/served.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 1975

publicstatic get_ccss_variant_file()

public static function get_ccss_variant_file(string $template_hash, string $variant): string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_variant_file}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).
$variantstring—Parameter (see Ccss_Store).

Return: string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 1998

publicstatic get_ccss_variant_content()

public static function get_ccss_variant_content(string $template_hash, string $variant): ?string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_variant_content}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).
$variantstring—Parameter (see Ccss_Store).

Return: ?string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 2011

publicstatic is_variant_stale()

public static function is_variant_stale(string $template_hash, string $variant): bool

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::is_variant_stale}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).
$variantstring—Parameter (see Ccss_Store).

Return: bool — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 2024

publicstatic invalidate_stale_variants()

public static function invalidate_stale_variants(string $template_hash): void

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::invalidate_stale_variants}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: void.

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 2035

publicstatic is_block_library_defer_exempt()

public static function is_block_library_defer_exempt(string $handle, string=\'\' $href): bool

Whether a stylesheet handle is exempt from CCSS deferral (issue #1164).

ParameterTypeDefaultDescription
$handlestring—Stylesheet handle.
$hrefstring=\'\'—Stylesheet URL (optional, substring match).

Return: bool — True when the handle must load normally.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 2053

publicstatic is_elementor_context()

public static function is_elementor_context(?int=null $post_id): bool

Whether the current request is an Elementor context (issue #1164).

ParameterTypeDefaultDescription
$post_id?int=null—Optional post ID to inspect.

Return: bool — True when Elementor handling applies.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 2091

publicstatic passes_elementor_smoke()

public static function passes_elementor_smoke(string $html, string $purged_css): bool

Elementor smoke check: purged CSS must still cover builder markers (issue #1164).

ParameterTypeDefaultDescription
$htmlstring—Page HTML.
$purged_cssstring—Purged/used CSS candidate.

Return: bool — True when it is safe to serve the purged CSS.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 2180

publicstatic get_ccss_safelist_presets()

public static function get_ccss_safelist_presets(): array

Built-in Critical CSS safelist presets (issue #1102).

Return: string[].

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 2229

publicstatic get_ccss_safelist()

public static function get_ccss_safelist(): array

User safelist of selectors always kept in Critical CSS (issue #1038).

Return: string[] — Safelisted selectors, trimmed and de-duplicated.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2274

publicstatic matches_ccss_safelist()

public static function matches_ccss_safelist(string $selector, ?array=null $safelist): bool

Whether a selector matches the Critical CSS user safelist.

ParameterTypeDefaultDescription
$selectorstring—CSS selector string (may be a group).
$safelist?array=null—Optional pre-fetched safelist; callers walking many rules pass the list in so settings are read once, not per rule.

Return: bool — True when safelisted.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2322

publicstatic get_ccss_effective_safelist()

public static function get_ccss_effective_safelist(): array

Effective Critical CSS safelist: built-in presets + user entries.

Return: string[] — Merged safelisted selectors.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 2388

publicstatic compute_css_checksum()

public static function compute_css_checksum(string $css): string

Stable content hash of CSS source (issue #1038).

ParameterTypeDefaultDescription
$cssstring—CSS content.

Return: string — SHA-256 checksum, or \’\’ for empty input.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2410

privatestatic get_source_checksum_key()

private static function get_source_checksum_key(string $template_hash): string

Multisite-aware transient key for a template\’s source checksum.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: string — Transient key.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2425

privatestatic get_source_urls_key()

private static function get_source_urls_key(string $template_hash): string

Multisite-aware transient key for a template\’s canonical source URL list.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: string — Transient key.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2441

privatestatic get_source_checksum_ttl()

private static function get_source_checksum_ttl(): int

TTL for the per-template source baseline transients.

Return: int — TTL in seconds.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2454

publicstatic store_source_urls()

public static function store_source_urls(string $template_hash, array $source_urls): void

Persist the canonical document-ordered source URL list after generation.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$source_urlsarray—Document-ordered stylesheet URLs.

Return: void.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2486

privatestatic get_stored_source_urls()

private static function get_stored_source_urls(string $template_hash): array

Read the persisted canonical source URL list.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: string[] — Persisted URLs, or array() when none.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2517

publicstatic is_source_checksum_stale()

public static function is_source_checksum_stale(string $template_hash, string $source_css): bool

Whether stored source checksum differs (stale CCSS, issue #1038).

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$source_cssstring—Locally-available source CSS content.

Return: bool — True when the source changed since generation.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2548

publicstatic store_source_checksum()

public static function store_source_checksum(string $template_hash, string $source_css): void

Persist the source checksum after a successful generation.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$source_cssstring—Source CSS content that was generated from.

Return: void.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2574

publicstatic maybe_refresh_from_local_css()

public static function maybe_refresh_from_local_css(string $template_hash, string $source_css): bool

Checksum-triggered refresh from locally-available CSS (issue #1038).

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$source_cssstring—Locally-available source CSS content.

Return: bool — True when the stored variant was dropped as stale.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2602

privatestatic build_local_source_css()

private static function build_local_source_css(array $urls, ?float=null $deadline): string

Build the canonical local-source CSS string from ordered URLs.

ParameterTypeDefaultDescription
$urlsarray—Ordered stylesheet URLs (document/queue order).
$deadline?float=null—Optional absolute wall-clock deadline; the file loop breaks early when expired (issue #1235 review).

Return: string — Concatenated source CSS, or \’\’ when none resolve locally.

Tags: @since 2.0.0 · @since 2.2.0 Optional deadline-aware early break.

Source: includes/CSS/class-critical-css.php, line 2680

privatestatic is_skipped_source_url()

private static function is_skipped_source_url(string $url): bool

Whether a stylesheet URL is excluded from the CCSS source set.

ParameterTypeDefaultDescription
$urlstring—Stylesheet URL or handle-like fragment.

Return: bool — True when skipped.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2733

privatestatic get_core_inlined_handles()

private static function get_core_inlined_handles(): array

Handles core\’s `wp_maybe_inline_styles()` will print inline.

Return: string[] — Handles that core will inline (queue order).

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2762

privatestatic get_local_source_css()

private static function get_local_source_css(): string

Aggregate locally-available source CSS from the queued stylesheets.

Return: string — Concatenated local source CSS, or \’\’ when unavailable.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2830

publicstatic maybe_check_stale_on_enqueue()

public static function maybe_check_stale_on_enqueue(): void

Checksum freshness probe wired into the production path (issue #1038).

Return: void.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 2885

publicstatic maybe_check_stale_and_requeue()

public static function maybe_check_stale_and_requeue(string $template_hash): bool

Checksum freshness probe (issue #1038).

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: bool — True when the stored variant was dropped as stale.

Tags: @since 2.0.0 · @since 2.3.0 Also activates via `ccssChecksumRegen` (issue #1388).

Source: includes/CSS/class-critical-css.php, line 2936

publicstatic maybe_regen_on_save()

public static function maybe_regen_on_save($post_id, =null $post): bool

Checksum-gated CCSS regen on post save (issue #1388).

ParameterTypeDefaultDescription
$post_idint—Post ID.
$post=null—Post object or null.

Return: bool — True when at least one stale template was requeued.

Tags: @since 2.3.0 · @see Critical_CSS::maybe_refresh_from_local_css() · @see Critical_CSS::regenerate_single()

Source: includes/CSS/class-critical-css.php, line 3016

privatestatic get_styles_inline_limit()

private static function get_styles_inline_limit(): int

Read core\’s `styles_inline_size_limit` budget.

Return: int — The inline size limit in bytes.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 3101

privatestatic is_inline_allowed()

private static function is_inline_allowed(): bool

Whether CCSS may be inlined on this request.

Return: bool — True when inlining is allowed.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 3116

publicstatic is_deferral_suspended_by_js()

public static function is_deferral_suspended_by_js(): bool

Whether stylesheet deferral is suspended by deferred/delayed JS.

Return: bool — True when deferJS or delayJS is enabled.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 3135

publicstatic is_ccss_effective()

public static function is_ccss_effective(): bool

Whether critical CSS is effective on this request.

Return: bool — True when CCSS emission and deferral should run.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 3152

privatestatic loadcss_loader_tag()

private static function loadcss_loader_tag(): string

Async loadCSS fallback snippet as a script tag (audit #1392).

Return: string — Inline loader script tag.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 3166

privatestatic has_strict_csp()

private static function has_strict_csp(): bool

Whether a strict Content-Security-Policy blocks raw inline scripts.

Return: bool — True when inline scripts would be blocked.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 3183

privatestatic get_ccss_file_url()

private static function get_ccss_file_url(string $template_hash): string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_file_url}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3223

publicstatic get_ccss_meta()

public static function get_ccss_meta(string $template_hash): array

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_meta}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: array — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3235

publicstatic reset_ccss_memo()

public static function reset_ccss_memo(): void

Reset the per-request CCSS memos (facade, FUT-001).

Return: void.

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3249

privatestatic invalidate_ccss_memo()

private static function invalidate_ccss_memo(string $template_hash): void

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::invalidate_ccss_memo}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: void.

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3268

publicstatic ccss_exists()

public static function ccss_exists(string $template_hash): bool

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::ccss_exists}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: bool — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3280

privatestatic get_ccss_content()

private static function get_ccss_content(string $template_hash): ?string

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_ccss_content}.

ParameterTypeDefaultDescription
$template_hashstring—Parameter (see Ccss_Store).

Return: ?string — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3292

publicstatic get_status_all()

public static function get_status_all(): array

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_status_all}.

Return: array — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3303

privatestatic get_templates()

private static function get_templates(): array

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_templates}.

Return: array — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3314

privatestatic get_sample_url()

private static function get_sample_url(string $template): string|false

Facade proxy (FUT-001): canonical owner is {@see \\PerformanceOptimise\\Inc\\Ccss_Store::get_sample_url}.

ParameterTypeDefaultDescription
$templatestring—Parameter (see Ccss_Store).

Return: string|false — Result (see Ccss_Store).

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 3326

publicstatic get_field_lcp_preload_url()

public static function get_field_lcp_preload_url(?string=null $url): string

Field-measured LCP image preload target for a page URL (issue #1255).

ParameterTypeDefaultDescription
$url?string=null—Page URL. Null resolves the current request path. Only the path is used.

Return: string — Same-origin LCP image URL, or \’\’ when none resolves.

Tags: @since 2.2.0 · @see RUM::get_lcp_preload_candidate() · @see RUM::get_field_lcp_url()

Source: includes/CSS/class-critical-css.php, line 3360

privatestatic is_image_preload_url()

private static function is_image_preload_url(string $url): bool

Whether a candidate URL is a plausible LCP image (text-LCP guard).

ParameterTypeDefaultDescription
$urlstring—The candidate URL.

Return: bool — True when the URL may be preloaded as an image.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 3447

privatestatic is_image_pipeline_lcp_preload_active()

private static function is_image_pipeline_lcp_preload_active(): bool

Whether the image pipeline owns LCP preloading on this request.

Return: bool — True when the image pipeline will preload the LCP hero.

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 3497

privatestatic is_ccss_field_lcp_preload_allowed()

private static function is_ccss_field_lcp_preload_allowed(): bool

Whether the CCSS-path field-LCP preload may fire on this request.

Return: bool — True when the CCSS-path preload may emit.

Tags: @since 2.2.0 · @see Critical_CSS::maybe_emit_field_lcp_preload()

Source: includes/CSS/class-critical-css.php, line 3536

privatestatic maybe_emit_field_lcp_preload()

private static function maybe_emit_field_lcp_preload(): void

Emit the field-measured LCP image preload for the current page.

Return: void.

Tags: @since 2.2.0 · @see Critical_CSS::get_field_lcp_preload_url() · @see Critical_CSS::is_ccss_field_lcp_preload_allowed()

Source: includes/CSS/class-critical-css.php, line 3576

privatestatic extract_css_sources_with_processor()

private static function extract_css_sources_with_processor(string $html, ?float $deadline): ?array

Extract inline `<style>` bodies and stylesheet hrefs via the HTML API.

ParameterTypeDefaultDescription
$htmlstring—Page HTML (already byte-capped by the caller).
$deadline?float—Absolute deadline, or null when uncapped.

Return: array{inline_css: — string, source_urls: string[]}|null Inline CSS plus document-ordered hrefs, or null to take the DOM path.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 3679

publicstatic generate()

public static function generate(string $url, ?string&=null $source_css, ?array&=null $resolved_urls, ?float=null $deadline)

Generate critical CSS for a given URL.

ParameterTypeDefaultDescription
$urlstring—The page URL to generate CCSS for.
$source_css?string&=null—Out-param: canonical local-source CSS (locally-resolvable external stylesheets, document order) used for the freshness checksum (issue #1038).
$resolved_urls?array&=null—Out-param: the exact document-ordered `//link[@rel=stylesheet]` href list the fetch saw, persisted so the runtime probe re-hashes the same list (audit #9). Pass a non-null array to receive it; null opts out and receives nothing.
$deadline?float=null—Optional absolute wall-clock deadline (see generation_deadline()). Trusted callers only: external deadlines clamp to now + MAX_CCSS_GEN_TIMEOUT so a caller can never smuggle an unbounded budget. When null a fresh get_ccss_gen_timeout() budget applies; expired runs abort fail-open (issue #1235).

Return: string|false — The critical CSS content, or false on failure.

Tags: @since 2.0.0 · @since 2.2.0 Time-boxed by the generation budget with fail-open abort.

Source: includes/CSS/class-critical-css.php, line 3837

privatestatic fetch_stylesheet_with_imports()

private static function fetch_stylesheet_with_imports(string $url, int=0 $depth, ?float=null $deadline, array&=array() $seen, int&=0 $fetches): string

Fetch a stylesheet and recursively resolve @import directives.

ParameterTypeDefaultDescription
$urlstring—The stylesheet URL.
$depthint=0—Current recursion depth.
$deadline?float=null—Optional absolute wall-clock deadline.
$seenarray&=array()—By-ref case-insensitive visited-URL set shared across the whole generation run (cycle dedupe).
$fetchesint&=0—By-ref total-fetch counter shared across the whole run, bounded by MAX_CCSS_FETCHES.

Return: string — The combined CSS content with @imports inlined, or empty string on failure or expiry.

Tags: @since 2.0.0 · @since 2.2.0 Budget-clamped request timeouts with fail-open abort.

Source: includes/CSS/class-critical-css.php, line 4123

privatestatic resolve_import_url()

private static function resolve_import_url(string $import_url, string $base_url): string

Resolve a potentially relative @import URL against a base stylesheet URL.

ParameterTypeDefaultDescription
$import_urlstring—The URL from the @import statement.
$base_urlstring—The base stylesheet URL.

Return: string — The absolute resolved URL, or empty string if unresolvable.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4227

privatestatic is_same_site_host()

private static function is_same_site_host(string $url): bool

Whether the URL points at this WordPress site\’s own host.

ParameterTypeDefaultDescription
$urlstring—The URL to inspect.

Return: bool — True when the URL host matches home_url().

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4273

privatestatic is_safe_stylesheet_url()

private static function is_safe_stylesheet_url(string $url): bool

Whether a stylesheet URL is safe to request server-side.

ParameterTypeDefaultDescription
$urlstring—The stylesheet URL.

Return: bool — True when safe to fetch.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4296

privatestatic decode_css_entities()

private static function decode_css_entities(string $css): string

Decode numeric/hex HTML entities so encoded payloads cannot smuggle `<` past the encoder (e.g.

ParameterTypeDefaultDescription
$cssstring—Raw critical CSS.

Return: string — Entity-decoded CSS.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4341

privatestatic contains_unsafe_css_tokens()

private static function contains_unsafe_css_tokens(string $css): bool

Whether decoded CSS contains tokens that could break out of a `<style>` element or execute script when inlined.

ParameterTypeDefaultDescription
$cssstring—Raw critical CSS.

Return: bool — True when hostile tokens are present.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4366

privatestatic sanitize_inline_css_tokens()

private static function sanitize_inline_css_tokens(string $css): string

Sanitize generated critical CSS for safe output inside a <style> tag.

ParameterTypeDefaultDescription
$cssstring—Raw critical CSS.

Return: string — Sanitized critical CSS.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4394

privatestatic sanitize_inline_css()

private static function sanitize_inline_css(string $css): string

Sanitize generated critical CSS for safe output inside a <style> tag.

ParameterTypeDefaultDescription
$cssstring—Raw critical CSS.

Return: string — Sanitized critical CSS.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4492

privatestatic extract_above_fold_css()

private static function extract_above_fold_css(string $css, ?float=null $deadline): string

Extract above-fold CSS rules using heuristic selector matching.

ParameterTypeDefaultDescription
$cssstring—Full CSS content.
$deadline?float=null—Optional absolute wall-clock deadline; the scan stops early when it expires (issue #1235).

Return: string — Extracted critical CSS.

Tags: @since 2.0.0 · @since 2.2.0 Deadline-aware early stop for the CPU-bound scan.

Source: includes/CSS/class-critical-css.php, line 4548

privatestatic parse_regular_rules()

private static function parse_regular_rules(string $css, array& $critical_parts, ?array=null $safelist, ?float=null $deadline): void

Parse regular (non-at-rule) CSS rules using brace-depth tracking.

ParameterTypeDefaultDescription
$cssstring—Full CSS content.
$critical_partsarray&—Reference to array of extracted critical CSS parts.
$safelist?array=null—Pre-fetched safelist (null = fetch once here).
$deadline?float=null—Optional absolute wall-clock deadline; the scan stops early when it expires (issue #1235).

Return: void.

Tags: @since 2.0.0 · @since 2.2.0 Deadline-aware early stop for the CPU-bound scan.

Source: includes/CSS/class-critical-css.php, line 4647

privatestatic filter_media_query_rules()

private static function filter_media_query_rules(string $media_query, ?array=null $safelist, ?float=null $deadline): string

Filter rules inside a media query to keep only above-fold selectors.

ParameterTypeDefaultDescription
$media_querystring—Full media query block.
$safelist?array=null—Pre-fetched safelist (null = fetch once here).
$deadline?float=null—Optional absolute wall-clock deadline; the per-rule loop aborts early when expired (issue #1235).

Return: string — Filtered media query or empty string.

Tags: @since 2.0.0 · @since 2.2.0 Deadline-aware early stop inside the per-rule loop.

Source: includes/CSS/class-critical-css.php, line 4721

privatestatic matches_above_fold()

private static function matches_above_fold(string $selector, ?array=null $safelist): bool

Check if a CSS selector matches above-fold selectors.

ParameterTypeDefaultDescription
$selectorstring—The CSS selector string (may contain multiple selectors separated by commas).
$safelist?array=null—Pre-fetched safelist (null = fetch once here).

Return: bool — True if any individual selector should be included in critical CSS.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4770

privatestatic matches_above_fold_single()

private static function matches_above_fold_single(string $selector, ?array=null $safelist): bool

Check if a single CSS selector matches above-fold selectors using token-based matching.

ParameterTypeDefaultDescription
$selectorstring—A single trimmed CSS selector.
$safelist?array=null—Pre-fetched safelist (null = fetch once here).

Return: bool — True if the selector matches.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4812

privatestatic get_above_fold_matcher()

private static function get_above_fold_matcher(): array

Build the precompiled above-fold matcher (exact hash sets + one alternation).

Return: array{exact: — array<string, bool>, regex: string}.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4892

privatestatic token_match()

private static function token_match(string $selector_part, string $above): bool

Token-based selector matching that prevents substring false positives.

ParameterTypeDefaultDescription
$selector_partstring—A single selector fragment (e.g., \’.container\’, \’#header\’, \’h1\’).
$abovestring—The above-fold selector pattern to match against.

Return: bool — True if the selector part matches the pattern.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4922

privatestatic token_match_precompiled()

private static function token_match_precompiled(string $selector_part): bool

Fast token match using the precompiled above-fold matcher.

ParameterTypeDefaultDescription
$selector_partstring—Single selector fragment (last descendant part).

Return: bool — True on match.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 4943

privatestatic generate_and_store()

private static function generate_and_store(string $template_hash, string $template, ?float=null $deadline, ?int=null $budget, bool=false $stage_only): bool

Generate critical CSS for a template and store it atomically.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$templatestring—Template identifier for the sample URL.
$deadline?float=null—Optional absolute wall-clock deadline.
$budget?int=null—Optional already-resolved budget for logging (avoids a second settings read).
$stage_onlybool=false—When true (issue #1348 dry-run), commit to the staged sibling: no variant mirrors, no source-checksum baselining, live file untouched.

Return: bool — True on success, false on failure or timeout.

Tags: @since 2.0.0 · @since 2.2.0 Time-boxed generation with fail-open timeout handling. · @since 2.3.0 Added the $stage_only dry-run flag.

Source: includes/CSS/class-critical-css.php, line 4991

publicstatic inline_ccss()

public static function inline_ccss(): void

Inline critical CSS in the <head> for non-logged-in visitors.

Return: void.

Tags: @since 2.0.0 · @since 2.2.0 Over-cap output without a file URL defers to the full stylesheet (and blocks deferral for the request). · @since 2.3.0 Commerce exclusion plus gzipped-budget used-CSS fallback (issue #1388). · @since 2.2.0 Field-measured LCP image is preloaded alongside served CCSS.

Source: includes/CSS/class-critical-css.php, line 5275

publicstatic defer_stylesheets()

public static function defer_stylesheets(string $tag, string $handle, string $href): string

Defer full stylesheets by adding media=\”print\” onload=\”this.media=\’all\’\”.

ParameterTypeDefaultDescription
$tagstring—The link tag HTML.
$handlestring—The stylesheet handle.
$hrefstring—The stylesheet URL.

Return: string — Modified link tag.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 5507

privatestatic purge_template_artifacts()

private static function purge_template_artifacts(string $template_hash): void

Purge every stored artifact for a template hash (issue #1347).

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: void.

Tags: @since 2.3.0

Source: includes/CSS/class-critical-css.php, line 5635

publicstatic background_generate()

public static function background_generate(array $args): void

Background generation callback for Action Scheduler.

ParameterTypeDefaultDescription
$argsarray—Arguments containing \’template_hash\’.

Return: void.

Tags: @since 2.0.0 · @since 2.2.0 Routed through the guarded generation wrapper. · @since 2.3.0 HMAC-mismatch path stamps short-lived \’rejected\’ instead of day-long \’failed\’; unsigned jobs logged throttled at WP_DEBUG level.

Source: includes/CSS/class-critical-css.php, line 5720

publicstatic order_templates_by_rum_priority()

public static function order_templates_by_rum_priority(array $templates): array

Order templates worst-p75 LCP first for CCSS queue prioritization.

ParameterTypeDefaultDescription
$templatesarray——

Return: array<string, — string> Ordered templates (same entries).

Tags: @since 2.0.0 · @since 2.3.0 Blends the template-segment LCP weight (issue #1388).

Source: includes/CSS/class-critical-css.php, line 5878

publicstatic regenerate_all()

public static function regenerate_all(bool=false $force): int

Regenerate all template CCSS files via Action Scheduler.

ParameterTypeDefaultDescription
$forcebool=false—Bypass the cooldown (explicit operator paths: builder purge after a wipe, manual triggers).

Return: int — Number of jobs queued.

Tags: @since 2.0.0 · @since 2.2.0 Capped per-run queue with RUM-worst-first ordering. · @since 2.3.0 Added $force parameter and 18000s full-regen cooldown.

Source: includes/CSS/class-critical-css.php, line 6015

publicstatic regenerate_single()

public static function regenerate_single(string $template, ?array=null $templates): int

Regenerate critical CSS for a single template (issue #1274).

ParameterTypeDefaultDescription
$templatestring—Template slug or template hash.
$templates?array=null—Optional pre-enumerated template map (reuses the caller\’s scan).

Return: int — 1 when queued, 0 for legit skip/unknown, -1 when the scheduler is unavailable (infra failure, not a benign skip).

Tags: @since 2.2.0

Source: includes/CSS/class-critical-css.php, line 6114

publicstatic clear_all()

public static function clear_all(?array=null $templates): void

Clear all CCSS files and status transients.

ParameterTypeDefaultDescription
$templates?array=null——

Return: void.

Tags: @since 2.0.0

Source: includes/CSS/class-critical-css.php, line 6192

publicstatic get_status_cache_for_store()

public static function get_status_cache_for_store(string $hash)

Read the generation-status cache through the canonical owner.

ParameterTypeDefaultDescription
$hashstring—Template hash.

Return: string|false — Status string, or false when unset.

Tags: @since 2.4.0

Source: includes/CSS/class-critical-css.php, line 6247

Hooks

Hooks referenced in includes/CSS/class-critical-css.php:

HookTypeLineNotes
wppo_ccss_regen_cooldownfilter699—
wppo_ccss_inline_budgetfilter736—
wppo_ccss_targeted_cooldownfilter824@param ×1
wppo_committed_inline_bytesfilter910—
wppo_ccss_queue_capfilter1395—
wppo_ccss_generation_timeoutfilter1452—
wppo_ccss_excluded_post_typesfilter1543—
wppo_is_elementor_pagefilter2128—
wppo_ccss_safelist_presetsfilter2253@param ×1
wppo_ccss_safelistfilter2289@param ×1
wppo_ccss_checksum_ttlfilter2462@param ×1
wppo_inline_combined_cssfilter3120—
wppo_critical_css_strict_cspfilter3196@param ×1
wppo_ccss_field_lcp_preloadfilter3539—
wppo_ccss_allowed_stylesheet_hostfilter4315@param ×2
wppo_ccss_sanitize_inlinefilter4515@param ×1