class-css.php

Minify CSS class for the PerformanceOptimise plugin.

Source includes/minify/class-css.php2 min readPart of Performance Optimisation

includes/minify/class-css.php

Minify CSS class for the PerformanceOptimise plugin.

Namespace: PerformanceOptimise\\Inc\\Minify · Lines: 403

Class CSS

CSS Minification and Image Optimization.

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

class CSS

Properties

PropertyVisibilityTypeDefaultLine
$file_pathprivatestring—34
$cache_dirprivatestring—41
$filesystemprivateobject—48
$cache_urlprivatestring—55

public __construct()

public function __construct(string $file_path, string $cache_dir)

Constructor for the CSS class.

ParameterTypeDefaultDescription
$file_pathstring—Path to the CSS file to be minified.
$cache_dirstring—Directory where the minified file will be cached.

Source: includes/minify/class-css.php, line 67

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.

Tags: @since 1.0.0

Source: includes/minify/class-css.php, line 112

public get_cache_file_path()

public function get_cache_file_path(): string

Gets the cache file path for the minified CSS.

Return: string — The full path to the cache file.

Tags: @since 1.0.0

Source: includes/minify/class-css.php, line 168

private save_min_file()

private function save_min_file($css, $file_path)

Saves the minified CSS and its gzip version to the cache.

ParameterTypeDefaultDescription
$cssstring—The minified CSS content.
$file_pathstring—The file path to save the minified CSS.

Tags: @since 1.0.0

Source: includes/minify/class-css.php, line 180

publicstatic update_image_paths()

public static function update_image_paths(string $css_content, string $file_path): ?string

Updates image paths in the CSS content.

ParameterTypeDefaultDescription
$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.

Tags: @since 1.0.0

Source: includes/minify/class-css.php, line 199

publicstatic inject_font_display_swap()

public static function inject_font_display_swap($css, =\'swap\' $display)

Injects font-display into font-face declarations safely.

ParameterTypeDefaultDescription
$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.

Tags: @since 2.0.0 · @since 2.2.0 Added optional $display parameter with block normalization.

Source: includes/minify/class-css.php, line 319