class-css-combine.php

CSS combine service — fetch, minify, write, journal, preload, inline-budget, fallback.

Source includes/Assets/class-css-combine.php9 min readPart of Performance Optimisation

includes/Assets/class-css-combine.php

CSS combine service — fetch, minify, write, journal, preload, inline-budget, fallback.

Namespace: PerformanceOptimise\\Inc · Lines: 1554

Class Css_Combine

Class Css_Combine

Source: includes/Assets/class-css-combine.php, line 79

final class Css_Combine

Tags: @since 2.4.0

Constants

ConstantVisibilityValueLine
SRC_STAT_CACHE_LIMITprivate500111

Properties

PropertyVisibilityTypeDefaultLine
$cacheprivateCache—91

public __construct()

public function __construct(Cache $cache)

Constructor.

ParameterTypeDefaultDescription
$cacheCache—Cache instance (memo + settings + policy owner).

Tags: @since 2.4.0

Source: includes/Assets/class-css-combine.php, line 99

public get_sandbox_effective_file_opt()

public function get_sandbox_effective_file_opt(array $file_opt): array

Sandbox-effective `file_optimisation` slice (issue #1259).

ParameterTypeDefaultDescription
$file_optarray—Production `file_optimisation` slice.

Return: array — Effective slice (staged values merged in preview). Relocated from Cache::get_sandbox_effective_file_opt() (ARCH-006).

Tags: @since 2.2.0

Source: includes/Assets/class-css-combine.php, line 129

public should_bypass_combine_for_elementor()

public function should_bypass_combine_for_elementor(array $file_opt, ?bool=null $looks_like): bool

Whether CSS combine/inline must be skipped for Elementor-safe mode (issue #1259).

ParameterTypeDefaultDescription
$file_optarray—Sandbox-effective `file_optimisation` slice.
$looks_like?bool=null—Pre-computed Main::looks_like_elementor_request() verdict (null to compute here). Threaded through so will_combine_css_inline() evaluates the pre-gate once instead of twice per request.

Return: bool — True when combine/inline must be skipped. Relocated from Cache::should_bypass_combine_for_elementor() (ARCH-006).

Tags: @since 2.2.0

Source: includes/Assets/class-css-combine.php, line 172

public combine_css()

public function combine_css()

Combines all enqueued CSS files into a single file.

Return: void.

Tags: @since 1.0.0 Relocated from Cache::combine_css() (ARCH-006).

Source: includes/Assets/class-css-combine.php, line 210

public resolve_eligible_handles()

public function resolve_eligible_handles(array $styles, array $exclusions): array

Resolve the handles eligible for CSS combining.

ParameterTypeDefaultDescription
$stylesarray—Queued handles.
$exclusionsarray—Excluded handles/patterns.

Return: array — Eligible handles. Relocated from Cache::resolve_eligible_handles() (ARCH-006).

Tags: @since 2.2.0

Source: includes/Assets/class-css-combine.php, line 440

public fetch_and_minify_css()

public function fetch_and_minify_css(array $eligible_handles): array

Fetch, concatenate and minify eligible stylesheets.

ParameterTypeDefaultDescription
$eligible_handlesarray—Eligible handles.

Return: array{css:string,handles:array,error:string} — Combined CSS + successful handles + error stage (\’\’ on success). Relocated from Cache::fetch_and_minify_css() (ARCH-006).

Tags: @since 2.2.0

Source: includes/Assets/class-css-combine.php, line 455

public write_combined_file()

public function write_combined_file(string $combined_css, string $css_variant): array

Write the combined CSS file to the cache directory.

ParameterTypeDefaultDescription
$combined_cssstring—Combined CSS.
$css_variantstring—Cache variant suffix.

Return: array{path:string,error:string} — File path (\’\’ on failure) + error stage. Relocated from Cache::write_combined_file() (ARCH-006).

Tags: @since 2.2.0

Source: includes/Assets/class-css-combine.php, line 535

public emit_combined_preload_hint()

public function emit_combined_preload_hint($css_url, $version, string $css_file_path): void

Emit the preload hint for the combined stylesheet.

ParameterTypeDefaultDescription
$css_urlstring—URL of the combined stylesheet.
$versionint|string—Cache-busting version suffix.
$css_file_pathstring—Absolute path to the combined CSS file.

Return: void — Relocated from Cache::emit_combined_preload_hint() (ARCH-006).

Tags: @since 2.2.0

Source: includes/Assets/class-css-combine.php, line 569

public set_combine_css_preload()

public function set_combine_css_preload($css_url, $version, $css_file_path): void

Record the combined-CSS preload URL for emission on `wp_head`.

ParameterTypeDefaultDescription
$css_urlstring—URL of the combined stylesheet.
$versionint|string—Cache-busting version suffix.
$css_file_pathstring—Absolute path to the combined CSS file.

Return: void.

Tags: @since 2.0.0 Relocated from Cache::set_combine_css_preload() (ARCH-006).

Source: includes/Assets/class-css-combine.php, line 589

public maybe_preload_combine_css()

public function maybe_preload_combine_css(): void

Emit the combined-CSS `rel=\”preload\”` resource hint on `wp_head`.

Return: void.

Tags: @since 2.0.0 Relocated from Cache::maybe_preload_combine_css() (ARCH-006).

Source: includes/Assets/class-css-combine.php, line 609

public is_excluded_from_combine()

public function is_excluded_from_combine($handle, $src, array $exclude_combine_css): bool

Whether a handle should be excluded from CSS combining.

ParameterTypeDefaultDescription
$handlestring—Handle to check.
$srcstring—Style src URL.
$exclude_combine_cssarray—Exclusion list.

Return: bool — True if excluded. Relocated from Cache::is_excluded_from_combine() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 651

public get_combined_handles()

public function get_combined_handles($styles, $exclude_combine_css): array

Computes the set of handles that belong in the combined CSS file.

ParameterTypeDefaultDescription
$stylesarray—The enqueued style handles.
$exclude_combine_cssarray—Handles/URL fragments excluded from combining.

Return: array — The handles that would be combined. Relocated from Cache::get_combined_handles() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 715

public combined_handles_match()

public function combined_handles_match($css_file_path, array $eligible_handles): bool

Whether a cached combined file was generated from the same handle set.

ParameterTypeDefaultDescription
$css_file_pathstring—Absolute path to the combined CSS file.
$eligible_handlesarray—The handles expected in the combined file.

Return: bool — True if the cached file matches the current handle set. Relocated from Cache::combined_handles_match() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 761

public write_combined_handles()

public function write_combined_handles($css_file_path, array $eligible_handles): void

Persists the set of combined handles next to the combined CSS file.

ParameterTypeDefaultDescription
$css_file_pathstring—Absolute path to the combined CSS file.
$eligible_handlesarray—The handles combined into the file.

Return: void — Relocated from Cache::write_combined_handles() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 788

public core_will_inline()

public function core_will_inline($handle): bool

Whether a queued style will be inlined by core instead of combined.

ParameterTypeDefaultDescription
$handlestring—The registered style handle.

Return: bool — True if core will inline the style, false otherwise. Relocated from Cache::core_will_inline() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 818

public core_inline_budget_will_inline()

public function core_inline_budget_will_inline($handle, $limit, $core_faithful): bool

Simulates core\’s greedy smallest-first inline-CSS budget for a handle.

ParameterTypeDefaultDescription
$handlestring—The registered style handle.
$limitint—The inline size limit in bytes.
$core_faithfulbool—Whether to mirror core\’s candidate collection.

Return: bool — True if core\’s budget pass would inline the style. Relocated from Cache::core_inline_budget_will_inline() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 898

public log_inline_budget_drift()

public function log_inline_budget_drift($handle, $limit): void

Logs that the inline-CSS budget prediction drifted from core.

ParameterTypeDefaultDescription
$handlestring—The handle whose prediction drifted.
$limitint—The inline size limit in bytes.

Return: void — Relocated from Cache::log_inline_budget_drift() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 998

public is_safe_css_combine_fallback_enabled()

public function is_safe_css_combine_fallback_enabled(): bool

Whether the safe CSS combine fallback is enabled.

Return: bool — True when fallback guards are active. Relocated from Cache::is_safe_css_combine_fallback_enabled() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1041

public is_combined_css_valid()

public function is_combined_css_valid(string $path): bool

Whether a combined CSS file is valid (exists, readable, non-empty).

ParameterTypeDefaultDescription
$pathstring—Absolute path to the combined CSS file.

Return: bool — True when the file is usable. Relocated from Cache::is_combined_css_valid() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1053

public log_combine_fallback()

public function log_combine_fallback(string $reason, array $handles): void

Log a combine fallback (fail-open) event with throttling.

ParameterTypeDefaultDescription
$reasonstring—Machine-readable reason (empty_payload, fetch_failure, write_failure, head_match_failure).
$handlesarray—Handles preserved by the fallback.

Return: void — Relocated from Cache::log_combine_fallback() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1070

public register_combine_css_path()

public function register_combine_css_path($css_file_path): void

Registers the combined CSS file with `path` data for core\’s inline pass.

ParameterTypeDefaultDescription
$css_file_pathstring—Absolute path to the combined CSS file.

Return: void — Relocated from Cache::register_combine_css_path() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 1083

public should_bypass_inline_for_safe_mode()

public function should_bypass_inline_for_safe_mode(array $file_opt): bool

Whether the combined CSS inline must be skipped for safe mode (issue #1465).

ParameterTypeDefaultDescription
$file_optarray—Production `file_optimisation` slice.

Return: bool — True when inlining must be skipped. Relocated from Cache::should_bypass_inline_for_safe_mode() (ARCH-006).

Tags: @since 2.3.0

Source: includes/Assets/class-css-combine.php, line 1135

public will_combine_css_inline()

public function will_combine_css_inline($css_file_path): bool

Whether the combined CSS file will be inlined by core.

ParameterTypeDefaultDescription
$css_file_pathstring—Absolute path to the combined CSS file.

Return: bool — True if core will inline the combined file, false otherwise. Relocated from Cache::will_combine_css_inline() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 1175

public get_styles_inline_limit()

public function get_styles_inline_limit(): int

Reads the core `styles_inline_size_limit` budget.

Return: int — The inline size limit in bytes. Relocated from Cache::get_styles_inline_limit() (ARCH-006).

Tags: @since 1.9.0

Source: includes/Assets/class-css-combine.php, line 1236

public inline_candidates_require_src()

public function inline_candidates_require_src(): bool

Whether inline candidates must carry a `src` on this core version.

Return: bool — True when inline candidates must carry a `src`. Relocated from Cache::inline_candidates_require_src() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1253

public inline_candidates_require_readable()

public function inline_candidates_require_readable(): bool

Whether inline candidates must be readable on this core version.

Return: bool — True when the core-faithful pass must skip unreadable styles. Relocated from Cache::inline_candidates_require_readable() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1274

public get_cached_src_stat()

public function get_cached_src_stat(string $path): array

Retrieve cached src file stat (readable + filesize) with per-request LRU.

ParameterTypeDefaultDescription
$pathstring—Absolute filesystem path.

Return: array{readable:bool,size:int|false} — Relocated from Cache::get_cached_src_stat() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1292

public should_skip_combine_for_inline_budget()

public function should_skip_combine_for_inline_budget(array $eligible_handles): bool

Whether the combined-CSS file should be skipped on small block-theme bundles.

ParameterTypeDefaultDescription
$eligible_handlesarray—Handles that would be combined.

Return: bool — True when combining should be skipped. Relocated from Cache::should_skip_combine_for_inline_budget() (ARCH-006).

Tags: @since 2.0.0

Source: includes/Assets/class-css-combine.php, line 1361

public measure_style_byte_size()

public function measure_style_byte_size($handle)

Measure a style\’s byte size using core\’s inline-budget accounting.

ParameterTypeDefaultDescription
$handlestring—The registered style handle.

Return: int|false — Byte size, 0 when the handle contributes nothing, false when unmeasurable.

Tags: @since 2.2.0 Relocated from Cache::measure_style_byte_size() (ARCH-006).

Source: includes/Assets/class-css-combine.php, line 1452

public fetch_remote_css()

public function fetch_remote_css($url)

Fetches CSS content from a remote URL or local path.

ParameterTypeDefaultDescription
$urlstring—The URL of the CSS file.

Return: string|false — The CSS content or false if fetching fails.

Tags: @since 1.0.0 Relocated from Cache::fetch_remote_css() (ARCH-006).

Source: includes/Assets/class-css-combine.php, line 1506

Hooks

Hooks referenced in includes/Assets/class-css-combine.php:

HookTypeLineNotes
wppo_combine_preload_fetchpriorityfilter627@param ×2
wppo_exclude_randomized_from_combinefilter672—
wppo_inline_combined_cssfilter1101—
wppo_inline_combined_cssfilter1388—
wppo_skip_combine_on_small_block_themefilter1410@param ×3
wppo_max_css_bytesfilter1532—