Fast Velocity Minify - Version 2.2.2

Version Description

[2017.11.12] = * fixed the current cdn option box * fixed some other minor bugs and notices * added option to remove all enqueued google fonts (so you can use your own CSS @fontfaces manually) * added font hinting for the "Inline Google Fonts CSS" option, so it looks better on Windows

Download this release

Release Info

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

Code changes from version 2.2.1 to 2.2.2

Files changed (4) hide show
  1. fvm.js +10 -1
  2. fvm.php +222 -139
  3. inc/functions.php +34 -43
  4. readme.txt +9 -3
fvm.js CHANGED
@@ -46,7 +46,16 @@
46
  }
47
  }).trigger('init');
48
 
49
-
 
 
 
 
 
 
 
 
 
50
 
51
  // disable collapse
52
  $('.postbox h3, .postbox .handlediv').unbind('click.postboxes');
46
  }
47
  }).trigger('init');
48
 
49
+ // disable some checkboxes when some other is on or off
50
+ $('#fastvelocity_min_fvm_removecss').bind('click init', function() {
51
+ if( $(this).is(':checked')) {
52
+ $("#fastvelocity_min_send_css_to_footer, #fastvelocity_min_critical_path_visibility").prop("disabled", true);
53
+ $("#fastvelocity_min_critical_css_tester").prop("disabled", true);
54
+ } else {
55
+ $("#fastvelocity_min_send_css_to_footer, #fastvelocity_min_critical_path_visibility").prop("disabled", false);
56
+ $("#fastvelocity_min_critical_css_tester").prop("disabled", false);
57
+ }
58
+ }).trigger('init');
59
 
60
  // disable collapse
61
  $('.postbox h3, .postbox .handlediv').unbind('click.postboxes');
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.1
9
  License: GPL2
10
 
11
  ------------------------------------------------------------------------
@@ -90,42 +90,58 @@ $fastvelocity_min_global_js_done = array();
90
  # build control panel pages ###############
91
  ###########################################
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  # default options
94
- $ignore = array(); # urls to exclude for merging and minification
95
- $default_protocol = 'dynamic'; # use dynamic "//" protocols by default
96
- $disable_js_merge = false; # disable JS merging? Default: false (if true, minification is also disabled)
97
- $disable_css_merge = false; # disable CSS merging? Default: false (if true, minification is also disabled)
98
- $disable_js_minification = false; # disable JS minification? Default: false
99
- $disable_css_minification = false; # disable CSS minification? Default: false
100
- $use_yui = false; # Use the YUI processor instead of PHP Minify? Default false
101
- $remove_print_mediatypes = false; # remove CSS files of "print" mediatype
102
- $skip_html_minification = false; # skip HTML minification? Default: false
103
- $use_alt_html_minification = false; # use alt HTML minification? Default: false
104
- $strip_htmlcomments = false; # whether to remove html comments on html minification
105
- $skip_cssorder = false; # skip reordering CSS files by mediatype
106
- $skip_google_fonts = false; # skip google fonts optimization? Default: false
107
- $skip_emoji_removal = false; # skip removing emoji support? Default: false
108
- $enable_defer_js = false; # Defer parsing of JavaScript? Default false
109
- $exclude_defer_jquery = false; # Disable defer for jquery on the home
110
- $use_google_closure = false; # Use Google closure (slower) instead of YUI processor? Default false
111
- $use_php_minify = false; # Use PHP Minify instead of YUI or Closure? Default false
112
- $force_inline_css = false; # Don't inline all css by default
113
- $force_inline_css_footer = false; # Don't inline all css by default
114
- $force_inline_googlefonts = false; # Don't inline all google fonts by default
115
- $defer_for_pagespeed = false; # force defer for when we are being tested by pagespeed insights
116
- $exclude_defer_login = false; # Disable defer js on the login page
117
- $preload = array(); # urls to preload before anything else
118
- $preconnect = array(); # domains to preconnect to
119
- $fvm_fix_editor = false; # enable production mode by default?
120
-
121
- # extra
122
- $send_css_to_footer = false; # force defer for css
123
- $critical_path_css = false; # critical path for homepage
124
- $critical_css_tester = false; # will remove all css, except the critical path code
125
- $generate_gulp_files = false; # will generate gulp files for gulp-uncss (spider the site first to generate the fvm cache files)
126
- $generate_gulp_path = false; # path to working directory where gulp-uncss is installed
127
  $used_css_files = array();
128
 
 
 
 
 
 
 
 
 
 
 
129
  # add admin page and rewrite defaults
