Version Description
- Google Fonts: some more removal logic
- fix for 404 fallback bug (hat tip to Asif for finding & reporting)
- Some other minor changes/ improvements/ filters, see the GitHub commit log.
Download this release
Release Info
Developer | futtta |
Plugin | Autoptimize |
Version | 3.1.2 |
Comparing to | |
See all releases |
Code changes from version 3.1.1.1 to 3.1.2
- autoptimize.php +2 -2
- classes/autoptimizeCache.php +1 -1
- classes/autoptimizeCriticalCSSSettings.php +2 -2
- classes/autoptimizeExtra.php +10 -1
- classes/autoptimizeImages.php +1 -1
- classes/autoptimizeVersionUpdatesHandler.php +16 -0
- classes/critcss-inc/admin_settings_key.php +9 -5
- classes/critcss-inc/admin_settings_rules.js.php +1 -1
- classes/critcss-inc/admin_settings_rules.php +9 -3
- config/autoptimize_404_handler.php +1 -1
- readme.txt +7 -1
autoptimize.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Autoptimize
|
4 |
* Plugin URI: https://autoptimize.com/
|
5 |
* Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
|
6 |
-
* Version: 3.1.
|
7 |
* Author: Frank Goossens (futtta)
|
8 |
* Author URI: https://autoptimize.com/
|
9 |
* Text Domain: autoptimize
|
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
21 |
exit;
|
22 |
}
|
23 |
|
24 |
-
define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.
|
25 |
|
26 |
// plugin_dir_path() returns the trailing slash!
|
27 |
define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
3 |
* Plugin Name: Autoptimize
|
4 |
* Plugin URI: https://autoptimize.com/
|
5 |
* Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
|
6 |
+
* Version: 3.1.2
|
7 |
* Author: Frank Goossens (futtta)
|
8 |
* Author URI: https://autoptimize.com/
|
9 |
* Text Domain: autoptimize
|
21 |
exit;
|
22 |
}
|
23 |
|
24 |
+
define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.2' );
|
25 |
|
26 |
// plugin_dir_path() returns the trailing slash!
|
27 |
define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
classes/autoptimizeCache.php
CHANGED
@@ -392,7 +392,7 @@ class autoptimizeCache
|
|
392 |
}
|
393 |
}
|
394 |
|
395 |
-
if ( ! self::cacheavail() ) {
|
396 |
return false;
|
397 |
}
|
398 |
|
392 |
}
|
393 |
}
|
394 |
|
395 |
+
if ( ! self::cacheavail() || true === apply_filters( 'autoptimize_filter_cache_clearall_disabled', false ) ) {
|
396 |
return false;
|
397 |
}
|
398 |
|
classes/autoptimizeCriticalCSSSettings.php
CHANGED
@@ -49,7 +49,7 @@ class autoptimizeCriticalCSSSettings {
|
|
49 |
|
50 |
public function add_critcss_tabs( $in )
|
51 |
{
|
52 |
-
$in = array_merge( $in, array( 'ao_critcss' => '⚡ ' . __( 'Critical CSS', 'autoptimize' ) ) );
|
53 |
|
54 |
return $in;
|
55 |
}
|
@@ -299,7 +299,7 @@ class autoptimizeCriticalCSSSettings {
|
|
299 |
</ul>
|
300 |
<?php
|
301 |
} else {
|
302 |
-
if ( 'valid' == $key['status'] ) {
|
303 |
// If key status is valid, render other panels.
|
304 |
// Render rules section.
|
305 |
ao_ccss_render_rules();
|
49 |
|
50 |
public function add_critcss_tabs( $in )
|
51 |
{
|
52 |
+
$in = array_merge( $in, array( 'ao_critcss' => apply_filters( 'autoptimize_filter_ccss_tab_text', '⚡ ' . __( 'Critical CSS', 'autoptimize' ) ) ) );
|
53 |
|
54 |
return $in;
|
55 |
}
|
299 |
</ul>
|
300 |
<?php
|
301 |
} else {
|
302 |
+
if ( 'valid' == $key['status'] || ( defined( 'AO_PRO_VERSION' ) && has_filter( 'autoptimize_filter_ccss_key' ) ) ) {
|
303 |
// If key status is valid, render other panels.
|
304 |
// Render rules section.
|
305 |
ao_ccss_render_rules();
|
classes/autoptimizeExtra.php
CHANGED
@@ -117,7 +117,7 @@ class autoptimizeExtra
|
|
117 |
{
|
118 |
if ( strpos( $src, '?ver=' ) ) {
|
119 |
$src = remove_query_arg( 'ver', $src );
|
120 |
-
}
|
121 |
$src = remove_query_arg( 'v', $src );
|
122 |
}
|
123 |
|
@@ -178,6 +178,15 @@ class autoptimizeExtra
|
|
178 |
add_filter( 'wp_resource_hints', array( $this, 'filter_remove_gfonts_dnsprefetch' ), 10, 2 );
|
179 |
add_filter( 'autoptimize_html_after_minify', array( $this, 'filter_optimize_google_fonts' ), 10, 1 );
|
180 |
add_filter( 'autoptimize_extra_filter_tobepreconn', array( $this, 'filter_preconnect_google_fonts' ), 10, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
}
|
182 |
|
183 |
// Preconnect!
|
117 |
{
|
118 |
if ( strpos( $src, '?ver=' ) ) {
|
119 |
$src = remove_query_arg( 'ver', $src );
|
120 |
+
} elseif ( strpos( $src, '?v=' ) ) {
|
121 |
$src = remove_query_arg( 'v', $src );
|
122 |
}
|
123 |
|
178 |
add_filter( 'wp_resource_hints', array( $this, 'filter_remove_gfonts_dnsprefetch' ), 10, 2 );
|
179 |
add_filter( 'autoptimize_html_after_minify', array( $this, 'filter_optimize_google_fonts' ), 10, 1 );
|
180 |
add_filter( 'autoptimize_extra_filter_tobepreconn', array( $this, 'filter_preconnect_google_fonts' ), 10, 1 );
|
181 |
+
|
182 |
+
if ( '2' === $options['autoptimize_extra_radio_field_4'] ) {
|
183 |
+
// remove Google Fonts, adding filters to also remove Google Fonts from 3rd party themes/ plugins.
|
184 |
+
// inspired by https://wordpress.org/plugins/disable-remove-google-fonts/.
|
185 |
+
remove_action( 'wp_footer', 'et_builder_print_font' ); // Divi.
|
186 |
+
remove_action( 'wp_footer', array( 'RevSliderFront', 'load_google_fonts' ) ); // Revslider.
|
187 |
+
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' ); // Elementor.
|
188 |
+
add_filter( 'fl_builder_google_fonts_pre_enqueue', '__return_empty_array' ); // Beaver Builder.
|
189 |
+
}
|
190 |
}
|
191 |
|
192 |
// Preconnect!
|
classes/autoptimizeImages.php
CHANGED
@@ -1166,7 +1166,7 @@ class autoptimizeImages
|
|
1166 |
public function add_imgopt_tab( $in )
|
1167 |
{
|
1168 |
if ( autoptimizeConfig::should_show_menu_tabs() ) {
|
1169 |
-
$in = array_merge( $in, array( 'autoptimize_imgopt' => __( 'Images', 'autoptimize' ) ) );
|
1170 |
}
|
1171 |
|
1172 |
return $in;
|
1166 |
public function add_imgopt_tab( $in )
|
1167 |
{
|
1168 |
if ( autoptimizeConfig::should_show_menu_tabs() ) {
|
1169 |
+
$in = array_merge( $in, array( 'autoptimize_imgopt' => apply_filters( 'autoptimize_filter_imgopt_tab_text', __( 'Images', 'autoptimize' ) ) ) );
|
1170 |
}
|
1171 |
|
1172 |
return $in;
|
classes/autoptimizeVersionUpdatesHandler.php
CHANGED
@@ -64,6 +64,12 @@ class autoptimizeVersionUpdatesHandler
|
|
64 |
$this->upgrade_from_2_9_before_compatibility();
|
65 |
}
|
66 |
$major_update = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
if ( true === $major_update ) {
|
@@ -281,4 +287,14 @@ class autoptimizeVersionUpdatesHandler
|
|
281 |
private function upgrade_from_2_9_before_compatibility() {
|
282 |
autoptimizeOptionWrapper::update_option( 'autoptimize_installed_before_compatibility', true );
|
283 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
64 |
$this->upgrade_from_2_9_before_compatibility();
|
65 |
}
|
66 |
$major_update = false;
|
67 |
+
// No break, intentionally, so all upgrades are ran during a single request...
|
68 |
+
case '3.0':
|
69 |
+
// nothing.
|
70 |
+
case '3.1':
|
71 |
+
$this->upgrade_from_3_1();
|
72 |
+
$major_update = false;
|
73 |
}
|
74 |
|
75 |
if ( true === $major_update ) {
|
287 |
private function upgrade_from_2_9_before_compatibility() {
|
288 |
autoptimizeOptionWrapper::update_option( 'autoptimize_installed_before_compatibility', true );
|
289 |
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* If the 404 handler is active, delete the current PHP-file so it can be re-created to fix the double underscore bug.
|
293 |
+
*/
|
294 |
+
private function upgrade_from_3_1() {
|
295 |
+
if ( autoptimizeCache::do_fallback() && version_compare( autoptimizeOptionWrapper::get_option( 'autoptimize_version', 'none' ), '3.1.2', 'lt' ) ) {
|
296 |
+
$_fallback_php = trailingslashit( WP_CONTENT_DIR ) . 'autoptimize_404_handler.php';
|
297 |
+
@unlink( $_fallback_php ); // @codingStandardsIgnoreLine
|
298 |
+
}
|
299 |
+
}
|
300 |
}
|
classes/critcss-inc/admin_settings_key.php
CHANGED
@@ -13,15 +13,19 @@
|
|
13 |
* @param string $color Color to highlight message in.
|
14 |
*/
|
15 |
function ao_ccss_render_key( $key, $status, $status_msg, $message, $color ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) {
|
17 |
$key = __( 'API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize' );
|
18 |
} else if ( has_filter( 'autoptimize_filter_ccss_key' ) ) {
|
19 |
-
|
20 |
-
$key = __( 'You\'re using Autoptimize Pro, so you don\'t need to provide an API Key.', 'autoptimize' );
|
21 |
-
} else {
|
22 |
-
$key = __( 'API Key provided by a filter, no need to enter anything here.', 'autoptimize' );
|
23 |
-
}
|
24 |
}
|
|
|
25 |
?>
|
26 |
<ul id="key-panel">
|
27 |
<li class="itemDetail">
|
13 |
* @param string $color Color to highlight message in.
|
14 |
*/
|
15 |
function ao_ccss_render_key( $key, $status, $status_msg, $message, $color ) {
|
16 |
+
if ( defined( 'AO_PRO_VERSION' ) && has_filter( 'autoptimize_filter_ccss_key' ) ) {
|
17 |
+
?>
|
18 |
+
<input type="hidden" id="autoptimize_ccss_key" name="autoptimize_ccss_key" value="">
|
19 |
+
<?php
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) {
|
24 |
$key = __( 'API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize' );
|
25 |
} else if ( has_filter( 'autoptimize_filter_ccss_key' ) ) {
|
26 |
+
$key = __( 'API Key provided by a filter, no need to enter anything here.', 'autoptimize' );
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
+
|
29 |
?>
|
30 |
<ul id="key-panel">
|
31 |
<li class="itemDetail">
|
classes/critcss-inc/admin_settings_rules.js.php
CHANGED
@@ -113,7 +113,7 @@ function drawTable(critCssArray) {
|
|
113 |
<?php
|
114 |
$_ao_ccss_review_notice_id = 'autoptimize-ccss-review-rules-notice-30';
|
115 |
// Translators: before the 1st word a number + a space will be displayed, as in e.g. "2 of above rules".
|
116 |
-
$_ao_ccss_review_notice_copy = __( 'of the above rules got flagged by criticalcss.com as
|
117 |
if ( PAnD::is_admin_notice_active( $_ao_ccss_review_notice_id ) ) {
|
118 |
?>
|
119 |
jQuery("#rules-notices").append( " <div class='rnotice notice notice-info is-dismissible hidden' data-dismissible='<?php echo $_ao_ccss_review_notice_id; ?>'><p>" + rnotice + " <?php echo $_ao_ccss_review_notice_copy; ?>" + "</p></div>");
|
113 |
<?php
|
114 |
$_ao_ccss_review_notice_id = 'autoptimize-ccss-review-rules-notice-30';
|
115 |
// Translators: before the 1st word a number + a space will be displayed, as in e.g. "2 of above rules".
|
116 |
+
$_ao_ccss_review_notice_copy = __( 'of the above rules got flagged by criticalcss.com as possibly needing review. This is often due to font-related issues which can be safely ignored, but in case of doubt do a visual test or check for Cumulative Layout Shift issues in e.g. Pagespeed Insights.', 'autoptimize' );
|
117 |
if ( PAnD::is_admin_notice_active( $_ao_ccss_review_notice_id ) ) {
|
118 |
?>
|
119 |
jQuery("#rules-notices").append( " <div class='rnotice notice notice-info is-dismissible hidden' data-dismissible='<?php echo $_ao_ccss_review_notice_id; ?>'><p>" + rnotice + " <?php echo $_ao_ccss_review_notice_copy; ?>" + "</p></div>");
|
classes/critcss-inc/admin_settings_rules.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
*/
|
9 |
function ao_ccss_render_rules() {
|
10 |
// Attach required arrays.
|
11 |
-
$criticalcss
|
12 |
$ao_ccss_rules = sanitize_rules( $criticalcss->get_option( 'rules' ) );
|
13 |
$ao_ccss_types = $criticalcss->get_types();
|
14 |
|
@@ -109,9 +109,9 @@ function ao_ccss_render_rules() {
|
|
109 |
$_type = str_replace( 'custom_post_', '', $type );
|
110 |
} elseif ( substr( $type, 0, 9 ) === 'template_' ) {
|
111 |
$_type = str_replace( 'template_', '', $type );
|
112 |
-
} elseif ( 'bbp_is_bbpress'
|
113 |
$_type = str_replace( 'bbp_', '', $type );
|
114 |
-
} elseif ( 'bp_is_buddypress'
|
115 |
$_type = str_replace( 'bp_', '', $type );
|
116 |
} elseif ( substr( $type, 0, 4 ) === 'woo_' ) {
|
117 |
$_type = str_replace( 'woo_', '', $type );
|
@@ -218,6 +218,12 @@ function sanitize_rules( $rules ) {
|
|
218 |
foreach ( $rules['paths'] as $key => $value ) {
|
219 |
$newkey = esc_url( $key );
|
220 |
if ( $newkey !== $key ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
unset( $rules['paths'][ $key ] );
|
222 |
$rules['paths'][ $newkey ] = $value;
|
223 |
}
|
8 |
*/
|
9 |
function ao_ccss_render_rules() {
|
10 |
// Attach required arrays.
|
11 |
+
$criticalcss = autoptimize()->criticalcss();
|
12 |
$ao_ccss_rules = sanitize_rules( $criticalcss->get_option( 'rules' ) );
|
13 |
$ao_ccss_types = $criticalcss->get_types();
|
14 |
|
109 |
$_type = str_replace( 'custom_post_', '', $type );
|
110 |
} elseif ( substr( $type, 0, 9 ) === 'template_' ) {
|
111 |
$_type = str_replace( 'template_', '', $type );
|
112 |
+
} elseif ( 'bbp_is_bbpress' === $type ) {
|
113 |
$_type = str_replace( 'bbp_', '', $type );
|
114 |
+
} elseif ( 'bp_is_buddypress' === $type ) {
|
115 |
$_type = str_replace( 'bp_', '', $type );
|
116 |
} elseif ( substr( $type, 0, 4 ) === 'woo_' ) {
|
117 |
$_type = str_replace( 'woo_', '', $type );
|
218 |
foreach ( $rules['paths'] as $key => $value ) {
|
219 |
$newkey = esc_url( $key );
|
220 |
if ( $newkey !== $key ) {
|
221 |
+
if ( 0 === strpos( $newkey, 'http://' ) && 0 !== strpos( $key, 'http://' ) ) {
|
222 |
+
// esc_url adds "http://" to any string that does not start with either a protocol or a
|
223 |
+
// slash, see https://developer.wordpress.org/reference/functions/esc_url/#more-information
|
224 |
+
// this removes that unneeded protocol again.
|
225 |
+
$newkey = substr_replace( $newkey, '', 0, 7 );
|
226 |
+
}
|
227 |
unset( $rules['paths'][ $key ] );
|
228 |
$rules['paths'][ $newkey ] = $value;
|
229 |
}
|
config/autoptimize_404_handler.php
CHANGED
@@ -38,7 +38,7 @@ if ( true === $multisite ) {
|
|
38 |
$ao_cache_dir = $ao_root_cache_dir . $child_site_id[1] . '/';
|
39 |
}
|
40 |
|
41 |
-
$fallback_path = $ao_cache_dir . $js_or_css . '/<!--ao-cachefile-prefix-->
|
42 |
|
43 |
if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
|
44 |
// error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
|
38 |
$ao_cache_dir = $ao_root_cache_dir . $child_site_id[1] . '/';
|
39 |
}
|
40 |
|
41 |
+
$fallback_path = $ao_cache_dir . $js_or_css . '/<!--ao-cachefile-prefix-->fallback.' . $js_or_css;
|
42 |
|
43 |
if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
|
44 |
// error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 3.1.
|
9 |
|
10 |
Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
|
11 |
|
@@ -298,6 +298,7 @@ The following great open source projects are used in Autoptimize in some form or
|
|
298 |
* [jQuery unslider](https://github.com/idiot/unslider/) for the mini-slider in the top right corner on the main settings page (repo gone)
|
299 |
* [JavaScript-md5](https://github.com/blueimp/JavaScript-MD5) for critical CSS rules editing
|
300 |
* [Speed Booster Pack](https://wordpress.org/plugins/speed-booster-pack/) for advanced JS deferring
|
|
|
301 |
|
302 |
= Where can I get help? =
|
303 |
|
@@ -315,6 +316,11 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
|
|
315 |
|
316 |
== Changelog ==
|
317 |
|
|
|
|
|
|
|
|
|
|
|
318 |
= 3.1.1.1 =
|
319 |
* Quick workaround for an autoload conflict with JetFormBuilder (and maybe other Crocoblock plugins?) that causes a critical error on the AO settings page.
|
320 |
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 3.1.2
|
9 |
|
10 |
Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
|
11 |
|
298 |
* [jQuery unslider](https://github.com/idiot/unslider/) for the mini-slider in the top right corner on the main settings page (repo gone)
|
299 |
* [JavaScript-md5](https://github.com/blueimp/JavaScript-MD5) for critical CSS rules editing
|
300 |
* [Speed Booster Pack](https://wordpress.org/plugins/speed-booster-pack/) for advanced JS deferring
|
301 |
+
* [Disable Remove Google Fonts](https://wordpress.org/plugins/disable-remove-google-fonts/) for additional Google Font removal
|
302 |
|
303 |
= Where can I get help? =
|
304 |
|
316 |
|
317 |
== Changelog ==
|
318 |
|
319 |
+
= 3.1.2 =
|
320 |
+
* Google Fonts: some more removal logic
|
321 |
+
* fix for 404 fallback bug (hat tip to Asif for finding & reporting)
|
322 |
+
* Some other minor changes/ improvements/ filters, see the [GitHub commit log](https://github.com/futtta/autoptimize/commits/beta).
|
323 |
+
|
324 |
= 3.1.1.1 =
|
325 |
* Quick workaround for an autoload conflict with JetFormBuilder (and maybe other Crocoblock plugins?) that causes a critical error on the AO settings page.
|
326 |
|