EWWW Image Optimizer - Version 4.2.1

Version Description

  • fixed: EXACTDN_LOCAL_DOMAIN does not work with auto-verification
  • fixed: uncaught error during upgrade when 'SHOW FULL COLUMNS' fails
  • fixed: async simulation gets 403 error
Download this release

Release Info

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

Code changes from version 4.2.0 to 4.2.1

changelog.txt CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  = 4.2.0 =
2
  * added: disable ExactDN attachment ID queries if they take too long
3
  * added: ExactDN compatibility with a3 Lazy Load
1
+ = 4.2.1 =
2
+ * fixed: EXACTDN_LOCAL_DOMAIN does not work with auto-verification
3
+ * fixed: uncaught error during upgrade when 'SHOW FULL COLUMNS' fails
4
+ * fixed: async simulation gets 403 error
5
+
6
  = 4.2.0 =
7
  * added: disable ExactDN attachment ID queries if they take too long
8
  * added: ExactDN compatibility with a3 Lazy Load
classes/class-exactdn.php CHANGED
@@ -214,7 +214,7 @@ class ExactDN {
214
  return false;
215
  } elseif ( get_option( 'ewww_image_optimizer_exactdn_failures' ) < 10 ) {
216
  $failures = (int) get_option( 'ewww_image_optimizer_exactdn_failures' );
217
- ewwwio_debug_message( 'could not verify existing exactDN domain, waiting for ' . human_time_diff( $this->get_exactdn_option( 'checkin' ) ) );
218
  ewwwio_debug_message( 10 - $failures . ' attempts remaining' );
219
  return false;
220
  }
