Version Description
[2022.02.01] = * changed writing the css/js files to WP_Filesystem_Direct with a secondary fallback method * fixed a bug when merging css/js can break the site layout if the plugin failed to write the cache file (there will be an html comment on the footer if this happens) * renamed a common name class to avoid conflicts with other plugins
Download this release
Release Info
Developer | Alignak |
Plugin | Fast Velocity Minify |
Version | 3.2.5 |
Comparing to | |
See all releases |
Code changes from version 3.2.4 to 3.2.5
- fvm.php +1 -1
- inc/common.php +104 -80
- inc/frontend.php +72 -47
- libs/simplehtmldom/simple_html_dom.php +3 -3
- readme.txt +6 -1
fvm.php
CHANGED
@@ -6,7 +6,7 @@ Description: Improve your speed score on GTmetrix, Pingdom Tools and Google Page
|
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
Text Domain: fast-velocity-minify
|
9 |
-
Version: 3.2.
|
10 |
License: GPL2
|
11 |
|
12 |
------------------------------------------------------------------------
|
6 |
Author: Raul Peixoto
|
7 |
Author URI: http://fastvelocity.com
|
8 |
Text Domain: fast-velocity-minify
|
9 |
+
Version: 3.2.5
|
10 |
License: GPL2
|
11 |
|
12 |
------------------------------------------------------------------------
|
inc/common.php
CHANGED
@@ -524,55 +524,36 @@ function fvm_generate_min_url($url, $tkey, $type, $code) {
|
|
524 |
if(isset($ch_info['ch_url']) && !empty($ch_info['ch_url']) && isset($ch_info['ch_dir']) && !empty($ch_info['ch_dir'])) {
|
525 |
if(is_dir($ch_info['ch_dir']) && is_writable($ch_info['ch_dir'])) {
|
526 |
|
527 |
-
#
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
$file = $ch_info['ch_dir'] . DIRECTORY_SEPARATOR . $filename;
|
546 |
-
$public = $ch_info['ch_url'] . '/' .$filename;
|
547 |
-
|
548 |
-
# create if doesn't exist
|
549 |
-
if(!$wp_filesystem->exists($file) || ($wp_filesystem->exists($file) && $wp_filesystem->mtime($file) < $tvers)) {
|
550 |
-
$wp_filesystem->put_contents($file, $code);
|
551 |
-
}
|
552 |
-
|
553 |
-
# return url
|
554 |
-
return $public;
|
555 |
-
|
556 |
-
|
557 |
-
} else {
|
558 |
-
/* don't have direct write access. Prompt user with our notice */
|
559 |
-
error_log('FVM has no direct write access for CSS / JS cache files.');
|
560 |
-
}
|
561 |
}
|
562 |
|
563 |
}
|
564 |
}
|
565 |
|
566 |
-
# default
|
567 |
-
return
|
568 |
}
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
# check if PHP has some functions disabled
|
577 |
function fvm_function_available($func) {
|
578 |
if (ini_get('safe_mode')) return false;
|
@@ -620,63 +601,67 @@ function fvm_purge_static_files() {
|
|
620 |
global $wpdb;
|
621 |
if(is_null($wpdb)) { return false; }
|
622 |
try {
|
623 |
-
|
624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
} catch (Exception $e) {
|
626 |
error_log('Error: '.$e->getMessage(), 0);
|
627 |
}
|
628 |
|
629 |
# increment
|
630 |
-
|
|
|
631 |
|
632 |
# check cache directory
|
633 |
$ch_info = fvm_get_cache_location();
|
634 |
if(isset($ch_info['ch_url']) && !empty($ch_info['ch_url']) && isset($ch_info['ch_dir']) && !empty($ch_info['ch_dir'])) {
|
635 |
if(is_dir($ch_info['ch_dir']) && is_writable($ch_info['ch_dir'])) {
|
636 |
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
$
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
if(is_array($list) && count($list) > 0) {
|
665 |
-
foreach($list as $k=>$arr) {
|
666 |
-
if(isset($arr['lastmodunix']) && $arr['type'] == 'f' && intval($arr['lastmodunix']) <= time()-86400*7) {
|
667 |
-
if(substr($arr['name'], 0, 10) !== time()) {
|
668 |
-
$wp_filesystem->delete($ch_info['ch_dir'] . DIRECTORY_SEPARATOR . $arr['name'], false, 'f');
|
669 |
-
}
|
670 |
}
|
671 |
}
|
672 |
}
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
} else {
|
677 |
-
|
678 |
-
|
679 |
}
|
|
|
680 |
}
|
681 |
|
682 |
}
|
@@ -685,6 +670,45 @@ function fvm_purge_static_files() {
|
|
685 |
}
|
686 |
|
687 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
688 |
# Fix the permission bits on generated files
|
689 |
function fvm_fix_permission_bits($file){
|
690 |
|
524 |
if(isset($ch_info['ch_url']) && !empty($ch_info['ch_url']) && isset($ch_info['ch_dir']) && !empty($ch_info['ch_dir'])) {
|
525 |
if(is_dir($ch_info['ch_dir']) && is_writable($ch_info['ch_dir'])) {
|
526 |
|
527 |
+
# filename
|
528 |
+
$file = $ch_info['ch_dir'] . DIRECTORY_SEPARATOR . $filename;
|
529 |
+
$public = $ch_info['ch_url'] . '/' .$filename;
|
530 |
+
|
531 |
+
# direct system
|
532 |
+
if(class_exists('WP_Filesystem_Direct')) {
|
533 |
+
|
534 |
+
# wp
|
535 |
+
$wpfs = new WP_Filesystem_Direct(null);
|
536 |
+
if(!$wpfs->exists($file) || ($wpfs->exists($file) && $wpfs->mtime($file) < $tvers)) { $wpfs->put_contents($file, $code); }
|
537 |
+
if($wpfs->exists($file)) { return $public; }
|
538 |
+
|
539 |
+
} else {
|
540 |
+
|
541 |
+
# php
|
542 |
+
if(!file_exists($file) || (file_exists($file) && filemtime($file) < $tvers)) { file_put_contents($file, $code); }
|
543 |
+
if(file_exists($file)) { return $public; }
|
544 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
545 |
}
|
546 |
|
547 |
}
|
548 |
}
|
549 |
|
550 |
+
# default, fail and log
|
551 |
+
return false;
|
552 |
}
|
553 |
|
554 |
|
555 |
|
556 |
|
|
|
|
|
|
|
557 |
# check if PHP has some functions disabled
|
558 |
function fvm_function_available($func) {
|
559 |
if (ini_get('safe_mode')) return false;
|
601 |
global $wpdb;
|
602 |
if(is_null($wpdb)) { return false; }
|
603 |
try {
|
604 |
+
|
605 |
+
# table names
|
606 |
+
$sqla_table_name = $wpdb->prefix . 'fvm_cache';
|
607 |
+
$sqlb_table_name = $wpdb->prefix . 'fvm_logs';
|
608 |
+
|
609 |
+
# test if at least one table exists and empty them
|
610 |
+
if (!$wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $sqla_table_name)) === $sqla_table_name) {
|
611 |
+
$wpdb->query("TRUNCATE TABLE {$sqla_table_name}");
|
612 |
+
$wpdb->query("TRUNCATE TABLE {$sqlb_table_name}");
|
613 |
+
}
|
614 |
+
|
615 |
} catch (Exception $e) {
|
616 |
error_log('Error: '.$e->getMessage(), 0);
|
617 |
}
|
618 |
|
619 |
# increment
|
620 |
+
$tver = time();
|
621 |
+
update_option('fvm_last_cache_update', $tver);
|
622 |
|
623 |
# check cache directory
|
624 |
$ch_info = fvm_get_cache_location();
|
625 |
if(isset($ch_info['ch_url']) && !empty($ch_info['ch_url']) && isset($ch_info['ch_dir']) && !empty($ch_info['ch_dir'])) {
|
626 |
if(is_dir($ch_info['ch_dir']) && is_writable($ch_info['ch_dir'])) {
|
627 |
|
628 |
+
|
629 |
+
# instant purge
|
630 |
+
if(isset($fvm_settings['cache']['min_instant_purge']) && $fvm_settings['cache']['min_instant_purge'] == true) {
|
631 |
+
|
632 |
+
# direct system
|
633 |
+
if(class_exists('WP_Filesystem_Direct')) {
|
634 |
+
$wpfs = new WP_Filesystem_Direct(null);
|
635 |
+
$wpfs->rmdir($ch_info['ch_dir'], true);
|
636 |
+
return true;
|
637 |
+
} else {
|
638 |
+
# iterator fallback
|
639 |
+
fvm_rrmdir($ch_info['ch_dir']);
|
640 |
+
}
|
641 |
+
|
642 |
+
} else {
|
643 |
+
|
644 |
+
# older than 7 days and not matching current timestamp
|
645 |
+
|
646 |
+
# direct system
|
647 |
+
if(class_exists('WP_Filesystem_Direct')) {
|
648 |
+
$wpfs = new WP_Filesystem_Direct(null);
|
649 |
+
$list = $wpfs->dirlist($ch_info['ch_dir'], false, true);
|
650 |
+
if(is_array($list) && count($list) > 0) {
|
651 |
+
foreach($list as $k=>$arr) {
|
652 |
+
if(isset($arr['lastmodunix']) && $arr['type'] == 'f' && intval($arr['lastmodunix']) <= $tver-86400*7) {
|
653 |
+
if(substr($arr['name'], 0, 10) !== time()) {
|
654 |
+
$wpfs->delete($ch_info['ch_dir'] . DIRECTORY_SEPARATOR . $arr['name'], false, 'f');
|
|
|
|
|
|
|
|
|
|
|
|
|
655 |
}
|
656 |
}
|
657 |
}
|
658 |
+
}
|
659 |
+
|
|
|
660 |
} else {
|
661 |
+
# iterator fallback
|
662 |
+
fvm_rrmdir($ch_info['ch_dir'], $tver);
|
663 |
}
|
664 |
+
|
665 |
}
|
666 |
|
667 |
}
|
670 |
}
|
671 |
|
672 |
|
673 |
+
# remove all cache files
|
674 |
+
function fvm_rrmdir($path, $tver=null) {
|
675 |
+
clearstatcache();
|
676 |
+
if(is_dir($path)) {
|
677 |
+
try {
|
678 |
+
|
679 |
+
$i = new DirectoryIterator($path);
|
680 |
+
foreach($i as $f){
|
681 |
+
|
682 |
+
# 7 days older than timestamp
|
683 |
+
if(isset($tver) && !is_null($tver)) {
|
684 |
+
|
685 |
+
if($f->isFile() && $f->getMTime() <= intval($tver) - 86400 * 7) { @unlink($f->getRealPath()); }
|
686 |
+
if($f->isDir() && !$f->isDot()){
|
687 |
+
fvm_rrmdir($f->getRealPath(), $tver);
|
688 |
+
@rmdir($f->getRealPath());
|
689 |
+
}
|
690 |
+
|
691 |
+
} else {
|
692 |
+
# immediate
|
693 |
+
if($f->isFile()){ @unlink($f->getRealPath()); }
|
694 |
+
if($f->isDir() && !$f->isDot()){
|
695 |
+
fvm_rrmdir($f->getRealPath());
|
696 |
+
@rmdir($f->getRealPath());
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
}
|
701 |
+
|
702 |
+
} catch (Exception $e) {
|
703 |
+
return get_class($e) . ": " . $e->getMessage();
|
704 |
+
}
|
705 |
+
|
706 |
+
# self
|
707 |
+
if(is_dir($path)) { @rmdir($path); }
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
|
712 |
# Fix the permission bits on generated files
|
713 |
function fvm_fix_permission_bits($file){
|
714 |
|
inc/frontend.php
CHANGED
@@ -53,6 +53,7 @@ function fvm_process_page($html) {
|
|
53 |
if (!is_object($html_object)) {
|
54 |
return $html . '<!-- simplehtmldom failed to process the html -->';
|
55 |
} else {
|
|
|
56 |
$html = $html_object;
|
57 |
}
|
58 |
|
@@ -66,13 +67,16 @@ function fvm_process_page($html) {
|
|
66 |
$htmljsheader = array();
|
67 |
$htmljsdefer = array();
|
68 |
|
|
|
|
|
|
|
69 |
|
70 |
# collect all link preload headers, skip amp
|
71 |
if(fvm_is_amp_page() !== true) {
|
72 |
|
73 |
# skip on web stories
|
74 |
if(count($html->find('script[src*=cdn.ampproject.org]')) > 0) {
|
75 |
-
return $
|
76 |
}
|
77 |
|
78 |
# add other preloads
|
@@ -277,6 +281,9 @@ function fvm_process_page($html) {
|
|
277 |
|
278 |
# generate url
|
279 |
$ind_css_url = fvm_generate_min_url($href, $css['tkey'], 'css', $css_code);
|
|
|
|
|
|
|
280 |
|
281 |
# cdn
|
282 |
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
|
@@ -402,14 +409,17 @@ function fvm_process_page($html) {
|
|
402 |
|
403 |
# generate url
|
404 |
$css_fonts_url = fvm_generate_min_url('fonts', $tkey, 'css', $css_lowpriority_code);
|
405 |
-
|
406 |
-
|
407 |
-
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
|
408 |
-
$css_fonts_url = fvm_rewrite_cdn_url($css_fonts_url);
|
409 |
}
|
410 |
-
|
411 |
-
|
412 |
-
|
|
|
|
|
|
|
|
|
|
|
413 |
|
414 |
}
|
415 |
# END OPTIMIZED FONT DELIVERY
|
@@ -435,29 +445,32 @@ function fvm_process_page($html) {
|
|
435 |
|
436 |
# url, preload, add
|
437 |
$merged_css_url = fvm_generate_min_url('combined', $tkey, 'css', $merged_css);
|
438 |
-
|
439 |
-
|
440 |
-
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
|
441 |
-
$merged_css_url = fvm_rewrite_cdn_url($merged_css_url);
|
442 |
}
|
443 |
-
|
444 |
-
# http, html preload + header
|
445 |
-
if($css_method == 'block') {
|
446 |
|
447 |
-
#
|
448 |
-
$
|
449 |
-
|
450 |
-
# http and html preload for render blocking css
|
451 |
-
if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
|
452 |
-
$htmlpreloads[] = '<link rel="preload" href="'.$merged_css_url.'" as="style" media="'.$mediatype.'" />';
|
453 |
}
|
454 |
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
|
457 |
-
|
458 |
-
$htmlcssheader[] = '<link rel="preload" as="style" href="'.$merged_css_url.'" media="'.$mediatype.'" onload="this.rel=\'stylesheet\'" />';
|
459 |
-
|
460 |
-
}
|
461 |
|
462 |
}
|
463 |
}
|
@@ -708,6 +721,9 @@ function fvm_process_page($html) {
|
|
708 |
|
709 |
# generate url
|
710 |
$ind_js_url = fvm_generate_min_url($tag->src, $js['tkey'], 'js', $js['code']);
|
|
|
|
|
|
|
711 |
|
712 |
# cdn
|
713 |
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
@@ -759,6 +775,9 @@ function fvm_process_page($html) {
|
|
759 |
|
760 |
# generate url
|
761 |
$ind_js_url = fvm_generate_min_url($tag->src, $js['tkey'], 'js', $js['code']);
|
|
|
|
|
|
|
762 |
|
763 |
# cdn
|
764 |
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
@@ -885,20 +904,23 @@ function fvm_process_page($html) {
|
|
885 |
|
886 |
# generate url
|
887 |
$merged_js_url = fvm_generate_min_url('combined', $tkey, 'js', $merged_js);
|
888 |
-
|
889 |
-
|
890 |
-
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
891 |
-
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
|
892 |
-
}
|
893 |
-
|
894 |
-
# http and html preload for render blocking scripts
|
895 |
-
if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
|
896 |
-
$htmlpreloads[] = '<link rel="preload" href="'.$merged_js_url.'" as="script" />';
|
897 |
}
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
}
|
903 |
|
904 |
# deferred scripts
|
@@ -910,15 +932,18 @@ function fvm_process_page($html) {
|
|
910 |
|
911 |
# generate url
|
912 |
$merged_js_url = fvm_generate_min_url('combined', $tkey, 'js', $merged_js);
|
913 |
-
|
914 |
-
|
915 |
-
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
916 |
-
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
|
917 |
}
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
|
|
|
|
|
|
|
|
|
|
922 |
}
|
923 |
|
924 |
}
|
53 |
if (!is_object($html_object)) {
|
54 |
return $html . '<!-- simplehtmldom failed to process the html -->';
|
55 |
} else {
|
56 |
+
$html_src = $html;
|
57 |
$html = $html_object;
|
58 |
}
|
59 |
|
67 |
$htmljsheader = array();
|
68 |
$htmljsdefer = array();
|
69 |
|
70 |
+
# only error possible for now
|
71 |
+
$fvm_error = PHP_EOL . '<!-- ['.date('r').'] FVM has no write access for CSS / JS cache files under '. fvm_get_cache_location()['ch_url'] . ' -->'. PHP_EOL;
|
72 |
+
|
73 |
|
74 |
# collect all link preload headers, skip amp
|
75 |
if(fvm_is_amp_page() !== true) {
|
76 |
|
77 |
# skip on web stories
|
78 |
if(count($html->find('script[src*=cdn.ampproject.org]')) > 0) {
|
79 |
+
return $html_src . DIRECTORY_SEPARATOR . '<!-- FVM ['.date('r').'] does not support AMP -->';
|
80 |
}
|
81 |
|
82 |
# add other preloads
|
281 |
|
282 |
# generate url
|
283 |
$ind_css_url = fvm_generate_min_url($href, $css['tkey'], 'css', $css_code);
|
284 |
+
if($ind_css_url === false) {
|
285 |
+
return $html_src . $fvm_error;
|
286 |
+
}
|
287 |
|
288 |
# cdn
|
289 |
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
|
409 |
|
410 |
# generate url
|
411 |
$css_fonts_url = fvm_generate_min_url('fonts', $tkey, 'css', $css_lowpriority_code);
|
412 |
+
if($css_fonts_url === false) {
|
413 |
+
return $html_src . $fvm_error;
|
|
|
|
|
414 |
}
|
415 |
+
|
416 |
+
# cdn
|
417 |
+
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
|
418 |
+
$css_fonts_url = fvm_rewrite_cdn_url($css_fonts_url);
|
419 |
+
}
|
420 |
+
|
421 |
+
# preload
|
422 |
+
$htmlcssheader[0] = '<link id="fvm-fonts" rel="stylesheet" href="'.$css_fonts_url.'" media="fonts" onload="if(fvmuag()){this.media=\'all\'}" />';
|
423 |
|
424 |
}
|
425 |
# END OPTIMIZED FONT DELIVERY
|
445 |
|
446 |
# url, preload, add
|
447 |
$merged_css_url = fvm_generate_min_url('combined', $tkey, 'css', $merged_css);
|
448 |
+
if($merged_css_url === false) {
|
449 |
+
return $html_src . $fvm_error;
|
|
|
|
|
450 |
}
|
|
|
|
|
|
|
451 |
|
452 |
+
# cdn
|
453 |
+
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
|
454 |
+
$merged_css_url = fvm_rewrite_cdn_url($merged_css_url);
|
|
|
|
|
|
|
455 |
}
|
456 |
|
457 |
+
# http, html preload + header
|
458 |
+
if($css_method == 'block') {
|
459 |
+
|
460 |
+
# add to header
|
461 |
+
$htmlcssheader[] = '<link rel="stylesheet" href="'.$merged_css_url.'" media="'.$mediatype.'" />';
|
462 |
+
|
463 |
+
# http and html preload for render blocking css
|
464 |
+
if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
|
465 |
+
$htmlpreloads[] = '<link rel="preload" href="'.$merged_css_url.'" as="style" media="'.$mediatype.'" />';
|
466 |
+
}
|
467 |
+
|
468 |
+
} else {
|
469 |
+
|
470 |
+
# async
|
471 |
+
$htmlcssheader[] = '<link rel="preload" as="style" href="'.$merged_css_url.'" media="'.$mediatype.'" onload="this.rel=\'stylesheet\'" />';
|
472 |
|
473 |
+
}
|
|
|
|
|
|
|
474 |
|
475 |
}
|
476 |
}
|
721 |
|
722 |
# generate url
|
723 |
$ind_js_url = fvm_generate_min_url($tag->src, $js['tkey'], 'js', $js['code']);
|
724 |
+
if($ind_js_url === false) {
|
725 |
+
return $html_src . $fvm_error;
|
726 |
+
}
|
727 |
|
728 |
# cdn
|
729 |
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
775 |
|
776 |
# generate url
|
777 |
$ind_js_url = fvm_generate_min_url($tag->src, $js['tkey'], 'js', $js['code']);
|
778 |
+
if($ind_js_url === false) {
|
779 |
+
return $html_src . $fvm_error;
|
780 |
+
}
|
781 |
|
782 |
# cdn
|
783 |
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
904 |
|
905 |
# generate url
|
906 |
$merged_js_url = fvm_generate_min_url('combined', $tkey, 'js', $merged_js);
|
907 |
+
if($merged_js_url === false) {
|
908 |
+
return $html_src . $fvm_error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
}
|
910 |
+
|
911 |
+
# cdn
|
912 |
+
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
913 |
+
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
|
914 |
+
}
|
915 |
+
|
916 |
+
# http and html preload for render blocking scripts
|
917 |
+
if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
|
918 |
+
$htmlpreloads[] = '<link rel="preload" href="'.$merged_js_url.'" as="script" />';
|
919 |
+
}
|
920 |
+
|
921 |
+
# add to header
|
922 |
+
$htmljsheader[] = "<script data-cfasync='false' src='".$merged_js_url."'></script>";
|
923 |
+
|
924 |
}
|
925 |
|
926 |
# deferred scripts
|
932 |
|
933 |
# generate url
|
934 |
$merged_js_url = fvm_generate_min_url('combined', $tkey, 'js', $merged_js);
|
935 |
+
if($merged_js_url === false) {
|
936 |
+
return $html_src . $fvm_error;
|
|
|
|
|
937 |
}
|
938 |
+
|
939 |
+
# cdn
|
940 |
+
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
|
941 |
+
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
|
942 |
+
}
|
943 |
+
|
944 |
+
# header, no preload for deferred files
|
945 |
+
$htmljsheader[] = "<script defer='defer' src='".$merged_js_url."'></script>";
|
946 |
+
|
947 |
}
|
948 |
|
949 |
}
|
libs/simplehtmldom/simple_html_dom.php
CHANGED
@@ -66,7 +66,7 @@ function fvm_file_get_html(
|
|
66 |
{
|
67 |
if($maxLen <= 0) { $maxLen = FVM_MAX_FILE_SIZE; }
|
68 |
|
69 |
-
$dom = new
|
70 |
null,
|
71 |
$lowercase,
|
72 |
$forceTagsClosed,
|
@@ -106,7 +106,7 @@ function fvm_str_get_html(
|
|
106 |
$defaultBRText = FVMDEFAULT_BR_TEXT,
|
107 |
$defaultSpanText = FVMDEFAULT_SPAN_TEXT)
|
108 |
{
|
109 |
-
$dom = new
|
110 |
null,
|
111 |
$lowercase,
|
112 |
$forceTagsClosed,
|
@@ -1391,7 +1391,7 @@ class fvm_simple_html_dom_node
|
|
1391 |
|
1392 |
}
|
1393 |
|
1394 |
-
class
|
1395 |
{
|
1396 |
public $root = null;
|
1397 |
public $nodes = array();
|
66 |
{
|
67 |
if($maxLen <= 0) { $maxLen = FVM_MAX_FILE_SIZE; }
|
68 |
|
69 |
+
$dom = new fvm_simple_html_dom(
|
70 |
null,
|
71 |
$lowercase,
|
72 |
$forceTagsClosed,
|
106 |
$defaultBRText = FVMDEFAULT_BR_TEXT,
|
107 |
$defaultSpanText = FVMDEFAULT_SPAN_TEXT)
|
108 |
{
|
109 |
+
$dom = new fvm_simple_html_dom(
|
110 |
null,
|
111 |
$lowercase,
|
112 |
$forceTagsClosed,
|
1391 |
|
1392 |
}
|
1393 |
|
1394 |
+
class fvm_simple_html_dom
|
1395 |
{
|
1396 |
public $root = null;
|
1397 |
public $nodes = array();
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Alignak
|
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6
|
6 |
-
Stable tag: 3.2.
|
7 |
Tested up to: 5.9.1
|
8 |
Text Domain: fast-velocity-minify
|
9 |
License: GPLv3 or later
|
@@ -49,6 +49,11 @@ You need a public directory to store and serve minified cache files. If you need
|
|
49 |
|
50 |
== Changelog ==
|
51 |
|
|
|
|
|
|
|
|
|
|
|
52 |
= 3.2.4 [2022.01.31] =
|
53 |
* WP 5.9 / PHP 8 maintenance release
|
54 |
* changed deferred css/js cache clearing from 24h to 7 days
|
3 |
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6
|
6 |
+
Stable tag: 3.2.5
|
7 |
Tested up to: 5.9.1
|
8 |
Text Domain: fast-velocity-minify
|
9 |
License: GPLv3 or later
|
49 |
|
50 |
== Changelog ==
|
51 |
|
52 |
+
= 3.2.5 [2022.02.01] =
|
53 |
+
* changed writing the css/js files to WP_Filesystem_Direct with a secondary fallback method
|
54 |
+
* fixed a bug when merging css/js can break the site layout if the plugin failed to write the cache file (there will be an html comment on the footer if this happens)
|
55 |
+
* renamed a common name class to avoid conflicts with other plugins
|
56 |
+
|
57 |
= 3.2.4 [2022.01.31] =
|
58 |
* WP 5.9 / PHP 8 maintenance release
|
59 |
* changed deferred css/js cache clearing from 24h to 7 days
|