EWWW Image Optimizer - Version 4.7.2

Version Description

  • changed: JS WebP no longer necessary with ExactDN
  • fixed: fatal error from NextGEN get_image_sizes() method
  • fixed: debugging mode gets stuck
  • fixed: ExactDN has unexpected results when content_width global equals zero
  • fixed: img elements with unquoted src attributes ignored by ExactDN, Lazy Load, and JS WebP
Download this release

Release Info

Developer nosilver4u
Plugin Icon 128x128 EWWW Image Optimizer
Version 4.7.2
Comparing to
See all releases

Code changes from version 4.7.1 to 4.7.2

changelog.txt CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  = 4.7.1 =
2
  * added: CSS background image support for <li> elements
3
  * added: ExactDN + Lazy Load will auto-calculate dimensions for img elements without srcset/responsive markup
1
+ = 4.7.2 =
2
+ * changed: JS WebP no longer necessary with ExactDN
3
+ * fixed: fatal error from NextGEN get_image_sizes() method
4
+ * fixed: debugging mode gets stuck
5
+ * fixed: ExactDN has unexpected results when content_width global equals zero
6
+ * fixed: img elements with unquoted src attributes ignored by ExactDN, Lazy Load, and JS WebP
7
+
8
  = 4.7.1 =
9
  * added: CSS background image support for <li> elements
10
  * added: ExactDN + Lazy Load will auto-calculate dimensions for img elements without srcset/responsive markup
