Version Description
[2018.12.04] * fixed a bug, where it may show a warning during cache purge on wp-admin * exclude footer FVM generated files from the HTTP header preload option (footer files are not in the critical path)
Download this release
Release Info
Developer | Alignak |
Plugin | Fast Velocity Minify |
Version | 2.4.5 |
Comparing to | |
See all releases |
Code changes from version 2.4.4 to 2.4.5
- fvm.php +27 -14
- inc/functions-cli.php +1 -1
- inc/functions-upgrade.php +5 -3
- inc/functions.php +36 -22
- readme.txt +5 -1
fvm.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://fastvelocity.com
|
|
5 |
Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
-
Version: 2.4.
|
9 |
License: GPL2
|
10 |
|
11 |
------------------------------------------------------------------------
|
@@ -179,6 +179,7 @@ if(is_admin()) {
|
|
179 |
add_action('after_switch_theme', 'fvm_purge_all');
|
180 |
add_action('activated_plugin', 'fvm_purge_all');
|
181 |
add_action('deactivated_plugin', 'fvm_purge_all');
|
|
|
182 |
|
183 |
# activation, deactivation
|
184 |
register_activation_hook( __FILE__, 'fastvelocity_plugin_activate' );
|
@@ -215,14 +216,15 @@ if(is_admin()) {
|
|
215 |
|
216 |
if($fvm_clean_header_one) {
|
217 |
# no resource hints, generator tag, shortlinks, manifest link, etc
|
218 |
-
remove_action('wp_head', 'wp_resource_hints', 2
|
219 |
remove_action('wp_head', 'wp_generator');
|
220 |
-
remove_action('
|
221 |
remove_action('wp_head', 'wlwmanifest_link');
|
222 |
remove_action('wp_head', 'rsd_link');
|
223 |
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
|
224 |
remove_action('wp_head','feed_links', 2);
|
225 |
remove_action('wp_head','feed_links_extra', 3);
|
|
|
226 |
}
|
227 |
|
228 |
# enable html minification
|
@@ -415,16 +417,16 @@ function fastvelocity_process_cache_purge_request(){
|
|
415 |
|
416 |
if(is_admin()) {
|
417 |
fvm_purge_all(); # purge all
|
418 |
-
|
419 |
-
$others =
|
420 |
$notice = array('All caches from <strong>FVM</strong> have been purged!', strip_tags($others, '<strong>'));
|
421 |
$notice = array_filter($notice);
|
422 |
-
$notice =
|
423 |
-
|
424 |
wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
|
425 |
} else {
|
426 |
fvm_purge_all(); # purge all
|
427 |
-
|
428 |
wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
|
429 |
}
|
430 |
}
|
@@ -435,10 +437,11 @@ add_action( 'admin_notices', 'fastvelocity_admin_notices' );
|
|
435 |
function fastvelocity_admin_notices() {
|
436 |
|
437 |
# cache purge notices
|
438 |
-
|
|
|
439 |
|
440 |
# decode to array or null
|
441 |
-
$jsonarr = json_decode(
|
442 |
if(!is_null($jsonarr) && is_array($jsonarr)){
|
443 |
|
444 |
# must be able to cleanup cache
|
@@ -451,7 +454,7 @@ function fastvelocity_admin_notices() {
|
|
451 |
}
|
452 |
|
453 |
# remove
|
454 |
-
|
455 |
}
|
456 |
}
|
457 |
|
@@ -967,12 +970,12 @@ Enable FVM Debug Mode<span class="note-info">[ Add extra info to the "status pag
|
|
967 |
<br />
|
968 |
<label for="fastvelocity_enabled_css_preload">
|
969 |
<input name="fastvelocity_enabled_css_preload" type="checkbox" id="fastvelocity_enabled_css_preload" value="1" <?php echo checked(1 == get_option('fastvelocity_enabled_css_preload'), true, false); ?>>
|
970 |
-
Enable FVM CSS files Preload<span class="note-info">[ Automatically create http headers for FVM generated CSS files
|
971 |
|
972 |
<br />
|
973 |
<label for="fastvelocity_enabled_js_preload">
|
974 |
<input name="fastvelocity_enabled_js_preload" type="checkbox" id="fastvelocity_enabled_js_preload" value="1" <?php echo checked(1 == get_option('fastvelocity_enabled_js_preload'), true, false); ?>>
|
975 |
-
Enable FVM JS files Preload<span class="note-info">[ Automatically create http headers for FVM generated JS files
|
976 |
|
977 |
|
978 |
</fieldset>
|
@@ -2744,7 +2747,7 @@ function fastvelocity_collect_js_preload_headers($html, $handle, $src){
|
|
2744 |
# generate css headers file
|
2745 |
add_action('wp_footer', 'fastvelocity_generate_preload_headers', PHP_INT_MAX);
|
2746 |
function fastvelocity_generate_preload_headers(){
|
2747 |
-
global $collect_preload_css, $collect_preload_js, $fvm_enabled_css_preload, $fvm_enabled_js_preload;
|
2748 |
|
2749 |
# return if disabled
|
2750 |
if ($fvm_enabled_css_preload != true && $fvm_enabled_js_preload != true) {
|
@@ -2769,6 +2772,11 @@ function fastvelocity_generate_preload_headers(){
|
|
2769 |
# css headers
|
2770 |
if ($fvm_enabled_css_preload != false && is_array($collect_preload_css) && count($collect_preload_css) > 0) {
|
2771 |
foreach($collect_preload_css as $u) {
|
|
|
|
|
|
|
|
|
|
|
2772 |
$headers[] = "Link: <$u>; rel=preload; as=style";
|
2773 |
}
|
2774 |
}
|
@@ -2776,6 +2784,11 @@ function fastvelocity_generate_preload_headers(){
|
|
2776 |
# js headers
|
2777 |
if ($fvm_enabled_js_preload != false && is_array($collect_preload_js) && count($collect_preload_js) > 0) {
|
2778 |
foreach($collect_preload_js as $u) {
|
|
|
|
|
|
|
|
|
|
|
2779 |
$headers[] = "Link: <$u>; rel=preload; as=script";
|
2780 |
}
|
2781 |
}
|
5 |
Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
+
Version: 2.4.5
|
9 |
License: GPL2
|
10 |
|
11 |
------------------------------------------------------------------------
|
179 |
add_action('after_switch_theme', 'fvm_purge_all');
|
180 |
add_action('activated_plugin', 'fvm_purge_all');
|
181 |
add_action('deactivated_plugin', 'fvm_purge_all');
|
182 |
+
add_action('admin_init', 'fastvelocity_purge_onsave', 1);
|
183 |
|
184 |
# activation, deactivation
|
185 |
register_activation_hook( __FILE__, 'fastvelocity_plugin_activate' );
|
216 |
|
217 |
if($fvm_clean_header_one) {
|
218 |
# no resource hints, generator tag, shortlinks, manifest link, etc
|
219 |
+
remove_action('wp_head', 'wp_resource_hints', 2);
|
220 |
remove_action('wp_head', 'wp_generator');
|
221 |
+
remove_action('template_redirect', 'wp_shortlink_header', 11);
|
222 |
remove_action('wp_head', 'wlwmanifest_link');
|
223 |
remove_action('wp_head', 'rsd_link');
|
224 |
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
|
225 |
remove_action('wp_head','feed_links', 2);
|
226 |
remove_action('wp_head','feed_links_extra', 3);
|
227 |
+
add_filter('after_setup_theme', 'fastvelocity_remove_redundant_shortlink');
|
228 |
}
|
229 |
|
230 |
# enable html minification
|
417 |
|
418 |
if(is_admin()) {
|
419 |
fvm_purge_all(); # purge all
|
420 |
+
fvm_purge_others(); # purge third party caches
|
421 |
+
$others = fvm_purge_others(); # purge third party caches
|
422 |
$notice = array('All caches from <strong>FVM</strong> have been purged!', strip_tags($others, '<strong>'));
|
423 |
$notice = array_filter($notice);
|
424 |
+
$notice = json_encode($notice); # encode
|
425 |
+
set_transient( 'wordpress_fvmcache', $notice, 10);
|
426 |
wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
|
427 |
} else {
|
428 |
fvm_purge_all(); # purge all
|
429 |
+
fvm_purge_others(); # purge third party caches
|
430 |
wp_safe_redirect(remove_query_arg('_wpnonce', remove_query_arg('_fvmcache', wp_get_referer())));
|
431 |
}
|
432 |
}
|
437 |
function fastvelocity_admin_notices() {
|
438 |
|
439 |
# cache purge notices
|
440 |
+
$inf = get_transient('wordpress_fvmcache');
|
441 |
+
if($inf != false && !empty($inf)) {
|
442 |
|
443 |
# decode to array or null
|
444 |
+
$jsonarr = json_decode($inf, true);
|
445 |
if(!is_null($jsonarr) && is_array($jsonarr)){
|
446 |
|
447 |
# must be able to cleanup cache
|
454 |
}
|
455 |
|
456 |
# remove
|
457 |
+
delete_transient('wordpress_fvmcache');
|
458 |
}
|
459 |
}
|
460 |
|
970 |
<br />
|
971 |
<label for="fastvelocity_enabled_css_preload">
|
972 |
<input name="fastvelocity_enabled_css_preload" type="checkbox" id="fastvelocity_enabled_css_preload" value="1" <?php echo checked(1 == get_option('fastvelocity_enabled_css_preload'), true, false); ?>>
|
973 |
+
Enable FVM CSS files Preload<span class="note-info">[ Automatically create http headers for FVM generated CSS files (when not inlined) ]</span></label>
|
974 |
|
975 |
<br />
|
976 |
<label for="fastvelocity_enabled_js_preload">
|
977 |
<input name="fastvelocity_enabled_js_preload" type="checkbox" id="fastvelocity_enabled_js_preload" value="1" <?php echo checked(1 == get_option('fastvelocity_enabled_js_preload'), true, false); ?>>
|
978 |
+
Enable FVM JS files Preload<span class="note-info">[ Automatically create http headers for FVM generated JS files ]</span></label>
|
979 |
|
980 |
|
981 |
</fieldset>
|
2747 |
# generate css headers file
|
2748 |
add_action('wp_footer', 'fastvelocity_generate_preload_headers', PHP_INT_MAX);
|
2749 |
function fastvelocity_generate_preload_headers(){
|
2750 |
+
global $collect_preload_css, $collect_preload_js, $fvm_enabled_css_preload, $fvm_enabled_js_preload, $force_inline_css_footer;
|
2751 |
|
2752 |
# return if disabled
|
2753 |
if ($fvm_enabled_css_preload != true && $fvm_enabled_js_preload != true) {
|
2772 |
# css headers
|
2773 |
if ($fvm_enabled_css_preload != false && is_array($collect_preload_css) && count($collect_preload_css) > 0) {
|
2774 |
foreach($collect_preload_css as $u) {
|
2775 |
+
|
2776 |
+
# filter out footer footer files, because they are not in the critical path
|
2777 |
+
if(stripos($u, '/fvm/out/footer-') !== false) { continue; }
|
2778 |
+
|
2779 |
+
# add headers
|
2780 |
$headers[] = "Link: <$u>; rel=preload; as=style";
|
2781 |
}
|
2782 |
}
|
2784 |
# js headers
|
2785 |
if ($fvm_enabled_js_preload != false && is_array($collect_preload_js) && count($collect_preload_js) > 0) {
|
2786 |
foreach($collect_preload_js as $u) {
|
2787 |
+
|
2788 |
+
# filter out footer footer files, because they are not in the critical path
|
2789 |
+
if(stripos($u, '/fvm/out/footer-') !== false) { continue; }
|
2790 |
+
|
2791 |
+
# add headers
|
2792 |
$headers[] = "Link: <$u>; rel=preload; as=script";
|
2793 |
}
|
2794 |
}
|
inc/functions-cli.php
CHANGED
@@ -13,7 +13,7 @@ class fastvelocity_WPCLI {
|
|
13 |
# purge files + cache
|
14 |
public function purge() {
|
15 |
fvm_purge_all();
|
16 |
-
|
17 |
WP_CLI::success('FVM and other caches were purged.');
|
18 |
}
|
19 |
|
13 |
# purge files + cache
|
14 |
public function purge() {
|
15 |
fvm_purge_all();
|
16 |
+
fvm_purge_others();
|
17 |
WP_CLI::success('FVM and other caches were purged.');
|
18 |
}
|
19 |
|
inc/functions-upgrade.php
CHANGED
@@ -5,13 +5,15 @@ function fastvelocity_version_check() {
|
|
5 |
|
6 |
# current FVM install date, create if it doesn't exist
|
7 |
$ver = get_option("fastvelocity_plugin_version");
|
8 |
-
if ($ver == false) {
|
|
|
|
|
|
|
9 |
update_option( "fastvelocity_plugin_version", $fastvelocity_plugin_version);
|
10 |
-
$ver = '0.0.0';
|
11 |
}
|
12 |
|
13 |
# compare versions (0.1.2)
|
14 |
-
$dots = explode('.', $
|
15 |
if(!is_array($dots) || count($dots) != 3) { return false; }
|
16 |
|
17 |
|
5 |
|
6 |
# current FVM install date, create if it doesn't exist
|
7 |
$ver = get_option("fastvelocity_plugin_version");
|
8 |
+
if ($ver == false) { $ver = '0.0.0'; }
|
9 |
+
|
10 |
+
# save on upgrade
|
11 |
+
if ($ver != $fastvelocity_plugin_version) {
|
12 |
update_option( "fastvelocity_plugin_version", $fastvelocity_plugin_version);
|
|
|
13 |
}
|
14 |
|
15 |
# compare versions (0.1.2)
|
16 |
+
$dots = explode('.', $ver);
|
17 |
if(!is_array($dots) || count($dots) != 3) { return false; }
|
18 |
|
19 |
|
inc/functions.php
CHANGED
@@ -319,28 +319,21 @@ function fastvelocity_min_html_compression_start() {
|
|
319 |
|
320 |
# remove all cache files
|
321 |
function fastvelocity_rrmdir($path) {
|
322 |
-
|
323 |
-
|
324 |
-
if(
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
if($f->isFile()){ unlink($f->getRealPath());
|
332 |
-
} else if(!$f->isDot() && $f->isDir()){
|
333 |
-
fastvelocity_rrmdir($f->getRealPath());
|
334 |
-
rmdir($f->getRealPath());
|
335 |
-
}
|
336 |
}
|
337 |
}
|
338 |
}
|
339 |
}
|
340 |
|
341 |
|
342 |
-
|
343 |
-
|
344 |
# return size in human format
|
345 |
function fastvelocity_format_filesize($bytes, $decimals = 2) {
|
346 |
$units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' );
|
@@ -360,8 +353,11 @@ function fastvelocity_get_cachestats() {
|
|
360 |
return fastvelocity_format_filesize($size);
|
361 |
}
|
362 |
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
365 |
|
366 |
# minify css on demand (one file at one time, for compatibility)
|
367 |
function fastvelocity_min_get_css($url, $css, $disable_css_minification) {
|
@@ -776,19 +772,37 @@ function fvm_purge_all() {
|
|
776 |
# get cache directories and urls
|
777 |
$cachepath = fvm_cachepath();
|
778 |
$cachebase = $cachepath['cachebase'];
|
779 |
-
|
|
|
780 |
# delete minification files and transients
|
781 |
if(!is_dir($cachebase)) {
|
782 |
return false;
|
783 |
}
|
784 |
|
785 |
-
|
786 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
787 |
do_action('fvm_after_purge_all');
|
788 |
return true;
|
789 |
}
|
790 |
|
791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
# get transients on the disk
|
793 |
function fvm_get_transient($key) {
|
794 |
$cachepath = fvm_cachepath();
|
@@ -934,7 +948,7 @@ function fastvelocity_godaddy_request( $method, $url = null ) {
|
|
934 |
}
|
935 |
|
936 |
|
937 |
-
function
|
938 |
|
939 |
# wordpress default cache
|
940 |
if (function_exists('wp_cache_flush')) {
|
319 |
|
320 |
# remove all cache files
|
321 |
function fastvelocity_rrmdir($path) {
|
322 |
+
# purge
|
323 |
+
clearstatcache();
|
324 |
+
if(is_dir($path)) {
|
325 |
+
$i = new DirectoryIterator($path);
|
326 |
+
foreach($i as $f){
|
327 |
+
if($f->isFile()){ unlink($f->getRealPath());
|
328 |
+
} else if(!$f->isDot() && $f->isDir()){
|
329 |
+
fastvelocity_rrmdir($f->getRealPath());
|
330 |
+
rmdir($f->getRealPath());
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
}
|
333 |
}
|
334 |
}
|
335 |
|
336 |
|
|
|
|
|
337 |
# return size in human format
|
338 |
function fastvelocity_format_filesize($bytes, $decimals = 2) {
|
339 |
$units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' );
|
353 |
return fastvelocity_format_filesize($size);
|
354 |
}
|
355 |
|
356 |
+
# remove default HTTP headers
|
357 |
+
function fastvelocity_remove_redundant_shortlink() {
|
358 |
+
remove_action('wp_head', 'wp_shortlink_wp_head', 10);
|
359 |
+
remove_action( 'template_redirect', 'wp_shortlink_header', 11);
|
360 |
+
}
|
361 |
|
362 |
# minify css on demand (one file at one time, for compatibility)
|
363 |
function fastvelocity_min_get_css($url, $css, $disable_css_minification) {
|
772 |
# get cache directories and urls
|
773 |
$cachepath = fvm_cachepath();
|
774 |
$cachebase = $cachepath['cachebase'];
|
775 |
+
$tmpdir = $cachepath['tmpdir'];
|
776 |
+
|
777 |
# delete minification files and transients
|
778 |
if(!is_dir($cachebase)) {
|
779 |
return false;
|
780 |
}
|
781 |
|
782 |
+
# preserve cache, or delete temp only
|
783 |
+
if(!get_option('fastvelocity_min_preserve_oldcache')) {
|
784 |
+
fastvelocity_rrmdir($cachebase);
|
785 |
+
} else {
|
786 |
+
if(is_dir($tmpdir)) {
|
787 |
+
fastvelocity_rrmdir($tmpdir);
|
788 |
+
return true;
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
+
fvm_cache_increment();
|
793 |
do_action('fvm_after_purge_all');
|
794 |
return true;
|
795 |
}
|
796 |
|
797 |
|
798 |
+
# purge temp cache on save settings
|
799 |
+
function fastvelocity_purge_onsave() {
|
800 |
+
if(current_user_can( 'manage_options') && isset($_POST['fastvelocity_min_save_options'])) {
|
801 |
+
fvm_purge_all();
|
802 |
+
fvm_purge_others();
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
# get transients on the disk
|
807 |
function fvm_get_transient($key) {
|
808 |
$cachepath = fvm_cachepath();
|
948 |
}
|
949 |
|
950 |
|
951 |
+
function fvm_purge_others(){
|
952 |
|
953 |
# wordpress default cache
|
954 |
if (function_exists('wp_cache_flush')) {
|
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,10 @@ If you would like to donate any amount to the plugin author (thank you in advanc
|
|
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
|
2 |
Contributors: Alignak
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, CSS Merging, JS Merging, CSS Minification, JS Minification, Speed Optimization, HTML Minification, Performance, Optimization, Speed, Fast
|
4 |
Requires at least: 4.5
|
5 |
+
Stable tag: 2.4.5
|
6 |
Tested up to: 5.0
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
202 |
|
203 |
== Changelog ==
|
204 |
|
205 |
+
= 2.4.5 [2018.12.04]
|
206 |
+
* fixed a bug, where it may show a warning during cache purge on wp-admin
|
207 |
+
* exclude footer FVM generated files from the HTTP header preload option (footer files are not in the critical path)
|
208 |
+
|
209 |
= 2.4.4 [2018.12.03]
|
210 |
* added option to inline CSS in the footer, while still preserving the merged file in the header
|
211 |
* improvements for the google fonts merging option
|