Autoptimize - Version 3.0.4

Version Description

  • fix for "undefined array key ao_post_preload on post/ page edit screens
  • fix for image optimization altering inline JS that contains an <img tag if lazyload is not active
  • improvements to exit survey
  • confirmed working with WordPress 6.0
Download this release

Release Info

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

Code changes from version 3.0.3 to 3.0.4

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.3
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.3' );
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.4
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.4' );
25
 
26
  // plugin_dir_path() returns the trailing slash!
27
  define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
classes/autoptimizeExitSurvey.php CHANGED
@@ -39,9 +39,10 @@ class autoptimizeExitSurvey
39
 
40
  <div class="ao-plugin-uninstall-feedback-popup ao-feedback" id="ao_uninstall_feedback_popup" data-modal="<?php echo base64_encode( json_encode( $data ) ) ?>">
41
  <div class="popup--header">
42
- <h5><?php _e( 'Sorry to see you go, we would appreciate if you let us know why you\'re deactivating Autoptimize!', 'autoptimize' ); ?></h5>
43
  </div><!--/.popup--header-->
44
  <div class="popup--body">
 
45
  <ul class="popup--form">
46
  <li ao-option-id="5">
47
  <input type="radio" name="ao-deactivate-option" id="ao_feedback5">
@@ -55,7 +56,7 @@ class autoptimizeExitSurvey
55
  <label for="ao_feedback6" data-reason="broke site">
56
  <?php _e( 'It broke my site.', 'autoptimize' ); ?>
57
  </label>
58
- <p class="last-attempt"><?php _e( 'Almost all problems can be fixed with the right configuration, have a look at <a href="https://wordpress.org/plugins/autoptimize/#faq" target="_blank">the FAQ</a> or create a topic on <a href="https://wordpress.org/support/plugin/autoptimize/#new-topic-0" target="_blank">the support forum here</a>!', 'autoptimize' ); ?></p>
59
  <li ao-option-id="4">
60
  <input type="radio" name="ao-deactivate-option" id="ao_feedback4">
61
  <label for="ao_feedback4" data-reason="found better">
@@ -73,10 +74,11 @@ class autoptimizeExitSurvey
73
  <textarea width="100%" rows="2" name="comments" placeholder="What can we do better?"></textarea></li>
74
  <hr />
75
  <li ao-option-id="998">
76
- <label for="ao_feedback998" data-reason="other detail">
77
- <?php _e( 'If you want to be contacted about or get help with Autoptimize, leave your email here (we never spam).', 'autoptimize' ); ?>
 
78
  </label>
79
- <input type="email" name="ao-deactivate-option" id="ao_feedback998" placeholder="mymail@domain.xyz">
80
  </li>
81
  </ul>
82
  </div><!--/.popup--body-->
39
 
40
  <div class="ao-plugin-uninstall-feedback-popup ao-feedback" id="ao_uninstall_feedback_popup" data-modal="<?php echo base64_encode( json_encode( $data ) ) ?>">
41
  <div class="popup--header">
42
+ <h5><?php _e( 'Sorry to see you go!', 'autoptimize' ); ?></h5>
43
  </div><!--/.popup--header-->
44
  <div class="popup--body">
45
+ <p><strong><?php _e( 'We would appreciate if you let us know why you\'re deactivating Autoptimize!', 'autoptimize' ); ?></strong></p>
46
  <ul class="popup--form">
47
  <li ao-option-id="5">
48
  <input type="radio" name="ao-deactivate-option" id="ao_feedback5">
56
  <label for="ao_feedback6" data-reason="broke site">
57
  <?php _e( 'It broke my site.', 'autoptimize' ); ?>
58
  </label>
