Fast Velocity Minify - Version 2.4.6

Version Description

[2018.12.05] * fixed a bug that could cause an error 500 if an enqueued CSS or JS file was not found * added brotli_static support, if you have the php-ext-brotli extension installed - https://github.com/kjdev/php-ext-brotli

Download this release

Release Info

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

Code changes from version 2.4.5 to 2.4.6

Files changed (3) hide show
  1. fvm.php +23 -5
  2. inc/functions.php +13 -8
  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.4.5
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
@@ -871,7 +871,7 @@ I know what I'm doing... <span class="note-info">[ Load my JS files from the CDN
871
  <p>
872
  <textarea name="fastvelocity_min_merge_allowed_urls" rows="7" cols="50" id="fastvelocity_min_merge_allowed_urls" class="large-text code" placeholder="ex: example.com"><?php echo get_option('fastvelocity_min_merge_allowed_urls'); ?></textarea>
873
  </p>
874
- <p class="description">[ Add any external "domains" for JS or CSS files than can be merged fetched and merged together by FVM, ie: example.com ]</p>
875
  </fieldset></td>
876
  </tr>
877
  </tbody></table>
@@ -1318,6 +1318,11 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1318
  file_put_contents($file.'.txt', $log);
1319
  file_put_contents($file, $code);
1320
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
 
 
 
 
 
1321
  }
1322
 
1323
  # register minified file
@@ -1419,7 +1424,7 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1419
  # static cache file info + done
1420
  $done = array_merge($done, $footer[$i]['handles']);
1421
  $hash = 'footer-'.hash('adler32',implode('',$footer[$i]['handles']));
1422
-
1423
  # create cache files and urls
1424
  $file = $cachedir.'/'.$hash.'-'.$ctime.'.min.js';
1425
  $file_url = fvm_get_protocol($cachedirurl.'/'.$hash.'-'.$ctime.'.min.js');
@@ -1484,6 +1489,11 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1484
  file_put_contents($file.'.txt', $log);
1485
  file_put_contents($file, $code);
1486
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
 
 
 
 
 
1487
  }
1488
 
1489
  # register minified file
@@ -1903,7 +1913,11 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1903
  file_put_contents($file.'.txt', $log);
1904
  file_put_contents($file, $code);
1905
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1906
-
 
 
 
 
1907
  }
1908
 
1909
  # register and enqueue minified file, consider excluding of mediatype "print" and inline css
@@ -2258,7 +2272,11 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
2258
  file_put_contents($file.'.txt', $log);
2259
  file_put_contents($file, $code); # preserve style tags
2260
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
2261
-
 
 
 
 
2262
  }
2263
 
2264
  # register and enqueue minified file, consider excluding of mediatype "print" and inline css
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.4.6
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
871
  <p>
872
  <textarea name="fastvelocity_min_merge_allowed_urls" rows="7" cols="50" id="fastvelocity_min_merge_allowed_urls" class="large-text code" placeholder="ex: example.com"><?php echo get_option('fastvelocity_min_merge_allowed_urls'); ?></textarea>
873
  </p>
874
+ <p class="description">[ Add any external "domains" for JS or CSS files than can be merged fetched and merged together by FVM, ie: cdnjs.cloudflare.com ]</p>
875
  </fieldset></td>
876
  </tr>
877
  </tbody></table>
1318
  file_put_contents($file.'.txt', $log);
1319
  file_put_contents($file, $code);
1320
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1321
+
1322
+ # brotli static support
1323
+ if(function_exists('brotli_compress')) {
1324
+ file_put_contents($file.'.br', brotli_compress(file_get_contents($file), 9));
1325
+ }
1326
  }
1327
 
1328
  # register minified file
1424
  # static cache file info + done
1425
  $done = array_merge($done, $footer[$i]['handles']);
1426
  $hash = 'footer-'.hash('adler32',implode('',$footer[$i]['handles']));
1427
+
1428
  # create cache files and urls
1429
  $file = $cachedir.'/'.$hash.'-'.$ctime.'.min.js';
1430
  $file_url = fvm_get_protocol($cachedirurl.'/'.$hash.'-'.$ctime.'.min.js');
1489
  file_put_contents($file.'.txt', $log);
1490
  file_put_contents($file, $code);
1491
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1492
+
1493
+ # brotli static support
1494
+ if(function_exists('brotli_compress')) {
1495
+ file_put_contents($file.'.br', brotli_compress(file_get_contents($file), 9));
1496
+ }
1497
  }
1498
 
1499
  # register minified file
1913
  file_put_contents($file.'.txt', $log);
1914
  file_put_contents($file, $code);
