EWWW Image Optimizer - Version 6.1.4

Version Description

  • changed: better handling for API quotas
  • fixed: picture elements not parsed when using JS WebP with Lazy Load
  • fixed: bundled tools don't work if the binary/tool directory is mounted on a filesystem separate from wp-content/
  • fixed: bulk optimizer not finding images from cloud storage (like S3) when local versions are removed
Download this release

Release Info

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

Code changes from version 6.1.3 to 6.1.4

bulk.php CHANGED
@@ -1157,7 +1157,7 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
1157
  $s3_uploads = S3_Uploads::get_instance();
1158
  remove_filter( 'upload_dir', array( $s3_uploads, 'filter_upload_dir' ) );
1159
  }
1160
- if ( ewww_image_optimizer_stream_wrapped( $file_path ) ) {
1161
  $file_path = get_attached_file( $selected_id, true );
1162
  }
1163
  if ( class_exists( 'S3_Uploads' ) && method_exists( 'S3_Uploads', 'filter_upload_dir' ) ) {
@@ -1915,14 +1915,20 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
1915
  list( $file, $msg, $converted, $original ) = ewww_image_optimizer( $image->file, 1, false, false, 'full' === $image->resize );
1916
  // Gotta make sure we don't delete a pending record if the license is exceeded, so the license check goes first.
1917
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
1918
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
1919
- if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
1920
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
1921
  delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
1922
  delete_transient( 'ewww_image_optimizer_bulk_current_image' );
1923
  ewwwio_ob_clean();
1924
  die( wp_json_encode( $output ) );
1925
  }
 
 
 
 
 
 
 
1926
  }
1927
  // Delete a pending record if the optimization failed for whatever reason.
1928
  if ( ! $file && $image->id ) {
1157
  $s3_uploads = S3_Uploads::get_instance();
1158
  remove_filter( 'upload_dir', array( $s3_uploads, 'filter_upload_dir' ) );
1159
  }
1160
+ if ( ewww_image_optimizer_stream_wrapped( $file_path ) || 0 === strpos( $file_path, 'http' ) ) {
1161
  $file_path = get_attached_file( $selected_id, true );
1162
  }
1163
  if ( class_exists( 'S3_Uploads' ) && method_exists( 'S3_Uploads', 'filter_upload_dir' ) ) {
1915
  list( $file, $msg, $converted, $original ) = ewww_image_optimizer( $image->file, 1, false, false, 'full' === $image->resize );
1916
  // Gotta make sure we don't delete a pending record if the license is exceeded, so the license check goes first.
1917
  if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
1918
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
1919
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
1920
  delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
1921
  delete_transient( 'ewww_image_optimizer_bulk_current_image' );
1922
  ewwwio_ob_clean();
1923
  die( wp_json_encode( $output ) );
1924
  }
1925
+ if ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
1926
+ $output['error'] = '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" data-beacon-article="608ddf128996210f18bd95d3" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>';
1927
+ delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
1928
+ delete_transient( 'ewww_image_optimizer_bulk_current_image' );
1929
+ ewwwio_ob_clean();
1930
+ die( wp_json_encode( $output ) );
1931
+ }
1932
  }
1933
  // Delete a pending record if the optimization failed for whatever reason.
