Fast Velocity Minify - Version 2.7.2

Version Description

[2019.07.29] = * fixed a PHP notice when WP_DEBUG mode is enabled on wordpress * small improvements on google fonts merging

Download this release

Release Info

Developer Alignak
Plugin Icon 128x128 Fast Velocity Minify
Version 2.7.2
Comparing to
See all releases

Code changes from version 2.7.1 to 2.7.2

Files changed (3) hide show
  1. fvm.php +10 -8
  2. inc/functions.php +13 -4
  3. readme.txt +5 -1
fvm.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://fastvelocity.com
5
  Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
- Version: 2.7.1
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
@@ -30,8 +30,7 @@ function fvm_compat_checker() {
30
 
31
  # defaults
32
  $error = '';
33
- $nwpv = implode('.', array_slice(explode('.', $wp_version), 0, 2)); # get 2 p only
34
-
35
  # php version requirements
36
  if (version_compare( PHP_VERSION, '5.5', '<' )) {
37
  $error = 'Fast Velocity Minify requires PHP 5.5 or higher. You’re still on '. PHP_VERSION;
@@ -43,10 +42,9 @@ function fvm_compat_checker() {
43
  }
44
 
45
  # wp version requirements
46
- if ( $nwpv < '4.5' ) {
47
- $error = 'Fast Velocity Minify requires WP 4.5 or higher. You’re still on ' . $wp_version;
48
  }
49
-
50
 
51
  if ((is_plugin_active(plugin_basename( __FILE__ )) && !empty($error)) || !empty($error)) {
52
  if (isset($_GET['activate'])) { unset($_GET['activate']); }
@@ -196,7 +194,12 @@ if(is_admin()) {
196
  register_uninstall_hook( __FILE__, 'fastvelocity_plugin_uninstall');
197
 
198
  } else {
199
-
 
 
 
 
 
200
  # skip on certain post_types or if there are specific keys on the url or if editor or admin
201
  if(!fastvelocity_exclude_contents()) {
202
 
@@ -262,7 +265,6 @@ if(is_admin()) {
262
  }
263
  }
264
 
265
-
266
  # exclude processing for editors and administrators (fix editors)
267
  add_action( 'plugins_loaded', 'fastvelocity_fix_editor' );
268
  function fastvelocity_fix_editor() {
5
  Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
+ Version: 2.7.2
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
30
 
31
  # defaults
32
  $error = '';
33
+
 
34
  # php version requirements
35
  if (version_compare( PHP_VERSION, '5.5', '<' )) {
36
  $error = 'Fast Velocity Minify requires PHP 5.5 or higher. You’re still on '. PHP_VERSION;
42
  }
43
 
44
  # wp version requirements
45
+ if ( version_compare( $GLOBALS['wp_version'], '4.5', '<' ) ) {
46
+ $error = 'Fast Velocity Minify requires WP 4.5 or higher. You’re still on ' . $GLOBALS['wp_version'];
47
  }
 
48
 
49
  if ((is_plugin_active(plugin_basename( __FILE__ )) && !empty($error)) || !empty($error)) {
50
  if (isset($_GET['activate'])) { unset($_GET['activate']); }
194
  register_uninstall_hook( __FILE__, 'fastvelocity_plugin_uninstall');
195
 
196
  } else {
197
+ add_action('setup_theme', 'fastvelocity_process_frontend' );
198
+ }
199
+
200
+ function fastvelocity_process_frontend() {
201
+ global $disable_js_merge, $disable_css_merge, $force_inline_css, $skip_emoji_removal, $fvm_clean_header_one, $skip_html_minification, $fvmloadcss, $fvm_fawesome_method, $fvm_gfonts_method;
202
+
203
  # skip on certain post_types or if there are specific keys on the url or if editor or admin
204
  if(!fastvelocity_exclude_contents()) {
205
 
265
  }
266
  }
267
 
 
268
  # exclude processing for editors and administrators (fix editors)
269
  add_action( 'plugins_loaded', 'fastvelocity_fix_editor' );
270
  function fastvelocity_fix_editor() {
inc/functions.php CHANGED
@@ -560,6 +560,9 @@ function fastvelocity_min_concatenate_google_fonts($array) {
560
  $families = array();
561
  foreach ($array as $font) {
562
 
 
 
 
563
  # must have
564
  if (stripos($font, 'family=') !== false) {
565
 
@@ -600,7 +603,7 @@ function fastvelocity_min_concatenate_google_fonts($array) {
600
  # subsets to array, unique, trim
601
  if (stripos($sub, ',') !== false) {
602
  $ft = explode(',', $sub);
603
- $ft = array_filter(array_map('trim', array_unique($ft)));
604
  foreach ($ft as $s) {
605
  $subsets[$s] = $s;
606
  }
@@ -618,11 +621,16 @@ function fastvelocity_min_concatenate_google_fonts($array) {
618
  if (stripos($font, ':') !== false) {
619
  $name = stristr($font, ':', true); # font name, before :
620
  $fwe = trim(stristr($font, ':'), ':'); # second part of the string, after :
 
 
 
 
 
621
 
622
  # ftypes to array, unique, trim
623
  if (stripos($font, ',') !== false) {
624
  $ft = explode(',', $fwe);
625
- $ftypes = array_filter(array_map('trim', array_unique($ft)));
626
  } else {
627
  if (!empty($fwe)) {
628
  $ftypes[] = $fwe;
@@ -638,7 +646,7 @@ function fastvelocity_min_concatenate_google_fonts($array) {
638
  if(!isset($fonts[$name])) {
639
  $fonts[$name] = array('name'=>$name, 'type'=>$ftypes);
640
  } else {
641
- $ftypes = array_merge($ftypes, $fonts[$name]['type']);
642
  $fonts[$name] = array('name'=>$name, 'type'=>$ftypes);
643
  }
644
 
@@ -661,7 +669,8 @@ function fastvelocity_min_concatenate_google_fonts($array) {
661
  if(count($build) > 0) {
662
  $merge = implode('|', $build);
663
  if(count($subsets) > 0) {
664
- $merge.= '&subset='.implode(',', $subsets);
 
665
  }
666
  }
667
 
560
  $families = array();
561
  foreach ($array as $font) {
562
 
563
+ # cleanup font display
564
+ $font = str_ireplace(array('&display=auto', '&display=block', '&display=swap', '&display=fallback', '&display=optional'), '', html_entity_decode(urldecode($font)));
565
+
566
  # must have
567
  if (stripos($font, 'family=') !== false) {
568
 
603
  # subsets to array, unique, trim
604
  if (stripos($sub, ',') !== false) {
605
  $ft = explode(',', $sub);
606
+ $ft = array_filter(array_map('trim', array_flip(array_flip($ft))));
607
  foreach ($ft as $s) {
608
  $subsets[$s] = $s;
609
  }
621
  if (stripos($font, ':') !== false) {
622
  $name = stristr($font, ':', true); # font name, before :
623
  $fwe = trim(stristr($font, ':'), ':'); # second part of the string, after :
624
+
625
+ # cleanup, void stuff like FONT:regular:regular:regular:regular,regular
626
+ if (stripos($fwe, ':') !== false) {
627
+ $fwe = stristr($fwe, ':', true);
628
+ }
629
 
630
  # ftypes to array, unique, trim
631
  if (stripos($font, ',') !== false) {
632
  $ft = explode(',', $fwe);
633
+ $ftypes = array_filter(array_map('trim', array_flip(array_flip($ft))));
634
  } else {
635
  if (!empty($fwe)) {
636
  $ftypes[] = $fwe;
646
  if(!isset($fonts[$name])) {
647
  $fonts[$name] = array('name'=>$name, 'type'=>$ftypes);
648
  } else {
649
+ $ftypes = array_filter(array_map('trim', array_unique(array_merge($ftypes, $fonts[$name]['type']))));
650
  $fonts[$name] = array('name'=>$name, 'type'=>$ftypes);
651
  }
652
 
669
  if(count($build) > 0) {
670
  $merge = implode('|', $build);
671
  if(count($subsets) > 0) {
672
+ $subsetfilter = str_replace('latin,latin-ext', 'latin-ext', implode(',', $subsets));
673
+ $merge.= '&subset='.$subsetfilter;
674
  }
675
  }
676
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Alignak
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
4
  Requires at least: 4.5
5
  Requires PHP: 5.5
6
- Stable tag: 2.7.1
7
  Tested up to: 5.2.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -198,6 +198,10 @@ Please backup your site before updating. Version 3.0 will have a major code rewr
198
 
199
  == Changelog ==
200
 
 
 
 
 
201
  = 2.7.1 [2019.07.27] =
202
  * fixed an AMP validation javascript error
203
 
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
4
  Requires at least: 4.5
5
  Requires PHP: 5.5
6
+ Stable tag: 2.7.2
7
  Tested up to: 5.2.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
198
 
199
  == Changelog ==
200
 
201
+ = 2.7.2 [2019.07.29] =
202
+ * fixed a PHP notice when WP_DEBUG mode is enabled on wordpress
203
+ * small improvements on google fonts merging
204
+
205
  = 2.7.1 [2019.07.27] =
206
  * fixed an AMP validation javascript error
207