Fast Velocity Minify - Version 3.2.2

Version Description

[2021.05.09] = * added auto varnish cache purge for Cloudways * fixed some JS files not being minified

Download this release

Release Info

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

Code changes from version 3.2.1 to 3.2.2

Files changed (4) hide show
  1. fvm.php +1 -1
  2. inc/common.php +10 -11
  3. inc/frontend.php +15 -12
  4. 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.2.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.2.2
10
  License: GPL2
11
 
12
  ------------------------------------------------------------------------
inc/common.php CHANGED
@@ -259,8 +259,8 @@ function fvm_purge_others(){
259
  # hosting companies
260
 
261
  # Purge SG Optimizer (Siteground)
262
- if (function_exists('sg_cachepress_purge_cache')) {
263
- sg_cachepress_purge_cache();
264
  return __( 'All caches on <strong>SG Optimizer</strong> have been purged.', 'fast-velocity-minify' );
265
  }
266
 
@@ -326,9 +326,9 @@ function fvm_purge_others(){
326
 
327
 
328
  # Purge Godaddy Managed WordPress Hosting (Varnish)
329
- function fvm_godaddy_request( $method, $url = null ) {
330
- $url = empty( $url ) ? home_url() : $url;
331
- $host = parse_url( $url, PHP_URL_HOST );
332
  $url = set_url_scheme( str_replace( $host, WPaas\Plugin::vip(), $url ), 'http' );
333
  update_option( 'gd_system_last_cache_flush', time(), 'no'); # purge apc
334
  wp_remote_request( esc_url_raw( $url ), array('method' => $method, 'blocking' => false, 'headers' => array('Host' => $host)) );
@@ -460,23 +460,22 @@ function fvm_generate_min_url($url, $tkey, $type, $code) {
460
  $file = $ch_info['ch_dir'] . DIRECTORY_SEPARATOR . $filename;
461
  $public = $ch_info['ch_url'] . '/' .$filename;
462
 
463
- # cache date
464
- $tvers = get_option('fvm_last_cache_update', '0');
465
-
466
  # wordpress functions
467
  require_once (ABSPATH . DIRECTORY_SEPARATOR . 'wp-admin'. DIRECTORY_SEPARATOR .'includes'. DIRECTORY_SEPARATOR .'class-wp-filesystem-base.php');
468
  require_once (ABSPATH . DIRECTORY_SEPARATOR .'wp-admin'. DIRECTORY_SEPARATOR .'includes'. DIRECTORY_SEPARATOR .'class-wp-filesystem-direct.php');
 
 
 
469
 
470
  # create if doesn't exist
471
- $fileSystemDirect = new WP_Filesystem_Direct(false);
472
  if(!$fileSystemDirect->exists($file) || ($fileSystemDirect->exists($file) && $fileSystemDirect->mtime($file) < $tvers)) {
473
  $fileSystemDirect->put_contents($file, $code);
474
  }
475
 
476
  # return url
477
  return $public;
478
-
479
- }
480
  }
481
 
482
  # default
259
  # hosting companies
260
 
261
  # Purge SG Optimizer (Siteground)
262
+ if (function_exists('sg_cachepress_purge_everything')) {
263
+ sg_cachepress_purge_everything();
264
  return __( 'All caches on <strong>SG Optimizer</strong> have been purged.', 'fast-velocity-minify' );
265
  }
266
 
326
 
327
 
328
  # Purge Godaddy Managed WordPress Hosting (Varnish)
329
+ function fvm_godaddy_request( $method) {
330
+ $url = home_url();
331
+ $host = wpraiser_get_domain();
332
  $url = set_url_scheme( str_replace( $host, WPaas\Plugin::vip(), $url ), 'http' );
333
  update_option( 'gd_system_last_cache_flush', time(), 'no'); # purge apc
334
  wp_remote_request( esc_url_raw( $url ), array('method' => $method, 'blocking' => false, 'headers' => array('Host' => $host)) );
460
  $file = $ch_info['ch_dir'] . DIRECTORY_SEPARATOR . $filename;
461
  $public = $ch_info['ch_url'] . '/' .$filename;
462
 
 
 
 
463
  # wordpress functions
464
  require_once (ABSPATH . DIRECTORY_SEPARATOR . 'wp-admin'. DIRECTORY_SEPARATOR .'includes'. DIRECTORY_SEPARATOR .'class-wp-filesystem-base.php');
465
  require_once (ABSPATH . DIRECTORY_SEPARATOR .'wp-admin'. DIRECTORY_SEPARATOR .'includes'. DIRECTORY_SEPARATOR .'class-wp-filesystem-direct.php');
466
+
467
+ # initialize
468
+ $fileSystemDirect = new WP_Filesystem_Direct(false);
469
 
470
  # create if doesn't exist
 
471
  if(!$fileSystemDirect->exists($file) || ($fileSystemDirect->exists($file) && $fileSystemDirect->mtime($file) < $tvers)) {
472
  $fileSystemDirect->put_contents($file, $code);
473
  }
474
 
475
  # return url
476
  return $public;
477
+
478
+ }
479
  }
480
 
481
  # default
inc/frontend.php CHANGED
@@ -140,13 +140,16 @@ function fvm_process_page($html) {
140
  # START CSS FILES
141
  if($tag->tag == 'link' && isset($tag->href)) {
142
 
 
 
 
143
  # Ignore css files
144
  $ignore_css_merging = false;
145
  if(isset($fvm_settings['css']['ignore']) && !empty($fvm_settings['css']['ignore'])) {
146
  $arr = fvm_string_toarray($fvm_settings['css']['ignore']);
147
  if(is_array($arr) && count($arr) > 0) {
148
  foreach ($arr as $e) {
149
- if(stripos($tag->href, $e) !== false) {
150
  unset($allcss[$k]);
151
  continue 2;
152
  }
@@ -159,7 +162,7 @@ function fvm_process_page($html) {
159
  $arr = fvm_string_toarray($fvm_settings['css']['remove']);
160
  if(is_array($arr) && count($arr) > 0) {
161
  foreach ($arr as $e) {
162
- if(stripos($tag->href, $e) !== false) {
163
  $tag->outertext = '';
164
  unset($allcss[$k]);
165
  continue 2;
@@ -186,7 +189,7 @@ function fvm_process_page($html) {
186
  # extract fonts and icons
187
  if(isset($fvm_settings['css']['fonts']) && $fvm_settings['css']['fonts'] == true) {
188
  $extract_fonts_arr = fvm_extract_fonts($css['code']);
189
- $css_lowpriority_code.= '/* '.$tag->href.' */'. PHP_EOL . $extract_fonts_arr['fonts'];
190
  $css_code = $extract_fonts_arr['code'];
191
  } else {
192
  $css_code = $css['code'];
@@ -199,7 +202,7 @@ function fvm_process_page($html) {
199
  $arr = fvm_string_toarray($fvm_settings['css']['async']);
200
  if(is_array($arr) && count($arr) > 0) {
201
  foreach ($arr as $aa) {
202
- if(stripos($tag->href, $aa) !== false) {
203
 
204
  # save css for merging
205
  $fvm_styles[$tag->media]['async'][] = $css_code;
@@ -257,7 +260,7 @@ function fvm_process_page($html) {
257
  # extract fonts and icons
258
  if(isset($fvm_settings['css']['fonts']) && $fvm_settings['css']['fonts'] == true) {
259
  $extract_fonts_arr = fvm_extract_fonts($css['code']);
260
- $css_lowpriority_code.= '/* '.$tag->href.' */'. PHP_EOL . $extract_fonts_arr['fonts'];
261
  $css_code = $extract_fonts_arr['code'];
262
  } else {
263
  $css_code = $css['code'];
@@ -269,11 +272,11 @@ function fvm_process_page($html) {
269
  unset($allcss[$k]);
270
  continue;
271
  } else {
272
- $css_code = '/* '.$tag->href.' */'. PHP_EOL . $css_code;
273
  }
274
 
275
  # generate url
276
- $ind_css_url = fvm_generate_min_url($tag->href, $css['tkey'], 'css', $css_code);
277
 
278
  # cdn
279
  if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
@@ -285,7 +288,7 @@ function fvm_process_page($html) {
285
  $arr = fvm_string_toarray($fvm_settings['css']['async']);
286
  if(is_array($arr) && count($arr) > 0) {
287
  foreach ($arr as $aa) {
288
- if(stripos($tag->href, $aa) !== false) {
289
 
290
  # async attributes
291
  $tag->rel = 'preload';
@@ -513,6 +516,9 @@ function fvm_process_page($html) {
513
  # START JS FILES
514
  if(isset($tag->src)) {
515
 
 
 
 
516
  # ignore js files
517
  if(isset($fvm_settings['js']['ignore']) && !empty($fvm_settings['js']['ignore'])) {
518
  $arr = fvm_string_toarray($fvm_settings['js']['ignore']);
@@ -649,9 +655,6 @@ function fvm_process_page($html) {
649
  # jquery needs to load earlier, if not being merged (while merging is active)
650
  if(stripos($tag->src, '/jquery.js') !== false || stripos($tag->src, '/jquery.min.js') !== false || stripos($tag->src, '/jquery-migrate') !== false) {
651
 
652
- # filter url
653
- $href = fvm_normalize_url($tag->src);
654
-
655
  # http and html preload for render blocking js
656
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
657
  $htmlpreloads[] = '<link rel="preload" href="'.$href.'" as="script" />';
@@ -661,7 +664,7 @@ function fvm_process_page($html) {
661
  if(stripos($tag->src, '/jquery-migrate') !== false) {
662
  $htmljsheader[1] = "<script data-cfasync='false' src='".$href."'></script>"; # jquery migrate
663
  } else {
664
- $htmljsheader[0] = "<script data-cfasync='false' src='".$tag->src."'></script>"; # jquery
665
  }
666
 
667
  # content
140
  # START CSS FILES
141
  if($tag->tag == 'link' && isset($tag->href)) {
142
 
143
+ # filter url
144
+ $href = fvm_normalize_url($tag->href);
145
+
146
  # Ignore css files
147
  $ignore_css_merging = false;
148
  if(isset($fvm_settings['css']['ignore']) && !empty($fvm_settings['css']['ignore'])) {
149
  $arr = fvm_string_toarray($fvm_settings['css']['ignore']);
150
  if(is_array($arr) && count($arr) > 0) {
151
  foreach ($arr as $e) {
152
+ if(stripos($href, $e) !== false) {
153
  unset($allcss[$k]);
154
  continue 2;
155
  }
162
  $arr = fvm_string_toarray($fvm_settings['css']['remove']);
163
  if(is_array($arr) && count($arr) > 0) {
164
  foreach ($arr as $e) {
165
+ if(stripos($href, $e) !== false) {
166
  $tag->outertext = '';
167
  unset($allcss[$k]);
168
  continue 2;
189
  # extract fonts and icons
190
  if(isset($fvm_settings['css']['fonts']) && $fvm_settings['css']['fonts'] == true) {
191
  $extract_fonts_arr = fvm_extract_fonts($css['code']);
192
+ $css_lowpriority_code.= '/* '.$href.' */'. PHP_EOL . $extract_fonts_arr['fonts'];
193
  $css_code = $extract_fonts_arr['code'];
194
  } else {
195
  $css_code = $css['code'];
202
  $arr = fvm_string_toarray($fvm_settings['css']['async']);
203
  if(is_array($arr) && count($arr) > 0) {
204
  foreach ($arr as $aa) {
205
+ if(stripos($href, $aa) !== false) {
206
 
207
  # save css for merging
208
  $fvm_styles[$tag->media]['async'][] = $css_code;
260
  # extract fonts and icons
261
  if(isset($fvm_settings['css']['fonts']) && $fvm_settings['css']['fonts'] == true) {
262
  $extract_fonts_arr = fvm_extract_fonts($css['code']);
263
+ $css_lowpriority_code.= '/* '.$href.' */'. PHP_EOL . $extract_fonts_arr['fonts'];
264
  $css_code = $extract_fonts_arr['code'];
265
  } else {
266
  $css_code = $css['code'];
272
  unset($allcss[$k]);
273
  continue;
274
  } else {
275
+ $css_code = '/* '.$href.' */'. PHP_EOL . $css_code;
276
  }
277
 
278
  # generate url
279
+ $ind_css_url = fvm_generate_min_url($href, $css['tkey'], 'css', $css_code);
280
 
281
  # cdn
282
  if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
288
  $arr = fvm_string_toarray($fvm_settings['css']['async']);
289
  if(is_array($arr) && count($arr) > 0) {
290
  foreach ($arr as $aa) {
291
+ if(stripos($href, $aa) !== false) {
292
 
293
  # async attributes
294
  $tag->rel = 'preload';
516
  # START JS FILES
517
  if(isset($tag->src)) {
518
 
519
+ # filter url
520
+ $href = fvm_normalize_url($tag->src);
521
+
522
  # ignore js files
523
  if(isset($fvm_settings['js']['ignore']) && !empty($fvm_settings['js']['ignore'])) {
524
  $arr = fvm_string_toarray($fvm_settings['js']['ignore']);
655
  # jquery needs to load earlier, if not being merged (while merging is active)
656
  if(stripos($tag->src, '/jquery.js') !== false || stripos($tag->src, '/jquery.min.js') !== false || stripos($tag->src, '/jquery-migrate') !== false) {
657
 
 
 
 
658
  # http and html preload for render blocking js
659
  if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
660
  $htmlpreloads[] = '<link rel="preload" href="'.$href.'" as="script" />';
664
  if(stripos($tag->src, '/jquery-migrate') !== false) {
665
  $htmljsheader[1] = "<script data-cfasync='false' src='".$href."'></script>"; # jquery migrate
666
  } else {
667
+ $htmljsheader[0] = "<script data-cfasync='false' src='".$href."'></script>"; # jquery
668
  }
669
 
670
  # content
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.2.1
7
  Tested up to: 5.7.1
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
@@ -49,6 +49,10 @@ You need a public directory to store and serve minified cache files. If you need
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 3.2.1 [2021.05.07] =
53
  * added support for custom cache location via wp-config.php constants
54
  * changed the default cache directory to wp-content/cache
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.2.2
7
  Tested up to: 5.7.1
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
49
 
50
  == Changelog ==
51
 
52
+ = 3.2.2 [2021.05.09] =
53
+ * added auto varnish cache purge for Cloudways
54
+ * fixed some JS files not being minified
55
+
56
  = 3.2.1 [2021.05.07] =
57
  * added support for custom cache location via wp-config.php constants
58
  * changed the default cache directory to wp-content/cache