1934
  if ( ! $file && $image->id ) {
changelog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  = 6.1.3 =
2
  * changed: bulk optimizer no longer skips image types set to "no compression" in WebP-only mode
3
  * fixed: CNAME setting from WP Offload Media triggers "unknown" error in Easy IO
1
+ = 6.1.4 =
2
+ * changed: better handling for API quotas
3
+ * fixed: picture elements not parsed when using JS WebP with Lazy Load
4
+ * fixed: bundled tools don't work if the binary/tool directory is mounted on a filesystem separate from wp-content/
5
+ * fixed: bulk optimizer not finding images from cloud storage (like S3) when local versions are removed
6
+
7
  = 6.1.3 =
8
  * changed: bulk optimizer no longer skips image types set to "no compression" in WebP-only mode
9
  * fixed: CNAME setting from WP Offload Media triggers "unknown" error in Easy IO
classes/class-eio-alt-webp.php CHANGED
@@ -548,6 +548,8 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
548
  $srcset_attr_name = 'srcset';
549
  if ( false !== strpos( $source, 'base64,R0lGOD' ) && false !== strpos( $source, 'data-srcset=' ) ) {
550
  $srcset_attr_name = 'data-srcset';
 
 
551
  }
552
  $srcset = $this->get_attribute( $source, $srcset_attr_name );
553
  if ( $srcset ) {
548
  $srcset_attr_name = 'srcset';
549
  if ( false !== strpos( $source, 'base64,R0lGOD' ) && false !== strpos( $source, 'data-srcset=' ) ) {
550
  $srcset_attr_name = 'data-srcset';
551
+ } elseif ( ! $this->get_attribute( $source, $srcset_attr_name ) && false !== strpos( $source, 'data-srcset=' ) ) {
552
+ $srcset_attr_name = 'data-srcset';
553
  }
554
  $srcset = $this->get_attribute( $source, $srcset_attr_name );
555
  if ( $srcset ) {
classes/class-eio-picture-webp.php CHANGED
@@ -208,6 +208,8 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
208
  $srcset_attr_name = 'srcset';
209
  if ( false !== strpos( $source, 'base64,R0lGOD' ) && false !== strpos( $source, 'data-srcset=' ) ) {
210
  $srcset_attr_name = 'data-srcset';
 
 
211
  }
212
  $srcset = $this->get_attribute( $source, $srcset_attr_name );
213
  if ( $srcset ) {
208
  $srcset_attr_name = 'srcset';
209
  if ( false !== strpos( $source, 'base64,R0lGOD' ) && false !== strpos( $source, 'data-srcset=' ) ) {
210
  $srcset_attr_name = 'data-srcset';
211
+ } elseif ( ! $this->get_attribute( $source, $srcset_attr_name ) && false !== strpos( $source, 'data-srcset=' ) ) {
212
+ $srcset_attr_name = 'data-srcset';
213
  }
214
  $srcset = $this->get_attribute( $source, $srcset_attr_name );
215
  if ( $srcset ) {
classes/class-ewww-flag.php CHANGED
@@ -611,13 +611,17 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
611
  $ewww_image = new EWWW_Image( $id, 'flag', $file_path );
612
  $ewww_image->resize = 'full';
613
  // Optimize the full-size version.
614
- $fres = ewww_image_optimizer( $file_path, 3, false, false, true );
615
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
616
- if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
617
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
618
  ewwwio_ob_clean();
619
  wp_die( wp_json_encode( $output ) );
620
  }
 
 
 
 
 
621
  // Let the user know what happened.
622
  $output['results'] = sprintf( '<p>' . esc_html__( 'Optimized image:', 'ewww-image-optimizer' ) . ' <strong>%s</strong><br>', esc_html( $meta->image->filename ) );
623
  /* Translators: %s: The compression results/savings */
611
  $ewww_image = new EWWW_Image( $id, 'flag', $file_path );
612
  $ewww_image->resize = 'full';
613
  // Optimize the full-size version.
614
+ $fres = ewww_image_optimizer( $file_path, 3, false, false, true );
615
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
616
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
617
  ewwwio_ob_clean();
618
  wp_die( wp_json_encode( $output ) );
619
  }
620
+ if ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
621
+ $output['error'] = '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>';
622
+ ewwwio_ob_clean();
623
+ wp_die( wp_json_encode( $output ) );
624
+ }
625
  // Let the user know what happened.
626
  $output['results'] = sprintf( '<p>' . esc_html__( 'Optimized image:', 'ewww-image-optimizer' ) . ' <strong>%s</strong><br>', esc_html( $meta->image->filename ) );
627
  /* Translators: %s: The compression results/savings */
classes/class-ewww-nextcellent.php CHANGED
@@ -614,12 +614,16 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
614
  $attachments = get_option( 'ewww_image_optimizer_bulk_ngg_attachments' );
615
  $id = array_shift( $attachments );
616
  list( $fres, $tres ) = $this->ewww_ngg_optimize( $id );
617
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
618
- if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
619
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
620
  ewwwio_ob_clean();
621
  wp_die( wp_json_encode( $output ) );
622
  }
 
 
 
 
 
623
  // Output the results of the optimization.
624
  if ( $fres[0] ) {
625
  $output['results'] = sprintf( '<p>' . esc_html__( 'Optimized image:', 'ewww-image-optimizer' ) . ' <strong>%s</strong><br>', esc_html( $fres[0] ) );
614
  $attachments = get_option( 'ewww_image_optimizer_bulk_ngg_attachments' );
615
  $id = array_shift( $attachments );
616
  list( $fres, $tres ) = $this->ewww_ngg_optimize( $id );
617
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
618
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
619
  ewwwio_ob_clean();
620
  wp_die( wp_json_encode( $output ) );
621
  }
622
+ if ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
623
+ $output['error'] = '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>';
624
+ ewwwio_ob_clean();
625
+ wp_die( wp_json_encode( $output ) );
626
+ }
627
  // Output the results of the optimization.
