Autoptimize - Version 2.6.1

Version Description

  • bugfixes for multiple lazyload bugs causing images not to load or load incorrectly
  • bugfixes for multiple multisite bugs causing settings-screen to be unavailable
  • bugfix re-added 3rd parameter to autoptimize_filter_js_minify_excluded-filter to ensure backwards-compatibility and thus avoid breaking Smart Cookie Kit which expected that 3rd parameter.
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 Autoptimize
Version 2.6.1
Comparing to
See all releases

Code changes from version 2.6.0 to 2.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: 2.6.0
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: autoptimize
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
20
  exit;
21
  }
22
 
23
- define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.6.0' );
24
 
25
  // plugin_dir_path() returns the trailing slash!
26
  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: 2.6.1
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: autoptimize
20
  exit;
21
  }
22
 
23
+ define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.6.1' );
24
 
25
  // plugin_dir_path() returns the trailing slash!
26
  define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
classes/autoptimizeConfig.php CHANGED
@@ -626,12 +626,15 @@ echo __( 'A comma-separated list of CSS you want to exclude from being optimized
626
 
627
  public function addmenu()
628
  {
629
- if ( is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
 
630
  $hook = add_submenu_page( 'settings.php', __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_network_options', 'autoptimize', array( $this, 'show_config' ) );
631
- } elseif ( ! is_multisite() || 'on' === autoptimizeOptionWrapper::get_option( 'autoptimize_enable_site_config' ) ) {
632
- $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show_config' ) );
633
- } else {
634
  $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show_network_message' ) );
 
 
 
635
  }
636
 
637
  add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) );
626
 
627
  public function addmenu()
628
  {
629
+ if ( is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
630
+ // multisite, network admin, ao network activated: add normal settings page at network level.
631
  $hook = add_submenu_page( 'settings.php', __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_network_options', 'autoptimize', array( $this, 'show_config' ) );
632
+ } elseif ( is_multisite() && ! is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_enable_site_config' ) ) {
633
+ // multisite, ao network activated, not network admin so site specific settings, but "autoptimize_enable_site_config" is off: show "sorry, ask network admin" message iso options.
 
634
  $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show_network_message' ) );
635
+ } else {
636
+ // default: show normal options page if not multisite, if multisite but not network activated, if multisite and network activated and "autoptimize_enable_site_config" is on.
637
+ $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show_config' ) );
638
  }
639
 
640
  add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) );
classes/autoptimizeExtra.php CHANGED
@@ -447,8 +447,8 @@ class autoptimizeExtra
447
  'autoptimize_extra',
448
  array( $this, 'options_page' )
449
  );
450
- register_setting( 'autoptimize_extra_settings', 'autoptimize_extra_settings' );
451
  }
 
452
  }
453
 
454
  public function add_extra_tab( $in )
447
  'autoptimize_extra',
448
  array( $this, 'options_page' )
449
  );
 
450
  }
451
+ register_setting( 'autoptimize_extra_settings', 'autoptimize_extra_settings' );
452
  }
453
 
454
  public function add_extra_tab( $in )
classes/autoptimizeImages.php CHANGED
@@ -593,7 +593,7 @@ class autoptimizeImages
593
  // background-image in inline style.
