Version Description
- fix for images being preloaded without this being configured when lazyload is on and per page/post settings are off.
- ensure critical CSS schedule is always known.
- when deferring non-aggregated JS, make the optimatization exclusions take the full script-tag into account instead of just the src URL.
Download this release
Release Info
Developer | futtta |
Plugin | Autoptimize |
Version | 3.0.3 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.0.3
- autoptimize.php +2 -2
- classes/autoptimizeConfig.php +4 -0
- classes/autoptimizeCriticalCSSBase.php +3 -3
- classes/autoptimizeImages.php +11 -4
- classes/autoptimizeMain.php +11 -6
- classes/autoptimizeScripts.php +1 -1
- readme.txt +6 -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.0.
|
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.0.
|
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.0.3
|
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.0.3' );
|
25 |
|
26 |
// plugin_dir_path() returns the trailing slash!
|
27 |
define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
classes/autoptimizeConfig.php
CHANGED
@@ -1005,6 +1005,10 @@ if ( true === autoptimizeImages::imgopt_active() && true === apply_filters( 'aut
|
|
1005 |
public static function get_post_meta_ao_settings( $optim ) {
|
1006 |
if ( ! autoptimizeConfig::is_ao_meta_settings_active() ) {
|
1007 |
// Per page/post settings not active, so always return true (as in; can be optimized).
|
|
|
|
|
|
|
|
|
1008 |
return true;
|
1009 |
}
|
1010 |
|
1005 |
public static function get_post_meta_ao_settings( $optim ) {
|
1006 |
if ( ! autoptimizeConfig::is_ao_meta_settings_active() ) {
|
1007 |
// Per page/post settings not active, so always return true (as in; can be optimized).
|
1008 |
+
if ( in_array( $optim, array( 'ao_post_preload' ) ) ) {
|
1009 |
+
// but make sure to return false for text input.
|
1010 |
+
return false;
|
1011 |
+
}
|
1012 |
return true;
|
1013 |
}
|
1014 |
|
classes/autoptimizeCriticalCSSBase.php
CHANGED
@@ -97,10 +97,10 @@ class autoptimizeCriticalCSSBase {
|
|
97 |
|
98 |
// add/ remove scheduled jobs.
|
99 |
if ( $this->is_api_active() ) {
|
100 |
-
|
101 |
-
|
102 |
-
add_filter( 'cron_schedules', array( $this, 'ao_ccss_interval' ) );
|
103 |
|
|
|
104 |
// make sure ao_ccss_queue is scheduled OK if an API key is active.
|
105 |
wp_schedule_event( time(), apply_filters( 'ao_ccss_queue_schedule', 'ao_ccss' ), 'ao_ccss_queue' );
|
106 |
}
|
97 |
|
98 |
// add/ remove scheduled jobs.
|
99 |
if ( $this->is_api_active() ) {
|
100 |
+
// make sure the 10 minutes cron schedule is added.
|
101 |
+
add_filter( 'cron_schedules', array( $this, 'ao_ccss_interval' ) );
|
|
|
102 |
|
103 |
+
if ( ! wp_next_scheduled( 'ao_ccss_queue' ) ) {
|
104 |
// make sure ao_ccss_queue is scheduled OK if an API key is active.
|
105 |
wp_schedule_event( time(), apply_filters( 'ao_ccss_queue_schedule', 'ao_ccss' ), 'ao_ccss_queue' );
|
106 |
}
|
classes/autoptimizeImages.php
CHANGED
@@ -667,7 +667,7 @@ class autoptimizeImages
|
|
667 |
}
|
668 |
|
669 |
// and check if image needs to be prelaoded.
|
670 |
-
if ( ! empty( $metabox_preloads ) && str_replace( $metabox_preloads, '', $tag ) !== $tag ) {
|
671 |
$to_preload .= $this->create_img_preload_tag( $tag );
|
672 |
}
|
673 |
}
|
@@ -716,7 +716,7 @@ class autoptimizeImages
|
|
716 |
$out = $this->process_picture_tag( $out, true, false );
|
717 |
}
|
718 |
|
719 |
-
if ( ! empty( $metabox_preloads ) && empty( $to_preload ) ) {
|
720 |
// the preload was not in an img tag, so adding a non-responsive preload instead.
|
721 |
foreach( $metabox_preloads as $img_preload ) {
|
722 |
$to_preload .= '<link rel="preload" href="' . $img_preload . '" as="image">' ;
|
@@ -830,7 +830,7 @@ class autoptimizeImages
|
|
830 |
}
|
831 |
|
832 |
// and check if image needs to be prelaoded.
|
833 |
-
if ( ! empty( $metabox_preloads ) && str_replace( $metabox_preloads, '', $tag ) !== $tag ) {
|
834 |
$to_preload .= $this->create_img_preload_tag( $tag );
|
835 |
}
|
836 |
}
|
@@ -849,7 +849,7 @@ class autoptimizeImages
|
|
849 |
$out
|
850 |
);
|
851 |
|
852 |
-
if ( ! empty( $metabox_preloads ) && empty( $to_preload ) ) {
|
853 |
// the preload was not in an img tag, so adding a non-responsive preload instead.
|
854 |
foreach( $metabox_preloads as $img_preload ) {
|
855 |
$to_preload .= '<link rel="preload" href="' . $img_preload . '" as="image">' ;
|
@@ -954,6 +954,13 @@ class autoptimizeImages
|
|
954 |
}
|
955 |
|
956 |
public static function create_img_preload_tag( $tag ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
957 |
// rewrite img tag to link preload img.
|
958 |
$_from = array( '<img ', ' src=', ' sizes=', ' srcset=' );
|
959 |
$_to = array( '<link rel="preload" as="image" ', ' href=', ' imagesizes=', ' imagesrcset=' );
|
667 |
}
|
668 |
|
669 |
// and check if image needs to be prelaoded.
|
670 |
+
if ( ! empty( $metabox_preloads ) && is_array( $metabox_preloads ) && str_replace( $metabox_preloads, '', $tag ) !== $tag ) {
|
671 |
$to_preload .= $this->create_img_preload_tag( $tag );
|
672 |
}
|
673 |
}
|
716 |
$out = $this->process_picture_tag( $out, true, false );
|
717 |
}
|
718 |
|
719 |
+
if ( ! empty( $metabox_preloads ) && is_array( $metabox_preloads ) && empty( $to_preload ) && false !== apply_filters( 'autoptimize_filter_imgopt_dopreloads', true ) ) {
|
720 |
// the preload was not in an img tag, so adding a non-responsive preload instead.
|
721 |
foreach( $metabox_preloads as $img_preload ) {
|
722 |
$to_preload .= '<link rel="preload" href="' . $img_preload . '" as="image">' ;
|
830 |
}
|
831 |
|
832 |
// and check if image needs to be prelaoded.
|
833 |
+
if ( ! empty( $metabox_preloads ) && is_array( $metabox_preloads ) && str_replace( $metabox_preloads, '', $tag ) !== $tag ) {
|
834 |
$to_preload .= $this->create_img_preload_tag( $tag );
|
835 |
}
|
836 |
}
|
849 |
$out
|
850 |
);
|
851 |
|
852 |
+
if ( ! empty( $metabox_preloads ) && is_array( $metabox_preloads ) && empty( $to_preload ) && false !== apply_filters( 'autoptimize_filter_imgopt_dopreloads', true ) ) {
|
853 |
// the preload was not in an img tag, so adding a non-responsive preload instead.
|
854 |
foreach( $metabox_preloads as $img_preload ) {
|
855 |
$to_preload .= '<link rel="preload" href="' . $img_preload . '" as="image">' ;
|
954 |
}
|
955 |
|
956 |
public static function create_img_preload_tag( $tag ) {
|
957 |
+
if ( false === apply_filters( 'autoptimize_filter_imgopt_dopreloads', true ) ) {
|
958 |
+
return '';
|
959 |
+
}
|
960 |
+
|
961 |
+
// clean up; remove tabs/ linebreaks/ spaces.
|
962 |
+
$tag = preg_replace( '/\s+/', ' ', $tag );
|
963 |
+
|
964 |
// rewrite img tag to link preload img.
|
965 |
$_from = array( '<img ', ' src=', ' sizes=', ' srcset=' );
|
966 |
$_to = array( '<link rel="preload" as="image" ', ' href=', ' imagesizes=', ' imagesrcset=' );
|
classes/autoptimizeMain.php
CHANGED
@@ -228,12 +228,16 @@ class autoptimizeMain
|
|
228 |
|
229 |
public function criticalcss()
|
230 |
{
|
231 |
-
|
|
|
|
|
|
|
|
|
232 |
}
|
233 |
|
234 |
public function maybe_run_criticalcss()
|
235 |
{
|
236 |
-
// Loads criticalcss if the power-up is not active
|
237 |
if ( apply_filters( 'autoptimize_filter_criticalcss_active', true ) && ! autoptimizeUtils::is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) {
|
238 |
$this->_criticalcss = new autoptimizeCriticalCSSBase();
|
239 |
$this->_criticalcss->setup();
|
@@ -386,11 +390,12 @@ class autoptimizeMain
|
|
386 |
}
|
387 |
}
|
388 |
|
389 |
-
//
|
|
|
390 |
if ( false === $ao_noptimize ) {
|
391 |
-
$
|
392 |
-
foreach ( $
|
393 |
-
if ( array_key_exists( $
|
394 |
$ao_noptimize = true;
|
395 |
break;
|
396 |
}
|
228 |
|
229 |
public function criticalcss()
|
230 |
{
|
231 |
+
if ( apply_filters( 'autoptimize_filter_criticalcss_active', true ) && ! autoptimizeUtils::is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) {
|
232 |
+
return $this->_criticalcss;
|
233 |
+
} else {
|
234 |
+
return false;
|
235 |
+
}
|
236 |
}
|
237 |
|
238 |
public function maybe_run_criticalcss()
|
239 |
{
|
240 |
+
// Loads criticalcss if the filter returns true & old power-up is not active.
|
241 |
if ( apply_filters( 'autoptimize_filter_criticalcss_active', true ) && ! autoptimizeUtils::is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) {
|
242 |
$this->_criticalcss = new autoptimizeCriticalCSSBase();
|
243 |
$this->_criticalcss->setup();
|
390 |
}
|
391 |
}
|
392 |
|
393 |
+
// Misc. querystring paramaters that will stop AO from doing optimizations (pagebuilders +
|
394 |
+
// 2 generic parameters that could/ should become standard between optimization plugins?)
|
395 |
if ( false === $ao_noptimize ) {
|
396 |
+
$_qs_showstoppers = array( 'no_cache', 'no_optimize', 'tve', 'elementor-preview', 'fl_builder', 'vc_action', 'et_fb', 'bt-beaverbuildertheme', 'ct_builder', 'fb-edit', 'siteorigin_panels_live_editor', 'preview' );
|
397 |
+
foreach ( $_qs_showstoppers as $_showstopper ) {
|
398 |
+
if ( array_key_exists( $_showstopper, $_GET ) ) {
|
399 |
$ao_noptimize = true;
|
400 |
break;
|
401 |
}
|
classes/autoptimizeScripts.php
CHANGED
@@ -377,7 +377,7 @@ class autoptimizeScripts extends autoptimizeBase
|
|
377 |
}
|
378 |
|
379 |
// not aggregating but deferring?
|
380 |
-
if ( $this->defer_not_aggregate && false === $this->aggregate && ( str_replace( $this->dontmove, '', $path ) === $path || ( apply_filters( 'autoptimize_filter_js_defer_external', true ) && str_replace( $this->dontmove, '', $
|
381 |
$new_tag = str_replace( '<script ', '<script defer ', $new_tag );
|
382 |
}
|
383 |
|
377 |
}
|
378 |
|
379 |
// not aggregating but deferring?
|
380 |
+
if ( $this->defer_not_aggregate && false === $this->aggregate && ( str_replace( $this->dontmove, '', $path ) === $path || ( apply_filters( 'autoptimize_filter_js_defer_external', true ) && str_replace( $this->dontmove, '', $orig_tag ) === $orig_tag ) ) && strpos( $new_tag, ' defer' ) === false && strpos( $new_tag, ' async' ) === false ) {
|
381 |
$new_tag = str_replace( '<script ', '<script defer ', $new_tag );
|
382 |
}
|
383 |
|
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: 5.9
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 3.0.
|
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 |
|
@@ -324,6 +324,11 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
|
|
324 |
|
325 |
== Changelog ==
|
326 |
|
|
|
|
|
|
|
|
|
|
|
327 |
= 3.0.2 =
|
328 |
* rollback automatic "minify inline CSS/ JS" which broke more then expected, this will come back as a separate default off option later and can now be enabled with a simple filter: `add_filter( 'autoptimize_html_minify_inline_js_css', '__return_true');` .
|
329 |
* fix for "Call to undefined method autoptimizeOptionWrapper::delete_option()" in autoptimizeVersionUpdatesHandler.php
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.9
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 3.0.3
|
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 |
|
324 |
|
325 |
== Changelog ==
|
326 |
|
327 |
+
= 3.0.3 =
|
328 |
+
* fix for images being preloaded without this being configured when lazyload is on and per page/post settings are off.
|
329 |
+
* ensure critical CSS schedule is always known.
|
330 |
+
* when deferring non-aggregated JS, make the optimatization exclusions take the full script-tag into account instead of just the src URL.
|
331 |
+
|
332 |
= 3.0.2 =
|
333 |
* rollback automatic "minify inline CSS/ JS" which broke more then expected, this will come back as a separate default off option later and can now be enabled with a simple filter: `add_filter( 'autoptimize_html_minify_inline_js_css', '__return_true');` .
|
334 |
* fix for "Call to undefined method autoptimizeOptionWrapper::delete_option()" in autoptimizeVersionUpdatesHandler.php
|