Version Description
[2021.05.05] = * fixed an issue with some base64 encoded fonts and icons becoming invalid * changed @import CSS rules order according to specification (@import rules need to get processed first when minifying)
Download this release
Release Info
Developer | Alignak |
Plugin | Fast Velocity Minify |
Version | 3.1.9 |
Comparing to | |
See all releases |
Code changes from version 3.1.8 to 3.1.9
- fvm.php +1 -1
- inc/common.php +17 -6
- readme.txt +5 -1
fvm.php
CHANGED
@@ -6,7 +6,7 @@ Description: Improve your speed score on GTmetrix, Pingdom Tools and Google Page
|
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
Text Domain: fast-velocity-minify
|
9 |
-
Version: 3.1.
|
10 |
License: GPL2
|
11 |
|
12 |
------------------------------------------------------------------------
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
Text Domain: fast-velocity-minify
|
9 |
+
Version: 3.1.9
|
10 |
License: GPL2
|
11 |
|
12 |
------------------------------------------------------------------------
|
inc/common.php
CHANGED
@@ -816,9 +816,13 @@ function fvm_replace_css_imports($css, $rq=null) {
|
|
816 |
|
817 |
# globals
|
818 |
global $fvm_urls, $fvm_settings;
|
|
|
|
|
|
|
|
|
|
|
819 |
|
820 |
# handle import url rules
|
821 |
-
$cssimports = array();
|
822 |
preg_match_all ("/@import[ ]*['\"]{0,}(url\()*['\"]*([^\(\{'\"\)]*)['\"\)]*[;]{0,}/ui", $css, $cssimports);
|
823 |
if(isset($cssimports[0]) && isset($cssimports[2])) {
|
824 |
foreach($cssimports[0] as $k=>$cssimport) {
|
@@ -879,15 +883,22 @@ function fvm_replace_css_imports($css, $rq=null) {
|
|
879 |
}
|
880 |
}
|
881 |
|
882 |
-
#
|
883 |
if ($subcss !== false && !empty($subcss)) {
|
884 |
-
$css = str_replace($cssimport,
|
|
|
885 |
}
|
886 |
|
887 |
}
|
888 |
}
|
889 |
}
|
890 |
|
|
|
|
|
|
|
|
|
|
|
|
|
891 |
# return
|
892 |
return trim($css);
|
893 |
|
@@ -1083,12 +1094,12 @@ function fvm_simplify_fontface($css_code) {
|
|
1083 |
$cssrules = preg_split("/;(?![^(]*\))/iu", $ff);
|
1084 |
foreach ($cssrules as $k=>$csr) {
|
1085 |
if(preg_match('/src\s*\:\s*url/Uui', $csr)) {
|
1086 |
-
|
1087 |
# woff
|
1088 |
$fonts = array();
|
1089 |
preg_match('/url\s*\(\s*[\'\"]*([^\'\"]*)[\'\"]*\)\s*format\s*\([\'\"]*woff[\'\"]*\s*\)/Uui', $csr, $fonts);
|
1090 |
if(isset($fonts[0])) { $cssrules[$k] = 'src:'.$fonts[0]; break; }
|
1091 |
-
|
1092 |
# woff2
|
1093 |
$fonts = array();
|
1094 |
preg_match('/url\s*\(\s*[\'\"]*([^\'\"]*)[\'\"]*\)\s*format\s*\([\'\"]*woff2[\'\"]*\s*\)/Uui', $csr, $fonts);
|
@@ -1737,7 +1748,7 @@ function fvm_maybe_minify_css_file($css, $url, $min) {
|
|
1737 |
|
1738 |
# adjust paths
|
1739 |
$bgimgs = array();
|
1740 |
-
preg_match_all ('/url\s*\(\s*[\'\"]*([
|
1741 |
if(isset($bgimgs[1]) && is_array($bgimgs[1])) {
|
1742 |
foreach($bgimgs[1] as $img) {
|
1743 |
if(stripos($img, 'http') !== false || stripos($img, '//') !== false) {
|
816 |
|
817 |
# globals
|
818 |
global $fvm_urls, $fvm_settings;
|
819 |
+
|
820 |
+
# reset
|
821 |
+
$cssimports = array();
|
822 |
+
$cssimports_prepend = array();
|
823 |
+
$css = trim($css);
|
824 |
|
825 |
# handle import url rules
|
|
|
826 |
preg_match_all ("/@import[ ]*['\"]{0,}(url\()*['\"]*([^\(\{'\"\)]*)['\"\)]*[;]{0,}/ui", $css, $cssimports);
|
827 |
if(isset($cssimports[0]) && isset($cssimports[2])) {
|
828 |
foreach($cssimports[0] as $k=>$cssimport) {
|
883 |
}
|
884 |
}
|
885 |
|
886 |
+
# remove import rule and prepend imported code
|
887 |
if ($subcss !== false && !empty($subcss)) {
|
888 |
+
$css = str_replace($cssimport, '', $css);
|
889 |
+
$cssimports_prepend[] = '/* Import rule from: '.$href . ' */' . PHP_EOL . $subcss;
|
890 |
}
|
891 |
|
892 |
}
|
893 |
}
|
894 |
}
|
895 |
|
896 |
+
# prepend import rules
|
897 |
+
# https://www.w3.org/TR/CSS2/cascade.html#at-import
|
898 |
+
if(count($cssimports_prepend) > 0) {
|
899 |
+
$css = implode(PHP_EOL, $cssimports_prepend) . $css;
|
900 |
+
}
|
901 |
+
|
902 |
# return
|
903 |
return trim($css);
|
904 |
|
1094 |
$cssrules = preg_split("/;(?![^(]*\))/iu", $ff);
|
1095 |
foreach ($cssrules as $k=>$csr) {
|
1096 |
if(preg_match('/src\s*\:\s*url/Uui', $csr)) {
|
1097 |
+
|
1098 |
# woff
|
1099 |
$fonts = array();
|
1100 |
preg_match('/url\s*\(\s*[\'\"]*([^\'\"]*)[\'\"]*\)\s*format\s*\([\'\"]*woff[\'\"]*\s*\)/Uui', $csr, $fonts);
|
1101 |
if(isset($fonts[0])) { $cssrules[$k] = 'src:'.$fonts[0]; break; }
|
1102 |
+
|
1103 |
# woff2
|
1104 |
$fonts = array();
|
1105 |
preg_match('/url\s*\(\s*[\'\"]*([^\'\"]*)[\'\"]*\)\s*format\s*\([\'\"]*woff2[\'\"]*\s*\)/Uui', $csr, $fonts);
|
1748 |
|
1749 |
# adjust paths
|
1750 |
$bgimgs = array();
|
1751 |
+
preg_match_all ('/url\s*\(\s*[\'\"]*([^;\'\"]*)[\'\"]*\)/Uui', $css, $bgimgs);
|
1752 |
if(isset($bgimgs[1]) && is_array($bgimgs[1])) {
|
1753 |
foreach($bgimgs[1] as $img) {
|
1754 |
if(stripos($img, 'http') !== false || stripos($img, '//') !== false) {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Alignak
|
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6
|
6 |
-
Stable tag: 3.1.
|
7 |
Tested up to: 5.7.1
|
8 |
Text Domain: fast-velocity-minify
|
9 |
License: GPLv3 or later
|
@@ -48,6 +48,10 @@ You can create a style tag, with an ID equal to "critical-path" ex: `<style id="
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
51 |
= 3.1.8 [2021.04.30] =
|
52 |
* fixed missing dynamic css/js urls
|
53 |
* fixed some relative static assets paths
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6
|
6 |
+
Stable tag: 3.1.9
|
7 |
Tested up to: 5.7.1
|
8 |
Text Domain: fast-velocity-minify
|
9 |
License: GPLv3 or later
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
= 3.1.9 [2021.05.05] =
|
52 |
+
* fixed an issue with some base64 encoded fonts and icons becoming invalid
|
53 |
+
* changed @import CSS rules order according to specification (@import rules need to get processed first when minifying)
|
54 |
+
|
55 |
= 3.1.8 [2021.04.30] =
|
56 |
* fixed missing dynamic css/js urls
|
57 |
* fixed some relative static assets paths
|