1915
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1916
+
1917
+ # brotli static support
1918
+ if(function_exists('brotli_compress')) {
1919
+ file_put_contents($file.'.br', brotli_compress(file_get_contents($file), 9));
1920
+ }
1921
  }
1922
 
1923
  # register and enqueue minified file, consider excluding of mediatype "print" and inline css
2272
  file_put_contents($file.'.txt', $log);
2273
  file_put_contents($file, $code); # preserve style tags
2274
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
2275
+
2276
+ # brotli static support
2277
+ if(function_exists('brotli_compress')) {
2278
+ file_put_contents($file.'.br', brotli_compress(file_get_contents($file), 9));
2279
+ }
2280
  }
2281
 
2282
  # register and enqueue minified file, consider excluding of mediatype "print" and inline css
inc/functions.php CHANGED
@@ -412,8 +412,8 @@ function fvm_file_get_contents_curl($url, $uagent=NULL) {
412
  curl_setopt($ch, CURLOPT_TIMEOUT, 15);
413
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
414
  $data = curl_exec($ch);
415
- curl_close($ch);
416
- return $data;
417
  }
418
 
419
 
@@ -907,7 +907,7 @@ function fastvelocity_ie_blacklist($url) {
907
  }
908
 
909
 
910
- # download function with cache support and fallback
911
  function fastvelocity_download($url) {
912
 
913
  # info (needed for google fonts woff files + hinted fonts) as well as to bypass some security filters
@@ -916,18 +916,23 @@ function fastvelocity_download($url) {
916
  # fetch via wordpress functions
917
  $response = wp_remote_get($url, array('user-agent'=>$uagent, 'timeout' => 7, 'httpversion' => '1.1', 'sslverify'=>false));
918
  $res_code = wp_remote_retrieve_response_code($response);
919
- if($res_code == '200') {
920
  $data = wp_remote_retrieve_body($response);
921
  if(strlen($data) > 1) {
922
- return $data;
923
  }
924
- }
 
 
 
 
 
925
 
926
  # fallback, let's try curl if available
927
  if(function_exists('curl_version')) {
928
  $curl = fvm_file_get_contents_curl($url, $uagent);
929
- if(!empty($curl) && strlen($curl) > 1) {
930
- return $data;
931
  }
932
  }
933
 
412
  curl_setopt($ch, CURLOPT_TIMEOUT, 15);
413
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
414
  $data = curl_exec($ch);
415
+ curl_close($ch);
416
+ return $data;
417
  }
418
 
419
 
907
  }
908
 
909
 
910
+ # download function with fallback
911
  function fastvelocity_download($url) {
912
 
913
  # info (needed for google fonts woff files + hinted fonts) as well as to bypass some security filters
916
  # fetch via wordpress functions
917
  $response = wp_remote_get($url, array('user-agent'=>$uagent, 'timeout' => 7, 'httpversion' => '1.1', 'sslverify'=>false));
918
  $res_code = wp_remote_retrieve_response_code($response);
919
+ if($res_code == '200') {
920
  $data = wp_remote_retrieve_body($response);
921
  if(strlen($data) > 1) {
922
+ return $data;
923
  }
924
+ }
925
+
926
+ # stop here, error 4xx or 5xx
927
+ if($res_code[0] == '4' || $res_code[0] == '5') {
928
+ return false;
929
+ }
930
 
931
  # fallback, let's try curl if available
932
  if(function_exists('curl_version')) {
933
  $curl = fvm_file_get_contents_curl($url, $uagent);
934
+ if($curl !== false && !empty($curl) && strlen($curl) > 1) {
935
+ return $curl;
936
  }
937
  }
938
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  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
- Stable tag: 2.4.5
6
  Tested up to: 5.0
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -202,6 +202,10 @@ If you would like to donate any amount to the plugin author (thank you in advanc
202
 
203
  == Changelog ==
204
 
 
 
 
 
205
  = 2.4.5 [2018.12.04]
206
  * fixed a bug, where it may show a warning during cache purge on wp-admin
207
  * exclude footer FVM generated files from the HTTP header preload option (footer files are not in the critical path)
2
  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
+ Stable tag: 2.4.6
6
  Tested up to: 5.0
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
202
 
203
  == Changelog ==
204
 
205
+ = 2.4.6 [2018.12.05]
206
+ * fixed a bug that could cause an error 500 if an enqueued CSS or JS file was not found
207
+ * added brotli_static support, if you have the php-ext-brotli extension installed - https://github.com/kjdev/php-ext-brotli
208
+
209
  = 2.4.5 [2018.12.04]
210
  * fixed a bug, where it may show a warning during cache purge on wp-admin
211
  * exclude footer FVM generated files from the HTTP header preload option (footer files are not in the critical path)