Fast Velocity Minify - Version 2.2.3

Version Description

[2017.12.17] = * added robots.txt and ajax requests to the exclusion list * added some cdn fixes * added a new Pro tab * added a global critical path css section * added an option to dequeue all css files * added an option to load CSS Async with LoadCSS (experimental) * added an option to merge external resources together * added the possibility to manage the default ignore list (reported files that cause conflicts when merged) * added the possibility to manage the blacklist (files that cannot be merged with normal files) * added better descriptions and labels for some options

Download this release

Release Info

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

Code changes from version 2.2.2 to 2.2.3

Files changed (4) hide show
  1. fvm.php +67 -216
  2. inc/functions-admin.php +6 -5
  3. inc/functions.php +25 -26
  4. readme.txt +14 -2
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.2.2
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
@@ -119,14 +119,10 @@ $exclude_defer_login = get_option('fastvelocity_min_exclude_defer_login');
119
  $preload = array_map('trim', explode("\n", get_option('fastvelocity_min_preload')));
120
  $preconnect = array_map('trim', explode("\n", get_option('fastvelocity_min_preconnect')));
121
  $fvm_fix_editor = get_option('fastvelocity_min_fvm_fix_editor');
122
- $send_css_to_footer = get_option('fastvelocity_min_send_css_to_footer');
123
- $critical_css_tester = get_option('fastvelocity_min_critical_css_tester');
124
- $critical_css_path_visibility = get_option('fastvelocity_min_critical_path_visibility');
125
  $critical_path_css = get_option('fastvelocity_min_critical_path_css');
126
- $generate_gulp_files = get_option('fastvelocity_min_generate_gulp_files');
127
- $generate_gulp_path = get_option('fastvelocity_min_generate_gulp_path');
128
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
129
- $fvm_remove_css = get_option('fastvelocity_min_fvm_removecss');
130
 
131
 
132
  # default options