628
  if ( $fres[0] ) {
629
  $output['results'] = sprintf( '<p>' . esc_html__( 'Optimized image:', 'ewww-image-optimizer' ) . ' <strong>%s</strong><br>', esc_html( $fres[0] ) );
classes/class-ewww-nextgen.php CHANGED
@@ -286,7 +286,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
286
  $image = $storage->object->_image_mapper->find( $id );
287
  $image = $this->ewww_added_new_image( $image, $storage );
288
  $success = $this->ewww_manage_image_custom_column( '', $image );
289
- if ( get_transient( 'ewww_image_optimizer_cloud_status' ) === 'exceeded' || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
290
  ewwwio_ob_clean();
291
  wp_die(
292
  wp_json_encode(
@@ -296,6 +296,16 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
296
  )
297
  );
298
  }
 
 
 
 
 
 
 
 
 
 
299
  if ( ! wp_doing_ajax() ) {
300
  // Get the referring page, and send the user back there.
301
  wp_safe_redirect( wp_get_referer() );
286
  $image = $storage->object->_image_mapper->find( $id );
287
  $image = $this->ewww_added_new_image( $image, $storage );
288
  $success = $this->ewww_manage_image_custom_column( '', $image );
289
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
290
  ewwwio_ob_clean();
291
  wp_die(
292
  wp_json_encode(
296
  )
297
  );
298
  }
299
+ if ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
300
+ ewwwio_ob_clean();
301
+ wp_die(
302
+ wp_json_encode(
303
+ array(
304
+ 'error' => '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>',
305
+ )
306
+ )
307
+ );
308
+ }
309
  if ( ! wp_doing_ajax() ) {
310
  // Get the referring page, and send the user back there.
311
  wp_safe_redirect( wp_get_referer() );
classes/class-exactdn.php CHANGED
@@ -348,16 +348,8 @@ if ( ! class_exists( 'ExactDN' ) ) {
348
  $this->set_exactdn_option( 'verify_method', -1, false );
349
  }
350
  if ( ! empty( $response['plan_id'] ) ) {
351
- if ( 2 === (int) $response['plan_id'] ) {
352
- $this->set_exactdn_option( 'plan_id', 2 );
353
- $this->plan_id = 2;
354
- } elseif ( 3 === (int) $response['plan_id'] ) {
355
- $this->set_exactdn_option( 'plan_id', 3 );
356
- $this->plan_id = 3;
357
- } else {
358
- $this->set_exactdn_option( 'plan_id', 1 );
359
- $this->plan_id = 1;
360
- }
361
  }
362
  if ( get_option( 'exactdn_never_been_active' ) ) {
363
  $this->set_option( $this->prefix . 'lazy_load', true );
@@ -490,15 +482,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
490
  } elseif ( ! empty( $result['body'] ) && false === strpos( $result['body'], 'error' ) ) {
491
  $response = json_decode( $result['body'], true );
492
  if ( ! empty( $response['success'] ) ) {
493
- if ( 2 === (int) $response['success'] ) {
494
- $this->set_exactdn_option( 'plan_id', 2 );
495
- $this->plan_id = 2;
496
- } elseif ( 3 === (int) $response['success'] ) {
497
- $this->set_exactdn_option( 'plan_id', 3 );
498
- $this->plan_id = 3;
499
- } elseif ( 1 !== (int) $this->plan_id ) {
500
- $this->set_exactdn_option( 'plan_id', 1 );
501
- $this->plan_id = 1;
502
  }
503
  $this->debug_message( 'exactdn verification via API succeeded' );
504
  $this->set_exactdn_option( 'verified', 1, false );
348
  $this->set_exactdn_option( 'verify_method', -1, false );
349
  }
350
  if ( ! empty( $response['plan_id'] ) ) {
351
+ $this->set_exactdn_option( 'plan_id', (int) $response['plan_id'] );
352
+ $this->plan_id = (int) $response['plan_id'];
 
 
 
 
 
 
 
 
353
  }
354
  if ( get_option( 'exactdn_never_been_active' ) ) {
355
  $this->set_option( $this->prefix . 'lazy_load', true );
482
  } elseif ( ! empty( $result['body'] ) && false === strpos( $result['body'], 'error' ) ) {
483
  $response = json_decode( $result['body'], true );
484
  if ( ! empty( $response['success'] ) ) {
485
+ if ( ! empty( $response['plan_id'] ) ) {
486
+ $this->set_exactdn_option( 'plan_id', (int) $response['plan_id'] );
487
+ $this->plan_id = (int) $response['plan_id'];
 
 
 
 
 
 
488
  }
489
  $this->debug_message( 'exactdn verification via API succeeded' );
490
  $this->set_exactdn_option( 'verified', 1, false );
common.php CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '613' );
18
 
19
  // Initialize a couple globals.
20
  $eio_debug = '';
@@ -3557,11 +3557,17 @@ function ewwwio_is_file( $file ) {
3557
  $upload_dir = $content_dir;
3558
  }
3559
  $plugin_dir = realpath( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH );
 
 
 
 
 
3560
  if (
3561
  false === strpos( $file, $upload_dir ) &&
3562
  false === strpos( $file, $content_dir ) &&
3563
  false === strpos( $file, $wp_dir ) &&
3564
- false === strpos( $file, $plugin_dir )
 
3565
  ) {
3566
  return false;
3567
  }
@@ -3723,7 +3729,7 @@ function ewww_image_optimizer_manual() {
3723
  if ( ! $meta_saved ) {
3724
  ewwwio_debug_message( 'failed to save meta, or no changes' );
3725
  }
3726
- if ( get_transient( 'ewww_image_optimizer_cloud_status' ) === 'exceeded' || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
3727
  if ( ! wp_doing_ajax() ) {
3728
  wp_die( '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License exceeded', 'ewww-image-optimizer' ) . '</a>' );
3729
  }
@@ -3735,6 +3741,18 @@ function ewww_image_optimizer_manual() {
3735
  )
3736
  )
3737
  );
 
 
 
 
 
 
 
 
 
 
 
 
3738
  }
3739
  $success = ewww_image_optimizer_custom_column_capture( 'ewww-image-optimizer', $attachment_id, $new_meta );
3740
  ewww_image_optimizer_debug_log();
@@ -4734,7 +4752,7 @@ function ewww_image_optimizer_cloud_quota( $raw = false ) {
4734
  *
4735
  * @type string Filename of the optimized version.
4736
  * @type bool True if the image was converted.
4737
- * @type string Set to 'exceeded' if the API key is out of credits.
4738
  * @type int File size of the (new) image.
4739
  * }
4740
  */
@@ -4752,9 +4770,8 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
4752
  }