594
  if ( strpos( $out, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_imgopt_backgroundimages', true ) ) {
595
  $out = preg_replace_callback(
596
- '/style=(?:"|\').*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)/',
597
  array( $this, 'replace_img_callback' ),
598
  $out
599
  );
@@ -775,7 +775,7 @@ class autoptimizeImages
775
  $noptimize_flag = ' data-noptimize="1"';
776
  }
777
 
778
- $lazysizes_js = plugins_url( 'external/js/lazysizes.min.js', __FILE__ );
779
  $cdn_url = $this->get_cdn_url();
780
  if ( ! empty( $cdn_url ) ) {
781
  $lazysizes_js = str_replace( AUTOPTIMIZE_WP_SITE_URL, $cdn_url, $lazysizes_js );
@@ -900,7 +900,7 @@ class autoptimizeImages
900
  public function process_bgimage( $in ) {
901
  if ( strpos( $in, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_imgopt_lazyload_backgroundimages', true ) ) {
902
  $out = preg_replace_callback(
903
- '/(<(?:article|aside|body|div|footer|header|p|section|table)[^>]*)\sstyle=(?:"|\').*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)[^>]*/',
904
  array( $this, 'lazyload_bgimg_callback' ),
905
  $in
906
  );
@@ -917,7 +917,7 @@ class autoptimizeImages
917
  // replace background-image URL with SVG placeholder.
918
  $out = str_replace( $matches[2], $placeholder, $matches[0] );
919
  // add data-bg attribute with real background-image URL for lazyload to pick up.
920
- $out = str_replace( $matches[1], $matches[1] . ' data-bg="' . $matches[2] . '"', $out );
921
  // add lazyload class to tag.
922
  $out = $this->inject_classes_in_tag( $out, "$lazyload_class " );
923
  return $out;
@@ -949,8 +949,8 @@ class autoptimizeImages
949
  'autoptimize_imgopt',
950
  array( $this, 'imgopt_options_page' )
951
  );
952
- register_setting( 'autoptimize_imgopt_settings', 'autoptimize_imgopt_settings' );
953
  }
 
954
  }
955
 
956
  public function add_imgopt_tab( $in )
593
  // background-image in inline style.
594
  if ( strpos( $out, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_imgopt_backgroundimages', true ) ) {
595
  $out = preg_replace_callback(
596
+ '/style=(?:"|\')[^<>]*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)/',
597
  array( $this, 'replace_img_callback' ),
598
  $out
599
  );
775
  $noptimize_flag = ' data-noptimize="1"';
776
  }
777
 
778
+ $lazysizes_js = plugins_url( 'external/js/lazysizes.min.js?ao_version=' . AUTOPTIMIZE_PLUGIN_VERSION, __FILE__ );
779
  $cdn_url = $this->get_cdn_url();
780
  if ( ! empty( $cdn_url ) ) {
781
  $lazysizes_js = str_replace( AUTOPTIMIZE_WP_SITE_URL, $cdn_url, $lazysizes_js );
900
  public function process_bgimage( $in ) {
901
  if ( strpos( $in, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_imgopt_lazyload_backgroundimages', true ) ) {
902
  $out = preg_replace_callback(
903
+ '/(<(?:article|aside|body|div|footer|header|p|section|table)[^>]*)\sstyle=(?:"|\')[^<>]*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)[^>]*/',
904
  array( $this, 'lazyload_bgimg_callback' ),
905
  $in
906
  );
917
  // replace background-image URL with SVG placeholder.
918
  $out = str_replace( $matches[2], $placeholder, $matches[0] );
919
  // add data-bg attribute with real background-image URL for lazyload to pick up.
920
+ $out = str_replace( $matches[1], $matches[1] . ' data-bg="' . trim( str_replace( "\r\n", '', $matches[2] ) ) . '"', $out );
921
  // add lazyload class to tag.
922
  $out = $this->inject_classes_in_tag( $out, "$lazyload_class " );
923
  return $out;
949
  'autoptimize_imgopt',
950
  array( $this, 'imgopt_options_page' )
951
  );
 
952
  }
953
+ register_setting( 'autoptimize_imgopt_settings', 'autoptimize_imgopt_settings' );
954
  }
955
 
956
  public function add_imgopt_tab( $in )
classes/autoptimizeOptionWrapper.php CHANGED
@@ -34,15 +34,15 @@ class autoptimizeOptionWrapper {
34
  * @return mixed Value set for the option.
35
  */
36
  public static function get_option( $option, $default = false ) {
37
- // This is always a network setting.
38
  if ( 'autoptimize_enable_site_config' === $option ) {
39
- return get_network_option( get_main_network_id(), $option );
40
  }
41
 
42
  // If the plugin is network activated and our per site setting is not on, use the network configuration.
43
- $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config' );
44
  if ( self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
45
- return get_network_option( get_main_network_id(), $option );
46
  }
47
 
48
  return get_option( $option, $default );
34
  * @return mixed Value set for the option.
35
  */
36
  public static function get_option( $option, $default = false ) {
37
+ // This is always a network setting, it is on by default to ensure settings are available at site level unless explicitly turned off.
38
  if ( 'autoptimize_enable_site_config' === $option ) {
39
+ return get_network_option( get_main_network_id(), $option, 'on' );
40
  }
41
 
42
  // If the plugin is network activated and our per site setting is not on, use the network configuration.
43
+ $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config', 'on' );
44
  if ( self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
45
+ return get_network_option( get_main_network_id(), $option, $default );
46
  }
47
 
48
  return get_option( $option, $default );
classes/autoptimizeScripts.php CHANGED
@@ -95,7 +95,7 @@ class autoptimizeScripts extends autoptimizeBase
95
  if ( ! $options['minify_excluded'] && $options['aggregate'] ) {
96
  $this->minify_excluded = false;
97
  }
98
- $this->minify_excluded = apply_filters( 'autoptimize_filter_js_minify_excluded', $this->minify_excluded );
99
 
100
  // get extra exclusions settings or filter.
101
  $excludeJS = $options['js_exclude'];
95
  if ( ! $options['minify_excluded'] && $options['aggregate'] ) {
96
  $this->minify_excluded = false;
97
  }
98
+ $this->minify_excluded = apply_filters( 'autoptimize_filter_js_minify_excluded', $this->minify_excluded, '' );
99
 
100
  // get extra exclusions settings or filter.
101
  $excludeJS = $options['js_exclude'];
classes/autoptimizeStyles.php CHANGED
@@ -129,7 +129,7 @@ class autoptimizeStyles extends autoptimizeBase
129
  if ( ! $options['minify_excluded'] && $options['aggregate'] ) {
130
  $this->minify_excluded = false;
131
  }
132
- $this->minify_excluded = apply_filters( 'autoptimize_filter_css_minify_excluded', $this->minify_excluded );
133
 
134
  // noptimize me.
135
  $this->content = $this->hide_noptimize( $this->content );
129
  if ( ! $options['minify_excluded'] && $options['aggregate'] ) {
130
  $this->minify_excluded = false;
131
  }
132
+ $this->minify_excluded = apply_filters( 'autoptimize_filter_css_minify_excluded', $this->minify_excluded, '' );
133
 
134
  // noptimize me.
135
  $this->content = $this->hide_noptimize( $this->content );
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: futtta, optimizingmatters, zytzagoo, turl
3
  Tags: optimize, minify, performance, pagespeed, images, lazy-load, google fonts
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
- Requires at least: 4.0
6
  Tested up to: 5.3
7
  Requires PHP: 5.6
8
- Stable tag: 2.6.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
 
@@ -278,6 +278,11 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
278
 
279
  == Changelog ==
280
 
 
 
 
 
 
281
  = 2.6.0 =
282
  * New: Autoptimize can be configured at network level or at individual site-level when on multisite.
283
  * Extra: new option to specify what resources need to be preloaded.
2
  Contributors: futtta, optimizingmatters, zytzagoo, turl
3
  Tags: optimize, minify, performance, pagespeed, images, lazy-load, google fonts
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
+ Requires at least: 4.4
6
  Tested up to: 5.3
7
  Requires PHP: 5.6
8
+ Stable tag: 2.6.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
 
278
 
279
  == Changelog ==
280
 
281
+ = 2.6.1 =
282
+ * bugfixes for multiple lazyload bugs causing images not to load or load incorrectly
283
+ * bugfixes for multiple multisite bugs causing settings-screen to be unavailable
284
+ * bugfix re-added 3rd parameter to `autoptimize_filter_js_minify_excluded`-filter to ensure backwards-compatibility and thus avoid breaking Smart Cookie Kit which expected that 3rd parameter.
285
+
286
  = 2.6.0 =
287
  * New: Autoptimize can be configured at network level or at individual site-level when on multisite.
288
  * Extra: new option to specify what resources need to be preloaded.