class-ccss-generator.php

Critical CSS generation lifecycle policy.

Source includes/CSS/class-ccss-generator.php4 min readPart of Performance Optimisation

includes/CSS/class-ccss-generator.php

Critical CSS generation lifecycle policy.

Namespace: PerformanceOptimise\\Inc · Lines: 593

Class Ccss_Generator

Critical CSS generation lifecycle policy.

Source: includes/CSS/class-ccss-generator.php, line 31

final class Ccss_Generator

Tags: @since NEXT

Constants

ConstantVisibilityValueLine
SALT_KEYprivate\'wppo_ccss_salt\'37
CCSS_AS_GROUPprivate\'wppo-ccss\'44
DEFAULT_CCSS_MAX_RETRIESprivate551
MAX_CCSS_MAX_RETRIESprivate558
MAX_CCSS_TIMEOUT_ATTEMPTSprivate565

Properties

PropertyVisibilityTypeDefaultLine
$pending_memoprivate staticarrayarray()72

publicstatic get_ccss_max_retries()

public static function get_ccss_max_retries(): int

Read the bounded generic retry cap.

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

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 80

publicstatic get_generation_attempts()

public static function get_generation_attempts(string $template_hash): int

Read consecutive generic failures for a template.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: int — Failure count.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 106

publicstatic clear_generation_attempts()

public static function clear_generation_attempts(string $template_hash): void

Clear consecutive generic failures.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 126

publicstatic get_timeout_attempts()

public static function get_timeout_attempts(string $template_hash): int

Read consecutive timeout failures.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: int — Timeout count.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 143

publicstatic clear_timeout_attempts()

public static function clear_timeout_attempts(string $template_hash): void

Clear consecutive timeout failures and their first-seen stamp.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 163

publicstatic clear_retry_state()

public static function clear_retry_state(string $template_hash): void

Clear all bounded retry state for a template.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 181

publicstatic get_status_cache()

public static function get_status_cache(string $hash)

Read a generation status from salted cache or transient fallback.

ParameterTypeDefaultDescription
$hashstring—Template hash.

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

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 201

publicstatic set_status_cache()

public static function set_status_cache(string $hash, string $status, int $ttl): void

Store a generation status in salted cache and transient fallback.

ParameterTypeDefaultDescription
$hashstring—Template hash.
$statusstring—Status value.
$ttlint—Time to live in seconds.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 219

publicstatic has_pending_job()

public static function has_pending_job(string $hook, array $hook_args): bool

Whether a generation job is pending or running in either AS group.

ParameterTypeDefaultDescription
$hookstring—Action hook.
$hook_argsarray—Action arguments.

Return: bool — True when a matching action is live.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 236

publicstatic schedule_job()

public static function schedule_job(string $hook, array $hook_args, int $timestamp): array

Atomically enqueue one generation job with the historic group matrix.

ParameterTypeDefaultDescription
$hookstring—Action hook.
$hook_argsarray—Wrapped action arguments.
$timestampint—When the job should run.

Return: array{id:int,pending:bool} — Enqueue result.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 302

publicstatic schedule_retry()

public static function schedule_retry(string $template_hash, ?int=null $attempts): array

Schedule a bounded exponential retry.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$attempts?int=null—Optional generic attempt count.

Return: array{id:int,pending:bool} — Enqueue result.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 378

publicstatic record_generation_failure()

public static function record_generation_failure(string $template_hash, int $budget, ?float $deadline): void

Record an ordinary generation failure and schedule a retry.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$budgetint—Generation budget in seconds.
$deadline?float—Absolute deadline, if bounded.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 423

publicstatic handle_timeout()

public static function handle_timeout(string $template_hash, int $budget): void

Record a generation timeout and schedule bounded retry/escalation.

ParameterTypeDefaultDescription
$template_hashstring—Template hash.
$budgetint—Generation budget in seconds.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 474

publicstatic generation_expired()

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

Whether an absolute generation deadline has expired.

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

Return: bool — True when expired.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 548

publicstatic bump_status_salt()

public static function bump_status_salt(): void

Bump the status-cache salt so all salted statuses are invalidated.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 562

publicstatic reset_pending_memo()

public static function reset_pending_memo(): void

Reset the per-request pending-job memo.

Return: void.

Tags: @since NEXT

Source: includes/CSS/class-ccss-generator.php, line 574

privatestatic memoize_pending()

private static function memoize_pending(string $hook, array $hook_args): void

Memoize a confirmed pending action key.

ParameterTypeDefaultDescription
$hookstring—Action hook.
$hook_argsarray—Action arguments.

Return: void.

Source: includes/CSS/class-ccss-generator.php, line 585

Hooks

Hooks referenced in includes/CSS/class-ccss-generator.php:

HookTypeLineNotes
wppo_ccss_max_retriesfilter87—