09b52d43 by Jeff Balicki

ddd

1 parent 4c19e6fe
......@@ -6,7 +6,7 @@ Description: Improve your speed score on GTmetrix, Pingdom Tools and Google Page
Author: Raul Peixoto
Author URI: http://fastvelocity.com
Text Domain: fast-velocity-minify
Version: 3.2.2
Version: 3.2.6
License: GPL2
------------------------------------------------------------------------
......
......@@ -83,6 +83,49 @@ function fvm_check_misconfiguration() {
}
}
# check if our tables exist, and do maintenance once a day
$fvm_table_checker = get_transient('fvm_table_checker');
$fvm_table_checker = false;
if ($fvm_table_checker === false) {
# test if at least one table exists
global $wpdb;
if(!is_null($wpdb)) {
$sqla_table_name = $wpdb->prefix . 'fvm_cache';
if (!$wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $sqla_table_name)) === $sqla_table_name) {
fvm_plugin_activate();
}
}
# daily maintenance
try {
if(!is_null($wpdb)) {
# limit cache table to 20k records
$lim = 20000;
$res = $wpdb->get_row("SELECT MAX(id) as maxid FROM ".$wpdb->prefix."fvm_cache");
if(isset($res->maxid) && intval($res->maxid) > $lim) {
$wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->prefix."fvm_cache WHERE id < %d LIMIT 1", (intval($res->maxid) - $lim)));
}
# limit logs table to 500 records
$lim = 500;
$res = $wpdb->get_row("SELECT MAX(id) as maxid FROM ".$wpdb->prefix."fvm_logs");
if(isset($res->maxid) && intval($res->maxid) > $lim) {
$wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->prefix."fvm_logs WHERE id < %d LIMIT 1", (intval($res->maxid) - $lim)));
}
}
} catch (Exception $e) {
error_log('Error: '.$e->getMessage(), 0);
}
}
} catch (Exception $e) {
error_log('Caught exception (fvm_initialize_database): '.$e->getMessage(), 0);
......@@ -207,25 +250,30 @@ function fvm_add_admin_menu() {
# print admin notices when needed (json)
function fvm_show_admin_notice_from_transient() {
if(current_user_can('manage_options')) {
$inf = get_transient('fvm_admin_notice');
$inf = get_transient('fvm_admin_notice_'.get_current_user_id());
# show transient after the redirect
if($inf != false && !empty($inf)) {
$jsonarr = json_decode($inf, true);
if(!is_null($jsonarr) && is_array($jsonarr)){
# add all
$jsonarr = array_unique($jsonarr);
foreach ($jsonarr as $notice) {
add_settings_error( 'fvm_admin_notice', 'fvm_admin_notice', 'FVM: '.$notice, 'info' );
}
$notices = json_decode($inf, true);
if(!is_null($notices) && is_array($notices)){
# output on other pages
if(!isset($_GET['page']) || (isset($_GET['page']) && $_GET['page'] != 'fvm')) {
settings_errors( 'fvm_admin_notice' );
# consolidate messages
$notices = array_unique($notices);
if(count($notices) > 1) {
$msg = '<div class="fvm-info-list"><h3>FVM</h3><ul>';
foreach ($notices as $notice) { $msg.= "<li>$notice</li>"; }
$msg.= '</ul></div>';
add_settings_error( 'fvm_admin_notice', 'fvm_admin_notice', $msg, 'info' );
} else {
$msg = 'FVM: '.implode(PHP_EOL, $notices);
add_settings_error( 'fvm_admin_notice', 'fvm_admin_notice', $msg, 'info' );
}
}
# remove
delete_transient('fvm_admin_notice');
# delete
delete_transient('fvm_admin_notice_'.get_current_user_id());
}
}
}
......@@ -301,47 +349,66 @@ function fvm_get_logs_callback() {
register_activation_hook($fvm_var_file, 'fvm_plugin_activate');
function fvm_plugin_activate() {
# defauls
global $wpdb;
if(is_null($wpdb)) { return false; }
# defauls
$sql = array();
$wpdb_collate = $wpdb->collate;
# create cache table
$charset_collate = $wpdb->get_charset_collate();
$sqla_table_name = $wpdb->prefix . 'fvm_cache';
$sqla = "CREATE TABLE IF NOT EXISTS {$sqla_table_name} (
`id` bigint(20) unsigned NOT NULL auto_increment ,
`uid` varchar(64) NOT NULL,
`date` bigint(10) unsigned NOT NULL,
`type` varchar(3) NOT NULL,
`content` mediumtext NOT NULL,
`meta` mediumtext NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uid (uid),
KEY date (date), KEY type (type)
)
COLLATE {$wpdb_collate}";
# create logs table
$sqlb_table_name = $wpdb->prefix . 'fvm_logs';
$sqlb = "CREATE TABLE IF NOT EXISTS {$sqlb_table_name} (
`id` bigint(20) unsigned NOT NULL auto_increment,
`uid` varchar(64) NOT NULL,
`date` bigint(10) unsigned NOT NULL,
`type` varchar(10) NOT NULL,
`msg` mediumtext NOT NULL,
`meta` mediumtext NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uid (uid),
KEY date (date),
KEY type (type)
)
COLLATE {$wpdb_collate}";
# create cache table
$sqla = "CREATE TABLE {$sqla_table_name} (
id bigint(20) unsigned NOT NULL auto_increment ,
uid varchar(64) NOT NULL,
date bigint(10) unsigned NOT NULL,
type varchar(3) NOT NULL,
content mediumtext NOT NULL,
meta mediumtext NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uid (uid),
KEY date (date), KEY type (type)
) $charset_collate;";
# create logs table
$sqlb = "CREATE TABLE {$sqlb_table_name} (
id bigint(20) unsigned NOT NULL auto_increment,
uid varchar(64) NOT NULL,
date bigint(10) unsigned NOT NULL,
type varchar(10) NOT NULL,
msg mediumtext NOT NULL,
meta mediumtext NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uid (uid),
KEY date (date),
KEY type (type)
) $charset_collate;";
# run sql
$wpdb->query($sqla);
$wpdb->query($sqlb);
# https://developer.wordpress.org/reference/functions/dbdelta/
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sqla );
dbDelta( $sqlb );
# test if at least one table exists
if (!$wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $sqla_table_name)) === $sqla_table_name) {
# log
$err = 'An error occurred when trying to create the database tables';
error_log($err);
# alert
if(is_admin()) {
$notices = array($err);
set_transient('fvm_admin_notice_'.get_current_user_id(), json_encode($notices), 10);
}
# try again in 1 hour
set_transient('fvm_table_checker', true, HOUR_IN_SECONDS);
} else {
# success, but check again tomorrow
set_transient('fvm_table_checker', true, DAY_IN_SECONDS);
}
}
......@@ -349,6 +416,9 @@ function fvm_plugin_activate() {
# run during deactivation
register_deactivation_hook($fvm_var_file, 'fvm_plugin_deactivate');
function fvm_plugin_deactivate() {
# process cache settings
fvm_purge_static_files();
global $wpdb;
if(is_null($wpdb)) { return false; }
......@@ -356,16 +426,17 @@ function fvm_plugin_deactivate() {
# remove options and tables
$wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name = 'fvm_last_cache_update'");
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fvm_cache");
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fvm_logs");
# process cache settings
fvm_purge_static_files();
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fvm_logs");
}
# run during uninstall
register_uninstall_hook($fvm_var_file, 'fvm_plugin_uninstall');
function fvm_plugin_uninstall() {
# process cache settings
fvm_purge_static_files();
global $wpdb;
if(is_null($wpdb)) { return false; }
......@@ -375,9 +446,6 @@ function fvm_plugin_uninstall() {
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fvm_cache");
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fvm_logs");
# process cache settings
fvm_purge_static_files();
}
......
......@@ -47,12 +47,13 @@ function fvm_process_page($html) {
# get html into an object
# https://simplehtmldom.sourceforge.io/manual.htm
$html_object = str_get_html($html, false, true, 'UTF-8', false, PHP_EOL, ' ');
$html_object = fvm_str_get_html($html, false, true, 'UTF-8', false, PHP_EOL, ' ');
# return early if html is not an object, or overwrite html into an object for processing
if (!is_object($html_object)) {
return $html . '<!-- simplehtmldom failed to process the html -->';
} else {
$html_src = $html;
$html = $html_object;
}
......@@ -66,13 +67,16 @@ function fvm_process_page($html) {
$htmljsheader = array();
$htmljsdefer = array();
# only error possible for now
$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;
# collect all link preload headers, skip amp
if(fvm_is_amp_page() !== true) {
# skip on web stories
if(count($html->find('script[src*=cdn.ampproject.org]')) > 0) {
return $html . '<!-- FVM does not support AMP -->';
return $html_src . DIRECTORY_SEPARATOR . '<!-- FVM ['.date('r').'] does not support AMP -->';
}
# add other preloads
......@@ -188,7 +192,7 @@ function fvm_process_page($html) {
# extract fonts and icons
if(isset($fvm_settings['css']['fonts']) && $fvm_settings['css']['fonts'] == true) {
$extract_fonts_arr = fvm_extract_fonts($css['code']);
$extract_fonts_arr = fvm_extract_fonts($css['code'], $href);
$css_lowpriority_code.= '/* '.$href.' */'. PHP_EOL . $extract_fonts_arr['fonts'];
$css_code = $extract_fonts_arr['code'];
} else {
......@@ -259,7 +263,7 @@ function fvm_process_page($html) {
# extract fonts and icons
if(isset($fvm_settings['css']['fonts']) && $fvm_settings['css']['fonts'] == true) {
$extract_fonts_arr = fvm_extract_fonts($css['code']);
$extract_fonts_arr = fvm_extract_fonts($css['code'], $href);
$css_lowpriority_code.= '/* '.$href.' */'. PHP_EOL . $extract_fonts_arr['fonts'];
$css_code = $extract_fonts_arr['code'];
} else {
......@@ -277,6 +281,9 @@ function fvm_process_page($html) {
# generate url
$ind_css_url = fvm_generate_min_url($href, $css['tkey'], 'css', $css_code);
if($ind_css_url === false) {
return $html_src . $fvm_error;
}
# cdn
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
......@@ -402,14 +409,17 @@ function fvm_process_page($html) {
# generate url
$css_fonts_url = fvm_generate_min_url('fonts', $tkey, 'css', $css_lowpriority_code);
# cdn
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
$css_fonts_url = fvm_rewrite_cdn_url($css_fonts_url);
if($css_fonts_url === false) {
return $html_src . $fvm_error;
}
# preload
$htmlcssheader[0] = '<link id="fvm-fonts" rel="stylesheet" href="'.$css_fonts_url.'" media="fonts" onload="if(fvmuag()){this.media=\'all\'}" />';
# cdn
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
$css_fonts_url = fvm_rewrite_cdn_url($css_fonts_url);
}
# preload
$htmlcssheader[0] = '<link id="fvm-fonts" rel="stylesheet" href="'.$css_fonts_url.'" media="fonts" onload="if(fvmuag()){this.media=\'all\'}" />';
}
# END OPTIMIZED FONT DELIVERY
......@@ -435,29 +445,32 @@ function fvm_process_page($html) {
# url, preload, add
$merged_css_url = fvm_generate_min_url('combined', $tkey, 'css', $merged_css);
# cdn
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
$merged_css_url = fvm_rewrite_cdn_url($merged_css_url);
if($merged_css_url === false) {
return $html_src . $fvm_error;
}
# http, html preload + header
if($css_method == 'block') {
# add to header
$htmlcssheader[] = '<link rel="stylesheet" href="'.$merged_css_url.'" media="'.$mediatype.'" />';
# http and html preload for render blocking css
if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
$htmlpreloads[] = '<link rel="preload" href="'.$merged_css_url.'" as="style" media="'.$mediatype.'" />';
# cdn
if(isset($fvm_settings['cdn']['cssok']) && $fvm_settings['cdn']['cssok'] == true) {
$merged_css_url = fvm_rewrite_cdn_url($merged_css_url);
}
} else {
# http, html preload + header
if($css_method == 'block') {
# add to header
$htmlcssheader[] = '<link rel="stylesheet" href="'.$merged_css_url.'" media="'.$mediatype.'" />';
# http and html preload for render blocking css
if(!isset($fvm_settings['css']['nopreload']) || (isset($fvm_settings['css']['nopreload']) && $fvm_settings['css']['nopreload'] != true)) {
$htmlpreloads[] = '<link rel="preload" href="'.$merged_css_url.'" as="style" media="'.$mediatype.'" />';
}
} else {
# async
$htmlcssheader[] = '<link rel="preload" as="style" href="'.$merged_css_url.'" media="'.$mediatype.'" onload="this.rel=\'stylesheet\'" />';
# async
$htmlcssheader[] = '<link rel="preload" as="style" href="'.$merged_css_url.'" media="'.$mediatype.'" onload="this.rel=\'stylesheet\'" />';
}
}
}
}
......@@ -708,6 +721,9 @@ function fvm_process_page($html) {
# generate url
$ind_js_url = fvm_generate_min_url($tag->src, $js['tkey'], 'js', $js['code']);
if($ind_js_url === false) {
return $html_src . $fvm_error;
}
# cdn
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
......@@ -759,6 +775,9 @@ function fvm_process_page($html) {
# generate url
$ind_js_url = fvm_generate_min_url($tag->src, $js['tkey'], 'js', $js['code']);
if($ind_js_url === false) {
return $html_src . $fvm_error;
}
# cdn
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
......@@ -885,20 +904,23 @@ function fvm_process_page($html) {
# generate url
$merged_js_url = fvm_generate_min_url('combined', $tkey, 'js', $merged_js);
# cdn
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
}
# http and html preload for render blocking scripts
if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
$htmlpreloads[] = '<link rel="preload" href="'.$merged_js_url.'" as="script" />';
if($merged_js_url === false) {
return $html_src . $fvm_error;
}
# add to header
$htmljsheader[] = "<script data-cfasync='false' src='".$merged_js_url."'></script>";
# cdn
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
}
# http and html preload for render blocking scripts
if(!isset($fvm_settings['js']['nopreload']) || (isset($fvm_settings['js']['nopreload']) && $fvm_settings['js']['nopreload'] != true)) {
$htmlpreloads[] = '<link rel="preload" href="'.$merged_js_url.'" as="script" />';
}
# add to header
$htmljsheader[] = "<script data-cfasync='false' src='".$merged_js_url."'></script>";
}
# deferred scripts
......@@ -910,15 +932,18 @@ function fvm_process_page($html) {
# generate url
$merged_js_url = fvm_generate_min_url('combined', $tkey, 'js', $merged_js);
# cdn
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
if($merged_js_url === false) {
return $html_src . $fvm_error;
}
# header, no preload for deferred files
$htmljsheader[] = "<script defer='defer' src='".$merged_js_url."'></script>";
# cdn
if(isset($fvm_settings['cdn']['jsok']) && $fvm_settings['cdn']['jsok'] == true) {
$merged_js_url = fvm_rewrite_cdn_url($merged_js_url);
}
# header, no preload for deferred files
$htmljsheader[] = "<script defer='defer' src='".$merged_js_url."'></script>";
}
}
......
......@@ -286,6 +286,21 @@
</div>
<div style="height: 20px;"></div>
<h2 class="title">Query String Settings</h2>
<div class="accordion">
<h3>Allowed Query Strings</h3>
<div>
<p><strong>Notes:</strong></p>
<p>This allows processing of CSS, HTML and JS when the url contains certain query strings, but note that if there are other query strings found on the same url not on the list of allowed query strings, it will still not process the url.</p>
<p><strong>Example Settings:</strong></p>
<p class="fvm-code-full">
utm_source<br />utm_campaign<br />utm_medium<br />utm_expid<br />utm_term<br />utm_content<br />fb_action_ids<br />fb_action_types<br />fb_source<br />fbclid<br />_ga<br />gclid<br />age-verified<br />usqp<br />cn-reloaded<br />lang<br />s<br />permalink_name<br />lp-variation-id<br />author<br />author_name<br />cat<br />category_name<br />order<br />orderby<br />p<br />page_id<br />page<br />paged<br />post_type<br />posts<br />s<br />search<br />taxonomy<br />tag<br />tag_id<br />term
</p>
</div>
</div>
<div style="height: 20px;"></div>
<h2 class="title">User Settings</h2>
<div class="accordion">
......
......@@ -22,7 +22,7 @@
<fieldset>
<label for="fvm_settings_cache_min_instant_purge">
<input name="fvm_settings[cache][min_instant_purge]" type="checkbox" id="fvm_settings_cache_min_instant_purge" value="1" <?php echo fvm_get_settings_checkbox(fvm_get_settings_value($fvm_settings, 'cache', 'min_instant_purge')); ?>>
<?php _e( 'Purge Minified CSS/JS files instantly', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'Cache files are only deleted if older than 24h by default, for compatibility with certain hosting providers.', 'fast-velocity-minify' ); ?> ]</span></label>
<?php _e( 'Purge Minified CSS/JS files instantly', 'fast-velocity-minify' ); ?> <span class="note-info">[ <?php _e( 'CSS & JS cache files are preserved for 7 days by default, for better compatibility with certain hosting providers.', 'fast-velocity-minify' ); ?> ]</span></label>
<br />
</fieldset></td>
......@@ -160,7 +160,7 @@
<td><fieldset>
<label for="fvm_settings_css_remove"><span class="fvm-bold-green fvm-rowintro"><?php _e( 'Remove the following CSS files', 'fast-velocity-minify' ); ?></span></label>
<p><textarea name="fvm_settings[css][remove]" rows="7" cols="50" id="fvm_settings_css_remove" class="large-text code" placeholder="ex: fonts.googleapis.com"><?php echo fvm_get_settings_value($fvm_settings, 'css', 'remove'); ?></textarea></p>
<p class="description">[ <?php _e( 'This will allow you to remove unwanted CSS files by URL path from the frontend', 'fast-velocity-minify' ); ?> ]</p>
<p class="description">[ <?php _e( 'This will allow you to remove unwanted CSS files by URI path from the frontend', 'fast-velocity-minify' ); ?> ]</p>
<p class="description">[ <?php _e( 'Will match using <code>PHP stripos</code> against the <code>href attribute</code> on the <code>link tag</code>', 'fast-velocity-minify' ); ?> ]</p>
</fieldset></td>
</tr>
......@@ -170,7 +170,7 @@
<td><fieldset>
<label for="fvm_settings_css_async"><span class="fvm-bold-green fvm-rowintro"><?php _e( 'Async the following CSS files', 'fast-velocity-minify' ); ?></span></label>
<p><textarea name="fvm_settings[css][async]" rows="7" cols="50" id="fvm_settings_css_async" class="large-text code" placeholder="ex: /plugins/something/assets/low-priority.css"><?php echo fvm_get_settings_value($fvm_settings, 'css', 'async'); ?></textarea></p>
<p class="description">[ <?php _e( 'This will allow you to remove unwanted CSS files by URL path from the frontend', 'fast-velocity-minify' ); ?> ]</p>
<p class="description">[ <?php _e( 'This will allow you to Async CSS files by URI path from the frontend', 'fast-velocity-minify' ); ?> ]</p>
<p class="description">[ <?php _e( 'Will match using <code>PHP stripos</code> against the <code>href attribute</code> on the <code>link tag</code>', 'fast-velocity-minify' ); ?> ]</p>
</fieldset></td>
</tr>
......@@ -364,6 +364,22 @@ www.googletagmanager.com/gtm.js"><?php echo fvm_get_settings_value($fvm_settings
<div style="height: 60px;"></div>
<h2 class="title"><?php _e( 'Query Strings', 'fast-velocity-minify' ); ?></h2>
<h3 class="fvm-bold-green"><?php _e( 'Allow processing of CSS, JS & HTML on specific query strings', 'fast-velocity-minify' ); ?></h3>
<table class="form-table fvm-settings">
<tbody>
<tr>
<th scope="row"><?php _e( 'Allowed Query Strings', 'fast-velocity-minify' ); ?></th>
<td><fieldset>
<label for="fvm_settings_settings_qs"><span class="fvm-bold-green fvm-rowintro"><?php _e( 'One query string key per line', 'fast-velocity-minify' ); ?></span></label>
<p><textarea name="fvm_settings[settings][qs]" rows="7" cols="50" id="fvm_settings_settings_qs" class="large-text code" placeholder="--- check the help section for suggestions ---"><?php echo fvm_get_settings_value($fvm_settings, 'settings', 'qs'); ?></textarea></p>
<p class="description">[ <?php _e( 'Additional query strings, keys only', 'fast-velocity-minify' ); ?> ]</p>
</fieldset></td>
</tr>
</tbody></table>
<div style="height: 60px;"></div>
<h2 class="title"><?php _e( 'User Settings', 'fast-velocity-minify' ); ?></h2>
<h3 class="fvm-bold-green"><?php _e( 'For compatibility reasons, only anonymous users should be optimized by default.', 'fast-velocity-minify' ); ?></h3>
<table class="form-table fvm-settings">
......
......@@ -563,47 +563,7 @@ class CSS extends Minify
*/
protected function shortenZeroes($content)
{
// we don't want to strip units in `calc()` expressions:
// `5px - 0px` is valid, but `5px - 0` is not
// `10px * 0` is valid (equates to 0), and so is `10 * 0px`, but
// `10 * 0` is invalid
// we've extracted calcs earlier, so we don't need to worry about this
// reusable bits of code throughout these regexes:
// before & after are used to make sure we don't match lose unintended
// 0-like values (e.g. in #000, or in http://url/1.0)
// units can be stripped from 0 values, or used to recognize non 0
// values (where wa may be able to strip a .0 suffix)
$before = '(?<=[:(, ])';
$after = '(?=[ ,);}])';
$units = '(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax|vm)';
// strip units after zeroes (0px -> 0)
// NOTE: it should be safe to remove all units for a 0 value, but in
// practice, Webkit (especially Safari) seems to stumble over at least
// 0%, potentially other units as well. Only stripping 'px' for now.
// @see https://github.com/matthiasmullie/minify/issues/60
$content = preg_replace('/'.$before.'(-?0*(\.0+)?)(?<=0)px'.$after.'/', '\\1', $content);
// strip 0-digits (.0 -> 0)
$content = preg_replace('/'.$before.'\.0+'.$units.'?'.$after.'/', '0\\1', $content);
// strip trailing 0: 50.10 -> 50.1, 50.10px -> 50.1px
$content = preg_replace('/'.$before.'(-?[0-9]+\.[0-9]+)0+'.$units.'?'.$after.'/', '\\1\\2', $content);
// strip trailing 0: 50.00 -> 50, 50.00px -> 50px
$content = preg_replace('/'.$before.'(-?[0-9]+)\.0+'.$units.'?'.$after.'/', '\\1\\2', $content);
// strip leading 0: 0.1 -> .1, 01.1 -> 1.1
$content = preg_replace('/'.$before.'(-?)0+([0-9]*\.[0-9]+)'.$units.'?'.$after.'/', '\\1\\2\\3', $content);
// strip negative zeroes (-0 -> 0) & truncate zeroes (00 -> 0)
$content = preg_replace('/'.$before.'-?0+'.$units.'?'.$after.'/', '0\\1', $content);
// IE doesn't seem to understand a unitless flex-basis value (correct -
// it goes against the spec), so let's add it in again (make it `%`,
// which is only 1 char: 0%, 0px, 0 anything, it's all just the same)
// @see https://developer.mozilla.org/nl/docs/Web/CSS/flex
$content = preg_replace('/flex:([0-9]+\s[0-9]+\s)0([;\}])/', 'flex:${1}0%${2}', $content);
$content = preg_replace('/flex-basis:0([;\}])/', 'flex-basis:0%${1}', $content);
// removed
return $content;
}
......
......@@ -3,13 +3,13 @@ Contributors: Alignak
Tags: PHP Minify, Lighthouse, GTmetrix, Pingdom, Pagespeed, Merging, Minification, Optimization, Speed, Performance, FVM
Requires at least: 4.9
Requires PHP: 5.6
Stable tag: 3.2.2
Tested up to: 5.7.1
Stable tag: 3.2.6
Tested up to: 5.9.1
Text Domain: fast-velocity-minify
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by adjusting your CSS and JS files (defer, async, minify, combine, etc), compressing HTML, simplifying fonts and a few more speed optimization options.
Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by adjusting CSS and JS files (defer, async, minify, combine, etc), compressing HTML, simplifying fonts and a few more speed optimization options.
== Description ==
......@@ -49,8 +49,26 @@ You need a public directory to store and serve minified cache files. If you need
== Changelog ==
= 3.2.2 [2021.05.09] =
= 3.2.6 [2022.02.06] =
* cache purging fixes
= 3.2.5 [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
= 3.2.4 [2022.01.31] =
* WP 5.9 / PHP 8 maintenance release
* changed deferred css/js cache clearing from 24h to 7 days
* added cache purging support for nginx helper plugin
* added option to allow processing on specific query strings
* other bug fixes
= 3.2.3 [2021.05.15] =
* added auto varnish cache purge for Cloudways
* switched from WP_Filesystem_Direct() to WP_Filesystem()
= 3.2.2 [2021.05.09] =
* fixed some JS files not being minified
= 3.2.1 [2021.05.07] =
......