@@ -177,7 +173,7 @@ if(is_admin()) {
177
  add_action( 'plugins_loaded', 'fastvelocity_fix_editor' );
178
  function fastvelocity_fix_editor() {
179
  global $fvm_fix_editor, $disable_js_merge, $disable_css_merge, $skip_emoji_removal;
180
- if($fvm_fix_editor == true && is_user_logged_in() && (current_user_can('editor') || current_user_can('administrator'))) {
181
  if(!$disable_js_merge) {
182
  remove_action( 'wp_print_scripts', 'fastvelocity_min_merge_header_scripts', PHP_INT_MAX );
183
  remove_action( 'wp_print_footer_scripts', 'fastvelocity_min_merge_footer_scripts', 9.999999 );
@@ -279,17 +275,12 @@ function fastvelocity_min_register_settings() {
279
  register_setting('fvm-group', 'fastvelocity_min_fvm_cdn_url');
280
 
281
  # pro version (for private usage... or if you know what you're doing)
282
- register_setting('fvm-group-pro', 'fastvelocity_min_send_css_to_footer');
283
- register_setting('fvm-group-pro', 'fastvelocity_min_critical_path_visibility');
284
- register_setting('fvm-group-pro', 'fastvelocity_min_critical_css_tester');
285
  register_setting('fvm-group-pro', 'fastvelocity_min_critical_path_css');
286
- register_setting('fvm-group-pro', 'fastvelocity_min_generate_gulp_files');
287
- register_setting('fvm-group-pro', 'fastvelocity_min_generate_gulp_path');
288
  register_setting('fvm-group-pro', 'fastvelocity_min_ignorelist');
289
  register_setting('fvm-group-pro', 'fastvelocity_min_blacklist');
290
  register_setting('fvm-group-pro', 'fastvelocity_min_merge_allowed_urls');
291
- register_setting('fvm-group-pro', 'fastvelocity_min_fvm_removecss');
292
- register_setting('fvm-group-license', 'fastvelocity_min_license_code');
293
  }
294
 
295
 
@@ -333,15 +324,7 @@ echo fastvelocity_purge_others(); # purge third party caches
333
  <h2 class="nav-tab-wrapper wp-clearfix">
334
  <a href="?page=fastvelocity-min&tab=status" class="nav-tab <?php echo $active_tab == 'status' ? 'nav-tab-active' : ''; ?>">Status</a>
335
  <a href="?page=fastvelocity-min&tab=settings" class="nav-tab <?php echo $active_tab == 'settings' ? 'nav-tab-active' : ''; ?>">Settings</a>
336
- <?php
337
- # this is still under development
338
- $fvm_license = get_option('fastvelocity_min_license_code');
339
- if($fvm_license != false && mb_strlen($fvm_license, 'UTF-8') == 32) {
340
- ?>
341
- <a href="?page=fastvelocity-min&tab=pro" class="nav-tab <?php echo $active_tab == 'pro' ? 'nav-tab-active' : ''; ?>">Extra</a>
342
- <?php
343
- }
344
- ?>
345
  <a href="?page=fastvelocity-min&tab=server" class="nav-tab <?php echo $active_tab == 'server' ? 'nav-tab-active' : ''; ?>">Server Info</a>
346
  <a href="?page=fastvelocity-min&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
347
  </h2>
@@ -355,11 +338,11 @@ if($fvm_license != false && mb_strlen($fvm_license, 'UTF-8') == 32) {
355
  <div class="meta-box">
356
 
357
  <div class="postbox" id="tab-purge">
358
- <h3 class="hndle"><span>Purge processed files</span></h3>
359
  <div class="inside" id="fastvelocity_min_topbtns">
360
  <ul class="processed">
361
  <li id="purgeall-row">
362
- <span class="filename">Purge processed CSS and JS files</span>
363
  <span class="actions">
364
  <form method="post" id="fastvelocity_min_clearall" action="<?php echo admin_url('options-general.php?page=fastvelocity-min&tab=status'); ?>">
365
  <input type="hidden" name="purgeall" value="1" />
@@ -394,6 +377,7 @@ if($fvm_license != false && mb_strlen($fvm_license, 'UTF-8') == 32) {
394
  <form method="post" action="options.php">
395
  <?php settings_fields('fvm-group'); do_settings_sections('fvm-group'); ?>
396
 
 
397
  <div style="height: 20px;"></div>
398
  <h2 class="title">Basic Options</h2>
399
  <p class="fvm-bold-green">These options are generaly safe to edit as needed. If you use a cache plugin, kindly purge all your caches once you're done with the changes.</p>
@@ -408,7 +392,7 @@ if($fvm_license != false && mb_strlen($fvm_license, 'UTF-8') == 32) {
408
  <fieldset>
409
  <label for="fastvelocity_min_fvm_fix_editor">
410
  <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); ?>>
411
- Fix Page Editors <span class="note-info">[ If selected, logged in users with the "editor" role (and above) will bypass all optimizations ]</span></label>
412
  </fieldset></td>
413
  </tr>
414
 
@@ -559,14 +543,17 @@ Disable minification on JS files <span class="note-info">[ If selected, JS files
559
  <tbody>
560
  <tr>
561
  <th scope="row">Render-blocking JS</th>
562
- <td><fieldset><legend class="screen-reader-text"><span>Render-blocking</span></legend>
 
 
 
563
  <label for="fastvelocity_min_enable_defer_js">
564
  <input name="fastvelocity_min_enable_defer_js" type="checkbox" id="fastvelocity_min_enable_defer_js" value="1" <?php echo checked(1 == get_option('fastvelocity_min_enable_defer_js'), true, false); ?>>
565
  Enable defer parsing of JS files globally <span class="note-info">[ Not all browsers, themes or plugins support this. Beware of broken functionality and design ]</span></label>
566
  <br />
567
  <label for="fastvelocity_min_defer_for_pagespeed">
568
  <input name="fastvelocity_min_defer_for_pagespeed" type="checkbox" id="fastvelocity_min_defer_for_pagespeed" value="1" <?php echo checked(1 == get_option('fastvelocity_min_defer_for_pagespeed'), true, false); ?>>
569
- Enable defer of JS for Pagespeed Insights <span class="note-info">[ This will defer JS files for Pagespeed Insights only, <a target="_blank" href="https://www.chromestatus.com/feature/5718547946799104">except external scripts</a> loaded from other domains ]</span></label>
570
  <br />
571
 
572
  <label for="fastvelocity_min_exclude_defer_jquery">
@@ -587,7 +574,7 @@ Skip deferring completely on the login page <span class="note-info">[ If selecte
587
 
588
  <div style="height: 20px;"></div>
589
  <h2 class="title">JS and CSS Exceptions</h2>
590
- <p class="fvm-bold-green">You can use this section to exclude certain CSS or JS files from being processed in case of conflicts while merging.</p>
591
 
592
  <table class="form-table fvm-settings">
593
  <tbody>
@@ -615,7 +602,7 @@ Skip deferring completely on the login page <span class="note-info">[ If selecte
615
  <td><fieldset>
616
  <label for="fastvelocity_min_fvm_cdn_url">
617
  <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>
618
- <p class="description">[ This will rewrite the generated CSS and JS urls to use your cdn domain name. ]</p></label>
619
  </fieldset></td>
620
  </tr>
621
  </tbody></table>
@@ -643,7 +630,7 @@ Skip deferring completely on the login page <span class="note-info">[ If selecte
643
 
644
  <div style="height: 20px;"></div>
645
  <h2 class="title">Homepage Optimization</h2>
646
- <p class="fvm-bold-green">Prioritize visible content by preloading images with high priority, such as the first image on a slider that is shown above the folder.</p>
647
 
648
  <table class="form-table fvm-settings">
649
  <tbody>
@@ -665,93 +652,82 @@ Skip deferring completely on the login page <span class="note-info">[ If selecte
665
  <?php } ?>
666
 
667
 
668
- <?php if( $active_tab == 'pro' ) {
669
-
670
- # this is still under development
671
- $fvm_license = get_option('fastvelocity_min_license_code');
672
- if($fvm_license != false && mb_strlen($fvm_license, 'UTF-8') == 32) {
673
- ?>
674
 
675
  <form method="post" action="options.php">
676
  <?php settings_fields('fvm-group-pro'); do_settings_sections('fvm-group-pro'); ?>
677
 
 
678
  <div style="height: 20px;"></div>
679
- <h2 class="title">Extra Optimization</h2>
680
- <p class="fvm-bold-green">These options are available for the professional version only.<br />
681
- When deferring all generated css files, you must enqueue any inline css code that was supposed to load after the generated files.</p>
682
 
683
 
684
  <table class="form-table fvm-settings">
685
  <tbody>
686
 
687
- <tr>
688
- <th scope="row">Extra CSS Options</th>
689
- <td><fieldset>
690
- <label for="fastvelocity_min_fvm_removecss">
691
- <input name="fastvelocity_min_fvm_removecss" type="checkbox" id="fastvelocity_min_fvm_removecss" value="1" <?php echo checked(1 == get_option('fastvelocity_min_fvm_removecss'), true, false); ?>>
692
- Remove CSS files<span class="note-info">[ If selected, all enqueued css files will be removed from the site ]</span></label>
693
- <br />
694
- <label for="fastvelocity_min_send_css_to_footer">
695
- <input name="fastvelocity_min_send_css_to_footer" type="checkbox" id="fastvelocity_min_send_css_to_footer" value="1" <?php echo checked(1 == get_option('fastvelocity_min_send_css_to_footer'), true, false); ?>>
696
- Async CSS with LoadCSS<span class="note-info">[ If selected, you will need a Critical Path CSS to Optimize CSS Delivery ]</span></label>
697
- <br />
698
- <label for="fastvelocity_min_critical_path_visibility">
699
- <input name="fastvelocity_min_critical_path_visibility" type="checkbox" id="fastvelocity_min_critical_path_visibility" value="1" <?php echo checked(1 == get_option('fastvelocity_min_critical_path_visibility'), true, false); ?>>
700
- Add Visibility Styles<span class="note-info">[ If selected, it will hide the body until css is loaded ]</span></label>
701
- <br />
702
- <label for="fastvelocity_min_critical_css_tester">
703
- <input name="fastvelocity_min_critical_css_tester" type="checkbox" id="fastvelocity_min_critical_css_tester" value="1" <?php echo checked(1 == get_option('fastvelocity_min_critical_css_tester'), true, false); ?>>
704
- Critical Path Tester<span class="note-info">[ If selected, only the critical path code will be shown and no css files will be enqueued ]</span></label>
705
- </fieldset>
706
- </td>
707
- </tr>
708
 
709
  <tr>
710
- <th scope="row">Global Critical CSS</th>
711
  <td>
 
 
712
  <p>
713
- <textarea name="fastvelocity_min_critical_path_css" rows="20" cols="50" id="fastvelocity_min_critical_path_css" class="large-text code" placeholder="your css code here"><?php echo get_option('fastvelocity_min_critical_path_css'); ?></textarea>
714
  </p>
715
- <p class="description">[ Please minify your CSS code manually and insert your Global Critical CSS here ]</p>
 
716
  </td>
717
  </tr>
718
 
719
 
720
  <tr>
721
- <th scope="row">Gulp Options</th>
722
  <td><fieldset>
723
- <label for="fastvelocity_min_generate_gulp_files">
724
- <input name="fastvelocity_min_generate_gulp_files" type="checkbox" id="fastvelocity_min_generate_gulp_files" value="1" <?php echo checked(1 == get_option('fastvelocity_min_generate_gulp_files'), true, false); ?>>
725
- Generate gulp-uncss files<span class="note-info">[ If selected, it will try to generate one gulp-uncss per pageview ]</span></label>
726
- </fieldset>
727
  </td>
728
  </tr>
 
729
 
 
 
 
 
 
 
 
730
  <tr>
731
- <th scope="row">Gulp Directory</th>
732
- <td>
733
- <label for="fastvelocity_min_generate_gulp_path">
734
- <input name="fastvelocity_min_generate_gulp_path" type="text" id="fastvelocity_min_generate_gulp_path" value="<?php echo get_option('fastvelocity_min_generate_gulp_path'); ?>" class="regular-text code">
735
- <p class="description">The absolute path to your local "Gulp" working directory</p>
 
736
  </td>
737
  </tr>
738
 
739
  </tbody></table>
740
 
 
 
 
 
741
  <div style="height: 20px;"></div>
742
  <h2 class="title">Special JS and CSS Exceptions</h2>
743
- <p class="fvm-bold-green">You can use this section to exclude certain CSS or JS files from being processed in case of conflicts while merging.</p>
744
 
745
  <div style="height: 20px;"></div>
746
  <table class="form-table fvm-settings">
747
  <tbody>
748
  <tr>
749
  <th scope="row">External URLs to Merge</th>
750
- <td><fieldset><label for="blacklist_keys"><span class="fvm-label-pad">List of external domains or urls that can be merged:</span></label>
751
  <p>
752
  <textarea name="fastvelocity_min_merge_allowed_urls" rows="10" 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>
753
  </p>
754
- <p class="description">[ Add any external domains, JS or CSS urls than can be merged together by FVM ]</p>
755
  </fieldset></td>
756
  </tr>
757
  </tbody></table>
@@ -790,40 +766,8 @@ Generate gulp-uncss files<span class="note-info">[ If selected, it will try to g
790
  </form>
791
 
792
  <?php
793
- } else {
794
-
795
- ?>
796
-
797
- <form method="post" action="options.php">
798
- <?php settings_fields('fvm-group-license'); do_settings_sections('fvm-group-license'); ?>
799
-
800
- <div style="height: 20px;"></div>
801
- <h2 class="title">Extra Optimization</h2>
802
- <p class="fvm-bold-green">These options are available for the professional version only.</p>
803
-
804
- <table class="form-table fvm-settings">
805
- <tbody>
806
-
807
- <tr>
808
- <th scope="row">License Code</th>
809
- <td>
810
- <input name="fastvelocity_min_license_code" type="text" id="fastvelocity_min_license_code" value="<?php echo get_option('fastvelocity_min_license_code'); ?>" class="regular-text">
811
- <p class="description">Please insert the license code that has been provided.</p>
812
- </td>
813
- </tr>
814
-
815
- </tbody></table>
816
-
817
- <p class="submit"><input type="submit" name="fastvelocity_min_save_options" id="fastvelocity_min_save_options" class="button button-primary" value="Save Changes"></p>
818
- </form>
819
-
820
- <?php
821
- }
822
  }
823
- ?>
824
-
825
 
826
- <?php
827
  if( $active_tab == 'server' ) {
828
  fvm_get_generalinfo();
829
  }
@@ -835,10 +779,7 @@ fvm_get_generalinfo();
835
  <div id="poststuff">
836
  <div id="fastvelocity_min_processed" class="postbox-container">
837
  <div class="meta-box-sortables ui-sortable">
838
-
839
-
840
-
841
-
842
  <div class="postbox" id="tab-info">
843
  <h3 class="hndle"><span>Frequently Asked Questions</span></h3>
844
  <div class="inside"><? echo fastvelocity_min_readme($plugindir.'readme.txt'); ?></div>
@@ -1140,7 +1081,7 @@ $wp_scripts->done = $done;
1140
  # enable defer for JavaScript (WP 4.1 and above) and remove query strings for ignored files
1141
  ###########################################
1142
  function fastvelocity_min_defer_js($tag, $handle, $src) {
1143
- global $ignore, $enable_defer_js, $defer_for_pagespeed, $wp_domain, $exclude_defer_login, $fvm_cdn_url;
1144
 
1145
  # no query strings
1146
  if (stripos($src, '?ver') !== false) {
@@ -1149,12 +1090,6 @@ if (stripos($src, '?ver') !== false) {
1149
  $src = $srcf;
1150
  }
1151
 
1152
- # cdn support
1153
- if(!empty($fvm_cdn_url)) {
1154
- $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
1155
- $tag = str_ireplace($wp_domain, $fvm_cdn_url, $tag);
1156
- }
1157
-
1158
  # should we exclude defer on the login page?
1159
  if($exclude_defer_login == true && stripos($_SERVER["SCRIPT_NAME"], strrchr(wp_login_url(), '/')) !== false){ return $tag; }
1160
 
@@ -1183,9 +1118,6 @@ if ($defer == 0) {
1183
  # no defer
1184
  if ($defer_for_pagespeed != true) { return $tag; } else {
1185
 
1186
- # return if external script url https://www.chromestatus.com/feature/5718547946799104
1187
- #if (stripos($src, $wp_domain) === false) { return $tag; }
1188
-
1189
  # print code or return
1190
  if(!empty($tagdefer)) {
1191
  $deferinsights = '<script type="text/javascript">if(navigator.userAgent.match(/speed|gtmetrix|x11.*firefox\/53|x11.*chrome\/39/i)){document.write('.json_encode($tagdefer).');}else{document.write('.json_encode($tag).');}</script>';
@@ -1207,7 +1139,7 @@ return $tag;
1207
  # process header css ######################
1208
  ###########################################
1209
  function fastvelocity_min_merge_header_css() {
1210
- global $wp_styles, $wp_domain, $wp_home, $wp_home_path, $cachedir, $cachedirurl, $ignore, $disable_css_merge, $disable_css_minification, $skip_google_fonts, $skip_cssorder, $remove_print_mediatypes, $force_inline_css, $force_inline_googlefonts, $remove_googlefonts, $send_css_to_footer, $critical_path_css, $critical_css_tester, $critical_css_path_visibility, $fvm_remove_css;
1211
  if(!is_object($wp_styles)) { return false; }
1212
  $ctime = get_option('fvm-last-cache-update', '0');
1213
  $styles = wp_clone($wp_styles);
@@ -1333,16 +1265,10 @@ $mediatype = $process[$handle]['mediatype'];
1333
 
1334
  # push it to the array
1335
  array_push($header[count($header)-1]['handles'], $handle);
1336
-
1337
- # collect generated file urls, except print
1338
- if ($mediatype != 'print') { $GLOBALS['used_css_files'][] = $hurl; }
1339
 
1340
  # external and ignored css
1341
  } else {
1342
 
1343
- # collect generated file urls for gulp, except print and conditionals
1344
- if ($mediatype != 'print' && !isset($conditional)) { $GLOBALS['used_css_files'][] = $hurl; }
1345
-
1346
  # normal enqueuing
1347
  array_push($header, array('handle'=>$handle));
1348
  }
@@ -1376,17 +1302,9 @@ if(!$skip_cssorder) {
1376
  }
1377
  }
1378
 
1379
-
1380
- # critical path default styles
1381
- if($critical_css_path_visibility != false) {
1382
- echo '<style id="critical-path-visibility" type="text/css" media="all">body div span label em i b strong embed h1 h2 h3 h4 h5 h6{font-family:sans-serif}body{visibility:hidden;}</style>'."\n";
1383
- }
1384
-
1385
  # critical path + default visibility styles
1386
  if(!empty($critical_path_css) && $critical_path_css != false) {
1387
- if($send_css_to_footer != false) {
1388
- echo '<style id="critical-path-global" type="text/css" media="all">'.$critical_path_css.'</style>'."\n";
1389
- }
1390
  }
1391
 
1392
 
@@ -1453,8 +1371,7 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1453
 
1454
  # generate cache, write log
1455
  file_put_contents($file.'.txt', $log);
1456
- $vis = ''; if($critical_css_path_visibility != false) { $vis = 'body {visibility:visible !important;}'; }
1457
- file_put_contents($file, $code.$vis);
1458
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1459
 
1460
  }
@@ -1465,26 +1382,16 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1465
  echo '<style type="text/css" media="'.$header[$i]['media'].'">'.file_get_contents($file).'</style>';
1466
  } else {
1467
 
1468
- # move CSS to footer ?
1469
- if($send_css_to_footer != false) {
1470
- if($critical_css_tester != true) {
1471
 
1472
  # save to some sort of global and show it on the footer
1473
  $mt = $header[$i]['media'];
1474
  echo <<<EOF
1475
- <script type="text/javascript">
1476
- var ldfvm$i = document.createElement('link');
1477
- ldfvm$i.rel = 'stylesheet';
1478
- ldfvm$i.type = 'text/css';
1479
- ldfvm$i.media = 'bogus';
1480
- ldfvm$i.href = '$file_url';
1481
- ldfvm$i.onload = function() {ldfvm$i.media = '$mt'}
1482
- document.getElementsByTagName('head')[0].appendChild(ldfvm$i);
1483
- </script>
1484
  EOF;
1485
 
1486
-
1487
-
1488
  }
1489
  } else {
1490
 
@@ -1513,7 +1420,7 @@ $wp_styles->done = $done;
1513
  # process css in the footer ###############
1514
  ###########################################
1515
  function fastvelocity_min_merge_footer_css() {
1516
- global $wp_styles, $wp_domain, $wp_home, $wp_home_path, $cachedir, $cachedirurl, $ignore, $disable_css_merge, $disable_css_minification, $skip_google_fonts, $skip_cssorder, $remove_print_mediatypes, $force_inline_css_footer, $force_inline_googlefonts, $remove_googlefonts, $send_css_to_footer, $critical_css_tester, $critical_css_path_visibility, $fvm_remove_css;
1517
  if(!is_object($wp_styles)) { return false; }
1518
  $ctime = get_option('fvm-last-cache-update', '0');
1519
  $styles = wp_clone($wp_styles);
@@ -1625,16 +1532,10 @@ foreach( $styles->to_do as $handle ) :
1625
 
1626
  # push it to the array get latest modified time
1627
  array_push($footer[count($footer)-1]['handles'], $handle);
1628
-
1629
- # collect generated file urls for gulp, except print
1630
- if ($media != 'print') { $GLOBALS['used_css_files'][] = $hurl; }
1631
 
1632
  # external and ignored css
1633
  } else {
1634
 
1635
- # collect generated file urls for gulp, except print and conditionals
1636
- if ($media != 'print' && !isset($conditional)) { $GLOBALS['used_css_files'][] = $hurl; }
1637
-
1638
  # normal enqueueing
1639
  array_push($footer, array('handle'=>$handle));
1640
  }
@@ -1731,8 +1632,7 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1731
 
1732
  # generate cache, add inline css, write log
1733
  file_put_contents($file.'.txt', $log);
1734
- $vis = ''; if($critical_css_path_visibility != false) { $vis = 'body {visibility:visible !important;}'; }
1735
- file_put_contents($file, $code.$vis); # preserve style tags
1736
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1737
 
1738
  }
@@ -1744,8 +1644,8 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1744
  } else {
1745
 
1746
  # footer css
1747
- if($send_css_to_footer != false) {
1748
- if($critical_css_tester != true) {
1749
  echo '<link rel="stylesheet" type="text/css" media="'.$footer[$i]['media'].'" href="'.$file_url.'">';
1750
  }
1751
  } else {
@@ -1768,55 +1668,6 @@ $wp_styles->done = $done;
1768
 
1769
 
1770
 
1771
- ###########################################
1772
- # generate gulp-uncss files for this page (dev only)
1773
- ###########################################
1774
- function fvm_generate_gulp_uncss() {
1775
- global $wp, $generate_gulp_files, $generate_gulp_path;
1776
-
1777
- if(isset($GLOBALS['used_css_files']) && $generate_gulp_files != false && !empty($generate_gulp_path)) {
1778
-
1779
- # some paths and urls
1780
- $currenturl = fvm_get_protocol($_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
1781
- $file = sanitize_title($currenturl);
1782
- $save = get_stylesheet_directory().'/criticalcss/css/'.$file.'.css';
1783
- $generate_gulp_path = rtrim(trim($generate_gulp_path), '/');
1784
- $generate_gulp_path_out = $generate_gulp_path.'/out/';
1785
- if(!is_dir($generate_gulp_path_out) && is_writable($generate_gulp_path_out)) { mkdir($generate_gulp_path_out); }
1786
- $gulpfile = "$generate_gulp_path/$file.js";
1787
-
1788
- # process
1789
- if(!file_exists($save) && !file_exists($gulpfile) && is_dir($generate_gulp_path_out)) {
1790
-
1791
- $cssfiles = json_encode($GLOBALS['used_css_files'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
1792
-
1793
- # gulp tasks
1794
- $gulptask = <<<EOF
1795
- var gulp = require('gulp');
1796
- var uncss = require('gulp-uncss');
1797
- var concat = require('gulp-concat');
1798
- var nano = require('gulp-cssnano');
1799
- var remoteSrc = require('gulp-remote-src');
1800
- gulp.task('uncss', function() {
1801
- remoteSrc($cssfiles, { base: null })
1802
- .pipe(concat('$file.css'))
1803
- .pipe(uncss({ html: ['$currenturl'] }))
1804
- .pipe(nano())
1805
- .pipe(gulp.dest('$generate_gulp_path/out/'));
1806
- });
1807
- EOF;
1808
-
1809
- # write gulp file
1810
- file_put_contents($gulpfile, $gulptask);
1811
-
1812
- }
1813
- }
1814
- }
1815
-
1816
- if (!is_admin()) { add_action('wp_footer', 'fvm_generate_gulp_uncss', PHP_INT_MAX); }
1817
-
1818
-
1819
-
1820
 
1821
  ###########################################
1822
  # add preconnect and preload headers
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.2.3
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
119
  $preload = array_map('trim', explode("\n", get_option('fastvelocity_min_preload')));
120
  $preconnect = array_map('trim', explode("\n", get_option('fastvelocity_min_preconnect')));
121
  $fvm_fix_editor = get_option('fastvelocity_min_fvm_fix_editor');
122
+ $loadcss = get_option('fastvelocity_min_loadcss');
123
+ $fvm_remove_css = get_option('fastvelocity_min_fvm_removecss');
 
124
  $critical_path_css = get_option('fastvelocity_min_critical_path_css');
 
 
125
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
 
126
 
127
 
128
  # default options
173
  add_action( 'plugins_loaded', 'fastvelocity_fix_editor' );
174
  function fastvelocity_fix_editor() {
175
  global $fvm_fix_editor, $disable_js_merge, $disable_css_merge, $skip_emoji_removal;
176
+ if($fvm_fix_editor == true && is_user_logged_in()) {
177
  if(!$disable_js_merge) {
178
  remove_action( 'wp_print_scripts', 'fastvelocity_min_merge_header_scripts', PHP_INT_MAX );
179
  remove_action( 'wp_print_footer_scripts', 'fastvelocity_min_merge_footer_scripts', 9.999999 );
275
  register_setting('fvm-group', 'fastvelocity_min_fvm_cdn_url');
276
 
277
  # pro version (for private usage... or if you know what you're doing)
278
+ register_setting('fvm-group-pro', 'fastvelocity_min_loadcss');
279
+ register_setting('fvm-group-pro', 'fastvelocity_min_fvm_removecss');
 
280
  register_setting('fvm-group-pro', 'fastvelocity_min_critical_path_css');
 
 
281
  register_setting('fvm-group-pro', 'fastvelocity_min_ignorelist');
282
  register_setting('fvm-group-pro', 'fastvelocity_min_blacklist');
283
  register_setting('fvm-group-pro', 'fastvelocity_min_merge_allowed_urls');
 
 
284
  }
285
 
286
 
324
  <h2 class="nav-tab-wrapper wp-clearfix">
325
  <a href="?page=fastvelocity-min&tab=status" class="nav-tab <?php echo $active_tab == 'status' ? 'nav-tab-active' : ''; ?>">Status</a>
326
  <a href="?page=fastvelocity-min&tab=settings" class="nav-tab <?php echo $active_tab == 'settings' ? 'nav-tab-active' : ''; ?>">Settings</a>
327
+ <a href="?page=fastvelocity-min&tab=pro" class="nav-tab <?php echo $active_tab == 'pro' ? 'nav-tab-active' : ''; ?>">Pro</a>
 
 
 
 
 
 
 
 
328
  <a href="?page=fastvelocity-min&tab=server" class="nav-tab <?php echo $active_tab == 'server' ? 'nav-tab-active' : ''; ?>">Server Info</a>
329
  <a href="?page=fastvelocity-min&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
330
  </h2>
338
  <div class="meta-box">
339
 
340
  <div class="postbox" id="tab-purge">
341
+ <h3 class="hndle"><span>Purge the cache files </span></h3>
342
  <div class="inside" id="fastvelocity_min_topbtns">
343
  <ul class="processed">
344
  <li id="purgeall-row">
345
+ <span class="filename">Purge processed CSS and JS files (<?php echo fastvelocity_get_cachestats(); ?>)</span>
346
  <span class="actions">
347
  <form method="post" id="fastvelocity_min_clearall" action="<?php echo admin_url('options-general.php?page=fastvelocity-min&tab=status'); ?>">
348
  <input type="hidden" name="purgeall" value="1" />
377
  <form method="post" action="options.php">
378
  <?php settings_fields('fvm-group'); do_settings_sections('fvm-group'); ?>
379
 
380
+
381
  <div style="height: 20px;"></div>
382
  <h2 class="title">Basic Options</h2>
383
  <p class="fvm-bold-green">These options are generaly safe to edit as needed. If you use a cache plugin, kindly purge all your caches once you're done with the changes.</p>
392
  <fieldset>
393
  <label for="fastvelocity_min_fvm_fix_editor">
394
  <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); ?>>
395
+ Fix Page Editors <span class="note-info">[ If selected, logged in users will bypass all optimizations ]</span></label>
396
  </fieldset></td>
397
  </tr>
398
 
543
  <tbody>
544
  <tr>
545
  <th scope="row">Render-blocking JS</th>
546
+ <td>
547
+ <fieldset><legend class="screen-reader-text"><span>Render-blocking</span></legend>
548
+
549
+ <p class="fvm-bold-green fvm-rowintro">Some themes and plugins "need" render blocking scripts to work, so please take a look at the dev console for errors.</p>
550
  <label for="fastvelocity_min_enable_defer_js">
551
  <input name="fastvelocity_min_enable_defer_js" type="checkbox" id="fastvelocity_min_enable_defer_js" value="1" <?php echo checked(1 == get_option('fastvelocity_min_enable_defer_js'), true, false); ?>>
552
  Enable defer parsing of JS files globally <span class="note-info">[ Not all browsers, themes or plugins support this. Beware of broken functionality and design ]</span></label>
553
  <br />
554
  <label for="fastvelocity_min_defer_for_pagespeed">
555
  <input name="fastvelocity_min_defer_for_pagespeed" type="checkbox" id="fastvelocity_min_defer_for_pagespeed" value="1" <?php echo checked(1 == get_option('fastvelocity_min_defer_for_pagespeed'), true, false); ?>>
556
+ Enable defer of JS for Pagespeed Insights <span class="note-info">[ Defer JS files for Pagespeed Insights only, <a target="_blank" href="https://www.chromestatus.com/feature/5718547946799104">except external scripts</a> (avoid using a CDN for JS files) ]</span></label>
557
  <br />
558
 
559
  <label for="fastvelocity_min_exclude_defer_jquery">
574
 
575
  <div style="height: 20px;"></div>
576
  <h2 class="title">JS and CSS Exceptions</h2>
577
+ <p class="fvm-bold-green">You can use this section to exclude certain CSS or JS files from being processed in case of conflicts while merging.<br />Read the HELP section for information on why you may need to use this.</p>
578
 
579
  <table class="form-table fvm-settings">
580
  <tbody>
602
  <td><fieldset>
603
  <label for="fastvelocity_min_fvm_cdn_url">
604
  <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>
605
+ <p class="description">[ This will rewrite the generated CSS and JS urls to use your cdn domain name, ie: cdn.example.com ]</p></label>
606
  </fieldset></td>
607
  </tr>
608
  </tbody></table>
630
 
631
  <div style="height: 20px;"></div>
632
  <h2 class="title">Homepage Optimization</h2>
633
+ <p class="fvm-bold-green">Use this only for images above the fold that exist in all pages, such as your logo.</p>
634
 
635
  <table class="form-table fvm-settings">
636
  <tbody>
652
  <?php } ?>
653
 
654
 
655
+ <?php if( $active_tab == 'pro' ) { ?>
 
 
 
 
 
656
 
657
  <form method="post" action="options.php">
658
  <?php settings_fields('fvm-group-pro'); do_settings_sections('fvm-group-pro'); ?>
659
 
660
+
661
  <div style="height: 20px;"></div>
662
+ <h2 class="title">Pro Optimization</h2>
663
+ <p class="fvm-bold-green">Do NOT touch these settings, unless you're a developer that understands exactly what this does.<br />This section is experimental and may or may not be removed or restructured in the future.</p>
 
664
 
665
 
666
  <table class="form-table fvm-settings">
667
  <tbody>
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
  <tr>
671
+ <th scope="row">Critical Path CSS</th>
672
  <td>
673
+ <fieldset>
674
+ <label for="blacklist_keys"><span class="fvm-label-pad">The CSS code here, will show up inside "style" tags in the header globally:</span></label>
675
  <p>
676
+ <textarea name="fastvelocity_min_critical_path_css" rows="10" cols="50" id="fastvelocity_min_critical_path_css" class="large-text code" placeholder="your css code here"><?php echo get_option('fastvelocity_min_critical_path_css'); ?></textarea>
677
  </p>
678
+ <p class="description">[ Use this if you're familiar with <a target="_blank" href="https://github.com/giakki/uncss">UnCSS</a> or have the critical path css. ]</p>
679
+ </fieldset>
680
  </td>
681
  </tr>
682
 
683
 
684
  <tr>
685
+ <th scope="row">Extra CSS Options</th>
686
  <td><fieldset>
687
+ <label for="fastvelocity_min_fvm_removecss">
688
+ <input name="fastvelocity_min_fvm_removecss" type="checkbox" id="fastvelocity_min_fvm_removecss" value="1" <?php echo checked(1 == get_option('fastvelocity_min_fvm_removecss'), true, false); ?>>
689
+ Dequeue all CSS files <span class="note-info">[ Use this if you have your own uncss stylesheet or want to test how the critical path css looks ]</span></label>
 
690
  </td>
691
  </tr>
692
+ </tbody></table>
693
 
694
+
695
+ <div style="height: 20px;"></div>
696
+ <h2 class="title">Async CSS</h2>
697
+ <p class="fvm-bold-green">If you have multiple css files per media type, they may load out of order and break your design.<br />Pagespeed will still complain about render blocking, until you have the correct critical path CSS code.</p>
698
+
699
+ <table class="form-table fvm-settings">
700
+ <tbody>
701
  <tr>
702
+ <th scope="row">Enable Async CSS</th>
703
+ <td><fieldset>
704
+ <label for="fastvelocity_min_loadcss">
705
+ <input name="fastvelocity_min_loadcss" type="checkbox" id="fastvelocity_min_loadcss" value="1" <?php echo checked(1 == get_option('fastvelocity_min_loadcss'), true, false); ?>>
706
+ Async CSS with LoadCSS<span class="note-info">[ Only works if "Inline all header /footer CSS files" is disabled ]</span></label>
707
+ </fieldset>
708
  </td>
709
  </tr>
710
 
711
  </tbody></table>
712
 
713
+
714
+
715
+
716
+
717
  <div style="height: 20px;"></div>
718
  <h2 class="title">Special JS and CSS Exceptions</h2>
719
+ <p class="fvm-bold-green">You can use this section to edit or change our default exclusions, as well as to add your own.<br />It's recommeded that you use the Ignore List before touching these settings.</p>
720
 
721
  <div style="height: 20px;"></div>
722
  <table class="form-table fvm-settings">
723
  <tbody>
724
  <tr>
725
  <th scope="row">External URLs to Merge</th>
726
+ <td><fieldset><label for="blacklist_keys"><span class="fvm-label-pad">List of external domains that can be fetched and merged together:</span></label>
727
  <p>
728
  <textarea name="fastvelocity_min_merge_allowed_urls" rows="10" 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>
729
  </p>
730
+ <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>
731
  </fieldset></td>
732
  </tr>
733
  </tbody></table>
766
  </form>
767
 
768
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
769
  }
 
 
770
 
 
771
  if( $active_tab == 'server' ) {
772
  fvm_get_generalinfo();
773
  }
779
  <div id="poststuff">
780
  <div id="fastvelocity_min_processed" class="postbox-container">
781
  <div class="meta-box-sortables ui-sortable">
782
+
 
 
 
783
  <div class="postbox" id="tab-info">
784
  <h3 class="hndle"><span>Frequently Asked Questions</span></h3>
785
  <div class="inside"><? echo fastvelocity_min_readme($plugindir.'readme.txt'); ?></div>
1081
  # enable defer for JavaScript (WP 4.1 and above) and remove query strings for ignored files
1082
  ###########################################
1083
  function fastvelocity_min_defer_js($tag, $handle, $src) {
1084
+ global $ignore, $enable_defer_js, $defer_for_pagespeed, $wp_domain, $exclude_defer_login;
1085
 
1086
  # no query strings
1087
  if (stripos($src, '?ver') !== false) {
1090
  $src = $srcf;
1091
  }
1092
 
 
 
 
 
 
 
1093
  # should we exclude defer on the login page?
1094
  if($exclude_defer_login == true && stripos($_SERVER["SCRIPT_NAME"], strrchr(wp_login_url(), '/')) !== false){ return $tag; }
1095
 
1118
  # no defer
1119
  if ($defer_for_pagespeed != true) { return $tag; } else {
1120
 
 
 
 
1121
  # print code or return
1122
  if(!empty($tagdefer)) {
1123
  $deferinsights = '<script type="text/javascript">if(navigator.userAgent.match(/speed|gtmetrix|x11.*firefox\/53|x11.*chrome\/39/i)){document.write('.json_encode($tagdefer).');}else{document.write('.json_encode($tag).');}</script>';
1139
  # process header css ######################
1140
  ###########################################
1141
  function fastvelocity_min_merge_header_css() {
1142
+ global $wp_styles, $wp_domain, $wp_home, $wp_home_path, $cachedir, $cachedirurl, $ignore, $disable_css_merge, $disable_css_minification, $skip_google_fonts, $skip_cssorder, $remove_print_mediatypes, $force_inline_css, $force_inline_googlefonts, $remove_googlefonts, $loadcss, $critical_path_css, $fvm_remove_css;
1143
  if(!is_object($wp_styles)) { return false; }
1144
  $ctime = get_option('fvm-last-cache-update', '0');
1145
  $styles = wp_clone($wp_styles);
1265
 
1266
  # push it to the array
1267
  array_push($header[count($header)-1]['handles'], $handle);
 
 
 
1268
 
1269
  # external and ignored css
1270
  } else {
1271
 
 
 
 
1272
  # normal enqueuing
1273
  array_push($header, array('handle'=>$handle));
1274
  }
1302
  }
1303
  }
1304
 
 
 
 
 
 
 
1305
  # critical path + default visibility styles
1306
  if(!empty($critical_path_css) && $critical_path_css != false) {
1307
+ echo '<style id="critical-path-global" type="text/css" media="all">'.$critical_path_css.'</style>'."\n";
 
 
1308
  }
1309
 
1310
 
1371
 
1372
  # generate cache, write log
1373
  file_put_contents($file.'.txt', $log);
1374
+ file_put_contents($file, $code);
 
1375
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1376
 
1377
  }
1382
  echo '<style type="text/css" media="'.$header[$i]['media'].'">'.file_get_contents($file).'</style>';
1383
  } else {
1384
 
1385
+ # move CSS to footer with loadCSS ?
1386
+ if($loadcss != false) {
1387
+ if($fvm_remove_css != true) {
1388
 
1389
  # save to some sort of global and show it on the footer
1390
  $mt = $header[$i]['media'];
1391
  echo <<<EOF
1392
+ <script type="text/javascript">var ldfvm$i=document.createElement("link");ldfvm$i.rel="stylesheet",ldfvm$i.type="text/css",ldfvm$i.media="bogus",ldfvm$i.href="$file_url",ldfvm$i.onload=function(){ldfvm$i.media="$mt"},document.getElementsByTagName("head")[0].appendChild(ldfvm$i);</script>
 
 
 
 
 
 
 
 
1393
  EOF;
1394
 
 
 
1395
  }
1396
  } else {
1397
 
1420
  # process css in the footer ###############
1421
  ###########################################
1422
  function fastvelocity_min_merge_footer_css() {
1423
+ global $wp_styles, $wp_domain, $wp_home, $wp_home_path, $cachedir, $cachedirurl, $ignore, $disable_css_merge, $disable_css_minification, $skip_google_fonts, $skip_cssorder, $remove_print_mediatypes, $force_inline_css_footer, $force_inline_googlefonts, $remove_googlefonts, $loadcss, $fvm_remove_css;
1424
  if(!is_object($wp_styles)) { return false; }
1425
  $ctime = get_option('fvm-last-cache-update', '0');
1426
  $styles = wp_clone($wp_styles);
1532
 
1533
  # push it to the array get latest modified time
1534
  array_push($footer[count($footer)-1]['handles'], $handle);
 
 
 
1535
 
1536
  # external and ignored css
1537
  } else {
1538
 
 
 
 
1539
  # normal enqueueing
1540
  array_push($footer, array('handle'=>$handle));
1541
  }
1632
 
1633
  # generate cache, add inline css, write log
1634
  file_put_contents($file.'.txt', $log);
1635
+ file_put_contents($file, $code); # preserve style tags
 
1636
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1637
 
1638
  }
1644
  } else {
1645
 
1646
  # footer css
1647
+ if($loadcss != false) {
1648
+ if($fvm_remove_css != true) {
1649
  echo '<link rel="stylesheet" type="text/css" media="'.$footer[$i]['media'].'" href="'.$file_url.'">';
1650
  }
1651
  } else {
1668
 
1669
 
1670
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1671
 
1672
  ###########################################
1673
  # add preconnect and preload headers
inc/functions-admin.php CHANGED
@@ -5,12 +5,12 @@ in development...
5
  */
6
 
7
  # add admin toolbar
8
- function fastvelocity_load_toolbar() {
9
- if(current_user_can('manage_options')) { add_action( 'admin_bar_menu', 'fastvelocity_add_toolbar', 100 ); }
10
- }
11
 
12
  # admin toolbar processing
13
  function fastvelocity_add_toolbar() {
 
14
  global $wp_admin_bar;
15
 
16
  # get cache size
@@ -45,9 +45,10 @@ $wp_admin_bar->add_node( array(
45
  ));
46
 
47
  }
 
48
 
49
 
50
-
51
  # get cache size and count
52
  function fastvelocity_get_cachestats() {
53
 
@@ -70,5 +71,5 @@ if(is_dir(rtrim($dir, '/'))) {
70
 
71
  return array('size'=>fastvelocity_format_filesize($size), 'count'=>$count);
72
  }
73
-
74
 
5
  */
6
 
7
  # add admin toolbar
8
+ add_action( 'admin_bar_menu', 'fastvelocity_add_toolbar', 100 );
9
+
 
10
 
11
  # admin toolbar processing
12
  function fastvelocity_add_toolbar() {
13
+ if(current_user_can('manage_options')) {
14
  global $wp_admin_bar;
15
 
16
  # get cache size
45
  ));
46
 
47
  }
48
+ }
49
 
50
 
51
+ /*
52
  # get cache size and count
53
  function fastvelocity_get_cachestats() {
54
 
71
 
72
  return array('size'=>fastvelocity_format_filesize($size), 'count'=>$count);
73
  }
74
+ *(
75
 
inc/functions.php CHANGED
@@ -31,7 +31,7 @@ $cachedirurl = rtrim($upload['baseurl'], '/').'/fvm/cache';
31
  if(!is_dir($cachebase)) { mkdir($cachebase); }
32
  if(!is_dir($cachedir)) { mkdir($cachedir); }
33
  if(!is_dir($tmpdir)) { mkdir($tmpdir); }
34
- $return = array('tmpdir'=>$tmpdir, 'cachedir'=>$cachedir, 'cachedirurl'=>$cachedirurl);
35
 
36
  # save or update
37
  $save = get_option('fvm-cachepath', array());
@@ -147,7 +147,12 @@ return fvm_compat_urls($css);
147
  # find if we are running windows
148
  function fvm_server_is_windows() {
149
  if(defined('PHP_OS_FAMILY') && strtolower(PHP_OS_FAMILY) == 'windows') { return true; } # PHP 7.2.0+
150
- if (stripos(php_uname('s'), 'Windows') !== false) { return true; }# fallback
 
 
 
 
 
151
  return false;
152
  }
153
 
@@ -260,25 +265,9 @@ function fastvelocity_format_filesize($bytes, $decimals = 2) {
260
 
261
  # get cache size and count
262
  function fastvelocity_get_cachestats() {
263
-
264
- # info
265
- $cachepath = fvm_cachepath();
266
- $tmpdir = $cachepath['tmpdir'];
267
- $cachedir = $cachepath['cachedir'];
268
- $search = array($tmpdir, $cachedir);
269
- $size = 0;
270
- $count = 0;
271
-
272
- foreach ($search as $dir) {
273
- if(is_dir(rtrim($dir, '/'))) {
274
- if ($handle = opendir($dir.'/')) {
275
- while (false !== ($file = readdir($handle))) { $f = $dir.'/'.$file; $size = $size + filesize($f); $count++; }
276
- closedir($handle);
277
- }
278
- }
279
- }
280
-
281
- return array('size'=>fastvelocity_format_filesize($size), 'count'=>$count);
282
  }
283
 
284
 
@@ -308,8 +297,8 @@ if(!$disable_css_minification) {
308
  # cdn urls
309
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
310
  if(!empty($fvm_cdn_url)) {
311
- $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
312
- $css = str_ireplace($wp_domain, $fvm_cdn_url, $css);
313
  }
314
 
315
  # return html
@@ -618,8 +607,8 @@ function fvm_get_protocol($url) {
618
  # cdn support
619
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
620
  if(!empty($fvm_cdn_url)) {
621
- $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
622
- $url = str_ireplace($wp_domain, $fvm_cdn_url, $url);
623
  }
624
 
625
  # enforce protocol if needed
@@ -667,7 +656,17 @@ return true;
667
 
668
  # exclude processing from some pages / posts / contents
669
  function fastvelocity_exclude_contents() {
670
-
 
 
 
 
 
 
 
 
 
 
671
  # customizer preview, visual composer
672
  $arr = array('customize_theme', 'preview_id', 'preview');
673
  foreach ($arr as $a) { if(isset($_GET[$a])) { return true; } }
31
  if(!is_dir($cachebase)) { mkdir($cachebase); }
32
  if(!is_dir($cachedir)) { mkdir($cachedir); }
33
  if(!is_dir($tmpdir)) { mkdir($tmpdir); }
34
+ $return = array('cachebase'=>$cachebase,'tmpdir'=>$tmpdir, 'cachedir'=>$cachedir, 'cachedirurl'=>$cachedirurl);
35
 
36
  # save or update
37
  $save = get_option('fvm-cachepath', array());
147
  # find if we are running windows
148
  function fvm_server_is_windows() {
149
  if(defined('PHP_OS_FAMILY') && strtolower(PHP_OS_FAMILY) == 'windows') { return true; } # PHP 7.2.0+
150
+ if(function_exists('php_uname')) {
151
+ $os = @php_uname('s');
152
+ if (stripos($os, 'Windows') !== false) {
153
+ return true;
154
+ }
155
+ }
156
  return false;
157
  }
158
 
265
 
266
  # get cache size and count
267
  function fastvelocity_get_cachestats() {
268
+ $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(fvm_cachepath()['cachebase'], FilesystemIterator::SKIP_DOTS));
269
+ $size = 0; foreach ( $dir as $file ) { $size += $file->getSize(); }
270
+ return fastvelocity_format_filesize($size);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  }
272
 
273
 
297
  # cdn urls
298
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
299
  if(!empty($fvm_cdn_url)) {
300
+ $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
301
+ $css = str_ireplace($wp_domain, $fvm_cdn_url, $css);
302
  }
303
 
304
  # return html
607
  # cdn support
608
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
609
  if(!empty($fvm_cdn_url)) {
610
+ $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
611
+ $url = str_ireplace($wp_domain, $fvm_cdn_url, $url);
612
  }
613
 
614
  # enforce protocol if needed
656
 
657
  # exclude processing from some pages / posts / contents
658
  function fastvelocity_exclude_contents() {
659
+
660
+ # ajax requests
661
+ if (
662
+ (defined('DOING_AJAX') && DOING_AJAX) || (function_exists('wp_doing_ajax') && wp_doing_ajax()) ||
663
+ (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') ||
664
+ (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
665
+ ) { return true; }
666
+
667
+ # robots.txt and xml dynamically generated sitemaps
668
+ if(isset($_SERVER['REQUEST_URI']) && (substr($_SERVER['REQUEST_URI'], -4) == '.txt' || substr($_SERVER['REQUEST_URI'], -4) == '.xml')) { return true; }
669
+
670
  # customizer preview, visual composer
671
  $arr = array('customize_theme', 'preview_id', 'preview');
672
  foreach ($arr as $a) { if(isset($_GET[$a])) { return true; } }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Alignak
3
  Tags: merge, combine, concatenate, PHP Minify, YUI Compressor, CSS, javascript, JS, minification, minify, optimization, optimize, stylesheet, aggregate, cache, CSS, html, minimize, pagespeed, performance, speed, GTmetrix, pingdom
4
  Requires at least: 4.5
5
- Stable tag: 2.2.2
6
- Tested up to: 4.9
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -274,6 +274,18 @@ Note: Kindly purge the plugin cache as well as your server /plugin cache after u
274
 
275
  == Changelog ==
276
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  = 2.2.2 [2017.11.12] =
278
  * fixed the current cdn option box
279
  * fixed some other minor bugs and notices
2
  Contributors: Alignak
3
  Tags: merge, combine, concatenate, PHP Minify, YUI Compressor, CSS, javascript, JS, minification, minify, optimization, optimize, stylesheet, aggregate, cache, CSS, html, minimize, pagespeed, performance, speed, GTmetrix, pingdom
4
  Requires at least: 4.5
5
+ Stable tag: 2.2.3
6
+ Tested up to: 4.9.1
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
274
 
275
  == Changelog ==
276
 
277
+ = 2.2.3 [2017.12.17] =
278
+ * added robots.txt and ajax requests to the exclusion list
279
+ * added some cdn fixes
280
+ * added a new Pro tab
281
+ * added a global critical path css section
282
+ * added an option to dequeue all css files
283
+ * added an option to load CSS Async with LoadCSS (experimental)
284
+ * added an option to merge external resources together
285
+ * added the possibility to manage the default ignore list (reported files that cause conflicts when merged)
286
+ * added the possibility to manage the blacklist (files that cannot be merged with normal files)
287
+ * added better descriptions and labels for some options
288
+
289
  = 2.2.2 [2017.11.12] =
290
  * fixed the current cdn option box
291
  * fixed some other minor bugs and notices