Skip to content

Commit

Permalink
initial working version
Browse files Browse the repository at this point in the history
  • Loading branch information
engahmeds3ed committed Feb 4, 2021
1 parent ed5935e commit efb7b07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
6 changes: 5 additions & 1 deletion inc/Dependencies/Minify/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function add($data /* $data = null, ... */)
* @param string|string[] $data
*
* @return static
*
*
* @throws IOException
*/
public function addFile($data /* $data = null, ... */)
Expand Down Expand Up @@ -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.
*
Expand Down
22 changes: 0 additions & 22 deletions inc/Engine/Optimization/CSSTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<quotes>["\'])
# fetch path
(?P<path>.+?)
# close path enclosure
(?P=quotes)
/ix',
];

// find all relative urls in css.
Expand Down
7 changes: 4 additions & 3 deletions inc/Engine/Optimization/Minify/CSS/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand All @@ -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();
}
}

0 comments on commit efb7b07

Please sign in to comment.