130
  if(is_admin()) {
131
  add_action('admin_menu', 'fastvelocity_min_admin_menu');
@@ -134,37 +150,6 @@ if(is_admin()) {
134
  add_action('admin_init', 'fastvelocity_min_register_settings');
135
  register_deactivation_hook( __FILE__, 'fastvelocity_min_plugin_deactivate');
136
  } else {
137
- # overwrite options from the database, false if not set
138
- $ignore = array_map('trim', explode("\n", get_option('fastvelocity_min_ignore', '')));
139
- $default_protocol = get_option('fastvelocity_min_default_protocol', 'dynamic');
140
- $disable_js_merge = get_option('fastvelocity_min_disable_js_merge');
141
- $disable_css_merge = get_option('fastvelocity_min_disable_css_merge');
142
- $disable_js_minification = get_option('fastvelocity_min_disable_js_minification');
143
- $disable_css_minification = get_option('fastvelocity_min_disable_css_minification');
144
- $use_yui = get_option('fastvelocity_min_use_yui');
145
- $remove_print_mediatypes = get_option('fastvelocity_min_remove_print_mediatypes');
146
- $skip_html_minification = get_option('fastvelocity_min_skip_html_minification');
147
- $use_alt_html_minification = get_option('fastvelocity_min_use_alt_html_minification');
148
- $strip_htmlcomments = get_option('fastvelocity_min_strip_htmlcomments');
149
- $skip_cssorder = get_option('fastvelocity_min_skip_cssorder');
150
- $skip_google_fonts = get_option('fastvelocity_min_skip_google_fonts');
151
- $skip_emoji_removal = get_option('fastvelocity_min_skip_emoji_removal');
152
- $enable_defer_js = get_option('fastvelocity_min_enable_defer_js');
153
- $exclude_defer_jquery = get_option('fastvelocity_min_exclude_defer_jquery');
154
- $force_inline_css = get_option('fastvelocity_min_force_inline_css');
155
- $force_inline_css_footer = get_option('fastvelocity_min_force_inline_css_footer');
156
- $force_inline_googlefonts = get_option('fastvelocity_min_force_inline_googlefonts');
157
- $defer_for_pagespeed = get_option('fastvelocity_min_defer_for_pagespeed');
158
- $exclude_defer_login = get_option('fastvelocity_min_exclude_defer_login');
159
- $preload = array_map('trim', explode("\n", get_option('fastvelocity_min_preload')));
160
- $preconnect = array_map('trim', explode("\n", get_option('fastvelocity_min_preconnect')));
161
- $fvm_fix_editor = get_option('fastvelocity_min_fvm_fix_editor');
162
- $send_css_to_footer = get_option('fastvelocity_min_send_css_to_footer');
163
- $critical_css_tester = get_option('fastvelocity_min_critical_css_tester');
164
- $critical_path_css = get_option('fastvelocity_min_critical_path_css');
165
- $generate_gulp_files = get_option('fastvelocity_min_generate_gulp_files');
166
- $generate_gulp_path = get_option('fastvelocity_min_generate_gulp_path');
167
-
168
 
169
  # skip on certain post_types or if there are specific keys on the url or if editor or admin
170
  if(!fastvelocity_exclude_contents()) {
@@ -182,7 +167,7 @@ if(is_admin()) {
182
  if(!$skip_emoji_removal) {
183
  add_action( 'init', 'fastvelocity_min_disable_wp_emojicons' );
184
  }
185
-
186
  }
187
  }
188
 
@@ -285,20 +270,25 @@ function fastvelocity_min_register_settings() {
285
  register_setting('fvm-group', 'fastvelocity_min_force_inline_css');
286
  register_setting('fvm-group', 'fastvelocity_min_force_inline_css_footer');
287
  register_setting('fvm-group', 'fastvelocity_min_force_inline_googlefonts');
 
288
  register_setting('fvm-group', 'fastvelocity_min_defer_for_pagespeed');
289
  register_setting('fvm-group', 'fastvelocity_min_exclude_defer_login');
290
  register_setting('fvm-group', 'fastvelocity_min_preload');
291
  register_setting('fvm-group', 'fastvelocity_min_preconnect');
292
  register_setting('fvm-group', 'fastvelocity_min_fvm_fix_editor');
293
- register_setting('fvm-group', 'fastvelocity_min_fvm_enable_cdn');
294
  register_setting('fvm-group', 'fastvelocity_min_fvm_cdn_url');
295
 
296
  # pro version (for private usage... or if you know what you're doing)
297
  register_setting('fvm-group-pro', 'fastvelocity_min_send_css_to_footer');
 
298
  register_setting('fvm-group-pro', 'fastvelocity_min_critical_css_tester');
299
  register_setting('fvm-group-pro', 'fastvelocity_min_critical_path_css');
300
  register_setting('fvm-group-pro', 'fastvelocity_min_generate_gulp_files');
301
- register_setting('fvm-group-pro', 'fastvelocity_min_generate_gulp_path');
 
 
 
 
302
  register_setting('fvm-group-license', 'fastvelocity_min_license_code');
303
  }
304
 
@@ -487,6 +477,11 @@ Disable Google Fonts merging <span class="note-info">[ If selected, Google Fonts
487
  Inline Google Fonts CSS <span class="note-info">[ If selected, Google Fonts CSS code will be inlined using "*.woof" format - NOTE: IE9+ and <a target="_blank" href="http://caniuse.com/#feat=woff">modern browsers</a> only]</span></label>
488
  <br />
489
 
 
 
 
 
 
490
  </fieldset></td>
491
  </tr>
492
 
@@ -598,13 +593,12 @@ Skip deferring completely on the login page <span class="note-info">[ If selecte
598
  <tbody>
599
  <tr>
600
  <th scope="row">Ignore List</th>
601
- <td><fieldset><legend class="screen-reader-text"><span>Ignore List</span></legend>
602
- <p><label for="blacklist_keys"><span class="fvm-label-pad">Ignore the following CSS and JS paths below:</span></label></p>
603
  <p>
604
  <textarea name="fastvelocity_min_ignore" rows="10" cols="50" id="fastvelocity_min_ignore" class="large-text code" placeholder="ex: /wp-includes/js/jquery/jquery.js"><?php echo get_option('fastvelocity_min_ignore'); ?></textarea>
605
  </p>
606
- <p class="description">[ Remove all query strings and use only relative or partial urls, ex: /wp-includes/js/jquery/jquery.js ]</p>
607
- <br />
608
  </fieldset></td>
609
  </tr>
610
  </tbody></table>
@@ -612,16 +606,16 @@ Skip deferring completely on the login page <span class="note-info">[ If selecte
612
 
613
  <div style="height: 20px;"></div>
614
  <h2 class="title">CDN Options</h2>
615
- <p class="fvm-bold-green">This rewrite our generated CSS and JS urls to use your cdn domain name.</p>
616
 
617
  <table class="form-table fvm-settings">
618
  <tbody>
619
  <tr>
620
- <th scope="row"><span class="fvm-label-special">CDN URL</span></th>
621
- <td><fieldset><legend class="screen-reader-text"><span>CDN URL</span></legend>
622
  <label for="fastvelocity_min_fvm_cdn_url">
623
  <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>
624
- <p class="description">[ Leave empty, or enter your CDN URL domain name here ]</p></label>
625
  </fieldset></td>
626
  </tr>
627
  </tbody></table>
@@ -692,11 +686,19 @@ When deferring all generated css files, you must enqueue any inline css code tha
692
 
693
  <tr>
694
  <th scope="row">Extra CSS Options</th>
695
- <td><fieldset><legend class="screen-reader-text"><span>Extra CSS Options</span></legend>
 
 
 
 
696
  <label for="fastvelocity_min_send_css_to_footer">
697
  <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); ?>>
698
  Async CSS with LoadCSS<span class="note-info">[ If selected, you will need a Critical Path CSS to Optimize CSS Delivery ]</span></label>
699
  <br />
 
 
 
 
700
  <label for="fastvelocity_min_critical_css_tester">
701
  <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); ?>>
702
  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>
@@ -734,9 +736,56 @@ Generate gulp-uncss files<span class="note-info">[ If selected, it will try to g
734
  </td>
735
  </tr>
736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
 
 
 
 
 
 
 
 
 
 
 
 
 
738
  </tbody></table>
739
 
 
740
  <p class="submit"><input type="submit" name="fastvelocity_min_save_options" id="fastvelocity_min_save_options" class="button button-primary" value="Save Changes"></p>
741
  </form>
742
 
@@ -899,7 +948,7 @@ for($i=0,$l=count($header);$i<$l;$i++) {
899
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
900
  $newcode = false; $newcode = get_transient($tkey);
901
  if ( $newcode === false) {
902
- $res = fvm_download_and_cache($hurl, $tkey, null, $disable_js_minification, 'js');
903
  if(is_array($res)) {
904
  $newcode = $res['code'];
905
  $newlog = $res['log'];
@@ -1031,7 +1080,7 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1031
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
1032
  $newcode = false; $newcode = get_transient($tkey);
1033
  if ( $newcode === false) {
1034
- $res = fvm_download_and_cache($hurl, $tkey, null, $disable_js_minification, 'js');
1035
  if(is_array($res)) {
1036
  $newcode = $res['code'];
1037
  $newlog = $res['log'];
@@ -1091,24 +1140,30 @@ $wp_scripts->done = $done;
1091
  # enable defer for JavaScript (WP 4.1 and above) and remove query strings for ignored files
1092
  ###########################################
1093
  function fastvelocity_min_defer_js($tag, $handle, $src) {
1094
- global $ignore, $enable_defer_js, $defer_for_pagespeed, $wp_domain, $exclude_defer_login;
1095
 
1096
  # no query strings
1097
  if (stripos($src, '?ver') !== false) {
1098
  $srcf = stristr($src, '?ver', true);
1099
  $tag = str_ireplace($src, $srcf, $tag);
1100
  $src = $srcf;
1101
- }
 
 
 
 
 
 
1102
 
1103
  # should we exclude defer on the login page?
1104
  if($exclude_defer_login == true && stripos($_SERVER["SCRIPT_NAME"], strrchr(wp_login_url(), '/')) !== false){ return $tag; }
1105
 
1106
  # reprocess the ignore list to remove the /fvm/cache/ from the list (else won't defer)
1107
- if(is_array($ignore)) { $nignore = array(); foreach ($ignore as $i) { if($i != '/fvm/cache/') { $nignore[] = $i; } } }
1108
 
1109
  # when to defer, order matters
1110
  $defer = 0; if($enable_defer_js == true) { $defer = 1; }
1111
- if (fastvelocity_min_in_arrayi($src, $nignore)) { $defer = 0; }
1112
 
1113
  # get available nodes and add create with defer tag (if not async)
1114
  $dom = new DOMDocument();
@@ -1129,7 +1184,7 @@ if ($defer == 0) {
1129
  if ($defer_for_pagespeed != true) { return $tag; } else {
1130
 
1131
  # return if external script url https://www.chromestatus.com/feature/5718547946799104
1132
- if (stripos($src, $wp_domain) === false) { return $tag; }
1133
 
1134
  # print code or return
1135
  if(!empty($tagdefer)) {
@@ -1152,7 +1207,7 @@ return $tag;
1152
  # process header css ######################
1153
  ###########################################
1154
  function fastvelocity_min_merge_header_css() {
1155
- 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, $send_css_to_footer, $critical_path_css, $critical_css_tester;
1156
  if(!is_object($wp_styles)) { return false; }
1157
  $ctime = get_option('fvm-last-cache-update', '0');
1158
  $styles = wp_clone($wp_styles);
@@ -1163,6 +1218,17 @@ $google_fonts = array();
1163
  $process = array();
1164
  $inline_css = array();
1165
 
 
 
 
 
 
 
 
 
 
 
 
1166
  # add defaults to ignore list
1167
  $ignore = fastvelocity_default_ignore($ignore);
1168
 
@@ -1194,7 +1260,10 @@ foreach( $styles->to_do as $handle):
1194
 
1195
  # google fonts to the top (collect and skip process array)
1196
  if (stripos($hurl, 'fonts.googleapis.com') !== false) {
1197
- if(!$skip_google_fonts) { $google_fonts[$handle] = $hurl; } else { wp_enqueue_style($handle); } # skip google fonts optimization?
 
 
 
1198
  continue;
1199
  }
1200
 
@@ -1209,7 +1278,7 @@ if(!$skip_google_fonts && count($google_fonts) > 0) {
1209
  $concat_google_fonts = fastvelocity_min_concatenate_google_fonts($google_fonts);
1210
  foreach ($google_fonts as $h=>$a) { $done = array_merge($done, array($h)); } # mark as done
1211
  if($force_inline_googlefonts == false) {
1212
- wp_enqueue_style('header-fvm-fonts', fvm_get_protocol($concat_google_fonts), array(), null, 'all');
1213
  } else {
1214
 
1215
  # google fonts download and inlining, ignore logs
@@ -1230,8 +1299,6 @@ if(!$skip_google_fonts && count($google_fonts) > 0) {
1230
  }
1231
 
1232
 
1233
-
1234
-
1235
  # get groups of handles
1236
  foreach( $styles->to_do as $handle ) :
1237
 
@@ -1310,7 +1377,12 @@ if(!$skip_cssorder) {
1310
  }
1311
 
1312
 
1313
- # critical path
 
 
 
 
 
1314
  if(!empty($critical_path_css) && $critical_path_css != false) {
1315
  if($send_css_to_footer != false) {
1316
  echo '<style id="critical-path-global" type="text/css" media="all">'.$critical_path_css.'</style>'."\n";
@@ -1354,7 +1426,7 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1354
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
1355
  $newcode = false; $newcode = get_transient($tkey);
1356
  if ( $newcode === false) {
1357
- $res = fvm_download_and_cache($hurl, $tkey, null, $disable_css_minification, 'css');
1358
  if(is_array($res)) {
1359
  $newcode = $res['code'];
1360
  $newlog = $res['log'];
@@ -1381,7 +1453,8 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1381
 
1382
  # generate cache, write log
1383
  file_put_contents($file.'.txt', $log);
1384
- file_put_contents($file, $code);
 
1385
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1386
 
1387
  }
@@ -1394,11 +1467,25 @@ for($i=0,$l=count($header);$i<$l;$i++) {
1394
 
1395
  # move CSS to footer ?
1396
  if($send_css_to_footer != false) {
1397
- if($critical_css_tester != true) {
1398
- echo '<link rel="preload" href="'.$file_url.'" as="style" media="'.$header[$i]['media'].'" onload="this.rel=\'stylesheet\'">';
1399
- echo '<noscript><link rel="stylesheet" type="text/css" media="'.$header[$i]['media'].'" href="'.$file_url.'"></noscript>';
1400
- echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="'.$header[$i]['media'].'" href="'.$file_url.'"><![endif]-->';
1401
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1402
  } else {
1403
 
1404
  # default
@@ -1426,7 +1513,7 @@ $wp_styles->done = $done;
1426
  # process css in the footer ###############
1427
  ###########################################
1428
  function fastvelocity_min_merge_footer_css() {
1429
- 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, $send_css_to_footer, $critical_css_tester;
1430
  if(!is_object($wp_styles)) { return false; }
1431
  $ctime = get_option('fvm-last-cache-update', '0');
1432
  $styles = wp_clone($wp_styles);
@@ -1436,9 +1523,28 @@ $footer = array();
1436
  $google_fonts = array();
1437
  $inline_css = array();
1438
 
 
 
 
 
 
 
 
 
 
 
 
 
1439
  # add defaults to ignore list
1440
  $ignore = fastvelocity_default_ignore($ignore);
1441
 
 
 
 
 
 
 
 
1442
 
1443
  # google fonts to the top
1444
  foreach( $styles->to_do as $handle ) :
@@ -1446,7 +1552,10 @@ foreach( $styles->to_do as $handle ) :
1446
  $hurl = fastvelocity_min_get_hurl($wp_styles->registered[$handle]->src, $wp_domain, $wp_home);
1447
  if (stripos($hurl, 'fonts.googleapis.com') !== false) {
1448
  wp_dequeue_style($handle);
1449
- if(!$skip_google_fonts) { $google_fonts[$handle] = $hurl; } else { wp_enqueue_style($handle); } # skip google fonts optimization?
 
 
 
1450
  } else {
1451
  wp_dequeue_style($handle); wp_enqueue_style($handle); # failsafe
1452
  }
@@ -1595,7 +1704,7 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1595
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
1596
  $newcode = false; $newcode = get_transient($tkey);
1597
  if ( $newcode === false) {
1598
- $res = fvm_download_and_cache($hurl, $tkey, null, $disable_css_minification, 'css');
1599
  if(is_array($res)) {
1600
  $newcode = $res['code'];
1601
  $newlog = $res['log'];
@@ -1622,32 +1731,26 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
1622
 
1623
  # generate cache, add inline css, write log
1624
  file_put_contents($file.'.txt', $log);
1625
- file_put_contents($file, $code); # preserve style tags
 
1626
  file_put_contents($file.'.gz', gzencode(file_get_contents($file), 9));
1627
 
1628
  }
1629
-
1630
  # register and enqueue minified file, consider excluding of mediatype "print" and inline css
1631
  if ($remove_print_mediatypes != 1 || ($remove_print_mediatypes == 1 && $footer[$i]['media'] != 'print')) {
1632
  if($force_inline_css_footer != false) {
1633
  echo '<style type="text/css" media="'.$footer[$i]['media'].'">'.file_get_contents($file).'</style>';
1634
  } else {
1635
 
1636
- # move CSS to footer
1637
  if($send_css_to_footer != false) {
1638
-
1639
- if($critical_css_tester != true) {
1640
- echo '<link rel="preload" href="'.$file_url.'" as="style" media="'.$footer[$i]['media'].'" onload="this.rel=\'stylesheet\'">';
1641
- echo '<noscript><link rel="stylesheet" type="text/css" media="'.$footer[$i]['media'].'" href="'.$file_url.'"></noscript>';
1642
- echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="'.$footer[$i]['media'].'" href="'.$file_url.'"><![endif]-->';
1643
- }
1644
-
1645
  } else {
1646
-
1647
- # default
1648
  wp_register_style("fvm-footer-$i", $file_url, array(), null, $footer[$i]['media']);
1649
  wp_enqueue_style("fvm-footer-$i");
1650
-
1651
  }
1652
  }
1653
  }
@@ -1665,29 +1768,6 @@ $wp_styles->done = $done;
1665
 
1666
 
1667
 
1668
-
1669
- ###########################################
1670
- # defer CSS globally from the header (order matters)
1671
- ###########################################
1672
- function fvm_movecss_to_footer_header() {
1673
- global $send_css_to_footer;
1674
- if($send_css_to_footer != false) {
1675
-
1676
- # echo LoadCSS scripts
1677
- echo '<script>
1678
- /*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
1679
- !function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
1680
- /*! loadCSS rel=preload polyfill. [c]2017 Filament Group, Inc. MIT License */
1681
- !function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}}(this);
1682
- </script>';
1683
-
1684
- } }
1685
-
1686
- if (!is_admin()) { add_action('wp_head', 'fvm_movecss_to_footer_header', PHP_INT_MAX); }
1687
- ###########################################
1688
-
1689
-
1690
-
1691
  ###########################################
1692
  # generate gulp-uncss files for this page (dev only)
1693
  ###########################################
@@ -1737,6 +1817,7 @@ if (!is_admin()) { add_action('wp_footer', 'fvm_generate_gulp_uncss', PHP_INT_MA
1737
 
1738
 
1739
 
 
1740
  ###########################################
1741
  # add preconnect and preload headers
1742
  ###########################################
@@ -1770,14 +1851,16 @@ if((is_home() || is_front_page()) && count($preload) > 0) {
1770
  echo implode('', $meta);
1771
  }
1772
 
 
1773
  # remove query from static assets and process defering (if enabled)
1774
- if (!is_admin()) {
1775
  add_filter('script_loader_tag', 'fastvelocity_min_defer_js', 10, 3);
1776
  add_filter('style_loader_src', 'fastvelocity_remove_cssjs_ver', 10, 2);
1777
  }
1778
 
 
1779
  # enable html minification
1780
  if(!$skip_html_minification && !is_admin()) {
1781
- add_action('get_header', 'fastvelocity_min_html_compression_start', PHP_INT_MAX);
1782
- }
1783
 
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
  ------------------------------------------------------------------------
90
  # build control panel pages ###############
91
  ###########################################
92
 
93
+ # options from the database, false if not set
94
+ $ignore = array_map('trim', explode("\n", get_option('fastvelocity_min_ignore', '')));
95
+ $blacklist = array_map('trim', explode("\n", get_option('fastvelocity_min_blacklist', '')));
96
+ $ignorelist = array_map('trim', explode("\n", get_option('fastvelocity_min_ignorelist', '')));
97
+ $merge_allowed_urls = array_map('trim', explode("\n", get_option('fastvelocity_min_merge_allowed_urls', '')));
98
+ $default_protocol = get_option('fastvelocity_min_default_protocol', 'dynamic');
99
+ $disable_js_merge = get_option('fastvelocity_min_disable_js_merge');
100
+ $disable_css_merge = get_option('fastvelocity_min_disable_css_merge');
101
+ $disable_js_minification = get_option('fastvelocity_min_disable_js_minification');
102
+ $disable_css_minification = get_option('fastvelocity_min_disable_css_minification');
103
+ $use_yui = get_option('fastvelocity_min_use_yui');
104
+ $remove_print_mediatypes = get_option('fastvelocity_min_remove_print_mediatypes');
105
+ $skip_html_minification = get_option('fastvelocity_min_skip_html_minification');
106
+ $use_alt_html_minification = get_option('fastvelocity_min_use_alt_html_minification');
107
+ $strip_htmlcomments = get_option('fastvelocity_min_strip_htmlcomments');
108
+ $skip_cssorder = get_option('fastvelocity_min_skip_cssorder');
109
+ $skip_google_fonts = get_option('fastvelocity_min_skip_google_fonts');
110
+ $skip_emoji_removal = get_option('fastvelocity_min_skip_emoji_removal');
111
+ $enable_defer_js = get_option('fastvelocity_min_enable_defer_js');
112
+ $exclude_defer_jquery = get_option('fastvelocity_min_exclude_defer_jquery');
113
+ $force_inline_css = get_option('fastvelocity_min_force_inline_css');
114
+ $force_inline_css_footer = get_option('fastvelocity_min_force_inline_css_footer');
115
+ $force_inline_googlefonts = get_option('fastvelocity_min_force_inline_googlefonts');
116
+ $remove_googlefonts = get_option('fastvelocity_min_remove_googlefonts');
117
+ $defer_for_pagespeed = get_option('fastvelocity_min_defer_for_pagespeed');
118
+ $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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  $used_css_files = array();
134
 
135
+ # default blacklist
136
+ $exc = array('/html5shiv.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');
137
+ if(!is_array($blacklist) || strlen(implode($blacklist)) == 0) { update_option('fastvelocity_min_blacklist', implode("\n", $exc)); }
138
+
139
+ # default ignore list
140
+ $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');
141
+ if(!is_array($ignorelist) || strlen(implode($ignorelist)) == 0) { update_option('fastvelocity_min_ignorelist', implode("\n", $exc)); }
142
+
143
+
144
+
145
  # add admin page and rewrite defaults
146
  if(is_admin()) {
147
  add_action('admin_menu', 'fastvelocity_min_admin_menu');
150
  add_action('admin_init', 'fastvelocity_min_register_settings');
151
  register_deactivation_hook( __FILE__, 'fastvelocity_min_plugin_deactivate');
152
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  # skip on certain post_types or if there are specific keys on the url or if editor or admin
155
  if(!fastvelocity_exclude_contents()) {
167
  if(!$skip_emoji_removal) {
168
  add_action( 'init', 'fastvelocity_min_disable_wp_emojicons' );
169
  }
170
+
171
  }
172
  }
173
 
270
  register_setting('fvm-group', 'fastvelocity_min_force_inline_css');
271
  register_setting('fvm-group', 'fastvelocity_min_force_inline_css_footer');
272
  register_setting('fvm-group', 'fastvelocity_min_force_inline_googlefonts');
273
+ register_setting('fvm-group', 'fastvelocity_min_remove_googlefonts');
274
  register_setting('fvm-group', 'fastvelocity_min_defer_for_pagespeed');
275
  register_setting('fvm-group', 'fastvelocity_min_exclude_defer_login');
276
  register_setting('fvm-group', 'fastvelocity_min_preload');
277
  register_setting('fvm-group', 'fastvelocity_min_preconnect');
278
  register_setting('fvm-group', 'fastvelocity_min_fvm_fix_editor');
 
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
 
477
  Inline Google Fonts CSS <span class="note-info">[ If selected, Google Fonts CSS code will be inlined using "*.woof" format - NOTE: IE9+ and <a target="_blank" href="http://caniuse.com/#feat=woff">modern browsers</a> only]</span></label>
478
  <br />
479
 
480
+ <label for="fastvelocity_min_remove_googlefonts">
481
+ <input name="fastvelocity_min_remove_googlefonts" type="checkbox" id="fastvelocity_min_remove_googlefonts" value="1" <?php echo checked(1 == get_option('fastvelocity_min_remove_googlefonts'), true, false); ?> >
482
+ Remove Google Fonts <span class="note-info">[ If selected, all enqueued Google Fonts will be removed from the site ]</span></label>
483
+ <br />
484
+
485
  </fieldset></td>
486
  </tr>
487
 
593
  <tbody>
594
  <tr>
595
  <th scope="row">Ignore List</th>
596
+ <td><fieldset>
597
+ <label for="blacklist_keys"><span class="fvm-label-pad">Ignore the following CSS and JS paths below:</span></label>
598
  <p>
599
  <textarea name="fastvelocity_min_ignore" rows="10" cols="50" id="fastvelocity_min_ignore" class="large-text code" placeholder="ex: /wp-includes/js/jquery/jquery.js"><?php echo get_option('fastvelocity_min_ignore'); ?></textarea>
600
  </p>
601
+ <p class="description">[ Your own list of js /css files to ignore with wildcard support (read the faqs) ]</p>
 
602
  </fieldset></td>
603
  </tr>
604
  </tbody></table>
606
 
607
  <div style="height: 20px;"></div>
608
  <h2 class="title">CDN Options</h2>
609
+ <p class="fvm-bold-green">Use this to map your static assets to your cdn url.</p>
610
 
611
  <table class="form-table fvm-settings">
612
  <tbody>
613
  <tr>
614
+ <th scope="row"><span class="fvm-label-special">Your CDN domain</span></th>
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>
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>
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>
758
+
759
+ <div style="height: 20px;"></div>
760
+ <table class="form-table fvm-settings">
761
+ <tbody>
762
+ <tr>
763
+ <th scope="row">Default Ignore List</th>
764
+ <td>
765
+ <fieldset><label for="blacklist_keys"><span class="fvm-label-pad">Do not edit, if you're not sure what this is:</span></label>
766
+ <p>
767
+ <textarea name="fastvelocity_min_ignorelist" rows="10" cols="50" id="fastvelocity_min_ignorelist" class="large-text code" placeholder="ex: /wp-includes/js/jquery/jquery.js"><?php echo get_option('fastvelocity_min_ignorelist'); ?></textarea>
768
+ </p>
769
+ <p class="description">[ Files that have been reported by other users to cause trouble when merged and that should always be ignored ]</p>
770
+ </fieldset></td>
771
+ </tr>
772
+ </tbody></table>
773
 
774
+ <div style="height: 20px;"></div>
775
+ <table class="form-table fvm-settings">
776
+ <tbody>
777
+ <tr>
778
+ <th scope="row">Default Blacklist</th>
779
+ <td><fieldset><label for="blacklist_keys"><span class="fvm-label-pad">Do not edit, if you're not sure what this is:</span></label>
780
+ <p>
781
+ <textarea name="fastvelocity_min_blacklist" rows="10" cols="50" id="fastvelocity_min_blacklist" class="large-text code" placeholder="ex: /wp-includes/js/jquery/jquery.js"><?php echo get_option('fastvelocity_min_blacklist'); ?></textarea>
782
+ </p>
783
+ <p class="description">[ Usually, any IE css /js files that should always be ignored without incrementing the groups ]</p>
784
+ </fieldset></td>
785
+ </tr>
786
  </tbody></table>
787
 
788
+
789
  <p class="submit"><input type="submit" name="fastvelocity_min_save_options" id="fastvelocity_min_save_options" class="button button-primary" value="Save Changes"></p>
790
  </form>
791
 
948
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
949
  $newcode = false; $newcode = get_transient($tkey);
950
  if ( $newcode === false) {
951
+ $res = fvm_download_and_cache($hurl, $tkey, null, $disable_js_minification, 'js', $handle);
952
  if(is_array($res)) {
953
  $newcode = $res['code'];
954
  $newlog = $res['log'];
1080
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
1081
  $newcode = false; $newcode = get_transient($tkey);
1082
  if ( $newcode === false) {
1083
+ $res = fvm_download_and_cache($hurl, $tkey, null, $disable_js_minification, 'js', $handle);
1084
  if(is_array($res)) {
1085
  $newcode = $res['code'];
1086
  $newlog = $res['log'];
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) {
1147
  $srcf = stristr($src, '?ver', true);
1148
  $tag = str_ireplace($src, $srcf, $tag);
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
 
1161
  # reprocess the ignore list to remove the /fvm/cache/ from the list (else won't defer)
1162
+ $nignore = array(); if(is_array($ignore)) { foreach ($ignore as $i) { if($i != '/fvm/cache/') { $nignore[] = $i; } } }
1163
 
1164
  # when to defer, order matters
1165
  $defer = 0; if($enable_defer_js == true) { $defer = 1; }
1166
+ if (count($nignore) > 0 && fastvelocity_min_in_arrayi($src, $nignore)) { $defer = 0; }
1167
 
1168
  # get available nodes and add create with defer tag (if not async)
1169
  $dom = new DOMDocument();
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)) {
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);
1218
  $process = array();
1219
  $inline_css = array();
1220
 
1221
+ # dequeue all styles
1222
+ if($fvm_remove_css != false) {
1223
+ foreach( $styles->to_do as $handle ) :
1224
+ $done = array_merge($done, array($handle));
1225
+ endforeach;
1226
+
1227
+ # remove from queue
1228
+ $wp_styles->done = $done;
1229
+ return false;
1230
+ }
1231
+
1232
  # add defaults to ignore list
1233
  $ignore = fastvelocity_default_ignore($ignore);
1234
 
1260
 
1261
  # google fonts to the top (collect and skip process array)
1262
  if (stripos($hurl, 'fonts.googleapis.com') !== false) {
1263
+ if($remove_googlefonts != false) { $done = array_merge($done, array($handle)); continue; } # mark as done if to be removed
1264
+ if(!$skip_google_fonts) { $google_fonts[$handle] = $hurl; } else {
1265
+ wp_enqueue_style($handle); # skip google fonts optimization?
1266
+ }
1267
  continue;
1268
  }
1269
 
1278
  $concat_google_fonts = fastvelocity_min_concatenate_google_fonts($google_fonts);
1279
  foreach ($google_fonts as $h=>$a) { $done = array_merge($done, array($h)); } # mark as done
1280
  if($force_inline_googlefonts == false) {
1281
+ wp_enqueue_style('header-fvm-fonts', fvm_get_protocol($concat_google_fonts), array(), null, 'all');
1282
  } else {
1283
 
1284
  # google fonts download and inlining, ignore logs
1299
  }
1300
 
1301
 
 
 
1302
  # get groups of handles
1303
  foreach( $styles->to_do as $handle ) :
1304
 
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";
1426
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
1427
  $newcode = false; $newcode = get_transient($tkey);
1428
  if ( $newcode === false) {
1429
+ $res = fvm_download_and_cache($hurl, $tkey, null, $disable_css_minification, 'css', $handle);
1430
  if(is_array($res)) {
1431
  $newcode = $res['code'];
1432
  $newlog = $res['log'];
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
  }
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
 
1491
  # default
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);
1523
  $google_fonts = array();
1524
  $inline_css = array();
1525
 
1526
+ # dequeue all styles
1527
+ if($fvm_remove_css != false) {
1528
+ foreach( $styles->to_do as $handle ) :
1529
+ $done = array_merge($done, array($handle));
1530
+ endforeach;
1531
+
1532
+ # remove from queue
1533
+ $wp_styles->done = $done;
1534
+ return false;
1535
+ }
1536
+
1537
+
1538
  # add defaults to ignore list
1539
  $ignore = fastvelocity_default_ignore($ignore);
1540
 
1541
+ # header styles that moved to footer
1542
+ if(isset($GLOBALS["fvm-css"]) && is_array($GLOBALS["fvm-css"])) {
1543
+ foreach ($GLOBALS["fvm-css"] as $st) {
1544
+ if(!empty($st)) { echo $st; }
1545
+ }
1546
+ }
1547
+
1548
 
1549
  # google fonts to the top
1550
  foreach( $styles->to_do as $handle ) :
1552
  $hurl = fastvelocity_min_get_hurl($wp_styles->registered[$handle]->src, $wp_domain, $wp_home);
1553
  if (stripos($hurl, 'fonts.googleapis.com') !== false) {
1554
  wp_dequeue_style($handle);
1555
+ if($remove_googlefonts != false) { $done = array_merge($done, array($handle)); continue; } # mark as done if to be removed
1556
+ if(!$skip_google_fonts) { $google_fonts[$handle] = $hurl; } else {
1557
+ wp_enqueue_style($handle); # skip google fonts optimization?
1558
+ }
1559
  } else {
1560
  wp_dequeue_style($handle); wp_enqueue_style($handle); # failsafe
1561
  }
1704
  $tkey = 'fvm-cache-'.$ctime.hash('adler32', $hurl);
1705
  $newcode = false; $newcode = get_transient($tkey);
1706
  if ( $newcode === false) {
1707
+ $res = fvm_download_and_cache($hurl, $tkey, null, $disable_css_minification, 'css', $handle);
1708
  if(is_array($res)) {
1709
  $newcode = $res['code'];
1710
  $newlog = $res['log'];
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
  }
1739
+
1740
  # register and enqueue minified file, consider excluding of mediatype "print" and inline css
1741
  if ($remove_print_mediatypes != 1 || ($remove_print_mediatypes == 1 && $footer[$i]['media'] != 'print')) {
1742
  if($force_inline_css_footer != false) {
1743
  echo '<style type="text/css" media="'.$footer[$i]['media'].'">'.file_get_contents($file).'</style>';
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 {
 
 
1752
  wp_register_style("fvm-footer-$i", $file_url, array(), null, $footer[$i]['media']);
1753
  wp_enqueue_style("fvm-footer-$i");
 
1754
  }
1755
  }
1756
  }
1768
 
1769
 
1770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1771
  ###########################################
1772
  # generate gulp-uncss files for this page (dev only)
1773
  ###########################################
1817
 
1818
 
1819
 
1820
+
1821
  ###########################################
1822
  # add preconnect and preload headers
1823
  ###########################################
1851
  echo implode('', $meta);
1852
  }
1853
 
1854
+
1855
  # remove query from static assets and process defering (if enabled)
1856
+ if (!is_admin()) {
1857
  add_filter('script_loader_tag', 'fastvelocity_min_defer_js', 10, 3);
1858
  add_filter('style_loader_src', 'fastvelocity_remove_cssjs_ver', 10, 2);
1859
  }
1860
 
1861
+
1862
  # enable html minification
1863
  if(!$skip_html_minification && !is_admin()) {
1864
+ add_action('template_redirect', 'fastvelocity_min_html_compression_start', PHP_INT_MAX);
1865
+ }
1866
 
inc/functions.php CHANGED
@@ -88,12 +88,23 @@ return $hurl;
88
 
89
 
90
  # check if it's an internal url or not
91
- function fvm_internal_url($hurl, $wp_home) {
92
  if (substr($hurl, 0, strlen($wp_home)) === $wp_home) { return true; }
93
  if (stripos($hurl, $wp_home) !== false) { return true; }
94
  if (isset($_SERVER['HTTP_HOST']) && stripos($hurl, preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST'])) !== false) { return true; }
95
  if (isset($_SERVER['SERVER_NAME']) && stripos($hurl, preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME'])) !== false) { return true; }
96
  if (isset($_SERVER['SERVER_ADDR']) && stripos($hurl, preg_replace('/:\d+$/', '', $_SERVER['SERVER_ADDR'])) !== false) { return true; }
 
 
 
 
 
 
 
 
 
 
 
97
  return false;
98
  }
99
 
@@ -205,20 +216,17 @@ return fvm_compat_urls($js);
205
 
206
  # functions, minify html
207
  function fastvelocity_min_minify_html($html) {
208
- return trim(fastvelocity_min_Minify_HTML::minify($html));
209
  }
210
 
211
  # functions to minify HTML
212
  function fastvelocity_min_html_compression_finish($html) { return fastvelocity_min_minify_html($html); }
213
  function fastvelocity_min_html_compression_start() {
214
-
215
  $use_alt_html_minification = get_option('fastvelocity_min_use_alt_html_minification', '0');
216
  if($use_alt_html_minification == '1') { ob_start('fastvelocity_min_minify_alt_html'); }
217
  else { ob_start('fastvelocity_min_html_compression_finish'); }
218
-
219
  }
220
 
221
-
222
  # alternative html minification, minimal
223
  function fastvelocity_min_minify_alt_html($html) {
224
  $html = trim(preg_replace('/\v(?:[\t\v\h]+)/iu', "\n", $html));
@@ -299,7 +307,7 @@ if(!$disable_css_minification) {
299
 
300
  # cdn urls
301
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
302
- if(!empty($fvm_cdn_url) && filter_var($fvm_cdn_url, FILTER_VALIDATE_URL) !== FALSE) {
303
  $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
304
  $css = str_ireplace($wp_domain, $fvm_cdn_url, $css);
305
  }
@@ -330,11 +338,12 @@ function fvm_file_get_contents_curl($url, $uagent=NULL) {
330
 
331
 
332
  # download and cache css and js files
333
- function fvm_download_and_cache($hurl, $tkey, $inline=null, $disable_minification=false, $type=null){
334
  global $cachedir, $cachedirurl, $wp_domain, $wp_home, $wp_home_path;
335
 
336
  # filters and defaults
337
  $printurl = str_ireplace(array(site_url(), home_url(), 'http:', 'https:'), '', $hurl);
 
338
 
339
  # try to open locally first, but skip if we are on windows
340
  if(fvm_server_is_windows() === false) {
@@ -346,7 +355,7 @@ if (stripos($hurl, $wp_domain) !== false) {
346
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
347
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
348
  fvm_update_transient_keys($tkey); # keep track
349
- $log = "$printurl --- Debug: File was opened from $f ---\n";
350
  return array('log'=>$log, 'code'=>$code);
351
  }
352
 
@@ -358,7 +367,7 @@ if (stripos($hurl, $wp_domain) !== false) {
358
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
359
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
360
  fvm_update_transient_keys($tkey); # keep track
361
- $log = "$printurl --- Debug: File was opened from $f ---\n";
362
  return array('log'=>$log, 'code'=>$code);
363
  }
364
  }
@@ -373,7 +382,7 @@ if($code !== false) {
373
  else { $code = fastvelocity_min_get_css($hurl, $code.$inline, $disable_minification); }
374
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
375
  fvm_update_transient_keys($tkey); # keep track
376
- $log = "$printurl --- Debug: Fetched url at $hurl \n";
377
  return array('log'=>$log, 'code'=>$code);
378
  }
379
 
@@ -387,7 +396,7 @@ if(stripos($hurl, $wp_domain) !== false && home_url() != site_url()) {
387
  else { $code = fastvelocity_min_get_css($hurl, $code.$inline, $disable_minification); }
388
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
389
  fvm_update_transient_keys($tkey); # keep track
390
- $log = "$printurl --- Debug: Fetched url at $hurl \n";
391
  return array('log'=>$log, 'code'=>$code);
392
  }
393
  }
@@ -402,7 +411,7 @@ if (stripos($hurl, $wp_domain) !== false) {
402
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
403
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
404
  fvm_update_transient_keys($tkey); # keep track
405
- $log = "$printurl --- Debug: File was opened from $f ---\n";
406
  return array('log'=>$log, 'code'=>$code);
407
  }
408
 
@@ -414,7 +423,7 @@ if (stripos($hurl, $wp_domain) !== false) {
414
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
415
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
416
  fvm_update_transient_keys($tkey); # keep track
417
- $log = "$printurl --- Debug: File was opened from $f ---\n";
418
  return array('log'=>$log, 'code'=>$code);
419
  }
420
  }
@@ -422,7 +431,7 @@ if (stripos($hurl, $wp_domain) !== false) {
422
 
423
  # else fail
424
  $code = false;
425
- $log = " - FAILED --- Debug: Tried to fetch via wp_remote_get, curl and also to open it locally. URL: $hurl ---\n";
426
  return array('log'=>$log, 'code'=>$code);
427
  }
428
 
@@ -603,11 +612,12 @@ function fastvelocity_remove_cssjs_ver( $src ) {
603
 
604
  # rewrite cache files to http, https or dynamic
605
  function fvm_get_protocol($url) {
 
606
  $url = ltrim(str_ireplace(array('http://', 'https://'), '', $url), '/'); # better compatibility
607
 
608
  # cdn support
609
  $fvm_cdn_url = get_option('fastvelocity_min_fvm_cdn_url');
610
- if(!empty($fvm_cdn_url) && filter_var($fvm_cdn_url, FILTER_VALIDATE_URL) !== FALSE) {
611
  $fvm_cdn_url = trim(trim(str_ireplace(array('http://', 'https://'), '', trim($fvm_cdn_url, '/'))), '/');
612
  $url = str_ireplace($wp_domain, $fvm_cdn_url, $url);
613
  }
@@ -674,19 +684,8 @@ return false;
674
  function fastvelocity_default_ignore($ignore) {
675
  if(is_array($ignore)) {
676
 
677
- # defaults, to be overwriten by api or transient
678
- $exc = array('/fvm/cache/', '/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');
679
-
680
- # info and api call
681
- $api = 'https://fastvelocity.com/api/fvm/ignore.txt';
682
- $ctime = get_option('fvm-last-cache-update', '0');
683
- $tkey = 'fvm-api-ignore-'.$ctime;
684
- $ttl = 24 * 3600; # one day, in seconds
685
- $json = fastvelocity_download($api, $tkey, $ttl);
686
- if($json !== false) {
687
- $data = json_decode($json, true);
688
- if (json_last_error() === JSON_ERROR_NONE && is_array($data)) { $exc = $data; }
689
- }
690
 
691
  # should we exclude jquery when defer is enabled?
692
  $exclude_defer_jquery = get_option('fastvelocity_min_exclude_defer_jquery');
@@ -709,20 +708,12 @@ if(is_array($ignore)) {
709
 
710
  # IE only files that should always be ignored, without incrementing our groups
711
  function fastvelocity_ie_blacklist($url) {
 
 
 
712
 
713
- # defaults, to be overwriten by api or transient
714
- $exc = array('/html5shiv.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');
715
-
716
- # info and api call
717
- $api = 'https://fastvelocity.com/api/fvm/ie_blacklist.txt';
718
- $ctime = get_option('fvm-last-cache-update', '0');
719
- $tkey = 'fvm-api-ie-blacklist-'.$ctime;
720
- $ttl = 24 * 3600; # one day, in seconds
721
- $json = fastvelocity_download($api, $tkey, $ttl);
722
- if($json !== false) {
723
- $data = json_decode($json, true);
724
- if (json_last_error() === JSON_ERROR_NONE && is_array($data)) { $exc = $data; }
725
- }
726
 
727
  # is the url on our list and return
728
  $res = fastvelocity_min_in_arrayi($url, $exc);
@@ -737,8 +728,8 @@ function fastvelocity_download($url, $tkey, $ttl) {
737
  $rtlim = false; $rtlim = get_transient($tkey.'_access');
738
  if ( $rtlim !== false) { return false; }
739
 
740
- # info (needed for google fonts woff files)
741
- $uagent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12';
742
  $data = false; $data = get_transient($tkey);
743
  if ( $data === false) {
744
 
88
 
89
 
90
  # check if it's an internal url or not
91
+ function fvm_internal_url($hurl, $wp_home, $noxtra=NULL) {
92
  if (substr($hurl, 0, strlen($wp_home)) === $wp_home) { return true; }
93
  if (stripos($hurl, $wp_home) !== false) { return true; }
94
  if (isset($_SERVER['HTTP_HOST']) && stripos($hurl, preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST'])) !== false) { return true; }
95
  if (isset($_SERVER['SERVER_NAME']) && stripos($hurl, preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME'])) !== false) { return true; }
96
  if (isset($_SERVER['SERVER_ADDR']) && stripos($hurl, preg_replace('/:\d+$/', '', $_SERVER['SERVER_ADDR'])) !== false) { return true; }
97
+
98
+ # allow specific external urls to be merged
99
+ if($noxtra === NULL) {
100
+ $merge_allowed_urls = array_map('trim', explode("\n", get_option('fastvelocity_min_merge_allowed_urls', '')));
101
+ if(is_array($merge_allowed_urls) && strlen(implode($merge_allowed_urls)) > 0) {
102
+ foreach ($merge_allowed_urls as $e) {
103
+ if (stripos($hurl, $e) !== false && !empty($e)) { return true; }
104
+ }
105
+ }
106
+ }
107
+
108
  return false;
109
  }
110
 
216
 
217
  # functions, minify html
218
  function fastvelocity_min_minify_html($html) {
219
+ return fastvelocity_min_Minify_HTML::minify($html);
220
  }
221
 
222
  # functions to minify HTML
223
  function fastvelocity_min_html_compression_finish($html) { return fastvelocity_min_minify_html($html); }
224
  function fastvelocity_min_html_compression_start() {
 
225
  $use_alt_html_minification = get_option('fastvelocity_min_use_alt_html_minification', '0');
226
  if($use_alt_html_minification == '1') { ob_start('fastvelocity_min_minify_alt_html'); }
227
  else { ob_start('fastvelocity_min_html_compression_finish'); }
 
228
  }
229
 
 
230
  # alternative html minification, minimal
231
  function fastvelocity_min_minify_alt_html($html) {
232
  $html = trim(preg_replace('/\v(?:[\t\v\h]+)/iu', "\n", $html));
307
 
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
  }
338
 
339
 
340
  # download and cache css and js files
341
+ function fvm_download_and_cache($hurl, $tkey, $inline=null, $disable_minification=false, $type=null, $handle=null){
342
  global $cachedir, $cachedirurl, $wp_domain, $wp_home, $wp_home_path;
343
 
344
  # filters and defaults
345
  $printurl = str_ireplace(array(site_url(), home_url(), 'http:', 'https:'), '', $hurl);
346
+ $printhandle = ''; if($handle !== null) { $printhandle = "[$handle]"; }
347
 
348
  # try to open locally first, but skip if we are on windows
349
  if(fvm_server_is_windows() === false) {
355
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
356
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
357
  fvm_update_transient_keys($tkey); # keep track
358
+ $log = "$printurl --- Debug: $printhandle File was opened from $f ---\n";
359
  return array('log'=>$log, 'code'=>$code);
360
  }
361
 
367
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
368
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
369
  fvm_update_transient_keys($tkey); # keep track
370
+ $log = "$printurl --- Debug: $printhandle File was opened from $f ---\n";
371
  return array('log'=>$log, 'code'=>$code);
372
  }
373
  }
382
  else { $code = fastvelocity_min_get_css($hurl, $code.$inline, $disable_minification); }
383
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
384
  fvm_update_transient_keys($tkey); # keep track
385
+ $log = "$printurl --- Debug: $printhandle Fetched url at $hurl \n";
386
  return array('log'=>$log, 'code'=>$code);
387
  }
388
 
396
  else { $code = fastvelocity_min_get_css($hurl, $code.$inline, $disable_minification); }
397
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
398
  fvm_update_transient_keys($tkey); # keep track
399
+ $log = "$printurl --- Debug: $printhandle Fetched url at $hurl \n";
400
  return array('log'=>$log, 'code'=>$code);
401
  }
402
  }
411
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
412
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
413
  fvm_update_transient_keys($tkey); # keep track
414
+ $log = "$printurl --- Debug: $printhandle File was opened from $f ---\n";
415
  return array('log'=>$log, 'code'=>$code);
416
  }
417
 
423
  else { $code = fastvelocity_min_get_css($hurl, file_get_contents($f).$inline, $disable_minification); }
424
  set_transient($tkey, $code, 7 * DAY_IN_SECONDS );
425
  fvm_update_transient_keys($tkey); # keep track
426
+ $log = "$printurl --- Debug: $printhandle File was opened from $f ---\n";
427
  return array('log'=>$log, 'code'=>$code);
428
  }
429
  }
431
 
432
  # else fail
433
  $code = false;
434
+ $log = " - FAILED --- Debug: $printhandle Tried to fetch via wp_remote_get, curl and also to open it locally. URL: $hurl ---\n";
435
  return array('log'=>$log, 'code'=>$code);
436
  }
437
 
612
 
613
  # rewrite cache files to http, https or dynamic
614
  function fvm_get_protocol($url) {
615
+ global $wp_domain;
616
  $url = ltrim(str_ireplace(array('http://', 'https://'), '', $url), '/'); # better compatibility
617
 
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
  }
684
  function fastvelocity_default_ignore($ignore) {
685
  if(is_array($ignore)) {
686
 
687
+ # from the database
688
+ $exc = array_map('trim', explode("\n", get_option('fastvelocity_min_ignorelist', '')));
 
 
 
 
 
 
 
 
 
 
 
689
 
690
  # should we exclude jquery when defer is enabled?
691
  $exclude_defer_jquery = get_option('fastvelocity_min_exclude_defer_jquery');
708
 
709
  # IE only files that should always be ignored, without incrementing our groups
710
  function fastvelocity_ie_blacklist($url) {
711
+
712
+ # from the database
713
+ $exc = array_map('trim', explode("\n", get_option('fastvelocity_min_blacklist', '')));
714
 
715
+ # must have
716
+ $exc[] = '/fvm/cache/';
 
 
 
 
 
 
 
 
 
 
 
717
 
718
  # is the url on our list and return
719
  $res = fastvelocity_min_in_arrayi($url, $exc);
728
  $rtlim = false; $rtlim = get_transient($tkey.'_access');
729
  if ( $rtlim !== false) { return false; }
730
 
731
+ # info (needed for google fonts woff files + hinted fonts)
732
+ $uagent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586';
733
  $data = false; $data = get_transient($tkey);
734
  if ( $data === false) {
735
 
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.1
6
- Tested up to: 4.8.1
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -274,6 +274,12 @@ Note: Kindly purge the plugin cache as well as your server /plugin cache after u
274
 
275
  == Changelog ==
276
 
 
 
 
 
 
 
277
  = 2.2.1 [2017.08.21] =
278
  * added unicode support to the alternative html minification option
279
  * improved some options description
@@ -283,7 +289,7 @@ Note: Kindly purge the plugin cache as well as your server /plugin cache after u
283
  * fixed the alternative html minification option
284
 
285
  = 2.1.9 [2017.08.11] =
286
- * fixed a devolopment bug
287
 
288
  = 2.1.8 [2017.08.11] =
289
  * fixed the html minification not working
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
 
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
280
+ * added option to remove all enqueued google fonts (so you can use your own CSS @fontfaces manually)
281
+ * added font hinting for the "Inline Google Fonts CSS" option, so it looks better on Windows
282
+
283
  = 2.2.1 [2017.08.21] =
284
  * added unicode support to the alternative html minification option
285
  * improved some options description
289
  * fixed the alternative html minification option
290
 
291
  = 2.1.9 [2017.08.11] =
292
+ * fixed a development bug
293
 
294
  = 2.1.8 [2017.08.11] =
295
  * fixed the html minification not working