Version Description
[2018.12.03] * added option to inline CSS in the footer, while still preserving the merged file in the header * improvements for the google fonts merging option * fixed double notification, when purging caches without a cache plugin
Download this release
Release Info
Developer | Alignak |
Plugin | Fast Velocity Minify |
Version | 2.4.4 |
Comparing to | |
See all releases |
Code changes from version 2.4.3 to 2.4.4
- fvm.php +12 -5
- inc/functions.php +98 -65
- readme.txt +6 -1
fvm.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://fastvelocity.com
|
|
5 |
Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
-
Version: 2.4.
|
9 |
License: GPL2
|
10 |
|
11 |
------------------------------------------------------------------------
|
@@ -127,6 +127,7 @@ $fvm_clean_header_one = get_option('fastvelocity_fvm_clean_header_one');
|
|
127 |
$enable_defer_js = get_option('fastvelocity_min_enable_defer_js');
|
128 |
$exclude_defer_jquery = get_option('fastvelocity_min_exclude_defer_jquery');
|
129 |
$force_inline_css = get_option('fastvelocity_min_force_inline_css');
|
|
|
130 |
$remove_googlefonts = get_option('fastvelocity_min_remove_googlefonts');
|
131 |
$defer_for_pagespeed = get_option('fastvelocity_min_defer_for_pagespeed');
|
132 |
$defer_for_pagespeed_optimize = get_option('fastvelocity_min_defer_for_pagespeed_optimize');
|
@@ -350,6 +351,7 @@ function fastvelocity_min_register_settings() {
|
|
350 |
register_setting('fvm-group', 'fastvelocity_min_enable_defer_js');
|
351 |
register_setting('fvm-group', 'fastvelocity_min_exclude_defer_jquery');
|
352 |
register_setting('fvm-group', 'fastvelocity_min_force_inline_css');
|
|
|
353 |
register_setting('fvm-group', 'fastvelocity_min_remove_googlefonts');
|
354 |
register_setting('fvm-group', 'fastvelocity_gfonts_method');
|
355 |
register_setting('fvm-group', 'fastvelocity_fontawesome_method');
|
@@ -416,6 +418,7 @@ function fastvelocity_process_cache_purge_request(){
|
|
416 |
fastvelocity_purge_others(); # purge third party caches
|
417 |
$others = fastvelocity_purge_others(); # purge third party caches
|
418 |
$notice = array('All caches from <strong>FVM</strong> have been purged!', strip_tags($others, '<strong>'));
|
|
|
419 |
$notice = base64_encode(json_encode($notice)); # encode
|
420 |
setcookie('wordpress_fvmcache', $notice, time()+60, COOKIEPATH, COOKIE_DOMAIN );
|
421 |
wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
|
@@ -697,9 +700,13 @@ Preserve the order of CSS files <span class="note-info">[ If selected, you will
|
|
697 |
<input name="fastvelocity_min_remove_print_mediatypes" type="checkbox" id="fastvelocity_min_remove_print_mediatypes" value="1" <?php echo checked(1 == get_option('fastvelocity_min_remove_print_mediatypes'), true, false); ?> >
|
698 |
Remove the "Print" related stylesheets <span class="note-info">[ If selected, CSS files of mediatype "print" will be removed from the site ]</span></label>
|
699 |
<br />
|
|
|
|
|
|
|
|
|
700 |
<label for="fastvelocity_min_force_inline_css">
|
701 |
<input name="fastvelocity_min_force_inline_css" type="checkbox" id="fastvelocity_min_force_inline_css" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css'), true, false); ?>>
|
702 |
-
Inline all CSS files <span class="note-info">[ If selected,
|
703 |
<br />
|
704 |
</fieldset></td>
|
705 |
</tr>
|
@@ -1942,7 +1949,7 @@ $wp_styles->done = $done;
|
|
1942 |
# process css in the footer ###############
|
1943 |
###########################################
|
1944 |
function fastvelocity_min_merge_footer_css() {
|
1945 |
-
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_googlefonts, $css_hide_googlefonts, $min_async_googlefonts, $remove_googlefonts, $fvmloadcss, $fvm_remove_css, $fvmualist, $fvm_debug, $fvm_fawesome_method, $fvm_min_excludecsslist;
|
1946 |
|
1947 |
if(!is_object($wp_styles)) { return false; }
|
1948 |
$ctime = get_option('fvm-last-cache-update', '0');
|
@@ -2267,8 +2274,8 @@ for($i=0,$l=count($footer);$i<$l;$i++) {
|
|
2267 |
} else {
|
2268 |
if(file_exists($file) && filesize($file) > 0) {
|
2269 |
|
2270 |
-
# inline if the file is smaller than 20KB
|
2271 |
-
if(filesize($file) < 20000) {
|
2272 |
echo '<style id="fvm-footer-'.$i.'" media="'.$footer[$i]['media'].'">'.file_get_contents($file).'</style>';
|
2273 |
} else {
|
2274 |
# enqueue it
|
5 |
Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
+
Version: 2.4.4
|
9 |
License: GPL2
|
10 |
|
11 |
------------------------------------------------------------------------
|
127 |
$enable_defer_js = get_option('fastvelocity_min_enable_defer_js');
|
128 |
$exclude_defer_jquery = get_option('fastvelocity_min_exclude_defer_jquery');
|
129 |
$force_inline_css = get_option('fastvelocity_min_force_inline_css');
|
130 |
+
$force_inline_css_footer = get_option('fastvelocity_min_force_inline_css_footer');
|
131 |
$remove_googlefonts = get_option('fastvelocity_min_remove_googlefonts');
|
132 |
$defer_for_pagespeed = get_option('fastvelocity_min_defer_for_pagespeed');
|
133 |
$defer_for_pagespeed_optimize = get_option('fastvelocity_min_defer_for_pagespeed_optimize');
|
351 |
register_setting('fvm-group', 'fastvelocity_min_enable_defer_js');
|
352 |
register_setting('fvm-group', 'fastvelocity_min_exclude_defer_jquery');
|
353 |
register_setting('fvm-group', 'fastvelocity_min_force_inline_css');
|
354 |
+
register_setting('fvm-group', 'fastvelocity_min_force_inline_css_footer');
|
355 |
register_setting('fvm-group', 'fastvelocity_min_remove_googlefonts');
|
356 |
register_setting('fvm-group', 'fastvelocity_gfonts_method');
|
357 |
register_setting('fvm-group', 'fastvelocity_fontawesome_method');
|
418 |
fastvelocity_purge_others(); # purge third party caches
|
419 |
$others = fastvelocity_purge_others(); # purge third party caches
|
420 |
$notice = array('All caches from <strong>FVM</strong> have been purged!', strip_tags($others, '<strong>'));
|
421 |
+
$notice = array_filter($notice);
|
422 |
$notice = base64_encode(json_encode($notice)); # encode
|
423 |
setcookie('wordpress_fvmcache', $notice, time()+60, COOKIEPATH, COOKIE_DOMAIN );
|
424 |
wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
|
700 |
<input name="fastvelocity_min_remove_print_mediatypes" type="checkbox" id="fastvelocity_min_remove_print_mediatypes" value="1" <?php echo checked(1 == get_option('fastvelocity_min_remove_print_mediatypes'), true, false); ?> >
|
701 |
Remove the "Print" related stylesheets <span class="note-info">[ If selected, CSS files of mediatype "print" will be removed from the site ]</span></label>
|
702 |
<br />
|
703 |
+
<label for="fastvelocity_min_force_inline_css_footer">
|
704 |
+
<input name="fastvelocity_min_force_inline_css_footer" type="checkbox" id="fastvelocity_min_force_inline_css_footer" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css_footer'), true, false); ?>>
|
705 |
+
Inline CSS in the footer <span class="note-info">[ If selected, any FVM generated CSS files in the footer, will be inlined ]</span></label>
|
706 |
+
<br />
|
707 |
<label for="fastvelocity_min_force_inline_css">
|
708 |
<input name="fastvelocity_min_force_inline_css" type="checkbox" id="fastvelocity_min_force_inline_css" value="1" <?php echo checked(1 == get_option('fastvelocity_min_force_inline_css'), true, false); ?>>
|
709 |
+
Inline all FVM generated CSS files <span class="note-info">[ If selected, any FVM generated CSS files (header + footer) will be inlined ]</span></label>
|
710 |
<br />
|
711 |
</fieldset></td>
|
712 |
</tr>
|
1949 |
# process css in the footer ###############
|
1950 |
###########################################
|
1951 |
function fastvelocity_min_merge_footer_css() {
|
1952 |
+
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_googlefonts, $css_hide_googlefonts, $min_async_googlefonts, $remove_googlefonts, $fvmloadcss, $fvm_remove_css, $fvmualist, $fvm_debug, $fvm_fawesome_method, $fvm_min_excludecsslist, $force_inline_css_footer;
|
1953 |
|
1954 |
if(!is_object($wp_styles)) { return false; }
|
1955 |
$ctime = get_option('fvm-last-cache-update', '0');
|
2274 |
} else {
|
2275 |
if(file_exists($file) && filesize($file) > 0) {
|
2276 |
|
2277 |
+
# inline if the file is smaller than 20KB or option has been enabled
|
2278 |
+
if(filesize($file) < 20000 || $force_inline_css_footer != false) {
|
2279 |
echo '<style id="fvm-footer-'.$i.'" media="'.$footer[$i]['media'].'">'.file_get_contents($file).'</style>';
|
2280 |
} else {
|
2281 |
# enqueue it
|
inc/functions.php
CHANGED
@@ -576,79 +576,112 @@ $printurl = str_ireplace(array(site_url(), home_url(), 'http:', 'https:'), '', $
|
|
576 |
# Concatenate Google Fonts tags (http://fonts.googleapis.com/css?...)
|
577 |
function fastvelocity_min_concatenate_google_fonts($array) {
|
578 |
|
579 |
-
# extract unique font families
|
580 |
-
$families = array();
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
$
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
$
|
594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
|
596 |
-
# if no type or subset
|
597 |
-
if(stristr($font, ':') === FALSE) {
|
598 |
-
$fonts[] = array('name'=>$font, 'type'=>'', 'sub'=>'');
|
599 |
-
} else {
|
600 |
-
|
601 |
-
# get type and subset
|
602 |
-
$name = stristr($font, ':', true); # font name, before :
|
603 |
-
$ftype = trim(stristr($font, ':'), ':'); # second part of the string, after :
|
604 |
-
|
605 |
-
# get font types and subset
|
606 |
-
if(stristr($ftype, '&subset=') === FALSE) {
|
607 |
-
$fonts[] = array('name'=>$name, 'type'=>$ftype, 'sub'=>'');
|
608 |
-
} else {
|
609 |
-
$newftype = stristr($ftype, '&', true); # font type, before &
|
610 |
-
$subset = trim(str_ireplace('&subset=', '', stristr($ftype, '&'))); # second part of the string, after &
|
611 |
-
$fonts[] = array('name'=>$name, 'type'=>$newftype, 'sub'=>$subset);
|
612 |
}
|
613 |
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
$
|
620 |
-
|
621 |
-
|
622 |
-
$fonts_and_types = $ufonts;
|
623 |
-
|
624 |
-
# get unique types and subsets for each unique font name
|
625 |
-
foreach ($ufonts as $uf) {
|
626 |
-
|
627 |
-
# types
|
628 |
-
$utypes = array();
|
629 |
-
foreach ($fonts as $f) {
|
630 |
-
if($f['name'] == $uf && !empty($f['type'])) { $utypes = array_merge($utypes, explode(',', $f['type'])); }
|
631 |
}
|
632 |
-
|
633 |
-
# filter types
|
634 |
-
$utypes = array_unique($utypes);
|
635 |
-
sort($utypes);
|
636 |
-
$ntype = ''; if(count($utypes) > 0) { $ntype = ':'.implode(',', $utypes); } # types to append to the font name
|
637 |
-
|
638 |
-
# generate font url queries
|
639 |
-
$fonts_and_types[$uf] = str_ireplace(' ', '+', $uf).$ntype;
|
640 |
-
}
|
641 |
|
642 |
-
#
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
|
|
|
|
|
|
647 |
|
648 |
-
return
|
|
|
|
|
|
|
|
|
|
|
649 |
}
|
650 |
|
651 |
-
|
652 |
# remove emoji support
|
653 |
function fastvelocity_min_disable_wp_emojicons() {
|
654 |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
|
576 |
# Concatenate Google Fonts tags (http://fonts.googleapis.com/css?...)
|
577 |
function fastvelocity_min_concatenate_google_fonts($array) {
|
578 |
|
579 |
+
# extract unique font families
|
580 |
+
$families = array();
|
581 |
+
foreach ($array as $font) {
|
582 |
+
|
583 |
+
# get fonts name, type and subset, remove wp query strings
|
584 |
+
$font = explode('family=', htmlspecialchars_decode(rawurldecode(urldecode($font))));
|
585 |
+
$a = explode('&v', end($font));
|
586 |
+
$font = trim(trim(trim(current($a)), ','));
|
587 |
+
|
588 |
+
# reprocess if fonts are already concatenated in this url
|
589 |
+
if(stristr($font, '|') !== FALSE) {
|
590 |
+
$multiple = explode('|', $font);
|
591 |
+
if (count($multiple) > 0) {
|
592 |
+
foreach ($multiple as $f) {
|
593 |
+
$families[] = trim($f);
|
594 |
+
}
|
595 |
+
}
|
596 |
+
} else {
|
597 |
+
$families[] = $font;
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
# process names, types, subsets
|
602 |
+
$fonts = array();
|
603 |
+
$subsets = array();
|
604 |
+
foreach ($families as $font) {
|
605 |
+
|
606 |
+
# extract the subsets
|
607 |
+
if (stripos($font, 'subset') !== false) {
|
608 |
+
$sub = trim(str_ireplace('&subset=', '', stristr($font, '&'))); # second part of the string, after &
|
609 |
+
$font = stristr($font, '&', true); # font name, before &
|
610 |
+
|
611 |
+
# subsets to array, unique, trim
|
612 |
+
if (stripos($sub, ',') !== false) {
|
613 |
+
$ft = explode(',', $sub);
|
614 |
+
$ft = array_filter(array_map('trim', array_unique($ft)));
|
615 |
+
foreach ($ft as $s) {
|
616 |
+
$subsets[$s] = $s;
|
617 |
+
}
|
618 |
+
} else {
|
619 |
+
if (!empty($sub)) {
|
620 |
+
$subsets[$sub] = $sub;
|
621 |
+
}
|
622 |
+
}
|
623 |
+
|
624 |
+
}
|
625 |
+
|
626 |
+
# check for font name and weights
|
627 |
+
$ftypes = array();
|
628 |
+
$name = $font;
|
629 |
+
if (stripos($font, ':') !== false) {
|
630 |
+
$name = stristr($font, ':', true); # font name, before :
|
631 |
+
$fwe = trim(stristr($font, ':'), ':'); # second part of the string, after :
|
632 |
+
|
633 |
+
# ftypes to array, unique, trim
|
634 |
+
if (stripos($font, ',') !== false) {
|
635 |
+
$ft = explode(',', $fwe);
|
636 |
+
$ftypes = array_filter(array_map('trim', array_unique($ft)));
|
637 |
+
} else {
|
638 |
+
if (!empty($fwe)) {
|
639 |
+
$ftypes[] = $fwe;
|
640 |
+
}
|
641 |
+
}
|
642 |
+
|
643 |
+
}
|
644 |
+
|
645 |
+
# name filter
|
646 |
+
$name = str_ireplace(' ', '+', trim($name));
|
647 |
+
|
648 |
+
# save fonts list, merge fontweights
|
649 |
+
if(!isset($fonts[$name])) {
|
650 |
+
$fonts[$name] = array('name'=>$name, 'type'=>$ftypes);
|
651 |
+
} else {
|
652 |
+
$ftypes = array_merge($ftypes, $fonts[$name]['type']);
|
653 |
+
$fonts[$name] = array('name'=>$name, 'type'=>$ftypes);
|
654 |
+
}
|
655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
656 |
}
|
657 |
|
658 |
+
# build font names with font weights
|
659 |
+
$build = array();
|
660 |
+
foreach($fonts as $farr) {
|
661 |
+
$f = $farr['name'];
|
662 |
+
if(count($farr['type']) > 0) {
|
663 |
+
$f.= ':'. implode(',', $farr['type']);
|
664 |
+
}
|
665 |
+
$build[] = $f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
666 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
|
668 |
+
# merge, append subsets
|
669 |
+
$merge = '';
|
670 |
+
if(count($build) > 0) {
|
671 |
+
$merge = implode('|', $build);
|
672 |
+
if(count($subsets) > 0) {
|
673 |
+
$merge.= '&subset='.implode(',', $subsets);
|
674 |
+
}
|
675 |
+
}
|
676 |
|
677 |
+
# return
|
678 |
+
if(!empty($merge)) {
|
679 |
+
return 'https://fonts.googleapis.com/css?family='.$merge;
|
680 |
+
} else {
|
681 |
+
return false;
|
682 |
+
}
|
683 |
}
|
684 |
|
|
|
685 |
# remove emoji support
|
686 |
function fastvelocity_min_disable_wp_emojicons() {
|
687 |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: Alignak
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
|
4 |
Requires at least: 4.5
|
5 |
-
Stable tag: 2.4.
|
6 |
Tested up to: 5.0
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -202,6 +202,11 @@ If you would like to donate any amount to the plugin author (thank you in advanc
|
|
202 |
|
203 |
== Changelog ==
|
204 |
|
|
|
|
|
|
|
|
|
|
|
205 |
= 2.4.3 [2018.12.03] =
|
206 |
* added font-display, to ensure text remains visible during webfont load for inlined google fonts and font-awesome
|
207 |
* added automatic removal of "source mappings" from JS files during merging or minification
|
2 |
Contributors: Alignak
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
|
4 |
Requires at least: 4.5
|
5 |
+
Stable tag: 2.4.4
|
6 |
Tested up to: 5.0
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
202 |
|
203 |
== Changelog ==
|
204 |
|
205 |
+
= 2.4.4 [2018.12.03]
|
206 |
+
* added option to inline CSS in the footer, while still preserving the merged file in the header
|
207 |
+
* improvements for the google fonts merging option
|
208 |
+
* fixed double notification, when purging caches without a cache plugin
|
209 |
+
|
210 |
= 2.4.3 [2018.12.03] =
|
211 |
* added font-display, to ensure text remains visible during webfont load for inlined google fonts and font-awesome
|
212 |
* added automatic removal of "source mappings" from JS files during merging or minification
|