4753
  ewww_image_optimizer_debug_log();
4754
  }
4755
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
4756
- $api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
4757
- if ( preg_match( '/exceeded/', $ewww_status ) ) {
4758
  $started = microtime( true );
4759
  if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
4760
  return array( $file, false, 'key verification failed', 0, '' );
@@ -4763,8 +4780,11 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
4763
  $elapsed = microtime( true ) - $started;
4764
  ewwwio_debug_message( "cloud verify took $elapsed seconds" );
4765
  }
4766
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
4767
- if ( ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
 
 
 
4768
  ewwwio_debug_message( 'license exceeded, image not processed' );
4769
  return array( $file, false, 'exceeded', 0, '' );
4770
  }
@@ -4954,6 +4974,11 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
4954
  if ( 100 > strlen( $response['body'] ) && strpos( $response['body'], 'invalid' ) ) {
4955
  ewwwio_debug_message( 'License Invalid' );
4956
  ewww_image_optimizer_remove_cloud_key( 'none' );
 
 
 
 
 
4957
  } elseif ( 100 > strlen( $response['body'] ) && strpos( $response['body'], 'exceeded' ) ) {
4958
  ewwwio_debug_message( 'License Exceeded' );
4959
  set_transient( 'ewww_image_optimizer_cloud_status', 'exceeded', HOUR_IN_SECONDS );
@@ -5006,9 +5031,8 @@ function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
5006
  if ( empty( $api_key ) ) {
5007
  return false;
5008
  }
5009
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
5010
- $started = microtime( true );
5011
- if ( preg_match( '/exceeded/', $ewww_status ) ) {
5012
  if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
5013
  ewwwio_debug_message( 'cloud verify failed, image not rotated' );
5014
  return false;
@@ -5017,8 +5041,7 @@ function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
5017
  // Calculate how much time has elapsed since we started.
5018
  $elapsed = microtime( true ) - $started;
5019
  ewwwio_debug_message( "cloud verify took $elapsed seconds" );
5020
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
5021
- if ( ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
5022
  ewwwio_debug_message( 'license exceeded, image not rotated' );
5023
  return false;
5024
  }
@@ -5249,9 +5272,8 @@ function ewww_image_optimizer_cloud_resize( $file, $type, $dst_x, $dst_y, $src_x
5249
  if ( empty( $api_key ) ) {
5250
  return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
5251
  }
5252
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
5253
- $started = microtime( true );
5254
- if ( false !== strpos( $ewww_status, 'exceeded' ) ) {
5255
  if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
5256
  ewwwio_debug_message( 'cloud verify failed, image not resized' );
5257
  return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
@@ -5260,8 +5282,7 @@ function ewww_image_optimizer_cloud_resize( $file, $type, $dst_x, $dst_y, $src_x
5260
  // Calculate how much time has elapsed since we started.
5261
  $elapsed = microtime( true ) - $started;
5262
  ewwwio_debug_message( "cloud verify took $elapsed seconds" );
5263
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
5264
- if ( ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
5265
  ewwwio_debug_message( 'license exceeded, image not rotated' );
5266
  return new WP_Error( 'invalid_key', __( 'License Exceeded', 'ewww-image-optimizer' ) );
5267
  }
@@ -5930,8 +5951,7 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
5930
  )
5931
  );
5932
  }
5933
- $ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
5934
- if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
5935
  if ( ! $auto ) {
5936
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
5937
  echo wp_json_encode( $output );
@@ -5941,6 +5961,16 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
5941
  }
5942
  die();
5943
  }
 
 
 
 
 
 
 
 
 
 
5944
  if ( ! $auto ) {
5945
  // Output the path.
5946
  $output['results'] = '<p>' . esc_html__( 'Optimized', 'ewww-image-optimizer' ) . ' <strong>' . esc_html( $attachment ) . '</strong><br>';
@@ -11798,7 +11828,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
11798
  <p>
11799
  <?php if ( false !== strpos( $verify_cloud, 'great' ) ) : ?>
11800
  <span style="color: #3eadc9; font-weight: bolder"><?php esc_html_e( 'Verified,', 'ewww-image-optimizer' ); ?> </span><?php echo esc_html( ewww_image_optimizer_cloud_quota() ); ?>
11801
- <?php elseif ( false !== strpos( $verify_cloud, 'exceeded' ) ) : ?>
 
 
11802
  <span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Out of credits', 'ewww-image-optimizer' ); ?></span> - <a href="https://ewww.io/buy-credits/" target="_blank"><?php esc_html_e( 'Purchase more', 'ewww-image-optimizer' ); ?></a>
11803
  <?php else : ?>
11804
  <span style="color: red; font-weight: bolder"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></span>
@@ -12317,14 +12349,14 @@ AddType image/webp .webp</pre>
12317
  <p class='description'><?php echo wp_kses_post( $webp_url_example ); ?></p>
12318
  </td>
12319
  </tr>
12320
- <tr class='ewww_image_optimizer_webp_rewrite_setting_container' <?php echo $webp_php_rewriting ? '' : ' style="display:none"'; ?>>
12321
  <th scope='row'>
12322
  <label for='ewww_image_optimizer_webp_force'><?php esc_html_e( 'Force WebP', 'ewww-image-optimizer' ); ?></label>
12323
  <span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
12324
  </th>
12325
  <td>
12326
  <input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
12327
- <span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
12328
  <?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
12329
  <p>
12330
  <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
14
  exit;
15
  }
16
 
17
+ define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '614' );
18
 
