includes/Assets/class-css-combine.php
CSS combine service — fetch, minify, write, journal, preload, inline-budget, fallback.
Class Css_Combine
Class Css_Combine
final class Css_CombineConstants
| Constant | Visibility | Value | Line |
|---|---|---|---|
SRC_STAT_CACHE_LIMIT | private | 500 | 111 |
Properties
| Property | Visibility | Type | Default | Line |
|---|---|---|---|---|
$cache | private | Cache | — | 91 |
public __construct()
public function __construct(Cache $cache)Constructor. Parameter Type Default Description $cacheCache— Cache instance (memo + settings + policy owner).
public get_sandbox_effective_file_opt()
public function get_sandbox_effective_file_opt(array $file_opt): arraySandbox-effective `file_optimisation` slice (issue #1259). Parameter Type Default Description $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).
public should_bypass_combine_for_elementor()
public function should_bypass_combine_for_elementor(array $file_opt, ?bool=null $looks_like): boolWhether CSS combine/inline must be skipped for Elementor-safe mode (issue #1259). Parameter Type Default Description $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).
public combine_css()
public function combine_css()Combines all enqueued CSS files into a single file.
Return: void.
public resolve_eligible_handles()
public function resolve_eligible_handles(array $styles, array $exclusions): arrayResolve the handles eligible for CSS combining. Parameter Type Default Description $stylesarray— Queued handles. $exclusionsarray— Excluded handles/patterns.
Return: array — Eligible handles. Relocated from Cache::resolve_eligible_handles() (ARCH-006).
public fetch_and_minify_css()
public function fetch_and_minify_css(array $eligible_handles): arrayFetch, concatenate and minify eligible stylesheets. Parameter Type Default Description $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).
public write_combined_file()
public function write_combined_file(string $combined_css, string $css_variant): arrayWrite the combined CSS file to the cache directory. Parameter Type Default Description $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).
public emit_combined_preload_hint()
public function emit_combined_preload_hint($css_url, $version, string $css_file_path): voidEmit the preload hint for the combined stylesheet. Parameter Type Default Description $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).
public set_combine_css_preload()
public function set_combine_css_preload($css_url, $version, $css_file_path): voidRecord the combined-CSS preload URL for emission on `wp_head`. Parameter Type Default Description $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.
public maybe_preload_combine_css()
public function maybe_preload_combine_css(): voidEmit the combined-CSS `rel=\”preload\”` resource hint on `wp_head`.
Return: void.
public is_excluded_from_combine()
public function is_excluded_from_combine($handle, $src, array $exclude_combine_css): boolWhether a handle should be excluded from CSS combining. Parameter Type Default Description $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).
public get_combined_handles()
public function get_combined_handles($styles, $exclude_combine_css): arrayComputes the set of handles that belong in the combined CSS file. Parameter Type Default Description $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).
public combined_handles_match()
public function combined_handles_match($css_file_path, array $eligible_handles): boolWhether a cached combined file was generated from the same handle set. Parameter Type Default Description $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).
public write_combined_handles()
public function write_combined_handles($css_file_path, array $eligible_handles): voidPersists the set of combined handles next to the combined CSS file. Parameter Type Default Description $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).
public core_will_inline()
public function core_will_inline($handle): boolWhether a queued style will be inlined by core instead of combined. Parameter Type Default Description $handlestring— The registered style handle.
Return: bool — True if core will inline the style, false otherwise. Relocated from Cache::core_will_inline() (ARCH-006).
public core_inline_budget_will_inline()
public function core_inline_budget_will_inline($handle, $limit, $core_faithful): boolSimulates core\’s greedy smallest-first inline-CSS budget for a handle. Parameter Type Default Description $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).
public log_inline_budget_drift()
public function log_inline_budget_drift($handle, $limit): voidLogs that the inline-CSS budget prediction drifted from core. Parameter Type Default Description $handlestring— The handle whose prediction drifted. $limitint— The inline size limit in bytes.
Return: void — Relocated from Cache::log_inline_budget_drift() (ARCH-006).
public is_safe_css_combine_fallback_enabled()
public function is_safe_css_combine_fallback_enabled(): boolWhether 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).
public is_combined_css_valid()
public function is_combined_css_valid(string $path): boolWhether a combined CSS file is valid (exists, readable, non-empty). Parameter Type Default Description $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).
public log_combine_fallback()
public function log_combine_fallback(string $reason, array $handles): voidLog a combine fallback (fail-open) event with throttling. Parameter Type Default Description $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).
public register_combine_css_path()
public function register_combine_css_path($css_file_path): voidRegisters the combined CSS file with `path` data for core\’s inline pass. Parameter Type Default Description $css_file_pathstring— Absolute path to the combined CSS file.
Return: void — Relocated from Cache::register_combine_css_path() (ARCH-006).
public should_bypass_inline_for_safe_mode()
public function should_bypass_inline_for_safe_mode(array $file_opt): boolWhether the combined CSS inline must be skipped for safe mode (issue #1465). Parameter Type Default Description $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).
public will_combine_css_inline()
public function will_combine_css_inline($css_file_path): boolWhether the combined CSS file will be inlined by core. Parameter Type Default Description $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).
public get_styles_inline_limit()
public function get_styles_inline_limit(): intReads the core `styles_inline_size_limit` budget.
Return: int — The inline size limit in bytes. Relocated from Cache::get_styles_inline_limit() (ARCH-006).
public inline_candidates_require_src()
public function inline_candidates_require_src(): boolWhether 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).
public inline_candidates_require_readable()
public function inline_candidates_require_readable(): boolWhether 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).
public get_cached_src_stat()
public function get_cached_src_stat(string $path): arrayRetrieve cached src file stat (readable + filesize) with per-request LRU. Parameter Type Default Description $pathstring— Absolute filesystem path.
Return: array{readable:bool,size:int|false} — Relocated from Cache::get_cached_src_stat() (ARCH-006).
public should_skip_combine_for_inline_budget()
public function should_skip_combine_for_inline_budget(array $eligible_handles): boolWhether the combined-CSS file should be skipped on small block-theme bundles. Parameter Type Default Description $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).
public measure_style_byte_size()
public function measure_style_byte_size($handle)Measure a style\’s byte size using core\’s inline-budget accounting. Parameter Type Default Description $handlestring— The registered style handle.
Return: int|false — Byte size, 0 when the handle contributes nothing, false when unmeasurable.
public fetch_remote_css()
public function fetch_remote_css($url)Fetches CSS content from a remote URL or local path. Parameter Type Default Description $urlstring— The URL of the CSS file.
Return: string|false — The CSS content or false if fetching fails.
Hooks
Hooks referenced in includes/Assets/class-css-combine.php: Hook Type Line Notes wppo_combine_preload_fetchpriorityfilter 627 @param ×2 wppo_exclude_randomized_from_combinefilter 672 — wppo_inline_combined_cssfilter 1101 — wppo_inline_combined_cssfilter 1388 — wppo_skip_combine_on_small_block_themefilter 1410 @param ×3 wppo_max_css_bytesfilter 1532 —