Fast Velocity Minify - Version 3.0.8

Version Description

[2021.01.02] = * Improved compatibility and better detection of dynamic CSS and JS files (files generated with PHP instead of being static)

Download this release

Release Info

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

Code changes from version 3.0.7 to 3.0.8

Files changed (4) hide show
  1. fvm.php +1 -1
  2. inc/common.php +8 -8
  3. inc/frontend.php +3 -3
  4. readme.txt +4 -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.0.7
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.8
10
  License: GPL2
11
 
12
  ------------------------------------------------------------------------
inc/common.php CHANGED
@@ -768,7 +768,7 @@ function fvm_maybe_download($url) {
768
  global $fvm_urls;
769
 
770
  # check if we can open the file locally first
771
- if (stripos($url, $fvm_urls['wp_domain']) !== false && defined('ABSPATH') && !empty('ABSPATH')) {
772
 
773
  # file path + windows compatibility
774
  $f = str_replace('/', DIRECTORY_SEPARATOR, str_replace(rtrim($fvm_urls['wp_site_url'], '/'), ABSPATH, $url));
@@ -1008,12 +1008,12 @@ function fvm_not_php_html($code) {
1008
 
1009
  # return early if not html
1010
  $code = trim($code);
1011
- $a = '<!doctype';
1012
- $b = '<html';
1013
- $c = '<?xml';
1014
- $d = '<?php';
1015
-
1016
- if ( strcasecmp(substr($code, 0, strlen($a)), $a) != 0 && strcasecmp(substr($code, 0, strlen($b)), $b) != 0 && strcasecmp(substr($code, 0, strlen($c)), $c) != 0 && strcasecmp(substr($code, 0, strlen($d)), $d) != 0 ) {
1017
  return true;
1018
  }
1019
 
@@ -1189,7 +1189,7 @@ function fvm_escape_url_js($str) {
1189
  # try catch wrapper for merged javascript
1190
  function fvm_try_catch_wrap($js, $href=null) {
1191
  $loc = ''; if(isset($href)) { $loc = '[ Merged: '. $href . ' ] '; }
1192
- return 'try{'. PHP_EOL . $js . PHP_EOL . '}catch(e){console.error("An error has occurred. '.$loc.'[ "+e.stack+" ]");}';
1193
  }
1194
 
1195
 
768
  global $fvm_urls;
769
 
770
  # check if we can open the file locally first
771
+ if (stripos($url, $fvm_urls['wp_domain']) !== false && defined('ABSPATH') && !empty('ABSPATH') && substr($url, -4) != '.php') {
772
 
773
  # file path + windows compatibility
774
  $f = str_replace('/', DIRECTORY_SEPARATOR, str_replace(rtrim($fvm_urls['wp_site_url'], '/'), ABSPATH, $url));
1008
 
1009
  # return early if not html
1010
  $code = trim($code);
1011
+ $a = '<!doctype'; # start
1012
+ $b = '<html'; # start
1013
+ $c = '<?xml'; # start
1014
+ $d = '<?php'; # anywhere
1015
+
1016
+ if ( strcasecmp(substr($code, 0, strlen($a)), $a) != 0 && strcasecmp(substr($code, 0, strlen($b)), $b) != 0 && strcasecmp(substr($code, 0, strlen($c)), $c) != 0 && stripos($code, $d) === false ) {
1017
  return true;
1018
  }
1019
 
1189
  # try catch wrapper for merged javascript
1190
  function fvm_try_catch_wrap($js, $href=null) {
1191
  $loc = ''; if(isset($href)) { $loc = '[ Merged: '. $href . ' ] '; }
1192
+ return PHP_EOL . 'try{'. PHP_EOL . $js . PHP_EOL . '}catch(e){console.error("An error has occurred. '.$loc.'[ "+e.stack+" ]");}';
1193
  }
1194
 
1195
 
inc/frontend.php CHANGED
@@ -432,7 +432,7 @@ function fvm_process_page($html) {
432
  if (file_exists($file_css)) {
433
 
434
  # add file with js
435
- $htmlcssheader['a_'.$css_uid] = '<script data-cfasync="false" id="fvmlpcss">var a;fvmuag()&&((a=document.getElementById("fvmlpcss")).outerHTML='.fvm_escape_url_js("<link rel='stylesheet' href='". $file_css_url . "' media='".$mediatype."' />").');</script>'; # prepend
436
 
437
  }
438
 
@@ -640,7 +640,7 @@ function fvm_process_page($html) {
640
  if(!empty($js) && $js != false) {
641
 
642
  # try catch
643
- $js = fvm_try_catch_wrap($js);
644
 
645
  # developers filter
646
  $js = apply_filters( 'fvm_after_download_and_minify_code', $js, 'js');
@@ -706,7 +706,7 @@ function fvm_process_page($html) {
706
  if(!empty($js) && $js != false) {
707
 
708
  # try catch
709
- $js = fvm_try_catch_wrap($js);
710
 
711
  # developers filter
712
  $js = apply_filters( 'fvm_after_download_and_minify_code', $js, 'js');
432
  if (file_exists($file_css)) {
433
 
434
  # add file with js
435
+ $htmlcssheader['a_'.$css_uid] = '<script data-cfasync="false" id="fvmlpcss">var fvmft;fvmuag()&&((fvmft=document.getElementById("fvmlpcss")).outerHTML='.fvm_escape_url_js("<link rel='stylesheet' href='". $file_css_url . "' media='".$mediatype."' />").');</script>'; # prepend
436
 
437
  }
438
 
640
  if(!empty($js) && $js != false) {
641
 
642
  # try catch
643
+ $js = fvm_try_catch_wrap($js, $href);
644
 
645
  # developers filter
646
  $js = apply_filters( 'fvm_after_download_and_minify_code', $js, 'js');
706
  if(!empty($js) && $js != false) {
707
 
708
  # try catch
709
+ $js = fvm_try_catch_wrap($js, $href);
710
 
711
  # developers filter
712
  $js = apply_filters( 'fvm_after_download_and_minify_code', $js, 'js');
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.7
7
  Tested up to: 5.6
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
@@ -55,6 +55,9 @@ Version 3.0 is a major code rewrite to improve JS and CSS merging, but it requir
55
 
56
  == Changelog ==
57
 
 
 
 
58
  = 3.0.7 [2021.01.02] =
59
  * Fixed incorrect paths on subdirectory sites (inside merged CSS files)
60
 
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.8
7
  Tested up to: 5.6
8
  Text Domain: fast-velocity-minify
9
  License: GPLv3 or later
55
 
56
  == Changelog ==
57
 
58
+ = 3.0.8 [2021.01.02] =
59
+ * Improved compatibility and better detection of dynamic CSS and JS files (files generated with PHP instead of being static)
60
+
61
  = 3.0.7 [2021.01.02] =
62
  * Fixed incorrect paths on subdirectory sites (inside merged CSS files)
63