19
  // Initialize a couple globals.
20
  $eio_debug = '';
3557
  $upload_dir = $content_dir;
3558
  }
3559
  $plugin_dir = realpath( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH );
3560
+ $tool_dir = $content_dir;
3561
+ if ( defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
3562
+ $tool_dir = realpath( EWWW_IMAGE_OPTIMIZER_TOOL_PATH );
3563
+ $tool_dir = dirname( $tool_dir );
3564
+ }
3565
  if (
3566
  false === strpos( $file, $upload_dir ) &&
3567
  false === strpos( $file, $content_dir ) &&
3568
  false === strpos( $file, $wp_dir ) &&
3569
+ false === strpos( $file, $plugin_dir ) &&
3570
+ false === strpos( $file, $tool_dir )
3571
  ) {
3572
  return false;
3573
  }
3729
  if ( ! $meta_saved ) {
3730
  ewwwio_debug_message( 'failed to save meta, or no changes' );
3731
  }
3732
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
3733
  if ( ! wp_doing_ajax() ) {
3734
  wp_die( '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License exceeded', 'ewww-image-optimizer' ) . '</a>' );
3735
  }
3741
  )
3742
  )
3743
  );
3744
+ } elseif ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
3745
+ if ( ! wp_doing_ajax() ) {
3746
+ wp_die( '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" data-beacon-article="608ddf128996210f18bd95d3" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>' );
3747
+ }
3748
+ ewwwio_ob_clean();
3749
+ wp_die(
3750
+ wp_json_encode(
3751
+ array(
3752
+ 'error' => '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" data-beacon-article="608ddf128996210f18bd95d3" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>',
3753
+ )
3754
+ )
3755
+ );
3756
  }
