From efb7b074ae31f4003ef082e687ff249930b8f419 Mon Sep 17 00:00:00 2001 From: Ahmed Saeed Date: Thu, 4 Feb 2021 20:03:29 +0200 Subject: [PATCH] initial working version --- inc/Dependencies/Minify/Minify.php | 6 ++++- inc/Engine/Optimization/CSSTrait.php | 22 ------------------- inc/Engine/Optimization/Minify/CSS/Minify.php | 7 +++--- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/inc/Dependencies/Minify/Minify.php b/inc/Dependencies/Minify/Minify.php index 2f175abcba..3bcb0aa50b 100644 --- a/inc/Dependencies/Minify/Minify.php +++ b/inc/Dependencies/Minify/Minify.php @@ -105,7 +105,7 @@ public function add($data /* $data = null, ... */) * @param string|string[] $data * * @return static - * + * * @throws IOException */ public function addFile($data /* $data = null, ... */) @@ -137,6 +137,10 @@ public function addFile($data /* $data = null, ... */) return $this; } + public function addData( $path, $content ) { + $this->data[ $path ] = $content; + } + /** * Minify the data & (optionally) saves it to a file. * diff --git a/inc/Engine/Optimization/CSSTrait.php b/inc/Engine/Optimization/CSSTrait.php index c0499e6bf9..bd33642382 100644 --- a/inc/Engine/Optimization/CSSTrait.php +++ b/inc/Engine/Optimization/CSSTrait.php @@ -107,28 +107,6 @@ protected function move( ConverterInterface $converter, $content, $source ) { \) /ix', - - // @import "xxx" - '/ - # import statement - @import - - # whitespace - \s+ - - # we don\'t have to check for @import url(), because the - # condition above will already catch these - - # open path enclosure - (?P["\']) - - # fetch path - (?P.+?) - - # close path enclosure - (?P=quotes) - - /ix', ]; // find all relative urls in css. diff --git a/inc/Engine/Optimization/Minify/CSS/Minify.php b/inc/Engine/Optimization/Minify/CSS/Minify.php index 7a521f13c9..e67e9ca4a4 100644 --- a/inc/Engine/Optimization/Minify/CSS/Minify.php +++ b/inc/Engine/Optimization/Minify/CSS/Minify.php @@ -310,7 +310,8 @@ protected function font_display_swap( $url, $minified_file, $content ) { */ protected function minify( $file_path, $minified_file, $file_content ) { $file_content = $this->rewrite_paths( $file_path, $minified_file, $file_content ); - $minifier = $this->get_minifier( $file_content ); + $minifier = $this->get_minifier(); + $minifier->addData( $file_path, $file_content ); $minified_content = $minifier->minify(); if ( empty( $minified_content ) ) { @@ -337,7 +338,7 @@ protected function minify( $file_path, $minified_file, $file_content ) { * * @return Minifier\CSS */ - protected function get_minifier( $file_content ) { - return new Minifier\CSS( $file_content ); + protected function get_minifier() { + return new Minifier\CSS(); } }