includes/minify/class-css.php
Minify CSS class for the PerformanceOptimise plugin.
Class CSS
CSS Minification and Image Optimization.
class CSSProperties
| Property | Visibility | Type | Default | Line |
|---|---|---|---|---|
$file_path | private | string | — | 34 |
$cache_dir | private | string | — | 41 |
$filesystem | private | object | — | 48 |
$cache_url | private | string | — | 55 |
public __construct()
public function __construct(string $file_path, string $cache_dir)Constructor for the CSS class. Parameter Type Default Description $file_pathstring— Path to the CSS file to be minified. $cache_dirstring— Directory where the minified file will be cached.
public minify()
public function minify()Minifies the CSS file and stores it in the cache directory.
Return: string — The URL of the minified CSS file, or empty string on failure.
public get_cache_file_path()
public function get_cache_file_path(): stringGets the cache file path for the minified CSS.
Return: string — The full path to the cache file.
private save_min_file()
private function save_min_file($css, $file_path)Saves the minified CSS and its gzip version to the cache. Parameter Type Default Description $cssstring— The minified CSS content. $file_pathstring— The file path to save the minified CSS.
publicstatic update_image_paths()
public static function update_image_paths(string $css_content, string $file_path): ?stringUpdates image paths in the CSS content. Parameter Type Default Description $css_contentstring— The CSS content to modify. $file_pathstring— The file path of the original CSS file.
Return: string|null — The updated CSS content with modified image paths, or null on PCRE failure.
publicstatic inject_font_display_swap()
public static function inject_font_display_swap($css, =\'swap\' $display)Injects font-display into font-face declarations safely. Parameter Type Default Description $cssstring— The original CSS content. $display=\'swap\'— Desired font-display value (swap|block|fallback|optional|auto). Falsy disables injection.
Return: string — The modified CSS content.