3757
  $success = ewww_image_optimizer_custom_column_capture( 'ewww-image-optimizer', $attachment_id, $new_meta );
3758
  ewww_image_optimizer_debug_log();
4752
  *
4753
  * @type string Filename of the optimized version.
4754
  * @type bool True if the image was converted.
4755
+ * @type string Set to 'exceeded' if the API key is out of credits. Or 'exceeded quota' if soft quota is reached.
4756
  * @type int File size of the (new) image.
4757
  * }
4758
  */
4770
  }
4771
  ewww_image_optimizer_debug_log();
4772
  }
4773
+ $api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
4774
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
4775
  $started = microtime( true );
4776
  if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
4777
  return array( $file, false, 'key verification failed', 0, '' );
4780
  $elapsed = microtime( true ) - $started;
4781
  ewwwio_debug_message( "cloud verify took $elapsed seconds" );
4782
  }
4783
+ if ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
4784
+ ewwwio_debug_message( 'soft quota reached, image not processed' );
4785
+ return array( $file, false, 'exceeded quota', 0, '' );
4786
+ }
4787
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
4788
  ewwwio_debug_message( 'license exceeded, image not processed' );
4789
  return array( $file, false, 'exceeded', 0, '' );
4790
  }
4974
  if ( 100 > strlen( $response['body'] ) && strpos( $response['body'], 'invalid' ) ) {
4975
  ewwwio_debug_message( 'License Invalid' );
4976
  ewww_image_optimizer_remove_cloud_key( 'none' );
4977
+ } elseif ( 100 > strlen( $response['body'] ) && strpos( $response['body'], 'exceeded quota' ) ) {
4978
+ ewwwio_debug_message( 'Soft quota Exceeded' );
4979
+ set_transient( 'ewww_image_optimizer_cloud_status', 'exceeded quota', HOUR_IN_SECONDS );
4980
+ $msg = 'exceeded quota';
4981
+ ewwwio_delete_file( $tempfile );
4982
  } elseif ( 100 > strlen( $response['body'] ) && strpos( $response['body'], 'exceeded' ) ) {
4983
  ewwwio_debug_message( 'License Exceeded' );
4984
  set_transient( 'ewww_image_optimizer_cloud_status', 'exceeded', HOUR_IN_SECONDS );
5031
  if ( empty( $api_key ) ) {
5032
  return false;
5033
  }
5034
+ $started = microtime( true );
5035
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
5036
  if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
5037
  ewwwio_debug_message( 'cloud verify failed, image not rotated' );
5038
  return false;
5041
  // Calculate how much time has elapsed since we started.
5042
  $elapsed = microtime( true ) - $started;
5043
  ewwwio_debug_message( "cloud verify took $elapsed seconds" );
5044
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
 
5045
  ewwwio_debug_message( 'license exceeded, image not rotated' );
5046
  return false;
5047
  }
