diff --git a/aux-optimize.php b/aux-optimize.php index 599d34b3..3ea4a0ed 100644 --- a/aux-optimize.php +++ b/aux-optimize.php @@ -149,7 +149,7 @@ function ewww_image_optimizer_aux_images_table() { $size_string"; ?>
- +
@@ -177,7 +177,7 @@ function ewww_image_optimizer_aux_images_table() { $size_string"; ?>
- +
diff --git a/bulk.php b/bulk.php index 4e389f52..27d756af 100644 --- a/bulk.php +++ b/bulk.php @@ -51,7 +51,10 @@ function ewww_image_optimizer_display_tools() { '' . "\n" . "\n"; echo $output; - echo "
\n

" . esc_html__( 'The optimization history prevents the plugin from re-optimizing images, but you may erase the history to reduce database size or to force the plugin to re-optimize all images.', 'ewww-image-optimizer' ) . "

\n"; + echo '
'; + echo "
\n

" . + esc_html__( 'The optimization history prevents the plugin from re-optimizing images, but you may erase the history to reduce database size or to force the plugin to re-optimize all images.', 'ewww-image-optimizer' ); + echo "

\n"; echo "
\n" . "\n" . "
\n
\n"; @@ -74,6 +77,10 @@ function ewww_image_optimizer_tool_script( $hook ) { $image_count = ewww_image_optimizer_aux_images_table_count(); // Submit a couple variables for our javascript to work with. $loading_image = plugins_url( '/images/wpspin.gif', __FILE__ ); + $erase_warning = esc_html__( 'Warning: this cannot be undone and will cause a bulk optimize to re-optimize all images.', 'ewww-image-optimizer' ); + if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) { + $erase_warning = esc_html__( 'Warning: this cannot be undone. Re-optimizing images will use additional API credits.', 'ewww-image-optimizer' ); + } wp_localize_script( 'ewwwtoolscript', 'ewww_vars', @@ -85,6 +92,7 @@ function ewww_image_optimizer_tool_script( $hook ) { 'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ), 'original_restored' => esc_html__( 'Original Restored', 'ewww-image-optimizer' ), 'restoring' => '

' . esc_html__( 'Restoring', 'ewww-image-optimizer' ) . " 

", + 'erase_warning' => $erase_warning, ) ); // Load the stylesheet for the jquery progressbar. diff --git a/changelog.txt b/changelog.txt index aa8541c3..d822f86a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ += 5.0.0 = +* added: use native lazy load attributes to supplement lazy loader and make placeholders more efficient +* added: GCS sub-folder rewriting with ExactDN for cleaner URLs +* added: option to optimize original versions of scaled images for WP 5.3 +* added: ability to erase optimization history from Tools page +* changed: define EWWWIO_WPLR_AUTO (any value) to enable auto-optimize on images from WP/LR Sync +* changed: thumbnails could be converted even if original was not +* changed: Show Optimized Images table moved to Tools menu +* fixed: full-size image optimization not deferred if scaled by WP 5.3 +* fixed: data-width and data-height attributes missing when JS WebP active +* security: rewrote escapeshellarg() wrapper to be more secure + = 4.9.3 = * fixed: ExactDN incorrectly scales Elementor background images rather than cropping * fixed: ExactDN cannot work with Divi/Elementor background images due to use of external CSS files diff --git a/common.php b/common.php index 8b37e630..7871ccd9 100644 --- a/common.php +++ b/common.php @@ -22,7 +22,7 @@ exit; } -define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '493.3' ); +define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '500.0' ); // Initialize a couple globals. $eio_debug = ''; @@ -8417,6 +8417,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) { '
'; $status_output .= $savings_guage; $status_output .= '

' . esc_html__( 'Savings', 'ewww-image-optimizer' ) . '

'; + if ( 'network-multisite' !== $network ) { + $status_output .= '

' . esc_html__( 'View optimized images.', 'ewww-image-optimizer' ) . '

'; + } $status_output .= ''; } ewwwio_debug_message( ewww_image_optimizer_aux_images_table_count() . ' images have been optimized' ); diff --git a/ewww-image-optimizer.php b/ewww-image-optimizer.php index 3023661e..8a76f15b 100644 --- a/ewww-image-optimizer.php +++ b/ewww-image-optimizer.php @@ -13,7 +13,7 @@ Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/ Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle. Author: Exactly WWW -Version: 4.9.3 +Version: 5.0.0 Author URI: https://ewww.io/ License: GPLv3 */ diff --git a/includes/eio-tools.js b/includes/eio-tools.js index 90343d83..aa63e9f7 100644 --- a/includes/eio-tools.js +++ b/includes/eio-tools.js @@ -110,12 +110,14 @@ jQuery(document).ready(function($) { action: 'bulk_aux_images_table_clear', ewww_wpnonce: ewww_vars._wpnonce, }; - $.post(ajaxurl, ewww_table_data, function(response) { - $('#ewww-table-info').hide(); - $('#ewww-show-table').hide(); - $('#ewww-clear-table').hide(); - $('#ewww-clear-table-info').html(response); - }); + if (confirm(ewww_vars.erase_warning)) { + $.post(ajaxurl, ewww_table_data, function(response) { + $('#ewww-table-info').hide(); + $('#ewww-show-table').hide(); + $('#ewww-clear-table').hide(); + $('#ewww-clear-table-info').html(response); + }); + } return false; }); }); diff --git a/includes/eio.js b/includes/eio.js index b54ef5ef..e76956b4 100644 --- a/includes/eio.js +++ b/includes/eio.js @@ -234,284 +234,180 @@ jQuery(document).ready(function($) { }); return false; } else { - $(function() { - $("#ewww-delay-slider").slider({ - min: 0, - max: 30, - value: $("#ewww-delay").val(), - slide: function(event, ui) { - $("#ewww-delay").val(ui.value); - } + $(function() { + $("#ewww-delay-slider").slider({ + min: 0, + max: 30, + value: $("#ewww-delay").val(), + slide: function(event, ui) { + $("#ewww-delay").val(ui.value); + } + }); }); - }); - var ewwwdelayinput = document.getElementById("ewww-delay"); - ewwwdelayinput.onblur = function() { - if (isNaN(this.value)) { - this.value = 0; + var ewwwdelayinput = document.getElementById("ewww-delay"); + ewwwdelayinput.onblur = function() { + if (isNaN(this.value)) { + this.value = 0; + } else { + this.value = Math.ceil(this.value); + } + }; + var ewww_attachments = ewww_vars.attachments; + var ewww_i = 0; + var ewww_k = 0; + var ewww_import_total = 0; + var ewww_force = 0; + var ewww_delay = 0; + var ewww_batch_limit = 0; + var ewww_aux = false; + var ewww_main = false; + var ewww_quota_update = 0; + var ewww_scan_failures = 0; + var ewww_bulk_start_time = 0; + var ewww_bulk_elapsed_time = 0; + var ewww_time_per_image = 0; + var ewww_time_remaining = 0; + var ewww_days_remaining = 0; + var ewww_hours_remaining = 0; + var ewww_minutes_remaining = 0; + var ewww_seconds_remaining = 0; + var ewww_countdown = false; + var ewww_tiny_skip = ''; + // initialize the ajax actions for the appropriate bulk page + var ewww_quota_update_data = { + action: 'bulk_quota_update', + ewww_wpnonce: ewww_vars._wpnonce, + }; + if (ewww_vars.gallery == 'flag') { + var ewww_init_action = 'bulk_flag_init'; + var ewww_loop_action = 'bulk_flag_loop'; + var ewww_cleanup_action = 'bulk_flag_cleanup'; + } else if (ewww_vars.gallery == 'nextgen') { + var ewww_preview_action = 'bulk_ngg_preview'; + var ewww_init_action = 'bulk_ngg_init'; + var ewww_loop_action = 'bulk_ngg_loop'; + var ewww_cleanup_action = 'bulk_ngg_cleanup'; } else { - this.value = Math.ceil(this.value); - } - }; - var ewww_attachments = ewww_vars.attachments; - var ewww_i = 0; - var ewww_k = 0; - var ewww_import_total = 0; - var ewww_force = 0; - var ewww_delay = 0; - var ewww_batch_limit = 0; - var ewww_aux = false; - var ewww_main = false; - var ewww_quota_update = 0; - var ewww_scan_failures = 0; - var ewww_bulk_start_time = 0; - var ewww_bulk_elapsed_time = 0; - var ewww_time_per_image = 0; - var ewww_time_remaining = 0; - var ewww_days_remaining = 0; - var ewww_hours_remaining = 0; - var ewww_minutes_remaining = 0; - var ewww_seconds_remaining = 0; - var ewww_countdown = false; - var ewww_tiny_skip = ''; - // initialize the ajax actions for the appropriate bulk page - var ewww_quota_update_data = { - action: 'bulk_quota_update', - ewww_wpnonce: ewww_vars._wpnonce, - }; - if (ewww_vars.gallery == 'flag') { - var ewww_init_action = 'bulk_flag_init'; - var ewww_loop_action = 'bulk_flag_loop'; - var ewww_cleanup_action = 'bulk_flag_cleanup'; - } else if (ewww_vars.gallery == 'nextgen') { - var ewww_preview_action = 'bulk_ngg_preview'; - var ewww_init_action = 'bulk_ngg_init'; - var ewww_loop_action = 'bulk_ngg_loop'; - var ewww_cleanup_action = 'bulk_ngg_cleanup'; - } else { - var ewww_scan_action = 'bulk_scan'; - var ewww_init_action = 'bulk_init'; - var ewww_loop_action = 'bulk_loop'; - var ewww_cleanup_action = 'bulk_cleanup'; - ewww_main = true; - } - var ewww_init_data = { - action: ewww_init_action, - ewww_wpnonce: ewww_vars._wpnonce, - }; - var ewww_table_action = 'bulk_aux_images_table'; - var ewww_table_count_action = 'bulk_aux_images_table_count'; - var ewww_import_init_action = 'bulk_import_init'; - var ewww_import_loop_action = 'bulk_import_loop'; - $(document).on('click', '.ewww-show-debug-meta', function() { - var post_id = $(this).data('id'); - $('.ewww-debug-meta-' + post_id).toggle(); - }); - $('#ewww-aux-start').submit(function() { - ewww_aux = true; - //ewww_init_action = 'bulk_init'; - //ewww_loop_action = 'bulk_aux_images_loop'; - //ewww_cleanup_action = 'bulk_aux_images_cleanup'; - if ($('#ewww-force:checkbox:checked').val()) { - ewww_force = 1; + var ewww_scan_action = 'bulk_scan'; + var ewww_init_action = 'bulk_init'; + var ewww_loop_action = 'bulk_loop'; + var ewww_cleanup_action = 'bulk_cleanup'; + ewww_main = true; } - $('#ewww-aux-start').hide(); - $('.ewww-bulk-info').hide(); - $('.ewww-aux-table').hide(); - $('#ewww-show-table').hide(); - $('#ewww-scanning').show(); - //ewww_vars.scanning = $('#ewww-scanning').html(); - ewwwStartScan(); - return false; - }); - function ewwwStartScan() { - var ewww_scan_data = { - action: ewww_scan_action, - ewww_force: ewww_force, - ewww_scan: true, + var ewww_init_data = { + action: ewww_init_action, ewww_wpnonce: ewww_vars._wpnonce, }; - $.post(ajaxurl, ewww_scan_data, function(response) { - var is_json = true; - try { - var ewww_response = $.parseJSON(response); - } catch (err) { - is_json = false; - } - if ( ! is_json ) { - $('#ewww-scanning').html('' + ewww_vars.invalid_response + ''); - console.log( response ); - return false; + var ewww_table_action = 'bulk_aux_images_table'; + var ewww_table_count_action = 'bulk_aux_images_table_count'; + var ewww_import_init_action = 'bulk_import_init'; + var ewww_import_loop_action = 'bulk_import_loop'; + $(document).on('click', '.ewww-show-debug-meta', function() { + var post_id = $(this).data('id'); + $('.ewww-debug-meta-' + post_id).toggle(); + }); + $('#ewww-aux-start').submit(function() { + ewww_aux = true; + //ewww_init_action = 'bulk_init'; + //ewww_loop_action = 'bulk_aux_images_loop'; + //ewww_cleanup_action = 'bulk_aux_images_cleanup'; + if ($('#ewww-force:checkbox:checked').val()) { + ewww_force = 1; } - ewww_init_data = { - action: ewww_init_action, + $('#ewww-aux-start').hide(); + $('.ewww-bulk-info').hide(); + $('.ewww-aux-table').hide(); + $('#ewww-show-table').hide(); + $('#ewww-scanning').show(); + //ewww_vars.scanning = $('#ewww-scanning').html(); + ewwwStartScan(); + return false; + }); + function ewwwStartScan() { + var ewww_scan_data = { + action: ewww_scan_action, + ewww_force: ewww_force, + ewww_scan: true, ewww_wpnonce: ewww_vars._wpnonce, }; - if ( ewww_response.error ) { - $('#ewww-scanning').html('' + ewww_response.error + ''); - } else if ( ewww_response.remaining ) { - $('.ewww-aux-table').hide(); - $('#ewww-show-table').hide(); - //if ( ! ewww_response.notice ) { - // ewww_response.notice = ''; - //} - $('#ewww-scanning').html( ewww_response.remaining ); - if ( ewww_response.notice ) { - $('#ewww-scanning').append( '
' + ewww_response.notice ); + $.post(ajaxurl, ewww_scan_data, function(response) { + var is_json = true; + try { + var ewww_response = $.parseJSON(response); + } catch (err) { + is_json = false; } - if ( ewww_response.tiny_skip ) { - $('#ewww-scanning').append( '
' + ewww_response.tiny_skip ); - ewww_tiny_skip = ewww_response.tiny_skip; - console.log( 'skipped some tiny images' ); - } - if ( ewww_response.bad_attachment ) { - $('#ewww-scanning').append( '
' + ewww_vars.bad_attachment + ' ' + ewww_response.bad_attachment ); + if ( ! is_json ) { + $('#ewww-scanning').html('' + ewww_vars.invalid_response + ''); + console.log( response ); + return false; } - ewww_scan_failures = 0; - ewwwStartScan(); - } else if ( ewww_response.ready ) { - ewww_attachments = ewww_response.ready; - if (ewww_attachments == 0) { - // $('#ewww-bulk-loading').hide(); - $('#ewww-scanning').hide(); - $('#ewww-nothing').show(); - if ( ewww_tiny_skip ) { - $('#ewww-nothing').append( '
' + ewww_tiny_skip + '' ); - console.log( 'done, skipped some tiny images' ); + ewww_init_data = { + action: ewww_init_action, + ewww_wpnonce: ewww_vars._wpnonce, + }; + if ( ewww_response.error ) { + $('#ewww-scanning').html('' + ewww_response.error + ''); + } else if ( ewww_response.remaining ) { + $('.ewww-aux-table').hide(); + $('#ewww-show-table').hide(); + //if ( ! ewww_response.notice ) { + // ewww_response.notice = ''; + //} + $('#ewww-scanning').html( ewww_response.remaining ); + if ( ewww_response.notice ) { + $('#ewww-scanning').append( '
' + ewww_response.notice ); } - //$('#ewww-aux-start').show(); - //$('#ewww-aux-again').show(); - //$('#ewww-aux-first').hide(); - } else { - $('#ewww-scanning').html(ewww_response.message); - if ( ewww_tiny_skip ) { - $('#ewww-scanning').append( '
' + ewww_tiny_skip + '' ); - console.log( 'done, skipped some tiny images' ); + if ( ewww_response.tiny_skip ) { + $('#ewww-scanning').append( '
' + ewww_response.tiny_skip ); + ewww_tiny_skip = ewww_response.tiny_skip; + console.log( 'skipped some tiny images' ); } - $('#ewww-bulk-start').show(); -// ewwwStartOpt(); - } - } - }) - .fail(function() { - ewww_scan_failures++; - if (ewww_scan_failures > 10) { - $('#ewww-scanning').html('' + ewww_vars.scan_fail + ': ' + ewww_vars.bulk_fail_more + ''); - } else { - $('#ewww-scanning').html('' + ewww_vars.scan_incomplete + ''); - setTimeout(function() { + if ( ewww_response.bad_attachment ) { + $('#ewww-scanning').append( '
' + ewww_vars.bad_attachment + ' ' + ewww_response.bad_attachment ); + } + ewww_scan_failures = 0; ewwwStartScan(); - }, 1000); - } - }); - } - $('#ewww-show-table').submit(function() { - var ewww_pointer = 0; - var ewww_total_pages = Math.ceil(ewww_vars.image_count / 50); - $('.ewww-aux-table').show(); - $('#ewww-show-table').hide(); - $('#ewww-table-info').hide(); - if (ewww_vars.image_count >= 50) { - $('.tablenav').show(); - $('#next-images').show(); - $('.last-page').show(); - } - var ewww_table_data = { - action: ewww_table_action, - ewww_wpnonce: ewww_vars._wpnonce, - ewww_offset: ewww_pointer, - }; - $('.displaying-num').text(ewww_vars.count_string); - $.post(ajaxurl, ewww_table_data, function(response) { - $('#ewww-bulk-table').html(response); - }); - $('.current-page').text(ewww_pointer + 1); - $('.total-pages').text(ewww_total_pages); - $('#ewww-pointer').text(ewww_pointer); - return false; - }); - $('#next-images').click(function() { - var ewww_pointer = $('#ewww-pointer').text(); - ewww_pointer++; - var ewww_table_data = { - action: ewww_table_action, - ewww_wpnonce: ewww_vars._wpnonce, - ewww_offset: ewww_pointer, - }; - $.post(ajaxurl, ewww_table_data, function(response) { - $('#ewww-bulk-table').html(response); - }); - if (ewww_vars.image_count <= ((ewww_pointer + 1) * 50)) { - $('#next-images').hide(); - $('.last-page').hide(); - } - $('.current-page').text(ewww_pointer + 1); - $('#ewww-pointer').text(ewww_pointer); - $('#prev-images').show(); - $('.first-page').show(); - return false; - }); - $('#prev-images').click(function() { - var ewww_pointer = $('#ewww-pointer').text(); - ewww_pointer--; - var ewww_table_data = { - action: ewww_table_action, - ewww_wpnonce: ewww_vars._wpnonce, - ewww_offset: ewww_pointer, - }; - $.post(ajaxurl, ewww_table_data, function(response) { - $('#ewww-bulk-table').html(response); - }); - if (!ewww_pointer) { - $('#prev-images').hide(); - $('.first-page').hide(); + } else if ( ewww_response.ready ) { + ewww_attachments = ewww_response.ready; + if (ewww_attachments == 0) { + // $('#ewww-bulk-loading').hide(); + $('#ewww-scanning').hide(); + $('#ewww-nothing').show(); + if ( ewww_tiny_skip ) { + $('#ewww-nothing').append( '
' + ewww_tiny_skip + '' ); + console.log( 'done, skipped some tiny images' ); + } + //$('#ewww-aux-start').show(); + //$('#ewww-aux-again').show(); + //$('#ewww-aux-first').hide(); + } else { + $('#ewww-scanning').html(ewww_response.message); + if ( ewww_tiny_skip ) { + $('#ewww-scanning').append( '
' + ewww_tiny_skip + '' ); + console.log( 'done, skipped some tiny images' ); + } + $('#ewww-bulk-start').show(); + // ewwwStartOpt(); + } + } + }) + .fail(function() { + ewww_scan_failures++; + if (ewww_scan_failures > 10) { + $('#ewww-scanning').html('' + ewww_vars.scan_fail + ': ' + ewww_vars.bulk_fail_more + ''); + } else { + $('#ewww-scanning').html('' + ewww_vars.scan_incomplete + ''); + setTimeout(function() { + ewwwStartScan(); + }, 1000); + } + }); } - $('.current-page').text(ewww_pointer + 1); - $('#ewww-pointer').text(ewww_pointer); - $('#next-images').show(); - $('.last-page').show(); - return false; - }); - $('.last-page').click(function() { - var ewww_pointer = $('.total-pages').text(); - ewww_pointer--; - var ewww_table_data = { - action: ewww_table_action, - ewww_wpnonce: ewww_vars._wpnonce, - ewww_offset: ewww_pointer, - }; - $.post(ajaxurl, ewww_table_data, function(response) { - $('#ewww-bulk-table').html(response); - }); - $('#next-images').hide(); - $('.last-page').hide(); - $('.current-page').text(ewww_pointer + 1); - $('#ewww-pointer').text(ewww_pointer); - $('#prev-images').show(); - $('.first-page').show(); - return false; - }); - $('.first-page').click(function() { - var ewww_pointer = 0; - var ewww_table_data = { - action: ewww_table_action, - ewww_wpnonce: ewww_vars._wpnonce, - ewww_offset: ewww_pointer, - }; - $.post(ajaxurl, ewww_table_data, function(response) { - $('#ewww-bulk-table').html(response); + $('#ewww-bulk-start').submit(function() { + ewwwStartOpt(); + return false; }); - $('#prev-images').hide(); - $('.first-page').hide(); - $('.current-page').text(ewww_pointer + 1); - $('#ewww-pointer').text(ewww_pointer); - $('#next-images').show(); - $('.last-page').show(); - return false; - }); - $('#ewww-bulk-start').submit(function() { - ewwwStartOpt(); - return false; - }); } function ewwwUpdateQuota() { if ($('#ewww-bulk-credits-available').length > 0) { diff --git a/readme.txt b/readme.txt index 0d423892..833f1b0e 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: nosilver4u Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale Requires at least: 5.0 -Tested up to: 5.2 +Tested up to: 5.3 Requires PHP: 5.6 -Stable tag: 4.9.3 +Stable tag: 5.0.0 License: GPLv3 Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales. @@ -173,7 +173,7 @@ https://developers.google.com/web/tools/lighthouse/audits/optimize-images * Feature requests can be viewed and submitted at https://github.com/nosilver4u/ewww-image-optimizer/labels/enhancement * 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/ -= 4.9.4 = += 5.0.0 = * added: use native lazy load attributes to supplement lazy loader and make placeholders more efficient * added: GCS sub-folder rewriting with ExactDN for cleaner URLs * added: option to optimize original versions of scaled images for WP 5.3 @@ -181,7 +181,7 @@ https://developers.google.com/web/tools/lighthouse/audits/optimize-images * changed: define EWWWIO_WPLR_AUTO (any value) to enable auto-optimize on images from WP/LR Sync * changed: thumbnails could be converted even if original was not * changed: Show Optimized Images table moved to Tools menu -* fixed: full size image optimization not deferred if scaled by WP 5.3 +* fixed: full-size image optimization not deferred if scaled by WP 5.3 * fixed: data-width and data-height attributes missing when JS WebP active * security: rewrote escapeshellarg() wrapper to be more secure