@@ -230,7 +230,7 @@ class ExactDN {
230
  */
231
  function activate_site() {
232
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
233
- $site_url = get_home_url();
234
  $url = 'http://optimize.exactlywww.com/exactdn/activate.php';
235
  $ssl = wp_http_supports( array( 'ssl' ) );
236
  if ( $ssl ) {
@@ -274,7 +274,7 @@ class ExactDN {
274
  // Check the time, to see how long it has been since we verified the domain.
275
  $last_checkin = $this->get_exactdn_option( 'checkin' );
276
  if ( ! empty( $last_checkin ) && $last_checkin > time() ) {
277
- ewwwio_debug_message( 'not time yet: ' . human_time_diff( $this->get_exactdn_option( 'checkin' ) ) );
278
  if ( $this->get_exactdn_option( 'suspended' ) ) {
279
  return false;
280
  }
@@ -283,9 +283,9 @@ class ExactDN {
283
 
284
  $this->check_verify_method();
285
 
286
- if ( $this->get_exactdn_option( 'verify_method' ) > 0 ) {
287
  // Test with an image file that should be available on the ExactDN zone.
288
- $test_url = plugins_url( '/images/testorig.jpg', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE );
289
  $local_domain = $this->parse_url( $test_url, PHP_URL_HOST );
290
  $test_url = str_replace( $local_domain, $domain, $test_url );
291
  ewwwio_debug_message( "test url is $test_url" );
@@ -296,14 +296,15 @@ class ExactDN {
296
  $this->set_exactdn_option( 'suspended', 1 );
297
  return false;
298
  } elseif ( ! empty( $test_result['body'] ) && strlen( $test_result['body'] ) > 300 ) {
299
- if ( 200 === $test_result['response']['code'] && 'ffd8ff' === bin2hex( substr( $test_result['body'], 0, 3 ) ) ) {
 
300
  ewwwio_debug_message( 'exactdn (real-world) verification succeeded' );
301
  $this->set_exactdn_option( 'checkin', time() + 3600 );
302
  $this->set_exactdn_option( 'verified', 1, false );
303
  $this->set_exactdn_option( 'suspended', 0 );
304
  return true;
305
  }
306
- ewwwio_debug_message( 'mime check failed' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
307
  }
308
  $this->set_exactdn_option( 'suspended', 1 );
309
  return false;
@@ -1982,6 +1983,24 @@ class ExactDN {
1982
  return parse_url( $url, $component );
1983
  }
1984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1985
  /**
1986
  * Adds link to header which enables DNS prefetching for faster speed.
1987
  */
214
  return false;
215
  } elseif ( get_option( 'ewww_image_optimizer_exactdn_failures' ) < 10 ) {
216
  $failures = (int) get_option( 'ewww_image_optimizer_exactdn_failures' );
217
+ ewwwio_debug_message( 'could not verify existing exactDN domain, waiting for ' . $this->human_time_diff( $this->get_exactdn_option( 'checkin' ) ) );
218
  ewwwio_debug_message( 10 - $failures . ' attempts remaining' );
219
  return false;
220
  }
230
  */
231
  function activate_site() {
232
  ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
233
+ $site_url = defined( 'EXACTDN_LOCAL_DOMAIN' ) && EXACTDN_LOCAL_DOMAIN ? EXACTDN_LOCAL_DOMAIN : get_home_url();
234
  $url = 'http://optimize.exactlywww.com/exactdn/activate.php';
235
  $ssl = wp_http_supports( array( 'ssl' ) );
236
  if ( $ssl ) {
274
  // Check the time, to see how long it has been since we verified the domain.
275
  $last_checkin = $this->get_exactdn_option( 'checkin' );
276
  if ( ! empty( $last_checkin ) && $last_checkin > time() ) {
277
+ ewwwio_debug_message( 'not time yet: ' . $this->human_time_diff( $this->get_exactdn_option( 'checkin' ) ) );
278
  if ( $this->get_exactdn_option( 'suspended' ) ) {
279
  return false;
280
  }
283
 
284
  $this->check_verify_method();
285
 
286
+ if ( ! defined( 'EXACTDN_LOCAL_DOMAIN' ) && $this->get_exactdn_option( 'verify_method' ) > 0 ) {
287
  // Test with an image file that should be available on the ExactDN zone.
288
+ $test_url = plugins_url( '/images/test.png', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE );
289
  $local_domain = $this->parse_url( $test_url, PHP_URL_HOST );
290
  $test_url = str_replace( $local_domain, $domain, $test_url );
291
  ewwwio_debug_message( "test url is $test_url" );
296
  $this->set_exactdn_option( 'suspended', 1 );
297
  return false;
298
  } elseif ( ! empty( $test_result['body'] ) && strlen( $test_result['body'] ) > 300 ) {
299
+ if ( 200 === $test_result['response']['code'] &&
300
+ ( '89504e470d0a1a0a' === bin2hex( substr( $test_result['body'], 0, 8 ) ) || '52494646' === bin2hex( substr( $test_result['body'], 0, 4 ) ) ) ) {
301
  ewwwio_debug_message( 'exactdn (real-world) verification succeeded' );
302
  $this->set_exactdn_option( 'checkin', time() + 3600 );
303
  $this->set_exactdn_option( 'verified', 1, false );
304
  $this->set_exactdn_option( 'suspended', 0 );
305
  return true;
306
  }
307
+ ewwwio_debug_message( 'mime check failed: ' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
308
  }
309
  $this->set_exactdn_option( 'suspended', 1 );
310
  return false;
1983
  return parse_url( $url, $component );
1984
  }
1985
 
1986
+ /**
1987
+ * A wrapper for human_time_diff() that gives sub-minute times in seconds.
1988
+ *
1989
+ * @param int $from Unix timestamp from which the difference begins.
1990
+ * @param int $to Optional. Unix timestamp to end the time difference. Default is time().
1991
+ * @return string Human readable time difference.
1992
+ */
1993
+ function human_time_diff( $from, $to = '' ) {
1994
+ if ( empty( $to ) ) {
1995
+ $to = time();
1996
+ }
1997
+ $diff = (int) abs( $to - $from );
1998
+ if ( $diff < 60 ) {
1999
+ return "$diff sec";
2000
+ }
2001
+ return human_time_diff( $from, $to );
2002
+ }
2003
+
2004
  /**
2005
  * Adds link to header which enables DNS prefetching for faster speed.
2006
  */
common.php CHANGED
@@ -33,7 +33,7 @@ if ( ! defined( 'ABSPATH' ) ) {
33
  exit;
34
  }
35
 
36
- define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '420.0' );
37
 
38
  // Initialize a couple globals.
39
  $ewww_debug = '';
@@ -1730,7 +1730,7 @@ function ewww_image_optimizer_install_table() {
1730
  ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
1731
  $wpdb->query( "UPDATE $wpdb->ewwwio_images SET updated = '1971-01-01 00:00:00' WHERE updated < '1001-01-01 00:00:01'" );
1732
  $column_collate = $wpdb->get_col_charset( $wpdb->ewwwio_images, 'path' );
1733
- if ( ! empty( $column_collate ) && 'utf8mb4' !== $column_collate ) {
1734
  $path_index_size = 255;
1735
  ewwwio_debug_message( "current column collation: $column_collate" );
1736
  if ( strpos( $column_collate, 'utf8' ) === false ) {
@@ -7893,7 +7893,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
7893
  $output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_parallel_optimization'>" . esc_html__( 'Parallel optimization', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_parallel_optimization' name='ewww_image_optimizer_parallel_optimization' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'All resizes generated from a single upload are optimized in parallel for faster optimization. If this is causing performance issues, disable parallel optimization to reduce the load on your server.', 'ewww-image-optimizer' ) . "</td></tr>\n";
7894
  ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? 'on' : 'off' ) );
7895
  ewwwio_debug_message( 'background optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) == true ? 'on' : 'off' ) );
7896
- if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ) {
7897
  $admin_ajax_url = admin_url( 'admin-ajax.php' );
7898
  if ( strpos( $admin_ajax_url, 'admin-ajax.php' ) ) {
7899
  ewwwio_debug_message( "admin ajax url: $admin_ajax_url" );
@@ -7916,6 +7916,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
7916
  'body' => array(
7917
  'ewwwio_test_verify' => '949c34123cf2a4e4ce2f985135830df4a1b2adc24905f53d2fd3f5df5b16293245',
7918
  ),
 
7919
  'sslverify' => false,
7920
  );
7921
  $async_response = wp_remote_post( esc_url_raw( $admin_ajax_url ), $async_post_args );
@@ -7923,7 +7924,10 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
7923
  $error_message = $async_response->get_error_message();
7924
  ewwwio_debug_message( "async test failed: $error_message" );
7925
  } elseif ( is_array( $async_response ) && isset( $async_response['body'] ) ) {
7926
- ewwwio_debug_message( 'async success, possibly: ' . $async_response['body'] );
 
 
 
7927
  } else {
7928
  ewwwio_debug_message( 'no async error, but no body either' );
7929
  }
33
  exit;
34
  }
35
 
36
+ define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '421.0' );
37
 
38
  // Initialize a couple globals.
39
  $ewww_debug = '';
1730
  ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
1731
  $wpdb->query( "UPDATE $wpdb->ewwwio_images SET updated = '1971-01-01 00:00:00' WHERE updated < '1001-01-01 00:00:01'" );
1732
  $column_collate = $wpdb->get_col_charset( $wpdb->ewwwio_images, 'path' );
1733
+ if ( ! empty( $column_collate ) && ! is_wp_error( $column_collate ) && 'utf8mb4' !== $column_collate ) {
1734
  $path_index_size = 255;
1735
  ewwwio_debug_message( "current column collation: $column_collate" );
1736
  if ( strpos( $column_collate, 'utf8' ) === false ) {
7893
  $output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_parallel_optimization'>" . esc_html__( 'Parallel optimization', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_parallel_optimization' name='ewww_image_optimizer_parallel_optimization' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'All resizes generated from a single upload are optimized in parallel for faster optimization. If this is causing performance issues, disable parallel optimization to reduce the load on your server.', 'ewww-image-optimizer' ) . "</td></tr>\n";
7894
  ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? 'on' : 'off' ) );
7895
  ewwwio_debug_message( 'background optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) == true ? 'on' : 'off' ) );
7896
+ if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ) {
7897
  $admin_ajax_url = admin_url( 'admin-ajax.php' );
7898
  if ( strpos( $admin_ajax_url, 'admin-ajax.php' ) ) {
7899
  ewwwio_debug_message( "admin ajax url: $admin_ajax_url" );
7916
  'body' => array(
7917
  'ewwwio_test_verify' => '949c34123cf2a4e4ce2f985135830df4a1b2adc24905f53d2fd3f5df5b16293245',
7918
  ),
7919
+ 'cookies' => $_COOKIE,
7920
  'sslverify' => false,
7921
  );
7922
  $async_response = wp_remote_post( esc_url_raw( $admin_ajax_url ), $async_post_args );
7924
  $error_message = $async_response->get_error_message();
7925
  ewwwio_debug_message( "async test failed: $error_message" );
7926
  } elseif ( is_array( $async_response ) && isset( $async_response['body'] ) ) {
7927
+ ewwwio_debug_message( 'async success, possibly (response should be empty): ' . $async_response['body'] );
7928
+ if ( ! empty( $async_response['response']['code'] ) ) {
7929
+ ewwwio_debug_message( 'async response code: ' . $async_response['response']['code'] );
7930
+ }
7931
  } else {
7932
  ewwwio_debug_message( 'no async error, but no body either' );
7933
  }
ewww-image-optimizer.php CHANGED
@@ -14,7 +14,7 @@ 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: Shane Bishop
16
  Text Domain: ewww-image-optimizer
17
- Version: 4.2.0
18
  Author URI: https://ewww.io/
19
  License: GPLv3
20
  */
14
  Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
15
  Author: Shane Bishop
16
  Text Domain: ewww-image-optimizer
17
+ Version: 4.2.1
18
  Author URI: https://ewww.io/
19
  License: GPLv3
20
  */
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: image, compress, optimize, optimization, lossless, lossy, seo, tinyjpg, ti
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.4
8
- Stable tag: 4.2.0
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.
@@ -177,6 +177,11 @@ http://developer.yahoo.com/performance/rules.html#opt_images
177
  * Feature requests can be submitted via https://ewww.io/contact-us/ and commented on here: https://trello.com/b/Fp81dWof/ewww-image-optimizer
178
  * 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/
179
 
 
 
 
 
 
180
  = 4.2.0 =
181
  * added: disable ExactDN attachment ID queries if they take too long
182
  * added: ExactDN compatibility with a3 Lazy Load
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
  Requires PHP: 5.4
8
+ Stable tag: 4.2.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.
177
  * Feature requests can be submitted via https://ewww.io/contact-us/ and commented on here: https://trello.com/b/Fp81dWof/ewww-image-optimizer
178
  * 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/
179
 
180
+ = 4.2.1 =
181
+ * fixed: EXACTDN_LOCAL_DOMAIN does not work with auto-verification
182
+ * fixed: uncaught error during upgrade when 'SHOW FULL COLUMNS' fails
183
+ * fixed: async simulation gets 403 error
184
+
185
  = 4.2.0 =
186
  * added: disable ExactDN attachment ID queries if they take too long
187
  * added: ExactDN compatibility with a3 Lazy Load