59
+ <p class="last-attempt"><?php _e( 'Ouch, sorry about that! But almost all problems can be fixed with the right configuration, have a look at <a href="https://blog.futtta.be/2022/05/05/what-to-do-when-autoptimize-breaks-your-site/" target="_blank">this short troubleshooting howto</a> or create a topic on <a href="https://wordpress.org/support/plugin/autoptimize/#new-topic-0" target="_blank">the support forum here</a>!', 'autoptimize' ); ?></p>
60
  <li ao-option-id="4">
61
  <input type="radio" name="ao-deactivate-option" id="ao_feedback4">
62
  <label for="ao_feedback4" data-reason="found better">
74
  <textarea width="100%" rows="2" name="comments" placeholder="What can we do better?"></textarea></li>
75
  <hr />
76
  <li ao-option-id="998">
77
+ <label for="ao_feedback_email_toggle" data-reason="other detail">
78
+ <input type="checkbox" id="ao_feedback_email_toggle" name="ao_feedback_email_toggle" onchange="jQuery('#ao_feedback998').toggle();"/>
79
+ <?php _e( 'I would like be contacted about my experience with Autoptimize.', 'autoptimize' ); ?>
80
  </label>
81
+ <input type="email" name="ao-deactivate-option" id="ao_feedback998" placeholder="mymail@domain.xyz" class="hidden">
82
  </li>
83
  </ul>
84
  </div><!--/.popup--body-->
classes/autoptimizeImages.php CHANGED
@@ -564,8 +564,8 @@ class autoptimizeImages
564
  $to_replace = array();
565
  $to_preload = '';
566
 
567
- // hide noscript tags to avoid nesting noscript tags (as lazyloaded images add noscript).
568
- if ( $this->should_lazyload() ) {
569
  $in = autoptimizeBase::replace_contents_with_marker_if_exists(
570
  'SCRIPT',
571
  '<script',
@@ -703,19 +703,22 @@ class autoptimizeImages
703
  );
704
  }
705
 
