Fast Velocity Minify - Version 2.4.7

Version Description

[2018.12.06] = * added better default options after new install * added option to preserve FVM settings on deactivation * added an HTML comment to the frontend with the path and notification, when FVM cannot generate the cache files (ie: wrong file permissions) * added a notification on wp-admin when FVM cannot generate the cache files due to wrong permissions * added an option to force "chmod 0777" on FVM cache files, to avoid errors on servers that need more than "chmod 0755" * improved the google fonts merging option when the enqueue is faulty (ie: incomplete google font urls ) * fixed the cache purge notifications not showing on wp-admin

Download this release

Release Info

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

Code changes from version 2.4.6 to 2.4.7

Files changed (3) hide show
  1. fvm.php +77 -22
  2. inc/functions.php +63 -42
  3. readme.txt +13 -4
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.6
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
@@ -184,6 +184,7 @@ if(is_admin()) {
184
  # activation, deactivation
185
  register_activation_hook( __FILE__, 'fastvelocity_plugin_activate' );
186
  register_deactivation_hook( __FILE__, 'fastvelocity_plugin_deactivate');
 
187
 
188
  } else {
189
 
@@ -337,6 +338,7 @@ function fastvelocity_min_load_admin_jscss($hook) {
337
  function fastvelocity_min_register_settings() {
338
  register_setting('fvm-group', 'fastvelocity_min_enable_purgemenu');
339
  register_setting('fvm-group', 'fastvelocity_min_preserve_oldcache');
 
340
  register_setting('fvm-group', 'fastvelocity_min_default_protocol');
341
  register_setting('fvm-group', 'fastvelocity_min_disable_js_merge');
342
  register_setting('fvm-group', 'fastvelocity_min_disable_css_merge');
@@ -365,6 +367,7 @@ function fastvelocity_min_register_settings() {
365
  register_setting('fvm-group', 'fastvelocity_min_fvm_cdn_force');
366
  register_setting('fvm-group', 'fastvelocity_min_change_cache_base_url');
367
  register_setting('fvm-group', 'fastvelocity_min_change_cache_path');
 
368
 
369
  # pro tab
370
  register_setting('fvm-group-pro', 'fastvelocity_min_ignore');
@@ -411,20 +414,19 @@ function fastvelocity_process_cache_purge_request(){
411
  if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.')); }
412
 
413
  # validate nonce
414
- if(isset($_GET['wordpress_fvmcache']) && (empty($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], 'fvm_clear_nonce'))) {
415
  wp_die( __('Invalid or expired request... please go back and refresh before trying again!'));
416
  }
417
 
418
  if(is_admin()) {
419
  fvm_purge_all(); # purge all
420
- fvm_purge_others(); # purge third party caches
421
  $others = fvm_purge_others(); # purge third party caches
422
  $notice = array('All caches from <strong>FVM</strong> have been purged!', strip_tags($others, '<strong>'));
423
  $notice = array_filter($notice);
424
  $notice = json_encode($notice); # encode
425
  set_transient( 'wordpress_fvmcache', $notice, 10);
426
  wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
427
- } else {
428
  fvm_purge_all(); # purge all
429
  fvm_purge_others(); # purge third party caches
430
  wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
@@ -433,8 +435,13 @@ function fastvelocity_process_cache_purge_request(){
433
  }
434
 
435
  # print admin notices after purging caches, if on wp-admin
436
- add_action( 'admin_notices', 'fastvelocity_admin_notices' );
437
- function fastvelocity_admin_notices() {
 
 
 
 
 
438
 
439
  # cache purge notices
440
  $inf = get_transient('wordpress_fvmcache');
@@ -443,9 +450,6 @@ function fastvelocity_admin_notices() {
443
  # decode to array or null
444
  $jsonarr = json_decode($inf, true);
445
  if(!is_null($jsonarr) && is_array($jsonarr)){
446
-
447
- # must be able to cleanup cache
448
- if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.')); }
449
 
450
  # print notices
451
  foreach ($jsonarr as $notice) {
@@ -459,6 +463,21 @@ function fastvelocity_admin_notices() {
459
  }
460
 
461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
 
463
 
464
  # manage settings page
@@ -499,7 +518,7 @@ $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'status';
499
  <li id="purgeall-row">
500
  <span class="filename">Purge FVM cache (<span id="fvm_cache_size"><?php echo fastvelocity_get_cachestats(); ?></span>)</span>
501
  <span class="actions">
502
- <form method="post" id="fastvelocity_min_clearall" action="<?php echo admin_url('options-general.php?page=fastvelocity-min&tab=status'); ?>">
503
  <input type="hidden" name="purgeall" value="1" />
504
  <?php submit_button('Delete', 'button-secondary', 'submit', false); ?>
505
  </form>
@@ -565,6 +584,11 @@ Admin Bar Purge <span class="note-info">[ If selected, a new option to purge FVM
565
  Preserve Cache Files <span class="note-info">[ This will reload your cache files when you purge, but preserve the old files ]</span></label>
566
  <br />
567
 
 
 
 
 
 
568
  <label for="fastvelocity_min_fvm_fix_editor">
569
  <input name="fastvelocity_min_fvm_fix_editor" type="checkbox" id="fastvelocity_min_fvm_fix_editor" value="1" <?php echo checked(1 == get_option('fastvelocity_min_fvm_fix_editor'), true, false); ?>>
570
  Fix Page Editors <span class="note-info">[ Will disable merging of JS and CSS for logged in users, to improve compatibility with visual editors ]</span></label>
@@ -705,7 +729,7 @@ Remove the "Print" related stylesheets <span class="note-info">[ If selected, CS
705
  <br />
706
  <label for="fastvelocity_min_force_inline_css_footer">
707
  <input name="fastvelocity_min_force_inline_css_footer" type="checkbox" id="fastvelocity_min_force_inline_css_footer" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css_footer'), true, false); ?>>
708
- Inline CSS in the footer <span class="note-info">[ If selected, any FVM generated CSS files in the footer, will be inlined ]</span></label>
709
  <br />
710
  <label for="fastvelocity_min_force_inline_css">
711
  <input name="fastvelocity_min_force_inline_css" type="checkbox" id="fastvelocity_min_force_inline_css" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css'), true, false); ?>>
@@ -788,20 +812,24 @@ Exclude JS files in the "ignore list" from PSI <span class="note-info">[ This on
788
  <tr>
789
  <th scope="row"><span class="fvm-label-special">Your CDN domain</span></th>
790
  <td><fieldset>
791
-
792
  <label for="fastvelocity_min_fvm_cdn_url">
793
  <p><input type="text" name="fastvelocity_min_fvm_cdn_url" id="fastvelocity_min_fvm_cdn_url" value="<?php echo get_option('fastvelocity_min_fvm_cdn_url', ''); ?>" size="80" /></p>
794
  <p class="description">[ Will rewrite the static assets urls inside FVM merged files to your cdn domain. Usage: cdn.example.com ]</p></label>
795
  </fieldset>
796
- <br />
 
797
 
 
 
 
 
 
798
  <label for="fastvelocity_min_fvm_cdn_force">
799
  <input name="fastvelocity_min_fvm_cdn_force" type="checkbox" id="fastvelocity_min_fvm_cdn_force" value="1" <?php echo checked(1 == get_option('fastvelocity_min_fvm_cdn_force'), true, false); ?>>
800
  I know what I'm doing... <span class="note-info">[ Load my JS files from the CDN, even when "defer for Pagespeed Insights" is enabled ]</span></label>
801
- <br />
802
-
803
- </td>
804
  </tr>
 
805
  </tbody></table>
806
 
807
  <div style="height: 20px;"></div>
@@ -816,17 +844,25 @@ I know what I'm doing... <span class="note-info">[ Load my JS files from the CDN
816
  <p><input type="text" name="fastvelocity_min_change_cache_path" id="fastvelocity_min_change_cache_path" value="<?php echo get_option('fastvelocity_min_change_cache_path', ''); ?>" size="80" /></p>
817
  <p class="description">[ Default cache path is: <?php echo rtrim(wp_upload_dir()['basedir'], '/'); ?> ]</p>
818
  </label>
819
- </fieldset></td>
820
- </tr>
821
- <tr>
822
- <th scope="row"><span class="fvm-label-special">Cache Base URL</span></th>
823
- <td><fieldset>
824
  <label for="fastvelocity_min_change_cache_base_url">
825
  <p><input type="text" name="fastvelocity_min_change_cache_base_url" id="fastvelocity_min_change_cache_base_url" value="<?php echo get_option('fastvelocity_min_change_cache_base_url', ''); ?>" size="80" /></p>
826
  <p class="description">[ Default cache base url is: <?php echo rtrim(fvm_get_protocol(wp_upload_dir()['baseurl']), '/'); ?> ]</p>
827
  </label>
828
  </fieldset></td>
829
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
830
  </tbody></table>
831
 
832
 
@@ -1338,6 +1374,11 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1338
  # enqueue file, if not empty
1339
  if(file_exists($file) && (filesize($file) > 0 || count($data) > 0)) {
1340
  wp_enqueue_script("fvm-header-$i");
 
 
 
 
 
1341
  }
1342
 
1343
  # other scripts need to be requeued for the order of files to be kept
@@ -1509,6 +1550,11 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1509
  # enqueue file, if not empty
1510
  if(file_exists($file) && (filesize($file) > 0 || count($data) > 0)) {
1511
  wp_enqueue_script("fvm-footer-$i");
 
 
 
 
 
1512
  }
1513
 
1514
  # other scripts need to be requeued for the order of files to be kept
@@ -1943,7 +1989,11 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1943
  # enqueue it
1944
  wp_enqueue_style("fvm-header-$i", $file_url, array(), null, $header[$i]['media']);
1945
  }
1946
-
 
 
 
 
1947
  }
1948
  }
1949
  }
@@ -2302,6 +2352,11 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
2302
  # enqueue it
2303
  wp_enqueue_style("fvm-footer-$i", $file_url, array(), null, $footer[$i]['media']);
2304
  }
 
 
 
 
 
2305
  }
2306
  }
2307
  }
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.7
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
184
  # activation, deactivation
185
  register_activation_hook( __FILE__, 'fastvelocity_plugin_activate' );
186
  register_deactivation_hook( __FILE__, 'fastvelocity_plugin_deactivate');
187
+ register_uninstall_hook( __FILE__, 'fastvelocity_plugin_uninstall');
188
 
189
  } else {
190
 
338
  function fastvelocity_min_register_settings() {
339
  register_setting('fvm-group', 'fastvelocity_min_enable_purgemenu');
340
  register_setting('fvm-group', 'fastvelocity_min_preserve_oldcache');
341
+ register_setting('fvm-group', 'fastvelocity_preserve_settings_on_uninstall');
342
  register_setting('fvm-group', 'fastvelocity_min_default_protocol');
343
  register_setting('fvm-group', 'fastvelocity_min_disable_js_merge');
344
  register_setting('fvm-group', 'fastvelocity_min_disable_css_merge');
367
  register_setting('fvm-group', 'fastvelocity_min_fvm_cdn_force');
368
  register_setting('fvm-group', 'fastvelocity_min_change_cache_base_url');
369
  register_setting('fvm-group', 'fastvelocity_min_change_cache_path');
370
+ register_setting('fvm-group', 'fastvelocity_force_chmodmax');
371
 
372
  # pro tab
373
  register_setting('fvm-group-pro', 'fastvelocity_min_ignore');
414
  if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.')); }
415
 
416
  # validate nonce
417
+ if(empty($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], 'fvm_clear_nonce')) {
418
  wp_die( __('Invalid or expired request... please go back and refresh before trying again!'));
419
  }
420
 
421
  if(is_admin()) {
422
  fvm_purge_all(); # purge all
 
423
  $others = fvm_purge_others(); # purge third party caches
424
  $notice = array('All caches from <strong>FVM</strong> have been purged!', strip_tags($others, '<strong>'));
425
  $notice = array_filter($notice);
426
  $notice = json_encode($notice); # encode
427
  set_transient( 'wordpress_fvmcache', $notice, 10);
428
  wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
429
+ } else {
430
  fvm_purge_all(); # purge all
431
  fvm_purge_others(); # purge third party caches
432
  wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
435
  }
436
 
437
  # print admin notices after purging caches, if on wp-admin
438
+ add_action( 'admin_notices', 'fastvelocity_cachepurge_admin_notices' );
439
+ function fastvelocity_cachepurge_admin_notices() {
440
+
441
+ # skip on submit
442
+ if((isset($_POST['purgeall']) && $_POST['purgeall'] == 1) || isset($_GET['_fvmcache'])) {
443
+ return true;
444
+ }
445
 
446
  # cache purge notices
447
  $inf = get_transient('wordpress_fvmcache');
450
  # decode to array or null
451
  $jsonarr = json_decode($inf, true);
452
  if(!is_null($jsonarr) && is_array($jsonarr)){
 
 
 
453
 
454
  # print notices
455
  foreach ($jsonarr as $notice) {
463
  }
464
 
465
 
466
+ # print admin notices if we don't have enough file permissions to write
467
+ add_action( 'admin_notices', 'fastvelocity_check_permissions_admin_notices' );
468
+ function fastvelocity_check_permissions_admin_notices() {
469
+
470
+ # get cache path
471
+ $cachepath = fvm_cachepath();
472
+ $cachebase = $cachepath['cachebase'];
473
+ if(is_dir($cachebase) && !is_writable($cachebase)) {
474
+ $chmod = substr(sprintf('%o', fileperms($cachebase)), -4);
475
+ echo __('<div class="notice notice-error is-dismissible"><p>FVM needs writting permissions on '.$cachebase.'</p></div>');
476
+ echo __('<div class="notice notice-error is-dismissible"><p>The current permissions for FVM are chmod '.$chmod.'</p></div>');
477
+ echo __('<div class="notice notice-error is-dismissible"><p>If you need something higher than 755 for it to work, your server is probaly misconfigured. Please contact your hosting provider or check the help section for other providers.</p></div>');
478
+ }
479
+
480
+ }
481
 
482
 
483
  # manage settings page
518
  <li id="purgeall-row">
519
  <span class="filename">Purge FVM cache (<span id="fvm_cache_size"><?php echo fastvelocity_get_cachestats(); ?></span>)</span>
520
  <span class="actions">
521
+ <form method="post" id="fastvelocity_min_clearall" action="<?php echo wp_nonce_url( add_query_arg('_fvmcache', 'clear'), 'fvm_clear_nonce'); ?>">
522
  <input type="hidden" name="purgeall" value="1" />
523
  <?php submit_button('Delete', 'button-secondary', 'submit', false); ?>
524
  </form>
584
  Preserve Cache Files <span class="note-info">[ This will reload your cache files when you purge, but preserve the old files ]</span></label>
585
  <br />
586
 
587
+ <label for="fastvelocity_preserve_settings_on_uninstall">
588
+ <input name="fastvelocity_preserve_settings_on_uninstall" type="checkbox" id="fastvelocity_preserve_settings_on_uninstall" value="1" <?php echo checked(1 == get_option('fastvelocity_preserve_settings_on_uninstall'), true, false); ?>>
589
+ Preserve Settings<span class="note-info">[ If selected, all FVM settings will be preserved, even if you uninstall the plugin ]</span></label>
590
+ <br />
591
+
592
  <label for="fastvelocity_min_fvm_fix_editor">
593
  <input name="fastvelocity_min_fvm_fix_editor" type="checkbox" id="fastvelocity_min_fvm_fix_editor" value="1" <?php echo checked(1 == get_option('fastvelocity_min_fvm_fix_editor'), true, false); ?>>
594
  Fix Page Editors <span class="note-info">[ Will disable merging of JS and CSS for logged in users, to improve compatibility with visual editors ]</span></label>
729
  <br />
730
  <label for="fastvelocity_min_force_inline_css_footer">
731
  <input name="fastvelocity_min_force_inline_css_footer" type="checkbox" id="fastvelocity_min_force_inline_css_footer" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css_footer'), true, false); ?>>
732
+ Inline only the CSS in the footer <span class="note-info">[ If selected, any FVM generated CSS files in the footer, will be inlined ]</span></label>
733
  <br />
734
  <label for="fastvelocity_min_force_inline_css">
735
  <input name="fastvelocity_min_force_inline_css" type="checkbox" id="fastvelocity_min_force_inline_css" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css'), true, false); ?>>
812
  <tr>
813
  <th scope="row"><span class="fvm-label-special">Your CDN domain</span></th>
814
  <td><fieldset>
 
815
  <label for="fastvelocity_min_fvm_cdn_url">
816
  <p><input type="text" name="fastvelocity_min_fvm_cdn_url" id="fastvelocity_min_fvm_cdn_url" value="<?php echo get_option('fastvelocity_min_fvm_cdn_url', ''); ?>" size="80" /></p>
817
  <p class="description">[ Will rewrite the static assets urls inside FVM merged files to your cdn domain. Usage: cdn.example.com ]</p></label>
818
  </fieldset>
819
+ </td>
820
+ </tr>
821
 
822
+ <tr>
823
+ <th scope="row">Force the CDN Usage</th>
824
+ <td>
825
+ <p class="fvm-bold-green fvm-rowintro">If you force this, your JS files may not load for certain slow internet users on Google Chrome.</p>
826
+ <fieldset>
827
  <label for="fastvelocity_min_fvm_cdn_force">
828
  <input name="fastvelocity_min_fvm_cdn_force" type="checkbox" id="fastvelocity_min_fvm_cdn_force" value="1" <?php echo checked(1 == get_option('fastvelocity_min_fvm_cdn_force'), true, false); ?>>
829
  I know what I'm doing... <span class="note-info">[ Load my JS files from the CDN, even when "defer for Pagespeed Insights" is enabled ]</span></label>
830
+ </fieldset></td>
 
 
831
  </tr>
832
+
833
  </tbody></table>
834
 
835
  <div style="height: 20px;"></div>
844
  <p><input type="text" name="fastvelocity_min_change_cache_path" id="fastvelocity_min_change_cache_path" value="<?php echo get_option('fastvelocity_min_change_cache_path', ''); ?>" size="80" /></p>
845
  <p class="description">[ Default cache path is: <?php echo rtrim(wp_upload_dir()['basedir'], '/'); ?> ]</p>
846
  </label>
847
+ <br />
 
 
 
 
848
  <label for="fastvelocity_min_change_cache_base_url">
849
  <p><input type="text" name="fastvelocity_min_change_cache_base_url" id="fastvelocity_min_change_cache_base_url" value="<?php echo get_option('fastvelocity_min_change_cache_base_url', ''); ?>" size="80" /></p>
850
  <p class="description">[ Default cache base url is: <?php echo rtrim(fvm_get_protocol(wp_upload_dir()['baseurl']), '/'); ?> ]</p>
851
  </label>
852
  </fieldset></td>
853
  </tr>
854
+
855
+ <tr>
856
+ <th scope="row">File Permissions</th>
857
+ <td>
858
+ <p class="fvm-bold-green fvm-rowintro">You should never need to tick this box, unless your server is misconfigured and FVM files are not being generated.</p>
859
+ <fieldset>
860
+ <label for="fastvelocity_force_chmodmax">
861
+ <input name="fastvelocity_force_chmodmax" type="checkbox" id="fastvelocity_force_chmodmax" value="1" <?php echo checked(1 == get_option('fastvelocity_force_chmodmax'), true, false); ?>>
862
+ Use chmod 0777 <span class="note-info">[ Some servers, need higher file permissions instead of the default chmod 0755 ]</span></label>
863
+ </fieldset></td>
864
+ </tr>
865
+
866
  </tbody></table>
867
 
868
 
1374
  # enqueue file, if not empty
1375
  if(file_exists($file) && (filesize($file) > 0 || count($data) > 0)) {
1376
  wp_enqueue_script("fvm-header-$i");
1377
+ } else {
1378
+ # file could not be generated, output something meaningful
1379
+ echo "<!-- ERROR: FVM was not allowed to save it's cache on - $file -->";
1380
+ echo "<!-- Please check if the path above is correct and ensure your server has writting permission there! -->";
1381
+ echo "<!-- If you found a bug, please report this on https://wordpress.org/support/plugin/fast-velocity-minify/ -->";
1382
  }
1383
 
1384
  # other scripts need to be requeued for the order of files to be kept
1550
  # enqueue file, if not empty
1551
  if(file_exists($file) && (filesize($file) > 0 || count($data) > 0)) {
1552
  wp_enqueue_script("fvm-footer-$i");
1553
+ } else {
1554
+ # file could not be generated, output something meaningful
1555
+ echo "<!-- ERROR: FVM was not allowed to save it's cache on - $file -->";
1556
+ echo "<!-- Please check if the path above is correct and ensure your server has writting permission there! -->";
1557
+ echo "<!-- If you found a bug, please report this on https://wordpress.org/support/plugin/fast-velocity-minify/ -->";
1558
  }
1559
 
1560
  # other scripts need to be requeued for the order of files to be kept
1989
  # enqueue it
1990
  wp_enqueue_style("fvm-header-$i", $file_url, array(), null, $header[$i]['media']);
1991
  }
1992
+ } else {
1993
+ # file could not be generated, output something meaningful
1994
+ echo "<!-- ERROR: FVM was not allowed to save it's cache on - $file -->";
1995
+ echo "<!-- Please check if the path above is correct and ensure your server has writting permission there! -->";
1996
+ echo "<!-- If you found a bug, please report this on https://wordpress.org/support/plugin/fast-velocity-minify/ -->";
1997
  }
1998
  }
1999
  }
2352
  # enqueue it
2353
  wp_enqueue_style("fvm-footer-$i", $file_url, array(), null, $footer[$i]['media']);
2354
  }
2355
+ } else {
2356
+ # file could not be generated, output something meaningful
2357
+ echo "<!-- ERROR: FVM was not allowed to save it's cache on - $file -->";
2358
+ echo "<!-- Please check if the path above is correct and ensure your server has writting permission there! -->";
2359
+ echo "<!-- If you found a bug, please report this on https://wordpress.org/support/plugin/fast-velocity-minify/ -->";
2360
  }