5272
  if ( empty( $api_key ) ) {
5273
  return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
5274
  }
5275
+ $started = microtime( true );
5276
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
5277
  if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
5278
  ewwwio_debug_message( 'cloud verify failed, image not resized' );
5279
  return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
5282
  // Calculate how much time has elapsed since we started.
5283
  $elapsed = microtime( true ) - $started;
5284
  ewwwio_debug_message( "cloud verify took $elapsed seconds" );
5285
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
 
5286
  ewwwio_debug_message( 'license exceeded, image not rotated' );
5287
  return new WP_Error( 'invalid_key', __( 'License Exceeded', 'ewww-image-optimizer' ) );
5288
  }
5951
  )
5952
  );
5953
  }
5954
+ if ( 'exceeded' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
 
5955
  if ( ! $auto ) {
5956
  $output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
5957
  echo wp_json_encode( $output );
5961
  }
5962
  die();
5963
  }
5964
+ if ( 'exceeded quota' === get_transient( 'ewww_image_optimizer_cloud_status' ) ) {
5965
+ if ( ! $auto ) {
5966
+ $output['error'] = '<a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" data-beacon-article="608ddf128996210f18bd95d3" target="_blank">' . esc_html__( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) . '</a>';
5967
+ echo wp_json_encode( $output );
5968
+ }
5969
+ if ( $cli ) {
5970
+ WP_CLI::error( __( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ) );
5971
+ }
5972
+ die();
5973
+ }
5974
  if ( ! $auto ) {
5975
  // Output the path.
5976
  $output['results'] = '<p>' . esc_html__( 'Optimized', 'ewww-image-optimizer' ) . ' <strong>' . esc_html( $attachment ) . '</strong><br>';
11828
  <p>
11829
  <?php if ( false !== strpos( $verify_cloud, 'great' ) ) : ?>
11830
  <span style="color: #3eadc9; font-weight: bolder"><?php esc_html_e( 'Verified,', 'ewww-image-optimizer' ); ?> </span><?php echo esc_html( ewww_image_optimizer_cloud_quota() ); ?>
11831
+ <?php elseif ( 'exceeded quota' === $verify_cloud ) : ?>
11832
+ <span style="color: orange; font-weight: bolder"><a href="https://docs.ewww.io/article/101-soft-quotas-on-unlimited-plans" data-beacon-article="608ddf128996210f18bd95d3" target="_blank"><?php esc_html_e( 'Soft quota reached, contact us for more', 'ewww-image-optimizer' ); ?></a></span>
11833
+ <?php elseif ( 'exceeded' === $verify_cloud ) : ?>
11834
  <span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Out of credits', 'ewww-image-optimizer' ); ?></span> - <a href="https://ewww.io/buy-credits/" target="_blank"><?php esc_html_e( 'Purchase more', 'ewww-image-optimizer' ); ?></a>
11835
  <?php else : ?>
11836
  <span style="color: red; font-weight: bolder"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></span>
12349
  <p class='description'><?php echo wp_kses_post( $webp_url_example ); ?></p>
12350
  </td>
12351
  </tr>
12352
+ <tr class='ewww_image_optimizer_webp_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ? '' : ' style="display:none"'; ?>>
12353
  <th scope='row'>
12354
  <label for='ewww_image_optimizer_webp_force'><?php esc_html_e( 'Force WebP', 'ewww-image-optimizer' ); ?></label>
12355
  <span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
12356
  </th>
12357
  <td>
12358
  <input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
12359
+ <span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. JS and <picture> WebP rewriters will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
12360
  <?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
12361
  <p>
12362
  <a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
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: 6.1.3
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: 6.1.4
17
  Author URI: https://ewww.io/
18
  License: GPLv3
19
  */
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization,
5
  Requires at least: 5.4
6
  Tested up to: 5.7
7
  Requires PHP: 7.1
8
- Stable tag: 6.1.3
9
  License: GPLv3
10
 
11
  Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
@@ -132,6 +132,12 @@ That's not a question, but since I made it up, I'll answer it. See this resource
132
  * Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io)
