Fast Velocity Minify - Version 3.0.5

Version Description

[2021.01.01] = * Fixed the cache paths on Windows Servers * Fixed incorrect paths on subdirectory sites * Fixed the CDN integration not replacing the domain name * Fixed CSS font-display replacements

Download this release

Release Info

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

Code changes from version 3.0.4 to 3.0.5

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.0.4
10
  License: GPL2
11
 
12
  ------------------------------------------------------------------------
6
  Author: Raul Peixoto
7
  Author URI: http://fastvelocity.com
8
  Text Domain: fast-velocity-minify
9
+ Version: 3.0.5
10
  License: GPL2
11
 
12
  ------------------------------------------------------------------------
inc/common.php CHANGED
@@ -184,7 +184,7 @@ function fvm_purge_minification() {
184
  if(is_null($fvm_cache_paths)) { $fvm_cache_paths = fvm_cachepath(); }
185
 
186
  # purge html directory?
187
- if(isset($fvm_cache_paths['cache_dir_min']) && is_dir($fvm_cache_paths['cache_dir_min']) && is_writable($fvm_cache_paths['cache_dir_min']) && stripos($fvm_cache_paths['cache_dir_min'], '/fvm') !== false) {
188
 
189
  # purge css/js files instantly
190
  if(isset($fvm_settings['cache']['min_instant_purge']) && $fvm_settings['cache']['min_instant_purge'] == true) {
@@ -208,7 +208,7 @@ function fvm_purge_minification() {
208
  # purge minified files right now
209
  function fvm_purge_minification_now() {
210
  global $fvm_cache_paths;
211
- if(isset($fvm_cache_paths['cache_dir_min']) && stripos($fvm_cache_paths['cache_dir_min'], '/fvm') !== false) {
212
  $result = fvm_rrmdir($fvm_cache_paths['cache_dir_min']);
213
  return $result;
214
  } else {
@@ -219,11 +219,11 @@ function fvm_purge_minification_now() {
219
  # purge expired minification files only
220
  function fvm_purge_minification_expired() {
221
  global $fvm_cache_paths;
222
- if(isset($fvm_cache_paths['cache_dir_min']) && !empty($fvm_cache_paths['cache_dir_min']) && stripos($fvm_cache_paths['cache_dir_min'], '/fvm') !== false) {
223
 
224
  # must be on the allowed path
225
  $wd = $fvm_cache_paths['cache_dir_min'];
226
- if(empty($wd) || !defined('WP_CONTENT_DIR') || stripos($wd, '/fvm') === false) {
227
  return __( 'Requested purge path is not allowed!', 'fast-velocity-minify' );
228
  }
229
 
@@ -573,7 +573,7 @@ function fvm_cache_increment() {
573
  function fvm_rrmdir($path) {
574
 
575
  # must be on the allowed path
576
- if(empty($path) || !defined('WP_CONTENT_DIR') || stripos($path, '/fvm') === false) {
577
  return __( 'Requested purge path is not allowed!', 'fast-velocity-minify' );
578
  }
579
 
@@ -604,7 +604,7 @@ function fvm_rrmdir($path) {
604
  function fvm_fix_permission_bits($file){
605
 
606
  # must be on the allowed path
607
- if(empty($file) || !defined('WP_CONTENT_DIR') || stripos($file, '/fvm') === false) {
608
  return __( 'Requested path is not allowed!', 'fast-velocity-minify' );
609
  }
610
 
@@ -765,11 +765,10 @@ function fvm_maybe_download($url) {
765
  global $fvm_urls;
766
 
767
  # check if we can open the file locally first
768
- if (stripos($url, $fvm_urls['wp_domain']) !== false && isset($_SERVER['DOCUMENT_ROOT'])) {
769
 
770
- # file path
771
- $f = str_replace(rtrim($fvm_urls['wp_home'], '/'), $_SERVER['DOCUMENT_ROOT'], $url);
772
- $f = str_replace('/', DIRECTORY_SEPARATOR, $f); # windows compatibility
773
 
774
  # did it work?
775
  if (file_exists($f)) {
@@ -796,11 +795,7 @@ function fvm_maybe_download($url) {
796
  # cache buster
797
  $query = 'nocache='.time();
798
  $separator = '&';
799
- if (isset($parsedUrl['query'])) {
800
- if ($parsedUrl['query'] === null) {
801
- $separator = '?';
802
- }
803
- }
804
 
805
  # final url
806
  $url .= $separator.$query;
@@ -827,7 +822,7 @@ function fvm_save_file($file, $content) {
827
  $path = dirname($file);
828
 
829
  # must be on the allowed path
830
- if(empty($path) || !defined('WP_CONTENT_DIR') || stripos($path, '/fvm') === false) {
831
  return __( 'Requested path is not allowed!', 'fast-velocity-minify' );
832
  }
833
 
@@ -1066,9 +1061,21 @@ function fvm_maybe_minify_css_file($css, $url, $min) {
1066
  $css = fvm_minify_css_string($css);
1067
  }
1068
 
1069
- # add font-display for google fonts and fontawesome
1070
  # https://developers.google.com/web/updates/2016/02/font-display
1071
- $css = str_ireplace('font-family:', 'font-display:block;font-family:', $css);
 
 
 
 
 
 
 
 
 
 
 
 
1072
 
1073
  # make relative urls when possible
1074
  global $fvm_urls;
184
  if(is_null($fvm_cache_paths)) { $fvm_cache_paths = fvm_cachepath(); }
185
 
186
  # purge html directory?
187
+ if(isset($fvm_cache_paths['cache_dir_min']) && is_dir($fvm_cache_paths['cache_dir_min']) && is_writable($fvm_cache_paths['cache_dir_min']) && stripos($fvm_cache_paths['cache_dir_min'], DIRECTORY_SEPARATOR . 'fvm') !== false) {
188
 
189
  # purge css/js files instantly
190
  if(isset($fvm_settings['cache']['min_instant_purge']) && $fvm_settings['cache']['min_instant_purge'] == true) {
208
  # purge minified files right now
209
  function fvm_purge_minification_now() {
210
  global $fvm_cache_paths;
211
+ if(isset($fvm_cache_paths['cache_dir_min']) && stripos($fvm_cache_paths['cache_dir_min'], DIRECTORY_SEPARATOR . 'fvm') !== false) {
212
  $result = fvm_rrmdir($fvm_cache_paths['cache_dir_min']);
213
  return $result;
214
  } else {
219
  # purge expired minification files only
220
  function fvm_purge_minification_expired() {
221
  global $fvm_cache_paths;
222
+ if(isset($fvm_cache_paths['cache_dir_min']) && !empty($fvm_cache_paths['cache_dir_min']) && stripos($fvm_cache_paths['cache_dir_min'], DIRECTORY_SEPARATOR . 'fvm') !== false) {
223
 
224
  # must be on the allowed path
225
  $wd = $fvm_cache_paths['cache_dir_min'];
226
+ if(empty($wd) || !defined('WP_CONTENT_DIR') || stripos($wd, DIRECTORY_SEPARATOR . 'fvm') === false) {
227
  return __( 'Requested purge path is not allowed!', 'fast-velocity-minify' );
228
  }
229
 
573
  function fvm_rrmdir($path) {
574
 
575
  # must be on the allowed path
576
+ if(empty($path) || !defined('WP_CONTENT_DIR') || stripos($path, DIRECTORY_SEPARATOR . 'fvm') === false) {
577
  return __( 'Requested purge path is not allowed!', 'fast-velocity-minify' );
578
  }
579
 
604
  function fvm_fix_permission_bits($file){
605
 
606
  # must be on the allowed path
607
+ if(empty($file) || !defined('WP_CONTENT_DIR') || stripos($file, DIRECTORY_SEPARATOR . 'fvm') === false) {
608
  return __( 'Requested path is not allowed!', 'fast-velocity-minify' );
609
  }
610
 
765
  global $fvm_urls;
766
 
767
  # check if we can open the file locally first
768
+ if (stripos($url, $fvm_urls['wp_domain']) !== false && defined('ABSPATH') && !empty('ABSPATH')) {
769
 
770
+ # file path + windows compatibility
771
+ $f = str_replace('/', DIRECTORY_SEPARATOR, str_replace(rtrim($fvm_urls['wp_home'], '/'), ABSPATH, $url));
 
772
 
773
  # did it work?
774
  if (file_exists($f)) {
795
  # cache buster
796
  $query = 'nocache='.time();
797
  $separator = '&';
798
+ if (!isset($parsedUrl['query']) || $parsedUrl['query'] === null) { $separator = '?'; }
 
 
 
 
799
 
800
  # final url
801
  $url .= $separator.$query;
822
  $path = dirname($file);
823
 
824
  # must be on the allowed path
825
+ if(empty($path) || !defined('WP_CONTENT_DIR') || stripos($path, DIRECTORY_SEPARATOR . 'fvm') === false) {
826
  return __( 'Requested path is not allowed!', 'fast-velocity-minify' );
827
  }
828
 
1061
  $css = fvm_minify_css_string($css);
1062
  }
1063
 
1064
+ # add font-display block for all font faces
1065
  # https://developers.google.com/web/updates/2016/02/font-display
1066
+ $mff = array();
1067
+ $mff2 = array();
1068
+ preg_match_all('/(\@font-face)([^}]+)(\})/usi', $css, $mff);
1069
+ if(isset($mff[0]) && is_array($mff[0])) {
1070
+ foreach($mff[0] as $ff) {
1071
+ preg_match_all('/\{{1}(.*)\}{1}/usi', $ff, $mff2);
1072
+ if(isset($mff2[1]) && is_array($mff2[1]) && isset($mff2[1][0])) {
1073
+ if(stripos($mff2[1][0], 'font-display:') === false) {
1074
+ $css = str_replace($mff2[1][0], 'font-display:block;'.$mff2[1][0], $css);
1075
+ }
1076
+ }
1077
+ }
1078
+ }
1079
 
1080
  # make relative urls when possible
1081
  global $fvm_urls;
inc/frontend.php CHANGED
@@ -354,7 +354,7 @@ function fvm_process_page($html) {
354
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
355
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
356
  if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
357
- $file_css_url = str_replace('//'.$wpraiser_urls['wp_domain'], '//'.$wpraiser_settings['cdn']['domain'], $file_css_url);
358
  }
359
  }
360
 
@@ -408,7 +408,7 @@ function fvm_process_page($html) {
408
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
409
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
410
  if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
411
- $file_css_url = str_replace('//'.$wpraiser_urls['wp_domain'], '//'.$wpraiser_settings['cdn']['domain'], $file_css_url);
412
  }
413
  }
414
 
@@ -462,7 +462,7 @@ function fvm_process_page($html) {
462
  foreach($html->find('script') as $element) {
463
  $allscripts[] = $element;
464
  }
465
-
466
  # process all scripts
467
  if (is_array($allscripts) && count($allscripts) > 0) {
468
  foreach($allscripts as $k=>$tag) {
@@ -762,7 +762,7 @@ function fvm_process_page($html) {
762
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
763
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
764
  if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
765
- $fheader_url = str_replace('//'.$wpraiser_urls['wp_domain'], '//'.$wpraiser_settings['cdn']['domain'], $fheader_url);
766
  }
767
  }
768
 
@@ -800,7 +800,7 @@ function fvm_process_page($html) {
800
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
801
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
802
  if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
803
- $ffooter_url = str_replace('//'.$wpraiser_urls['wp_domain'], '//'.$wpraiser_settings['cdn']['domain'], $ffooter_url);
804
 
805
  }
806
  }
354
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
355
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
356
  if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
357
+ $file_css_url = str_replace('//'.$fvm_urls['wp_domain'], '//'.$fvm_settings['cdn']['domain'], $file_css_url);
358
  }
359
  }
360
 
408
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
409
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
410
  if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
411
+ $file_css_url = str_replace('//'.$fvm_urls['wp_domain'], '//'.$fvm_settings['cdn']['domain'], $file_css_url);
412
  }
413
  }
414
 
462
  foreach($html->find('script') as $element) {
463
  $allscripts[] = $element;
464
  }
465
+
466
  # process all scripts
467
  if (is_array($allscripts) && count($allscripts) > 0) {
468
  foreach($allscripts as $k=>$tag) {
762
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
763
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
764
  if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
765
+ $fheader_url = str_replace('//'.$fvm_urls['wp_domain'], '//'.$fvm_settings['cdn']['domain'], $fheader_url);
766
  }
767
  }
768
 
800
  if(isset($fvm_settings['cdn']['enable']) && $fvm_settings['cdn']['enable'] == true &&
801
  isset($fvm_settings['cdn']['domain']) && !empty($fvm_settings['cdn']['domain'])) {
802
  if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
803
+ $ffooter_url = str_replace('//'.$fvm_urls['wp_domain'], '//'.$fvm_settings['cdn']['domain'], $ffooter_url);
804
 
805
  }
806
  }
inc/serverinfo.php CHANGED
@@ -22,7 +22,7 @@ function fvm_get_generalinfo() {
22
 
23
  echo'---'. PHP_EOL;
24
  echo'SITE INFO:'. PHP_EOL;
25
- echo'Site Path: '. $_SERVER['DOCUMENT_ROOT'] . PHP_EOL;
26
  echo'Hostname: '. $_SERVER['SERVER_NAME'] . PHP_EOL;
27
  echo'DB Data Size: '. fvm_format_php_size(fvm_get_mysql_data_usage()) . PHP_EOL;
28
  echo'DB Index Size: '. fvm_format_php_size(fvm_get_mysql_index_usage()) . PHP_EOL;
22
 
23
  echo'---'. PHP_EOL;
24
  echo'SITE INFO:'. PHP_EOL;
25
+ echo'Site Path: '. ABSPATH . PHP_EOL;
26
  echo'Hostname: '. $_SERVER['SERVER_NAME'] . PHP_EOL;
27
  echo'DB Data Size: '. fvm_format_php_size(fvm_get_mysql_data_usage()) . PHP_EOL;
28
  echo'DB Index Size: '. fvm_format_php_size(fvm_get_mysql_index_usage()) . PHP_EOL;
layout/admin-layout-help.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php if( $at == 'help' ) { ?>
2
 
3
  <div class="fvm-wrapper">
4
 
1
+ <?php if( $active_tab == 'help' ) { ?>
2
 
3
  <div class="fvm-wrapper">
4
 
layout/admin-layout-settings.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php if( $at == 'settings' ) { ?>
2
  <div class="fvm-wrapper">
3
 
4
  <form method="post" id="fvm-save-changes">
1
+ <?php if( $active_tab == 'settings' ) { ?>
2
  <div class="fvm-wrapper">
3
 
4
  <form method="post" id="fvm-save-changes">
layout/admin-layout-status.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  # server info
4
- if( $at == 'status' ) {
5
  ?>
6
  <div class="fvm-wrapper">
7
 
1
  <?php
2
 
3
  # server info
4
+ if( $active_tab == 'status' ) {
5
  ?>
6
  <div class="fvm-wrapper">
7
 
layout/admin-layout-upgrade.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php if( $at == 'upgrade' ) { ?>
2
 
3
  <div class="fvm-wrapper">
4
 
1
+ <?php if( $active_tab == 'upgrade' ) { ?>
2
 
3
  <div class="fvm-wrapper">
4
 
layout/admin-layout.php CHANGED
@@ -4,14 +4,14 @@
4
 
5
  <?php
6
  # get active tab, set default
7
- $at = isset($_GET['tab']) ? $_GET['tab'] : 'settings';
8
  ?>
9
 
10
  <h2 class="nav-tab-wrapper wp-clearfix">
11
- <a href="?page=fvm" class="nav-tab <?php echo $at == 'settings' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Settings', 'fast-velocity-minify' ); ?></a>
12
- <a href="?page=fvm&tab=status" class="nav-tab <?php echo $at == 'status' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Status', 'fast-velocity-minify' ); ?></a>
13
- <?php /*<a href="?page=fvm&tab=upgrade" class="nav-tab <?php echo $at == 'upgrade' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Upgrade', 'fast-velocity-minify' ); ?></a>*/ ?>
14
- <a href="?page=fvm&tab=help" class="nav-tab <?php echo $at == 'help' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Help', 'fast-velocity-minify' ); ?></a>
15
  </h2>
16
 
17
  <div id="fvm">
4
 
5
  <?php
6
  # get active tab, set default
7
+ $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'settings';
8
  ?>
9
 
10
  <h2 class="nav-tab-wrapper wp-clearfix">
11
+ <a href="?page=fvm" class="nav-tab <?php echo $active_tab == 'settings' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Settings', 'fast-velocity-minify' ); ?></a>
12
+ <a href="?page=fvm&tab=status" class="nav-tab <?php echo $active_tab == 'status' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Status', 'fast-velocity-minify' ); ?></a>
13
+ <?php /*<a href="?page=fvm&tab=upgrade" class="nav-tab <?php echo $active_tab == 'upgrade' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Upgrade', 'fast-velocity-minify' ); ?></a>*/ ?>
14
+ <a href="?page=fvm&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Help', 'fast-velocity-minify' ); ?></a>
15
  </h2>
16
 
17
  <div id="fvm">
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.7
5
  Requires PHP: 5.6
6
- Stable tag: 3.0.4
7
  Tested up to: 5.6
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
@@ -55,6 +55,12 @@ Version 3.0 is a major code rewrite to improve JS and CSS merging, but it requir
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
58
  = 3.0.4 [2020.12.31] =
59
  * Improved compatibility on CSS merging with optimole and similar services
60
  * Fixed some PHP notices and other minor issues
3
  Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
4
  Requires at least: 4.7
5
  Requires PHP: 5.6
6
+ Stable tag: 3.0.5
7
  Tested up to: 5.6
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
55
 
56
  == Changelog ==
57
 
58
+ = 3.0.5 [2021.01.01] =
59
+ * Fixed the cache paths on Windows Servers
60
+ * Fixed incorrect paths on subdirectory sites
61
+ * Fixed the CDN integration not replacing the domain name
62
+ * Fixed CSS font-display replacements
63
+
64
  = 3.0.4 [2020.12.31] =
65
  * Improved compatibility on CSS merging with optimole and similar services
66
  * Fixed some PHP notices and other minor issues