706
- // lazyload: restore noscript tags + lazyload picture source tags and bgimage.
707
  if ( $this->should_lazyload() ) {
708
- $out = autoptimizeBase::restore_marked_content(
709
- 'SCRIPT',
710
- $out
711
- );
712
-
713
  $out = $this->process_picture_tag( $out, true, true );
714
  $out = $this->process_bgimage( $out );
715
  } else {
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 ) {
564
  $to_replace = array();
565
  $to_preload = '';
566
 
567
+ // hide (no)script tags to avoid replacing (and potentially breaking) images in script tags.
568
+ if ( apply_filters( 'autoptimize_filter_imgopt_hide_script', true ) || $this->should_lazyload() ) {
569
  $in = autoptimizeBase::replace_contents_with_marker_if_exists(
570
  'SCRIPT',
571
  '<script',
703
  );
704
  }
705
 
706
+ // lazyload picture source tags and bgimage.
707
  if ( $this->should_lazyload() ) {
 
 
 
 
 
708
  $out = $this->process_picture_tag( $out, true, true );
709
  $out = $this->process_bgimage( $out );
710
  } else {
711
  $out = $this->process_picture_tag( $out, true, false );
712
  }
713
 
714
+ // restore (no)script tags.
715
+ if ( apply_filters( 'autoptimize_filter_imgopt_hide_script', true ) || $this->should_lazyload() ) {
716
+ $out = autoptimizeBase::restore_marked_content(
717
+ 'SCRIPT',
718
+ $out
719
+ );
720
+ }
721
+
722
  if ( ! empty( $metabox_preloads ) && is_array( $metabox_preloads ) && empty( $to_preload ) && false !== apply_filters( 'autoptimize_filter_imgopt_dopreloads', true ) ) {
723
  // the preload was not in an img tag, so adding a non-responsive preload instead.
724
  foreach( $metabox_preloads as $img_preload ) {
classes/autoptimizeMetabox.php CHANGED
@@ -117,7 +117,14 @@ class autoptimizeMetabox
117
  <label for="autoptimize_post_preload">
118
  <?php _e( 'LCP Image to preload', 'autoptimize' ); ?>
119
  </label>
120
- <input type="text" id="autoptimize_post_preload" name="ao_post_preload" value="<?php echo esc_attr( $ao_opt_value['ao_post_preload'] ) ?>">
 
 
 
 
 
 
 
121
  </p>
122
  <p>&nbsp;</p>
123
  <p>
117
  <label for="autoptimize_post_preload">
118
  <?php _e( 'LCP Image to preload', 'autoptimize' ); ?>
119
  </label>
120
+ <?php
121
+ if ( is_array( $ao_opt_value ) && array_key_exists( 'ao_post_preload', $ao_opt_value ) ) {
122
+ $_preload_img = esc_attr( $ao_opt_value['ao_post_preload'] );
123
+ } else {
124
+ $_preload_img = '';
125
+ }
126
+ ?>
127
+ <input type="text" id="autoptimize_post_preload" name="ao_post_preload" value="<?php echo $_preload_img ?>">
128
  </p>
129
  <p>&nbsp;</p>
130
  <p>
classes/static/exit-survey/exit-survey.css CHANGED
@@ -19,20 +19,22 @@ tr[data-slug="autoptimize"] span.deactivate{
19
 
20
  .ao-feedback .popup--header h5 {
21
  margin: 0;
22
- font-size: 13px;
23
  padding: 10px 15px;
24
  color: #222;
25
- font-weight: 600;
26
  text-align: left;
27
  }
28
 
29
  .ao-feedback .popup--body {
30
  padding: 15px;
 
31
  }
32
 
33
  .ao-feedback .popup--form {
34
  margin: 0;
35
  font-size: 13px;
 
36
  }
37
 
38
  .ao-feedback .popup--form input[type="radio"] {
19
 
20
  .ao-feedback .popup--header h5 {
21
  margin: 0;
22
+ font-size: 16px;
23
  padding: 10px 15px;
24
  color: #222;
25
+ font-weight: 900;
26
  text-align: left;
27
  }
28
 
29
  .ao-feedback .popup--body {
30
  padding: 15px;
31
+ padding-top: 5px;
32
  }
33
 
34
  .ao-feedback .popup--form {
35
  margin: 0;
36
  font-size: 13px;
37
+ padding-top: 10px;
38
  }
39
 
40
  .ao-feedback .popup--form input[type="radio"] {
classes/static/exit-survey/exit-survey.js CHANGED
@@ -8,7 +8,7 @@
8
  $('#ao_uninstall_feedback_popup').appendTo($(targetElement).parent());
9
 
10
  $(targetElement).on('click', function (e) {
11
- if ( false == e.target.href.includes('https://wordpress.org/') ) {
12
  e.preventDefault();
13
  }
14
  $('#ao_uninstall_feedback_popup ').addClass('active');
8
  $('#ao_uninstall_feedback_popup').appendTo($(targetElement).parent());
9
 
10
  $(targetElement).on('click', function (e) {
11
+ if ( false == e.target.href.includes('https://wordpress.org/') && false == e.target.href.includes('https://blog.futtta.be/') ) {
12
  e.preventDefault();
13
  }
14
  $('#ao_uninstall_feedback_popup ').addClass('active');
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: futtta, optimizingmatters, zytzagoo, turl
3
  Tags: optimize, minify, performance, images, core web vitals, lazy-load, pagespeed, google fonts
4
  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.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,6 +324,12 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
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.
3
  Tags: optimize, minify, performance, images, core web vitals, lazy-load, pagespeed, google fonts
4
  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.0.4
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.4 =
328
+ * fix for "undefined array key ao_post_preload” on post/ page edit screens
329
+ * fix for image optimization altering inline JS that contains an `<img` tag if lazyload is not active
330
+ * improvements to exit survey
331
+ * confirmed working with WordPress 6.0
332
+
333
  = 3.0.3 =
334
  * fix for images being preloaded without this being configured when lazyload is on and per page/post settings are off.
335
  * ensure critical CSS schedule is always known.