2361
  }
2362
  }
inc/functions.php CHANGED
@@ -43,10 +43,15 @@ $cachedir = rtrim($upload['basedir'], '/').'/fvm/out';
43
  $tmpdir = rtrim($upload['basedir'], '/').'/fvm/tmp';
44
  $cachedirurl = rtrim($upload['baseurl'], '/').'/fvm/out';
45
  $headerdir = rtrim($upload['basedir'], '/').'/fvm/header';
46
- if(!is_dir($cachebase)) { mkdir($cachebase, 0755, true); }
47
- if(!is_dir($cachedir)) { mkdir($cachedir, 0755, true); }
48
- if(!is_dir($tmpdir)) { mkdir($tmpdir, 0755, true); }
49
- if(!is_dir($headerdir)) { mkdir($headerdir, 0755, true); }
 
 
 
 
 
50
 
51
  # return
52
  return array('cachebase'=>$cachebase,'tmpdir'=>$tmpdir, 'cachedir'=>$cachedir, 'cachedirurl'=>$cachedirurl, 'headerdir'=>$headerdir);
@@ -56,37 +61,49 @@ return array('cachebase'=>$cachebase,'tmpdir'=>$tmpdir, 'cachedir'=>$cachedir, '
56
  # run during activation
57
  function fastvelocity_plugin_activate() {
58
 
59
- # default options to enable
60
- $options_enable_default = array('fastvelocity_min_fvm_fix_editor', 'fastvelocity_min_remove_print_mediatypes', 'fastvelocity_fvm_clean_header_one', 'fastvelocity_gfonts_method');
61
- foreach($options_enable_default as $option) {
62
- update_option($option, 1, 'yes');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
-
65
- # increment time
66
- fvm_cache_increment();
67
-
68
- # default blacklist
69
- $exc = array('/html5shiv.js', '/html5shiv-printshiv.min.js', '/excanvas.js', '/avada-ie9.js', '/respond.js', '/respond.min.js', '/selectivizr.js', '/Avada/assets/css/ie.css', '/html5.js', '/IE9.js', '/fusion-ie9.js', '/vc_lte_ie9.min.css', '/old-ie.css', '/ie.css', '/vc-ie8.min.css', '/mailchimp-for-wp/assets/js/third-party/placeholders.min.js', '/assets/js/plugins/wp-enqueue/min/webfontloader.js', '/a.optnmstr.com/app/js/api.min.js', '/pixelyoursite/js/public.js', '/assets/js/wcdrip-drip.js');
70
- update_option('fastvelocity_min_blacklist', implode(PHP_EOL, $exc));
71
-
72
- # default ignore list
73
- $exc = array('/Avada/assets/js/main.min.js', '/woocommerce-product-search/js/product-search.js', '/includes/builder/scripts/frontend-builder-scripts.js', '/assets/js/jquery.themepunch.tools.min.js', '/js/TweenMax.min.js', '/jupiter/assets/js/min/full-scripts', '/wp-content/themes/Divi/core/admin/js/react-dom.production.min.js');
74
- update_option('fastvelocity_min_ignorelist', implode(PHP_EOL, $exc));
75
-
76
  }
77
 
78
  # run during deactivation
79
  function fastvelocity_plugin_deactivate() {
 
 
 
 
 
 
80
  global $wpdb;
81
 
82
- # delete all fvm options
83
- $plugin_options = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'fastvelocity_%' OR option_name LIKE 'fvm-%'" );
84
- if(is_array($plugin_options) && count($plugin_options) > 0) {
85
- foreach( $plugin_options as $option ) { delete_option( $option->option_name ); }
86
- }
87
 
88
- # purge cache
89
- fvm_purge_all();
 
 
 
 
 
90
  }
91
 
92
 
@@ -575,22 +592,26 @@ function fastvelocity_min_concatenate_google_fonts($array) {
575
  # extract unique font families
576
  $families = array();
577
  foreach ($array as $font) {
578
-
579
- # get fonts name, type and subset, remove wp query strings
580
- $font = explode('family=', htmlspecialchars_decode(rawurldecode(urldecode($font))));
581
- $a = explode('&v', end($font));
582
- $font = trim(trim(trim(current($a)), ','));
583
-
584
- # reprocess if fonts are already concatenated in this url
585
- if(stristr($font, '|') !== FALSE) {
586
- $multiple = explode('|', $font);
587
- if (count($multiple) > 0) {
588
- foreach ($multiple as $f) {
589
- $families[] = trim($f);
590
- }
 
 
 
 
 
 
591
  }
592
- } else {
593
- $families[] = $font;
594
  }
595
  }
596
 
43
  $tmpdir = rtrim($upload['basedir'], '/').'/fvm/tmp';
44
  $cachedirurl = rtrim($upload['baseurl'], '/').'/fvm/out';
45
  $headerdir = rtrim($upload['basedir'], '/').'/fvm/header';
46
+
47
+ # chmod level
48
+ if(get_option('fastvelocity_force_chmodmax') != false) { $chmod = 0777; } else { $chmod = 0755; }
49
+
50
+ # create and chmod accordingly
51
+ if(!is_dir($cachebase)) { mkdir($cachebase, $chmod, true); }
52
+ if(!is_dir($cachedir)) { mkdir($cachedir, $chmod, true); }
53
+ if(!is_dir($tmpdir)) { mkdir($tmpdir, $chmod, true); }
54
+ if(!is_dir($headerdir)) { mkdir($headerdir, $chmod, true); }
55
 
56
  # return
57
  return array('cachebase'=>$cachebase,'tmpdir'=>$tmpdir, 'cachedir'=>$cachedir, 'cachedirurl'=>$cachedirurl, 'headerdir'=>$headerdir);
61
  # run during activation
62
  function fastvelocity_plugin_activate() {
63
 
64
+ # setup defaults if no option to preserve exists
65
+ if(get_option('fastvelocity_preserve_settings_on_uninstall') == false) {
66
+
67
+ # increment time
68
+ fvm_cache_increment();
69
+
70
+ # default options to enable
71
+ $options_enable_default = array('fastvelocity_min_remove_print_mediatypes', 'fastvelocity_fvm_clean_header_one', 'fastvelocity_gfonts_method', 'fastvelocity_min_force_inline_css_footer');
72
+ foreach($options_enable_default as $option) {
73
+ update_option($option, 1, 'yes');
74
+ }
75
+
76
+ # default blacklist
77
+ $exc = array('/html5shiv.js', '/html5shiv-printshiv.min.js', '/excanvas.js', '/avada-ie9.js', '/respond.js', '/respond.min.js', '/selectivizr.js', '/Avada/assets/css/ie.css', '/html5.js', '/IE9.js', '/fusion-ie9.js', '/vc_lte_ie9.min.css', '/old-ie.css', '/ie.css', '/vc-ie8.min.css', '/mailchimp-for-wp/assets/js/third-party/placeholders.min.js', '/assets/js/plugins/wp-enqueue/min/webfontloader.js', '/a.optnmstr.com/app/js/api.min.js', '/pixelyoursite/js/public.js', '/assets/js/wcdrip-drip.js');
78
+ update_option('fastvelocity_min_blacklist', implode(PHP_EOL, $exc));
79
+
80
+ # default ignore list
81
+ $exc = array('/Avada/assets/js/main.min.js', '/woocommerce-product-search/js/product-search.js', '/includes/builder/scripts/frontend-builder-scripts.js', '/assets/js/jquery.themepunch.tools.min.js', '/js/TweenMax.min.js', '/jupiter/assets/js/min/full-scripts', '/wp-content/themes/Divi/core/admin/js/react-dom.production.min.js');
82
+ update_option('fastvelocity_min_ignorelist', implode(PHP_EOL, $exc));
83
+
84
  }
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  # run during deactivation
88
  function fastvelocity_plugin_deactivate() {
89
+ fvm_purge_all();
90
+ fvm_purge_others();
91
+ }
92
+
93
+ # run during uninstall
94
+ function fastvelocity_plugin_uninstall() {
95
  global $wpdb;
96
 
97
+ # remove defaults if no option to preserve exists
98
+ if(get_option('fastvelocity_preserve_settings_on_uninstall') == false) {
 
 
 
99
 
100
+ # delete all fvm options
101
+ $plugin_options = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'fastvelocity_%' OR option_name LIKE 'fvm-%'" );
102
+ if(is_array($plugin_options) && count($plugin_options) > 0) {
103
+ foreach( $plugin_options as $option ) { delete_option( $option->option_name ); }
104
+ }
105
+
106
+ }
107
  }
108
 
109
 
592
  # extract unique font families
593
  $families = array();
594
  foreach ($array as $font) {
595
+
596
+ # must have
597
+ if (stripos($font, 'family=') !== false) {
598
+
599
+ # get fonts name, type and subset, remove wp query strings
600
+ $font = explode('family=', htmlspecialchars_decode(rawurldecode(urldecode($font))));
601
+ $a = explode('&v', end($font));
602
+ $font = trim(trim(trim(current($a)), ','));
603
+
604
+ # reprocess if fonts are already concatenated in this url
605
+ if(stristr($font, '|') !== FALSE) {
606
+ $multiple = explode('|', $font);
607
+ if (count($multiple) > 0) {
608
+ foreach ($multiple as $f) {
609
+ $families[] = trim($f);
610
+ }
611
+ }
612
+ } else {
613
+ $families[] = $font;
614
  }
 
 
615
  }
616
  }
617
 
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.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,15 +202,24 @@ If you would like to donate any amount to the plugin author (thank you in advanc
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)
212
 
213
- = 2.4.4 [2018.12.03]
214
  * added option to inline CSS in the footer, while still preserving the merged file in the header
215
  * improvements for the google fonts merging option
216
  * fixed double notification, when purging caches without a cache plugin
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.7
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.7 [2018.12.06] =
206
+ * added better default options after new install
207
+ * added option to preserve FVM settings on deactivation
208
+ * added an HTML comment to the frontend with the path and notification, when FVM cannot generate the cache files (ie: wrong file permissions)
209
+ * added a notification on wp-admin when FVM cannot generate the cache files due to wrong permissions
210
+ * added an option to force "chmod 0777" on FVM cache files, to avoid errors on servers that need more than "chmod 0755"
211
+ * improved the google fonts merging option when the enqueue is faulty (ie: incomplete google font urls )
212
+ * fixed the cache purge notifications not showing on wp-admin
213
+
214
+ = 2.4.6 [2018.12.05] =
215
  * fixed a bug that could cause an error 500 if an enqueued CSS or JS file was not found
216
  * added brotli_static support, if you have the php-ext-brotli extension installed - https://github.com/kjdev/php-ext-brotli
217
 
218
+ = 2.4.5 [2018.12.04] =
219
  * fixed a bug, where it may show a warning during cache purge on wp-admin
220
  * exclude footer FVM generated files from the HTTP header preload option (footer files are not in the critical path)
221
 
222
+ = 2.4.4 [2018.12.03] =
223
  * added option to inline CSS in the footer, while still preserving the merged file in the header
224
  * improvements for the google fonts merging option
225
  * fixed double notification, when purging caches without a cache plugin