classes/class-ewww-nextgen.php CHANGED
@@ -114,7 +114,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
114
  function maybe_get_more_sizes( $sizes, $meta ) {
115
  if ( 2 == count( $sizes ) && ewww_image_optimizer_iterable( $meta ) ) {
116
  foreach ( $meta as $meta_key => $meta_val ) {
117
- if ( 0 === strpos( $meta_key, 'ngg0dyn-' ) && is_array( $meta_val ) && ! empty( $meta_val['filename'] ) ) {
118
  $sizes[] = $meta_key;
119
  }
120
  }
@@ -184,7 +184,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
184
  }
185
  ewwwio_debug_message( "image id: $image_id" );
186
  // Get an array of sizes available for the $image.
187
- $sizes = $storage->get_image_sizes();
188
  $sizes = $this->maybe_get_more_sizes( $sizes, $image->meta_data );
189
  // Run the optimizer on the image for each $size.
190
  if ( ewww_image_optimizer_iterable( $sizes ) ) {
@@ -481,7 +481,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
481
  }
482
  // If we have metadata, populate db from meta.
483
  if ( ! empty( $image->meta_data['ewww_image_optimizer'] ) ) {
484
- $sizes = $storage->get_image_sizes();
485
  $sizes = $this->maybe_get_more_sizes( $sizes, $image->meta_data );
486
  if ( ewww_image_optimizer_iterable( $sizes ) ) {
487
  foreach ( $sizes as $size ) {
@@ -903,7 +903,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
903
  // Output the results of the optimization.
904
  $output['results'] = sprintf( '<p>' . esc_html__( 'Optimized image:', 'ewww-image-optimizer' ) . ' <strong>%s</strong><br>', esc_html( basename( $storage->object->get_image_abspath( $image, 'full' ) ) ) );
905
  // Get an array of sizes available for the $image.
906
- $sizes = $storage->get_image_sizes();
907
  $sizes = $this->maybe_get_more_sizes( $sizes, $image->meta_data );
908
  if ( ewww_image_optimizer_iterable( $sizes ) ) {
909
  foreach ( $sizes as $size ) {
114
  function maybe_get_more_sizes( $sizes, $meta ) {
115
  if ( 2 == count( $sizes ) && ewww_image_optimizer_iterable( $meta ) ) {
116
  foreach ( $meta as $meta_key => $meta_val ) {
117
+ if ( is_array( $meta_val ) && isset( $meta_val['width'] ) ) {
118
  $sizes[] = $meta_key;
119
  }
120
  }
184
  }
185
  ewwwio_debug_message( "image id: $image_id" );
186
  // Get an array of sizes available for the $image.
187
+ $sizes = $storage->get_image_sizes( $image );
188
  $sizes = $this->maybe_get_more_sizes( $sizes, $image->meta_data );
189
  // Run the optimizer on the image for each $size.
190
  if ( ewww_image_optimizer_iterable( $sizes ) ) {
481
  }
482
  // If we have metadata, populate db from meta.
483
  if ( ! empty( $image->meta_data['ewww_image_optimizer'] ) ) {
484
+ $sizes = $storage->get_image_sizes( $image );
485
  $sizes = $this->maybe_get_more_sizes( $sizes, $image->meta_data );
486
  if ( ewww_image_optimizer_iterable( $sizes ) ) {
487
  foreach ( $sizes as $size ) {
903
  // Output the results of the optimization.
904
  $output['results'] = sprintf( '<p>' . esc_html__( 'Optimized image:', 'ewww-image-optimizer' ) . ' <strong>%s</strong><br>', esc_html( basename( $storage->object->get_image_abspath( $image, 'full' ) ) ) );
905
  // Get an array of sizes available for the $image.
906
+ $sizes = $storage->get_image_sizes( $image );
907
  $sizes = $this->maybe_get_more_sizes( $sizes, $image->meta_data );
908
  if ( ewww_image_optimizer_iterable( $sizes ) ) {
909
  foreach ( $sizes as $size ) {
classes/class-ewwwio-lazy-load.php CHANGED
@@ -153,7 +153,7 @@ class EWWWIO_Lazy_Load extends EWWWIO_Page_Parser {
153
  $images_processed = 0;
154
 
155
  $images = $this->get_images_from_html( preg_replace( '/<noscript.*?\/noscript>/', '', $buffer ), false );
156
- if ( ewww_image_optimizer_iterable( $images[0] ) ) {
157
  foreach ( $images[0] as $index => $image ) {
158
  $images_processed++;
159
  if ( $images_processed <= $above_the_fold ) {
@@ -371,7 +371,7 @@ class EWWWIO_Lazy_Load extends EWWWIO_Page_Parser {
371
  $tag
372
  );
373
  foreach ( $exclusions as $exclusion ) {
374
- if ( false !== strpos( $image, $exclusion ) ) {
375
  return false;
376
  }
377
  }
153
  $images_processed = 0;
154
 
155
  $images = $this->get_images_from_html( preg_replace( '/<noscript.*?\/noscript>/', '', $buffer ), false );
156
+ if ( ! empty( $images[0] ) && ewww_image_optimizer_iterable( $images[0] ) ) {
157
  foreach ( $images[0] as $index => $image ) {
158
  $images_processed++;
159
  if ( $images_processed <= $above_the_fold ) {
371
  $tag
372
  );
373
  foreach ( $exclusions as $exclusion ) {
374
+ if ( false !== strpos( $tag, $exclusion ) ) {
375
  return false;
376
  }
377
  }
classes/class-ewwwio-page-parser.php CHANGED
@@ -30,10 +30,13 @@ class EWWWIO_Page_Parser {
30
  ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
31
  $images = array();
32
 
 
33
  if ( $hyperlinks ) {
34
- $search_pattern = '#(?:<figure[^>]+?class\s*=\s*["\'](?P<figure_class>[\w\s-]+?)["\'][^>]*?>\s*)?(?:<a[^>]+?href\s*=\s*["\'](?P<link_url>[^\s]+?)["\'][^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*["\'](?P<img_url>[^\s]+?)["\'].*?>){1}(?:\s*</a>)?#is';
 
35
  } elseif ( $src_required ) {
36
- $search_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*["\'](?P<img_url>[^\s]+?)["\'].*?>)#is';
 
37
  } else {
38
  $search_pattern = '#(?P<img_tag><img.*?>)#is';
39
  }
@@ -46,6 +49,16 @@ class EWWWIO_Page_Parser {
46
  }
47
  return $images;
48
  }
 
 
 
 
 
 
 
 
 
 
49
  return array();
50
  }
51
 
30
  ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
31
  $images = array();
32
 
33
+ $fallback_pattern = '';
34
  if ( $hyperlinks ) {
35
+ $search_pattern = '#(?:<figure[^>]+?class\s*=\s*["\'](?P<figure_class>[\w\s-]+?)["\'][^>]*?>\s*)?(?:<a[^>]+?href\s*=\s*["\'](?P<link_url>[^\s]+?)["\'][^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*["\'](?P<img_url>[^\s]+?)["\'].*?>){1}(?:\s*</a>)?#is';
36
+ $fallback_pattern = '#(?:<figure[^>]+?class\s*=\s*["\'](?P<figure_class>[\w\s-]+?)["\'][^>]*?>\s*)?(?:<a[^>]+?href\s*=\s*["\'](?P<link_url>[^\s]+?)["\'][^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*["\']?(?P<img_url>[^\s]+?)["\']?.*?>){1}(?:\s*</a>)?#is';
37
  } elseif ( $src_required ) {
38
+ $search_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*["\'](?P<img_url>[^\s]+?)["\'].*?>)#is';
39
+ $fallback_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*["\']?(?P<img_url>[^\s]+?)["\']?.*?>)#is';
40
  } else {
41
  $search_pattern = '#(?P<img_tag><img.*?>)#is';
42
  }
49
  }
50
  return $images;
51
  }
52
+ ewwwio_debug_message( 'trying fallback pattern' );
53
+ if ( preg_match_all( $fallback_pattern, $content, $images ) ) {
54
+ foreach ( $images as $key => $unused ) {
55
+ // Simplify the output as much as possible.
56
+ if ( is_numeric( $key ) && $key > 0 ) {
57
+ unset( $images[ $key ] );
58
+ }
59
+ }
60
+ return $images;
61
+ }
62
  return array();
63
  }
64
 
classes/class-exactdn.php CHANGED
@@ -614,7 +614,7 @@ class ExactDN extends EWWWIO_Page_Parser {
614
  * @return bool|string The content width, if set. Default false.
615
  */
616
  function get_content_width() {
617
- $content_width = isset( $GLOBALS['content_width'] ) && is_numeric( $GLOBALS['content_width'] ) ? $GLOBALS['content_width'] : 1920;
618
  if ( function_exists( 'twentynineteen_setup' ) && 640 == $content_width ) {
619
  $content_width = 932;
620
  }
614
  * @return bool|string The content width, if set. Default false.
615
  */
616
  function get_content_width() {
617
+ $content_width = isset( $GLOBALS['content_width'] ) && is_numeric( $GLOBALS['content_width'] ) && $GLOBALS['content_width'] > 100 ? $GLOBALS['content_width'] : 1920;
618
  if ( function_exists( 'twentynineteen_setup' ) && 640 == $content_width ) {
619
  $content_width = 932;
620
  }
common.php CHANGED
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
22
  exit;
23
  }
24
 
25
- define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '471.0' );
26
 
27
  // Initialize a couple globals.
28
  $ewww_debug = '';
@@ -238,7 +238,7 @@ function ewww_image_optimizer_parser_init() {
238
  require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-ewwwio-lazy-load.php' );
239
  }
240
  // If Alt WebP Rewriting is enabled.
241
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ) {
242
  $buffer_start = true;
243
  /**
244
  * Page Parsing class for working with HTML content.
@@ -493,7 +493,6 @@ function ewww_image_optimizer_gallery_support() {
493
  if ( is_admin() && ! wp_doing_ajax() ) {
494
  if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
495
  $ewwwio_temp_debug = true;
496
- ewww_image_optimizer_set_option( 'ewww_image_optimizer_debug', true );
497
  }
498
  }
499
 
@@ -981,9 +980,6 @@ function ewww_image_optimizer_current_screen( $screen ) {
981
  global $ewwwio_temp_debug;
982
  global $ewww_debug;
983
  if ( false === strpos( $screen->id, 'settings_page_ewww-image-optimizer' ) ) {
984
- if ( $ewwwio_temp_debug ) {
985
- ewww_image_optimizer_set_option( 'ewww_image_optimizer_debug', false );
986
- }
987
  $ewwwio_temp_debug = false;
988
  $ewww_debug = '';
989
  }
@@ -8021,6 +8017,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8021
  echo '</table></div><!-- end container general settings -->';
8022
  echo "<p class='submit'><input type='submit' class='button-primary' value='" . esc_attr__( 'Save Changes', 'ewww-image-optimizer' ) . "' /></p>\n";
8023
  echo '</form></div><!-- end container left --></div><!-- end container wrap -->';
 
8024
  return;
8025
  }
8026
  }
@@ -8319,23 +8316,25 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8319
  esc_html__( 'WebP images will be generated and saved for all JPG/PNG images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url.', 'ewww-image-optimizer' ) . "</span></td></tr>\n";
8320
  ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) == true ? 'on' : 'off' ) );
8321
  }
8322
- if ( ! ewww_image_optimizer_ce_webp_enabled() ) {
8323
- if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
8324
- $webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) ) : '';
8325
- $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_webp_paths'>" . esc_html__( 'WebP URLs', 'ewww-image-optimizer' ) . '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ) . '</th><td>' . esc_html__( 'If Force WebP is enabled, enter URL patterns that should be permitted for JS WebP Rewriting. One pattern per line, may be partial URLs, but must include the domain name.', 'ewww-image-optimizer' ) . '<br>' .
8326
- "<textarea id='ewww_image_optimizer_webp_paths' name='ewww_image_optimizer_webp_paths' rows='3' cols='60'>$webp_paths</textarea></td></tr>\n";
8327
- ewwwio_debug_message( 'webp paths:' );
8328
- ewwwio_debug_message( $webp_paths );
8329
- }
8330
  $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_webp_for_cdn'>" .
8331
  esc_html__( 'JS WebP Rewriting', 'ewww-image-optimizer' ) .
8332
  '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ) . "</th><td><span><input type='checkbox' id='ewww_image_optimizer_webp_for_cdn' name='ewww_image_optimizer_webp_for_cdn' value='true' " .
8333
  ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) == true ? "checked='true'" : '' ) . ' /> ' .
8334
- ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ? esc_html( 'Enables automatic WebP conversion with ExactDN.', 'ewww-image-optimizer' ) : esc_html__( 'Use this if the Apache rewrite rules do not work, or if your images are served from a CDN.', 'ewww-image-optimizer' ) ) . ' ' .
8335
  /* translators: %s: Cache Enabler (link) */
8336
- ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ? sprintf( esc_html__( 'Sites using a CDN may also use the WebP option in the %s plugin.', 'ewww-image-optimizer' ), '<a href="https://wordpress.org/plugins/cache-enabler/">Cache Enabler</a>' ) : '' ) . '</span></td></tr>';
 
 
 
8337
  }
8338
- ewwwio_debug_message( 'alt webp rewriting: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) == true ? 'on' : 'off' ) );
8339
  $output[] = "</table>\n</div>\n";
8340
 
8341
  $output[] = "<div id='ewww-support-settings'>\n";
@@ -8351,9 +8350,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8351
  $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_debug'>" . esc_html__( 'Debugging', 'ewww-image-optimizer' ) . '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2' ) . '</th>' .
8352
  "<td><input type='checkbox' id='ewww_image_optimizer_debug' name='ewww_image_optimizer_debug' value='true' " . ( ! $ewwwio_temp_debug && ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'Use this to provide information for support purposes, or if you feel comfortable digging around in the code to fix a problem you are experiencing.', 'ewww-image-optimizer' ) . "</td></tr>\n";
8353
  $output[] = "</table>\n";
8354
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
8355
- $output[] = 'DEBUG_PLACEHOLDER';
8356
- }
8357
  $output[] = "</div>\n";
8358
 
8359
  $output[] = "<div id='ewww-contribute-settings'>\n";
@@ -8433,19 +8432,20 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8433
  ewww_image_optimizer_function_exists( 'sleep', true );
8434
  ewwwio_check_memory_available();
8435
  if ( 'debug-silent' === $network ) {
 
8436
  return;
8437
  }
8438
  $output = apply_filters( 'ewww_image_optimizer_settings', $output );
8439
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() ) {
8440
  global $ewwwio_alt_webp;
8441
  $ewwwio_alt_webp->inline_script();
8442
  }
8443
 
8444
  $help_instructions = esc_html__( 'Enable the Debugging option and refresh this page to include debugging information with your question.', 'ewww-image-optimizer' ) . ' ' .
8445
  esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
8446
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
8447
- global $ewww_debug;
8448
 
 
 
8449
  $debug_output = '<p style="clear:both"><b>' . esc_html__( 'Debugging Information', 'ewww-image-optimizer' ) . ':</b> <button id="ewww-copy-debug" class="button button-secondary" type="button">' . esc_html__( 'Copy', 'ewww-image-optimizer' ) . '</button>';
8450
  if ( is_file( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) ) {
8451
  $debug_output .= "&emsp;<a href='admin.php?action=ewww_image_optimizer_view_debug_log'>" . esc_html( 'View Debug Log', 'ewww-image-optimizer' ) . "</a> - <a href='admin.php?action=ewww_image_optimizer_delete_debug_log'>" . esc_html( 'Remove Debug Log', 'ewww-image-optimizer' ) . '</a>';
@@ -8457,7 +8457,10 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8457
  esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
8458
 
8459
  $output = str_replace( 'DEBUG_PLACEHOLDER', $debug_output, $output );
 
 
8460
  }
 
8461
  echo $output;
8462
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
8463
  $current_user = wp_get_current_user();
@@ -8475,7 +8478,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8475
  $hs_identify = array(
8476
  'email' => utf8_encode( $help_email ),
8477
  );
8478
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
8479
  $ewww_debug_array = explode( '<br>', $ewww_debug );
8480
  $ewww_debug_i = 0;
8481
  foreach ( $ewww_debug_array as $ewww_debug_line ) {
@@ -8496,11 +8499,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
8496
  <?php
8497
  }
8498
  ewwwio_memory( __FUNCTION__ );
8499
- if ( $ewwwio_temp_debug ) {
8500
- ewww_image_optimizer_set_option( 'ewww_image_optimizer_debug', false );
8501
- $ewwwio_temp_debug = false;
8502
- }
8503
- $ewww_debug = '';
8504
  }
8505
 
8506
  /**
@@ -8693,7 +8692,8 @@ function ewwwio_debug_message( $message ) {
8693
  WP_CLI::debug( $message );
8694
  return;
8695
  }
8696
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
 
8697
  $memory_limit = ewwwio_memory_limit();
8698
  if ( strlen( $message ) + 4000000 + memory_get_usage( true ) <= $memory_limit ) {
8699
  global $ewww_debug;
@@ -8974,6 +8974,18 @@ function ewww_image_optimizer_image_queue_debug() {
8974
  <?php }
8975
  }
8976
 
 
 
 
 
 
 
 
 
 
 
 
 
8977
  /**
8978
  * Finds the current PHP memory limit or a reasonable default.
8979
  *
22
  exit;
23
  }
24
 
25
+ define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '472.0' );
26
 
27
  // Initialize a couple globals.
28
  $ewww_debug = '';
238
  require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-ewwwio-lazy-load.php' );
239
  }
240
  // If Alt WebP Rewriting is enabled.
241
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
242
  $buffer_start = true;
243
  /**
244
  * Page Parsing class for working with HTML content.
493
  if ( is_admin() && ! wp_doing_ajax() ) {
494
  if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
495
  $ewwwio_temp_debug = true;
 
496
  }
497
  }
498
 
980
  global $ewwwio_temp_debug;
981
  global $ewww_debug;
982
  if ( false === strpos( $screen->id, 'settings_page_ewww-image-optimizer' ) ) {
 
 
 
983
  $ewwwio_temp_debug = false;
984
  $ewww_debug = '';
985
  }
8017
  echo '</table></div><!-- end container general settings -->';
8018
  echo "<p class='submit'><input type='submit' class='button-primary' value='" . esc_attr__( 'Save Changes', 'ewww-image-optimizer' ) . "' /></p>\n";
8019
  echo '</form></div><!-- end container left --></div><!-- end container wrap -->';
8020
+ ewww_image_optimizer_temp_debug_clear();
8021
  return;
8022
  }
8023
  }
8316
  esc_html__( 'WebP images will be generated and saved for all JPG/PNG images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url.', 'ewww-image-optimizer' ) . "</span></td></tr>\n";
8317
  ewwwio_debug_message( 'forced webp: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) == true ? 'on' : 'off' ) );
8318
  }
8319
+ if ( ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
8320
+ $webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) ) : '';
8321
+ $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_webp_paths'>" . esc_html__( 'WebP URLs', 'ewww-image-optimizer' ) . '</label>' .
8322
+ ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ) . '</th><td>' .
8323
+ esc_html__( 'If Force WebP is enabled, enter URL patterns that should be permitted for JS WebP Rewriting. One pattern per line, may be partial URLs, but must include the domain name.', 'ewww-image-optimizer' ) . '<br>' .
8324
+ "<textarea id='ewww_image_optimizer_webp_paths' name='ewww_image_optimizer_webp_paths' rows='3' cols='60'>$webp_paths</textarea></td></tr>\n";
8325
+ ewwwio_debug_message( 'webp paths:' );
8326
+ ewwwio_debug_message( $webp_paths );
8327
  $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_webp_for_cdn'>" .
8328
  esc_html__( 'JS WebP Rewriting', 'ewww-image-optimizer' ) .
8329
  '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ) . "</th><td><span><input type='checkbox' id='ewww_image_optimizer_webp_for_cdn' name='ewww_image_optimizer_webp_for_cdn' value='true' " .
8330
  ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) == true ? "checked='true'" : '' ) . ' /> ' .
8331
+ esc_html__( 'Use this if the Apache rewrite rules do not work, or if your images are served from a CDN.', 'ewww-image-optimizer' ) . ' ' .
8332
  /* translators: %s: Cache Enabler (link) */
8333
+ sprintf( esc_html__( 'Sites using a CDN may also use the WebP option in the %s plugin.', 'ewww-image-optimizer' ), '<a href="https://wordpress.org/plugins/cache-enabler/">Cache Enabler</a>' ) . '</span></td></tr>';
8334
+ ewwwio_debug_message( 'alt webp rewriting: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) == true ? 'on' : 'off' ) );
8335
+ } elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
8336
+ $output[] = "<tr class='$network_class'><th>&nbsp;</th><td><p class='description'>" . esc_html__( 'WebP images are served automatically by ExactDN.', 'ewww-image-optimizer' ) . '</p></td></tr>';
8337
  }
 
8338
  $output[] = "</table>\n</div>\n";
8339
 
8340
  $output[] = "<div id='ewww-support-settings'>\n";
8350
  $output[] = "<tr class='$network_class'><th scope='row'><label for='ewww_image_optimizer_debug'>" . esc_html__( 'Debugging', 'ewww-image-optimizer' ) . '</label>' . ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2' ) . '</th>' .
8351
  "<td><input type='checkbox' id='ewww_image_optimizer_debug' name='ewww_image_optimizer_debug' value='true' " . ( ! $ewwwio_temp_debug && ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'Use this to provide information for support purposes, or if you feel comfortable digging around in the code to fix a problem you are experiencing.', 'ewww-image-optimizer' ) . "</td></tr>\n";
8352
  $output[] = "</table>\n";
8353
+
8354
+ $output[] = 'DEBUG_PLACEHOLDER';
8355
+
8356
  $output[] = "</div>\n";
8357
 
8358
  $output[] = "<div id='ewww-contribute-settings'>\n";
8432
  ewww_image_optimizer_function_exists( 'sleep', true );
8433
  ewwwio_check_memory_available();
8434
  if ( 'debug-silent' === $network ) {
8435
+ ewww_image_optimizer_temp_debug_clear();
8436
  return;
8437
  }
8438
  $output = apply_filters( 'ewww_image_optimizer_settings', $output );
8439
+ if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
8440
  global $ewwwio_alt_webp;
8441
  $ewwwio_alt_webp->inline_script();
8442
  }
8443
 
8444
  $help_instructions = esc_html__( 'Enable the Debugging option and refresh this page to include debugging information with your question.', 'ewww-image-optimizer' ) . ' ' .
8445
  esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
 
 
8446
 
8447
+ global $ewww_debug;
8448
+ if ( ! empty( $ewww_debug ) ) {
8449
  $debug_output = '<p style="clear:both"><b>' . esc_html__( 'Debugging Information', 'ewww-image-optimizer' ) . ':</b> <button id="ewww-copy-debug" class="button button-secondary" type="button">' . esc_html__( 'Copy', 'ewww-image-optimizer' ) . '</button>';
8450
  if ( is_file( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) ) {
8451
  $debug_output .= "&emsp;<a href='admin.php?action=ewww_image_optimizer_view_debug_log'>" . esc_html( 'View Debug Log', 'ewww-image-optimizer' ) . "</a> - <a href='admin.php?action=ewww_image_optimizer_delete_debug_log'>" . esc_html( 'Remove Debug Log', 'ewww-image-optimizer' ) . '</a>';
8457
  esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
8458
 
8459
  $output = str_replace( 'DEBUG_PLACEHOLDER', $debug_output, $output );
8460
+ } else {
8461
+ $output = str_replace( 'DEBUG_PLACEHOLDER', '', $output );
8462
  }
8463
+
8464
  echo $output;
8465
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
8466
  $current_user = wp_get_current_user();
8478
  $hs_identify = array(
8479
  'email' => utf8_encode( $help_email ),
8480
  );
8481
+ if ( ! empty( $ewww_debug ) ) {
8482
  $ewww_debug_array = explode( '<br>', $ewww_debug );
8483
  $ewww_debug_i = 0;
8484
  foreach ( $ewww_debug_array as $ewww_debug_line ) {
8499
  <?php
8500
  }
8501
  ewwwio_memory( __FUNCTION__ );
8502
+ ewww_image_optimizer_temp_debug_clear();
 
 
 
 
8503
  }
8504
 
8505
  /**
8692
  WP_CLI::debug( $message );
8693
  return;
8694
  }
8695
+ global $ewwwio_temp_debug;
8696
+ if ( $ewwwio_temp_debug || ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
8697
  $memory_limit = ewwwio_memory_limit();
8698
  if ( strlen( $message ) + 4000000 + memory_get_usage( true ) <= $memory_limit ) {
8699
  global $ewww_debug;
8974
  <?php }
8975
  }
8976
 
8977
+ /**
8978
+ * Make sure to clear temp debug option on shutdown.
8979
+ */
8980
+ function ewww_image_optimizer_temp_debug_clear() {
8981
+ global $ewwwio_temp_debug;
8982
+ global $ewww_debug;
8983
+ if ( $ewwwio_temp_debug ) {
8984
+ $ewww_debug = '';
8985
+ }
8986
+ $ewwwio_temp_debug = false;
8987
+ }
8988
+
8989
  /**
8990
  * Finds the current PHP memory limit or a reasonable default.
8991
  *
ewww-image-optimizer.php CHANGED
@@ -13,7 +13,7 @@ Plugin Name: EWWW Image Optimizer
13
  Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Exactly WWW
16
- Version: 4.7.1
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
13
  Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Exactly WWW
16
+ Version: 4.7.2
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: image, compress, resize, optimize, optimization, lossless, lossy, seo, web
5
  Requires at least: 4.9
6
  Tested up to: 5.1
7
  Requires PHP: 5.6
8
- Stable tag: 4.7.1
9
  License: GPLv3
10
 
11
  Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales.
@@ -59,7 +59,7 @@ All images created by the built-in WP_Image_Editor class will be automatically o
59
 
60
  = WebP Images =
61
 
62
- One-click WebP with ExactDN and JS WebP Rewriting. Otherwise, can generate WebP versions of your images, and enables you to serve even smaller images to supported browsers. Several methods are available for serving WebP images, including Apache-compatible rewrite rules and our JS WebP Rewriting option compatible with caches and CDNs. Also works with the WebP option in the Cache Enabler plugin from KeyCDN.
63
 
64
  = WP-CLI =
65
 
@@ -174,6 +174,13 @@ http://developer.yahoo.com/performance/rules.html#opt_images
174
  * Feature requests can be viewed and submitted at https://github.com/nosilver4u/ewww-image-optimizer/labels/enhancement
175
  * If you would like to help translate this plugin in your language, get started here: https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/
176
 
 
 
 
 
 
 
 
177
  = 4.7.1 =
178
  * added: CSS background image support for <li> elements
179
  * added: ExactDN + Lazy Load will auto-calculate dimensions for img elements without srcset/responsive markup
5
  Requires at least: 4.9
6
  Tested up to: 5.1
7
  Requires PHP: 5.6
8
+ Stable tag: 4.7.2
9
  License: GPLv3
10
 
11
  Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales.
59
 
60
  = WebP Images =
61
 
62
+ Automatic WebP conversion with ExactDN, no additional configuration. Otherwise, can generate WebP versions of your images, and enables you to serve even smaller images to supported browsers. Several methods are available for serving WebP images, including Apache-compatible rewrite rules and our JS WebP Rewriting option compatible with caches and CDNs. Also works with the WebP option in the Cache Enabler plugin from KeyCDN.
63
 
64
  = WP-CLI =
65
 
174
  * Feature requests can be viewed and submitted at https://github.com/nosilver4u/ewww-image-optimizer/labels/enhancement
175
  * If you would like to help translate this plugin in your language, get started here: https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/
176
 
177
+ = 4.7.2 =
178
+ * changed: JS WebP no longer necessary with ExactDN
179
+ * fixed: fatal error from NextGEN get_image_sizes() method
180
+ * fixed: debugging mode gets stuck
181
+ * fixed: ExactDN has unexpected results when content_width global equals zero
182
+ * fixed: img elements with unquoted src attributes ignored by ExactDN, Lazy Load, and JS WebP
183
+
184
  = 4.7.1 =
185
  * added: CSS background image support for <li> elements
186
  * added: ExactDN + Lazy Load will auto-calculate dimensions for img elements without srcset/responsive markup