133
  * If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
134
 
 
 
 
 
 
 
135
  = 6.1.3 =
136
  * changed: bulk optimizer no longer skips image types set to "no compression" in WebP-only mode
137
  * fixed: CNAME setting from WP Offload Media triggers "unknown" error in Easy IO
5
  Requires at least: 5.4
6
  Tested up to: 5.7
7
  Requires PHP: 7.1
8
+ Stable tag: 6.1.4
9
  License: GPLv3
10
 
11
  Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
132
  * Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io)
133
  * If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
134
 
135
+ = 6.1.4 =
136
+ * changed: better handling for API quotas
137
+ * fixed: picture elements not parsed when using JS WebP with Lazy Load
138
+ * fixed: bundled tools don't work if the binary/tool directory is mounted on a filesystem separate from wp-content/
139
+ * fixed: bulk optimizer not finding images from cloud storage (like S3) when local versions are removed
140
+
141
  = 6.1.3 =
142
  * changed: bulk optimizer no longer skips image types set to "no compression" in WebP-only mode
143
  * fixed: CNAME setting from WP Offload Media triggers "unknown" error in Easy IO
unique.php CHANGED
@@ -2917,6 +2917,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
2917
  // If their cloud api license limit has been exceeded.
2918
  if ( 'exceeded' === $result ) {
2919
  return array( false, __( 'License exceeded', 'ewww-image-optimizer' ), $converted, $original );
 
 
2920
  }
2921
  if ( ! empty( $new_size ) ) {
2922
  // Set correct file permissions.
2917
  // If their cloud api license limit has been exceeded.
2918
  if ( 'exceeded' === $result ) {
2919
  return array( false, __( 'License exceeded', 'ewww-image-optimizer' ), $converted, $original );
2920
+ } elseif ( 'exceeded quota' === $result ) {
2921
+ return array( false, __( 'Soft Quota Reached', 'ewww-image-optimizer' ), $converted, $original );
2922
  }
2923
  if ( ! empty( $new_size ) ) {
2924
  // Set correct file permissions.