Version Description
- changed: prevent unintentional image re-optimization from plugins with a threshold of 5x, indicate intential regen with ewww_image_optimizer_allowed_reopt filter
- changed: include lazy load and WebP in optimization score
- fixed: query paramaters added to videos via image_downsize filter
- fixed: WP-CLI command triggers async queueing
- fixed: WPML check skips too many images during bulk scanner
- fixed: WP-CLI command options for FlAGallery and NextGEN using outdated code
- fixed: re-optimization tracker not tracking
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 5.6.1 |
Comparing to | |
See all releases |
Code changes from version 5.6.0 to 5.6.1
- .travis.yml +4 -4
- aux-optimize.php +1 -1
- bulk.php +9 -5
- changelog.txt +9 -0
- classes/class-ewww-flag.php +1 -1
- classes/class-ewww-nextcellent.php +1 -1
- classes/class-ewww-nextgen.php +3 -2
- classes/class-ewwwio-cli.php +75 -87
- classes/class-exactdn.php +6 -1
- common.php +142 -89
- ewww-image-optimizer.php +1 -1
- includes/jquery-ui-1.10.1.custom.css +17 -6
- readme.txt +12 -80
- unique.php +1 -1
.travis.yml
CHANGED
@@ -13,23 +13,23 @@ branches:
|
|
13 |
|
14 |
php:
|
15 |
- 5.6
|
16 |
-
- 7.
|
17 |
|
18 |
services:
|
19 |
- mysql
|
20 |
|
21 |
env:
|
22 |
- WP_VERSION=latest WP_MULTISITE=0
|
23 |
-
- WP_VERSION=5.
|
24 |
|
25 |
jobs:
|
26 |
include:
|
27 |
- php: 5.6
|
28 |
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
29 |
- php: 7.2
|
30 |
-
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
31 |
-
- php: 7.3
|
32 |
env: WP_VERSION=latest
|
|
|
|
|
33 |
- php: 7.4
|
34 |
env: WP_VERSION=latest
|
35 |
|
13 |
|
14 |
php:
|
15 |
- 5.6
|
16 |
+
- 7.3
|
17 |
|
18 |
services:
|
19 |
- mysql
|
20 |
|
21 |
env:
|
22 |
- WP_VERSION=latest WP_MULTISITE=0
|
23 |
+
- WP_VERSION=5.1 WP_MULTISITE=0
|
24 |
|
25 |
jobs:
|
26 |
include:
|
27 |
- php: 5.6
|
28 |
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
29 |
- php: 7.2
|
|
|
|
|
30 |
env: WP_VERSION=latest
|
31 |
+
- php: 7.3
|
32 |
+
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
33 |
- php: 7.4
|
34 |
env: WP_VERSION=latest
|
35 |
|
aux-optimize.php
CHANGED
@@ -1217,7 +1217,7 @@ function ewww_image_optimizer_aux_images_script( $hook = '' ) {
|
|
1217 |
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
1218 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
1219 |
ewww_image_optimizer_debug_log();
|
1220 |
-
if ( wp_doing_ajax() && 'ewww-image-optimizer-auto' !== $hook ) {
|
1221 |
$verify_cloud = ewww_image_optimizer_cloud_verify( false );
|
1222 |
$usage = false;
|
1223 |
if ( preg_match( '/great/', $verify_cloud ) ) {
|
1217 |
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
1218 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
1219 |
ewww_image_optimizer_debug_log();
|
1220 |
+
if ( wp_doing_ajax() && 'ewww-image-optimizer-auto' !== $hook && ( ! defined( 'WP_CLI' ) || ! WP_CLI ) ) {
|
1221 |
$verify_cloud = ewww_image_optimizer_cloud_verify( false );
|
1222 |
$usage = false;
|
1223 |
if ( preg_match( '/great/', $verify_cloud ) ) {
|
bulk.php
CHANGED
@@ -1059,9 +1059,12 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
1059 |
$pending = false;
|
1060 |
$remote_file = false;
|
1061 |
if ( ! empty( $attachment_meta[ $selected_id ]['wpml_media_processed'] ) ) {
|
1062 |
-
|
1063 |
-
$
|
1064 |
-
|
|
|
|
|
|
|
1065 |
}
|
1066 |
if ( in_array( $selected_id, $bad_attachments, true ) ) { // a known broken attachment, which would mean we already tried this once before...
|
1067 |
ewwwio_debug_message( "skipping bad attachment $selected_id" );
|
@@ -1763,6 +1766,7 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1763 |
$ewww_defer = false;
|
1764 |
$output = array();
|
1765 |
$time_adjustment = 0;
|
|
|
1766 |
// Verify that an authorized user has started the optimizer.
|
1767 |
$permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
|
1768 |
if (
|
@@ -1989,13 +1993,13 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1989 |
// Output how much time has elapsed since we started.
|
1990 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
1991 |
/* translators: %s: number of seconds */
|
1992 |
-
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed ) ) );
|
1993 |
if ( ewww_image_optimizer_function_exists( 'sleep' ) ) {
|
1994 |
sleep( $delay );
|
1995 |
}
|
1996 |
}
|
1997 |
/* translators: %s: number of seconds */
|
1998 |
-
$output['results'] .= sprintf( '<p>' . esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed ) );
|
1999 |
// Store the updated list of attachment IDs back in the 'bulk_attachments' option.
|
2000 |
// update_option( 'ewww_image_optimizer_bulk_attachments', $attachments, false );.
|
2001 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
1059 |
$pending = false;
|
1060 |
$remote_file = false;
|
1061 |
if ( ! empty( $attachment_meta[ $selected_id ]['wpml_media_processed'] ) ) {
|
1062 |
+
$wpml_id = ewww_image_optimizer_get_primary_wpml_id( $selected_id );
|
1063 |
+
if ( (int) $wpml_id !== (int) $selected_id ) {
|
1064 |
+
ewwwio_debug_message( "skipping WPML replica image $selected_id" );
|
1065 |
+
$skipped_ids[] = $selected_id;
|
1066 |
+
continue;
|
1067 |
+
}
|
1068 |
}
|
1069 |
if ( in_array( $selected_id, $bad_attachments, true ) ) { // a known broken attachment, which would mean we already tried this once before...
|
1070 |
ewwwio_debug_message( "skipping bad attachment $selected_id" );
|
1766 |
$ewww_defer = false;
|
1767 |
$output = array();
|
1768 |
$time_adjustment = 0;
|
1769 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1770 |
// Verify that an authorized user has started the optimizer.
|
1771 |
$permissions = apply_filters( 'ewww_image_optimizer_bulk_permissions', '' );
|
1772 |
if (
|
1993 |
// Output how much time has elapsed since we started.
|
1994 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
1995 |
/* translators: %s: number of seconds */
|
1996 |
+
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed, 2 ) ) );
|
1997 |
if ( ewww_image_optimizer_function_exists( 'sleep' ) ) {
|
1998 |
sleep( $delay );
|
1999 |
}
|
2000 |
}
|
2001 |
/* translators: %s: number of seconds */
|
2002 |
+
$output['results'] .= sprintf( '<p>' . esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed, 1 ) );
|
2003 |
// Store the updated list of attachment IDs back in the 'bulk_attachments' option.
|
2004 |
// update_option( 'ewww_image_optimizer_bulk_attachments', $attachments, false );.
|
2005 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
changelog.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 5.6.0 =
|
2 |
* added: if exec() is disabled, free cloud-based JPG compression will be enabled
|
3 |
* added: tool to remove originals for converted images
|
1 |
+
= 5.6.1 =
|
2 |
+
* changed: prevent unintentional image re-optimization from plugins with a threshold of 5x, indicate intential regen with ewww_image_optimizer_allowed_reopt filter
|
3 |
+
* changed: include lazy load and WebP in optimization score
|
4 |
+
* fixed: query paramaters added to videos via image_downsize filter
|
5 |
+
* fixed: WP-CLI command triggers async queueing
|
6 |
+
* fixed: WPML check skips too many images during bulk scanner
|
7 |
+
* fixed: WP-CLI command options for FlAGallery and NextGEN using outdated code
|
8 |
+
* fixed: re-optimization tracker not tracking
|
9 |
+
|
10 |
= 5.6.0 =
|
11 |
* added: if exec() is disabled, free cloud-based JPG compression will be enabled
|
12 |
* added: tool to remove originals for converted images
|
classes/class-ewww-flag.php
CHANGED
@@ -643,7 +643,7 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
|
|
643 |
$elapsed = microtime( true ) - $started;
|
644 |
// And output it to the user.
|
645 |
/* Translators: %s: number of seconds, localized */
|
646 |
-
$output['results'] .= sprintf( esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed ) );
|
647 |
$output['completed'] = 1;
|
648 |
// Send the list back to the db.
|
649 |
update_option( 'ewww_image_optimizer_bulk_flag_attachments', $attachments, false );
|
643 |
$elapsed = microtime( true ) - $started;
|
644 |
// And output it to the user.
|
645 |
/* Translators: %s: number of seconds, localized */
|
646 |
+
$output['results'] .= sprintf( esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed, 2 ) );
|
647 |
$output['completed'] = 1;
|
648 |
// Send the list back to the db.
|
649 |
update_option( 'ewww_image_optimizer_bulk_flag_attachments', $attachments, false );
|
classes/class-ewww-nextcellent.php
CHANGED
@@ -632,7 +632,7 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
632 |
// Output how much time we spent.
|
633 |
$elapsed = microtime( true ) - $started;
|
634 |
/* Translators: %s: localized number of seconds */
|
635 |
-
$output['results'] .= sprintf( esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed ) );
|
636 |
$output['completed'] = 1;
|
637 |
// Store the list back in the db.
|
638 |
update_option( 'ewww_image_optimizer_bulk_ngg_attachments', $attachments, false );
|
632 |
// Output how much time we spent.
|
633 |
$elapsed = microtime( true ) - $started;
|
634 |
/* Translators: %s: localized number of seconds */
|
635 |
+
$output['results'] .= sprintf( esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed, 2 ) );
|
636 |
$output['completed'] = 1;
|
637 |
// Store the list back in the db.
|
638 |
update_option( 'ewww_image_optimizer_bulk_ngg_attachments', $attachments, false );
|
classes/class-ewww-nextgen.php
CHANGED
@@ -23,12 +23,13 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
23 |
* @access private
|
24 |
* @var array $bulk_sizes
|
25 |
*/
|
26 |
-
|
27 |
|
28 |
/**
|
29 |
* Initializes the nextgen integration functions.
|
30 |
*/
|
31 |
public function __construct() {
|
|
|
32 |
add_filter( 'ngg_manage_images_number_of_columns', array( $this, 'ewww_manage_images_number_of_columns' ) );
|
33 |
add_filter( 'ngg_manage_images_columns', array( $this, 'manage_images_columns' ) );
|
34 |
add_filter( 'ngg_manage_images_row_actions', array( $this, 'ewww_manage_images_row_actions' ) );
|
@@ -962,7 +963,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
962 |
// Output how much time we spent.
|
963 |
$elapsed = microtime( true ) - $started;
|
964 |
/* Translators: %s: The localized number of seconds */
|
965 |
-
$output['results'] .= sprintf( esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed ) );
|
966 |
$output['completed'] = 1;
|
967 |
// Store the list back in the db.
|
968 |
update_option( 'ewww_image_optimizer_bulk_ngg_attachments', $attachments, false );
|
23 |
* @access private
|
24 |
* @var array $bulk_sizes
|
25 |
*/
|
26 |
+
public $bulk_sizes = array();
|
27 |
|
28 |
/**
|
29 |
* Initializes the nextgen integration functions.
|
30 |
*/
|
31 |
public function __construct() {
|
32 |
+
ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
|
33 |
add_filter( 'ngg_manage_images_number_of_columns', array( $this, 'ewww_manage_images_number_of_columns' ) );
|
34 |
add_filter( 'ngg_manage_images_columns', array( $this, 'manage_images_columns' ) );
|
35 |
add_filter( 'ngg_manage_images_row_actions', array( $this, 'ewww_manage_images_row_actions' ) );
|
963 |
// Output how much time we spent.
|
964 |
$elapsed = microtime( true ) - $started;
|
965 |
/* Translators: %s: The localized number of seconds */
|
966 |
+
$output['results'] .= sprintf( esc_html( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ) ) . '</p>', number_format_i18n( $elapsed, 2 ) );
|
967 |
$output['completed'] = 1;
|
968 |
// Store the list back in the db.
|
969 |
update_option( 'ewww_image_optimizer_bulk_ngg_attachments', $attachments, false );
|
classes/class-ewwwio-cli.php
CHANGED
@@ -25,7 +25,7 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
25 |
* : valid values are 'all' (default), 'media', 'nextgen', and 'flagallery'
|
26 |
* : media: Media Library, theme, and configured folders
|
27 |
* : nextgen: Nextcellent and NextGEN 2.x
|
28 |
-
* : flagallery: Grand
|
29 |
*
|
30 |
* <delay>
|
31 |
* : optional, number of seconds to pause between images
|
@@ -45,7 +45,6 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
45 |
* @synopsis <library> [<delay>] [--force] [--reset] [--noprompt]
|
46 |
*
|
47 |
* @global bool $ewww_defer Gets set to false to make sure optimization happens inline.
|
48 |
-
* @global object $ngg
|
49 |
*
|
50 |
* @param array $args A numeric array of required arguments.
|
51 |
* @param array $assoc_args An associative array of optional arguments.
|
@@ -99,44 +98,37 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
99 |
// Do a filter to increase the timeout to 999 or something crazy.
|
100 |
add_filter( 'ewww_image_optimizer_timeout', 'ewww_image_optimizer_cli_timeout', 200 );
|
101 |
ewww_image_optimizer_media_scan( 'ewww-image-optimizer-cli' );
|
102 |
-
$pending_count = ewww_image_optimizer_aux_images_script( 'ewww-image-optimizer-
|
103 |
-
if ( class_exists( '
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
/* translators: %d: number of images */
|
112 |
-
WP_CLI::line( 'Nextgen: ' . sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', count( $attachments ), 'ewww-image-optimizer' ), count( $attachments ) ) );
|
113 |
-
}
|
114 |
}
|
115 |
-
if ( class_exists( '
|
116 |
-
list( $fullsize_count, $
|
117 |
-
/* translators: 1-
|
118 |
-
WP_CLI::line( '
|
119 |
}
|
120 |
if ( empty( $assoc_args['noprompt'] ) ) {
|
121 |
/* translators: %d: number of images */
|
122 |
WP_CLI::confirm( sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', $pending_count, 'ewww-image-optimizer' ), $pending_count ) );
|
123 |
}
|
124 |
-
/* ewww_image_optimizer_bulk_media( $delay ); */
|
125 |
$_REQUEST['ewww_batch_limit'] = 1;
|
126 |
while ( ewww_image_optimizer_bulk_loop( 'ewww-image-optimizer-cli', $delay ) ) {
|
127 |
$something = 1;
|
128 |
}
|
129 |
ewww_image_optimizer_bulk_media_cleanup();
|
130 |
-
if ( class_exists( '
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
$attachments = ewww_image_optimizer_scan_next();
|
136 |
-
ewww_image_optimizer_bulk_next( $delay, $attachments );
|
137 |
-
}
|
138 |
}
|
139 |
-
if ( class_exists( '
|
140 |
ewww_image_optimizer_bulk_flag( $delay );
|
141 |
}
|
142 |
break;
|
@@ -159,7 +151,7 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
159 |
// Do a filter to increase the timeout to 999 or something crazy.
|
160 |
add_filter( 'ewww_image_optimizer_timeout', 'ewww_image_optimizer_cli_timeout', 200 );
|
161 |
ewww_image_optimizer_media_scan( 'ewww-image-optimizer-cli' );
|
162 |
-
$pending_count = ewww_image_optimizer_aux_images_script( 'ewww-image-optimizer-
|
163 |
if ( empty( $assoc_args['noprompt'] ) ) {
|
164 |
/* translators: %d: number of images */
|
165 |
WP_CLI::confirm( sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', $pending_count, 'ewww-image-optimizer' ), $pending_count ) );
|
@@ -175,23 +167,20 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
175 |
update_option( 'ewww_image_optimizer_bulk_ngg_resume', '' );
|
176 |
WP_CLI::line( __( 'Bulk status has been reset, starting from the beginning.', 'ewww-image-optimizer' ) );
|
177 |
}
|
178 |
-
if ( class_exists( '
|
179 |
-
|
180 |
-
if (
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
/* translators: %d: number of images */
|
191 |
-
WP_CLI::confirm( sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', count( $attachments ), 'ewww-image-optimizer' ), count( $attachments ) ) );
|
192 |
-
}
|
193 |
-
ewww_image_optimizer_bulk_next( $delay, $attachments );
|
194 |
}
|
|
|
195 |
} else {
|
196 |
WP_CLI::error( __( 'NextGEN/Nextcellent not installed.', 'ewww-image-optimizer' ) );
|
197 |
}
|
@@ -201,11 +190,11 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
201 |
update_option( 'ewww_image_optimizer_bulk_flag_resume', '' );
|
202 |
WP_CLI::line( __( 'Bulk status has been reset, starting from the beginning.', 'ewww-image-optimizer' ) );
|
203 |
}
|
204 |
-
if ( class_exists( '
|
205 |
-
list( $fullsize_count, $
|
206 |
if ( empty( $assoc_args['noprompt'] ) ) {
|
207 |
-
/* translators: 1-
|
208 |
-
WP_CLI::confirm( sprintf( __( '%1$d images have been selected
|
209 |
}
|
210 |
ewww_image_optimizer_bulk_flag( $delay );
|
211 |
} else {
|
@@ -235,7 +224,6 @@ function ewww_image_optimizer_bulk_media_cleanup() {
|
|
235 |
// All done, so we can update the bulk options with empty values...
|
236 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
237 |
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
238 |
-
update_option( 'ewww_image_optimizer_bulk_attachments', '', false );
|
239 |
// and let the user know we are done.
|
240 |
WP_CLI::success( __( 'Finished Optimization!', 'ewww-image-optimizer' ) );
|
241 |
}
|
@@ -259,6 +247,7 @@ function ewww_image_optimizer_bulk_flag( $delay = 0 ) {
|
|
259 |
// Store the IDs to optimize in the options table of the db.
|
260 |
update_option( 'ewww_image_optimizer_bulk_flag_attachments', $ids, false );
|
261 |
}
|
|
|
262 |
// Set the resume flag to indicate the bulk operation is in progress.
|
263 |
update_option( 'ewww_image_optimizer_bulk_flag_resume', 'true' );
|
264 |
// Need this file to work with flag meta.
|
@@ -274,8 +263,10 @@ function ewww_image_optimizer_bulk_flag( $delay = 0 ) {
|
|
274 |
// Record the starting time for the current image (in microseconds).
|
275 |
$started = microtime( true );
|
276 |
// Retrieve the meta for the current ID.
|
277 |
-
$meta
|
278 |
-
$file_path
|
|
|
|
|
279 |
// Optimize the full-size version.
|
280 |
$fres = ewww_image_optimizer( $file_path, 3, false, false, true );
|
281 |
WP_CLI::line( __( 'Optimized image:', 'ewww-image-optimizer' ) . ' ' . esc_html( $meta->image->filename ) );
|
@@ -283,12 +274,16 @@ function ewww_image_optimizer_bulk_flag( $delay = 0 ) {
|
|
283 |
WP_CLI::line( sprintf( __( 'Full size – %s', 'ewww-image-optimizer' ), html_entity_decode( $fres[1] ) ) );
|
284 |
if ( ! empty( $meta->image->meta_data['webview'] ) ) {
|
285 |
// Determine path of the webview.
|
286 |
-
$web_path
|
287 |
-
$
|
|
|
|
|
288 |
/* translators: %s: compression results */
|
289 |
WP_CLI::line( sprintf( __( 'Optimized size – %s', 'ewww-image-optimizer' ), html_entity_decode( $wres[1] ) ) );
|
290 |
}
|
291 |
-
$thumb_path
|
|
|
|
|
292 |
// Optimize the thumbnail.
|
293 |
$tres = ewww_image_optimizer( $thumb_path, 3, false, true );
|
294 |
/* translators: %s: compression results */
|
@@ -297,9 +292,7 @@ function ewww_image_optimizer_bulk_flag( $delay = 0 ) {
|
|
297 |
$elapsed = microtime( true ) - $started;
|
298 |
// and output it to the user.
|
299 |
/* translators: %s: localized number of seconds */
|
300 |
-
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed ) ) );
|
301 |
-
// Retrieve the list of attachments left to work on.
|
302 |
-
$attachments = get_option( 'ewww_image_optimizer_bulk_flag_attachments' );
|
303 |
// Take the first image off the list.
|
304 |
if ( ! empty( $attachments ) ) {
|
305 |
array_shift( $attachments );
|
@@ -359,7 +352,10 @@ function ewww_image_optimizer_bulk_ngg( $delay = 0 ) {
|
|
359 |
WP_CLI::line( __( 'You do not appear to have uploaded any images yet.', 'ewww-image-optimizer' ) );
|
360 |
return;
|
361 |
}
|
|
|
362 |
global $ewwwngg;
|
|
|
|
|
363 |
foreach ( $images as $id ) {
|
364 |
if ( ewww_image_optimizer_function_exists( 'sleep' ) ) {
|
365 |
sleep( $delay );
|
@@ -375,30 +371,29 @@ function ewww_image_optimizer_bulk_ngg( $delay = 0 ) {
|
|
375 |
$image = $ewwwngg->ewww_added_new_image( $image, $storage );
|
376 |
// Output the results of the optimization.
|
377 |
WP_CLI::line( __( 'Optimized image:', 'ewww-image-optimizer' ) . ' ' . basename( $storage->object->get_image_abspath( $image, 'full' ) ) );
|
378 |
-
|
379 |
-
$sizes = $storage->get_image_sizes();
|
380 |
-
if ( ewww_image_optimizer_iterable( $sizes ) ) {
|
381 |
// Output the results for each $size.
|
382 |
-
foreach ( $
|
383 |
-
if ( '
|
|
|
|
|
384 |
/* translators: %s: compression results */
|
385 |
-
WP_CLI::line( sprintf( __( 'Full size - %s', 'ewww-image-optimizer' ), html_entity_decode( $
|
386 |
} elseif ( 'thumbnail' === $size ) {
|
387 |
// Output the results of the thumb optimization.
|
388 |
/* translators: %s: compression results */
|
389 |
-
WP_CLI::line( sprintf( __( 'Thumbnail - %s', 'ewww-image-optimizer' ), html_entity_decode( $
|
390 |
} else {
|
391 |
// Output savings for any other sizes, if they ever exist...
|
392 |
-
WP_CLI::line( ucfirst( $size ) . ' - ' . html_entity_decode( $
|
393 |
}
|
394 |
}
|
|
|
395 |
}
|
396 |
// Output how much time we spent.
|
397 |
$elapsed = microtime( true ) - $started;
|
398 |
/* translators: %s: number of seconds */
|
399 |
-
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed ) ) );
|
400 |
-
// Get the list of attachments remaining from the db.
|
401 |
-
$attachments = get_option( 'ewww_image_optimizer_bulk_ngg_attachments' );
|
402 |
// Remove the first item.
|
403 |
if ( ! empty( $attachments ) ) {
|
404 |
array_shift( $attachments );
|
@@ -436,12 +431,15 @@ function ewww_image_optimizer_scan_next() {
|
|
436 |
}
|
437 |
|
438 |
/**
|
439 |
-
* Bulk Optimize all
|
440 |
*
|
441 |
* @param int $delay Number of seconds to pause between images.
|
442 |
* @param array $attachments A list of image IDs to optimize.
|
443 |
*/
|
444 |
function ewww_image_optimizer_bulk_next( $delay, $attachments ) {
|
|
|
|
|
|
|
445 |
// Toggle the resume flag to indicate an operation is in progress.
|
446 |
update_option( 'ewww_image_optimizer_bulk_ngg_resume', 'true' );
|
447 |
// Need this file to work with metadata.
|
@@ -452,31 +450,21 @@ function ewww_image_optimizer_bulk_next( $delay, $attachments ) {
|
|
452 |
}
|
453 |
// Find out what time we started, in microseconds.
|
454 |
$started = microtime( true );
|
455 |
-
//
|
456 |
-
$
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
// Update the metadata of the optimized image.
|
462 |
-
nggdb::update_image_meta( $id, array( 'ewww_image_optimizer' => $fres[1] ) );
|
463 |
-
// Output the results of the optimization.
|
464 |
-
WP_CLI::line( __( 'Optimized image:', 'ewww-image-optimizer' ) . $meta->image->filename );
|
465 |
/* translators: %s: compression results */
|
466 |
WP_CLI::line( sprintf( __( 'Full size - %s', 'ewww-image-optimizer' ), html_entity_decode( $fres[1] ) ) );
|
467 |
-
// Get the filepath of the thumbnail image.
|
468 |
-
$thumb_path = $meta->image->thumbPath;
|
469 |
-
// Run the optimization on the thumbnail.
|
470 |
-
$tres = ewww_image_optimizer( $thumb_path, 2, false, true );
|
471 |
// Output the results of the thumb optimization.
|
472 |
/* translators: %s: compression results */
|
473 |
WP_CLI::line( sprintf( __( 'Thumbnail - %s', 'ewww-image-optimizer' ), html_entity_decode( $tres[1] ) ) );
|
474 |
// Output how much time we spent.
|
475 |
$elapsed = microtime( true ) - $started;
|
476 |
/* translators: %s: number of seconds */
|
477 |
-
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed ) ) );
|
478 |
-
// Get the list of attachments remaining from the db.
|
479 |
-
$attachments = get_option( 'ewww_image_optimizer_bulk_ngg_attachments' );
|
480 |
// Remove the first item.
|
481 |
if ( ! empty( $attachments ) ) {
|
482 |
array_shift( $attachments );
|
25 |
* : valid values are 'all' (default), 'media', 'nextgen', and 'flagallery'
|
26 |
* : media: Media Library, theme, and configured folders
|
27 |
* : nextgen: Nextcellent and NextGEN 2.x
|
28 |
+
* : flagallery: Grand FlAGallery
|
29 |
*
|
30 |
* <delay>
|
31 |
* : optional, number of seconds to pause between images
|
45 |
* @synopsis <library> [<delay>] [--force] [--reset] [--noprompt]
|
46 |
*
|
47 |
* @global bool $ewww_defer Gets set to false to make sure optimization happens inline.
|
|
|
48 |
*
|
49 |
* @param array $args A numeric array of required arguments.
|
50 |
* @param array $assoc_args An associative array of optional arguments.
|
98 |
// Do a filter to increase the timeout to 999 or something crazy.
|
99 |
add_filter( 'ewww_image_optimizer_timeout', 'ewww_image_optimizer_cli_timeout', 200 );
|
100 |
ewww_image_optimizer_media_scan( 'ewww-image-optimizer-cli' );
|
101 |
+
$pending_count = ewww_image_optimizer_aux_images_script( 'ewww-image-optimizer-cli' );
|
102 |
+
if ( class_exists( 'EWWW_Nextgen' ) ) {
|
103 |
+
list( $fullsize_count, $resize_count ) = ewww_image_optimizer_count_optimized( 'ngg' );
|
104 |
+
/* translators: 1-2: number of images */
|
105 |
+
WP_CLI::line( 'Nextgen: ' . sprintf( __( '%1$d images have been selected, with %2$d resized versions.', 'ewww-image-optimizer' ), $fullsize_count, $resize_count ) );
|
106 |
+
} elseif ( class_exists( 'EWWW_Nextcellent' ) ) {
|
107 |
+
$attachments = ewww_image_optimizer_scan_next();
|
108 |
+
/* translators: %d: number of images */
|
109 |
+
WP_CLI::line( 'Nextgen: ' . sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', count( $attachments ), 'ewww-image-optimizer' ), count( $attachments ) ) );
|
|
|
|
|
|
|
110 |
}
|
111 |
+
if ( class_exists( 'EWWW_Flag' ) ) {
|
112 |
+
list( $fullsize_count, $resize_count ) = ewww_image_optimizer_count_optimized( 'flag' );
|
113 |
+
/* translators: 1-2: number of images */
|
114 |
+
WP_CLI::line( 'FlAGallery: ' . sprintf( __( '%1$d images have been selected, with %2$d resized versions.', 'ewww-image-optimizer' ), $fullsize_count, $resize_count ) );
|
115 |
}
|
116 |
if ( empty( $assoc_args['noprompt'] ) ) {
|
117 |
/* translators: %d: number of images */
|
118 |
WP_CLI::confirm( sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', $pending_count, 'ewww-image-optimizer' ), $pending_count ) );
|
119 |
}
|
|
|
120 |
$_REQUEST['ewww_batch_limit'] = 1;
|
121 |
while ( ewww_image_optimizer_bulk_loop( 'ewww-image-optimizer-cli', $delay ) ) {
|
122 |
$something = 1;
|
123 |
}
|
124 |
ewww_image_optimizer_bulk_media_cleanup();
|
125 |
+
if ( class_exists( 'EWWW_Nextgen' ) ) {
|
126 |
+
ewww_image_optimizer_bulk_ngg( $delay );
|
127 |
+
} elseif ( class_exists( 'EWWW_Nextcellent' ) ) {
|
128 |
+
$attachments = ewww_image_optimizer_scan_next();
|
129 |
+
ewww_image_optimizer_bulk_next( $delay, $attachments );
|
|
|
|
|
|
|
130 |
}
|
131 |
+
if ( class_exists( 'EWWW_Flag' ) ) {
|
132 |
ewww_image_optimizer_bulk_flag( $delay );
|
133 |
}
|
134 |
break;
|
151 |
// Do a filter to increase the timeout to 999 or something crazy.
|
152 |
add_filter( 'ewww_image_optimizer_timeout', 'ewww_image_optimizer_cli_timeout', 200 );
|
153 |
ewww_image_optimizer_media_scan( 'ewww-image-optimizer-cli' );
|
154 |
+
$pending_count = ewww_image_optimizer_aux_images_script( 'ewww-image-optimizer-cli' );
|
155 |
if ( empty( $assoc_args['noprompt'] ) ) {
|
156 |
/* translators: %d: number of images */
|
157 |
WP_CLI::confirm( sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', $pending_count, 'ewww-image-optimizer' ), $pending_count ) );
|
167 |
update_option( 'ewww_image_optimizer_bulk_ngg_resume', '' );
|
168 |
WP_CLI::line( __( 'Bulk status has been reset, starting from the beginning.', 'ewww-image-optimizer' ) );
|
169 |
}
|
170 |
+
if ( class_exists( 'EWWW_Nextgen' ) ) {
|
171 |
+
list( $fullsize_count, $resize_count ) = ewww_image_optimizer_count_optimized( 'ngg' );
|
172 |
+
if ( empty( $assoc_args['noprompt'] ) ) {
|
173 |
+
/* translators: 1-2: number of images */
|
174 |
+
WP_CLI::confirm( sprintf( __( '%1$d images have been selected, with %2$d resized versions.', 'ewww-image-optimizer' ), $fullsize_count, $resize_count ) );
|
175 |
+
}
|
176 |
+
ewww_image_optimizer_bulk_ngg( $delay );
|
177 |
+
} elseif ( class_exists( 'EWWW_Nextcellent' ) ) {
|
178 |
+
$attachments = ewww_image_optimizer_scan_next();
|
179 |
+
if ( empty( $assoc_args['noprompt'] ) ) {
|
180 |
+
/* translators: %d: number of images */
|
181 |
+
WP_CLI::confirm( sprintf( _n( 'There is %d image ready to optimize.', 'There are %d images ready to optimize.', count( $attachments ), 'ewww-image-optimizer' ), count( $attachments ) ) );
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
+
ewww_image_optimizer_bulk_next( $delay, $attachments );
|
184 |
} else {
|
185 |
WP_CLI::error( __( 'NextGEN/Nextcellent not installed.', 'ewww-image-optimizer' ) );
|
186 |
}
|
190 |
update_option( 'ewww_image_optimizer_bulk_flag_resume', '' );
|
191 |
WP_CLI::line( __( 'Bulk status has been reset, starting from the beginning.', 'ewww-image-optimizer' ) );
|
192 |
}
|
193 |
+
if ( class_exists( 'EWWW_Flag' ) ) {
|
194 |
+
list( $fullsize_count, $resize_count ) = ewww_image_optimizer_count_optimized( 'flag' );
|
195 |
if ( empty( $assoc_args['noprompt'] ) ) {
|
196 |
+
/* translators: 1-2: number of images */
|
197 |
+
WP_CLI::confirm( 'FlAGallery: ' . sprintf( __( '%1$d images have been selected, with %2$d resized versions.', 'ewww-image-optimizer' ), $fullsize_count, $resize_count ) );
|
198 |
}
|
199 |
ewww_image_optimizer_bulk_flag( $delay );
|
200 |
} else {
|
224 |
// All done, so we can update the bulk options with empty values...
|
225 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
226 |
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
|
|
227 |
// and let the user know we are done.
|
228 |
WP_CLI::success( __( 'Finished Optimization!', 'ewww-image-optimizer' ) );
|
229 |
}
|
247 |
// Store the IDs to optimize in the options table of the db.
|
248 |
update_option( 'ewww_image_optimizer_bulk_flag_attachments', $ids, false );
|
249 |
}
|
250 |
+
$attachments = $ids; // Use this separately to keep track of progress in the db.
|
251 |
// Set the resume flag to indicate the bulk operation is in progress.
|
252 |
update_option( 'ewww_image_optimizer_bulk_flag_resume', 'true' );
|
253 |
// Need this file to work with flag meta.
|
263 |
// Record the starting time for the current image (in microseconds).
|
264 |
$started = microtime( true );
|
265 |
// Retrieve the meta for the current ID.
|
266 |
+
$meta = new flagMeta( $id );
|
267 |
+
$file_path = $meta->image->imagePath;
|
268 |
+
$ewww_image = new EWWW_Image( $id, 'flag', $file_path );
|
269 |
+
$ewww_image->resize = 'full';
|
270 |
// Optimize the full-size version.
|
271 |
$fres = ewww_image_optimizer( $file_path, 3, false, false, true );
|
272 |
WP_CLI::line( __( 'Optimized image:', 'ewww-image-optimizer' ) . ' ' . esc_html( $meta->image->filename ) );
|
274 |
WP_CLI::line( sprintf( __( 'Full size – %s', 'ewww-image-optimizer' ), html_entity_decode( $fres[1] ) ) );
|
275 |
if ( ! empty( $meta->image->meta_data['webview'] ) ) {
|
276 |
// Determine path of the webview.
|
277 |
+
$web_path = $meta->image->webimagePath;
|
278 |
+
$ewww_image = new EWWW_Image( $id, 'flag', $web_path );
|
279 |
+
$ewww_image->resize = 'webview';
|
280 |
+
$wres = ewww_image_optimizer( $web_path, 3, false, true );
|
281 |
/* translators: %s: compression results */
|
282 |
WP_CLI::line( sprintf( __( 'Optimized size – %s', 'ewww-image-optimizer' ), html_entity_decode( $wres[1] ) ) );
|
283 |
}
|
284 |
+
$thumb_path = $meta->image->thumbPath;
|
285 |
+
$ewww_image = new EWWW_Image( $id, 'flag', $thumb_path );
|
286 |
+
$ewww_image->resize = 'thumbnail';
|
287 |
// Optimize the thumbnail.
|
288 |
$tres = ewww_image_optimizer( $thumb_path, 3, false, true );
|
289 |
/* translators: %s: compression results */
|
292 |
$elapsed = microtime( true ) - $started;
|
293 |
// and output it to the user.
|
294 |
/* translators: %s: localized number of seconds */
|
295 |
+
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed, 2 ) ) );
|
|
|
|
|
296 |
// Take the first image off the list.
|
297 |
if ( ! empty( $attachments ) ) {
|
298 |
array_shift( $attachments );
|
352 |
WP_CLI::line( __( 'You do not appear to have uploaded any images yet.', 'ewww-image-optimizer' ) );
|
353 |
return;
|
354 |
}
|
355 |
+
$attachments = $images; // Kept separate to update status in db.
|
356 |
global $ewwwngg;
|
357 |
+
global $ewww_defer;
|
358 |
+
$ewww_defer = false;
|
359 |
foreach ( $images as $id ) {
|
360 |
if ( ewww_image_optimizer_function_exists( 'sleep' ) ) {
|
361 |
sleep( $delay );
|
371 |
$image = $ewwwngg->ewww_added_new_image( $image, $storage );
|
372 |
// Output the results of the optimization.
|
373 |
WP_CLI::line( __( 'Optimized image:', 'ewww-image-optimizer' ) . ' ' . basename( $storage->object->get_image_abspath( $image, 'full' ) ) );
|
374 |
+
if ( ewww_image_optimizer_iterable( $ewwwngg->bulk_sizes ) ) {
|
|
|
|
|
375 |
// Output the results for each $size.
|
376 |
+
foreach ( $ewwwngg->bulk_sizes as $size => $results_msg ) {
|
377 |
+
if ( 'backup' === $size ) {
|
378 |
+
continue;
|
379 |
+
} elseif ( 'full' === $size ) {
|
380 |
/* translators: %s: compression results */
|
381 |
+
WP_CLI::line( sprintf( __( 'Full size - %s', 'ewww-image-optimizer' ), html_entity_decode( $results_msg ) ) );
|
382 |
} elseif ( 'thumbnail' === $size ) {
|
383 |
// Output the results of the thumb optimization.
|
384 |
/* translators: %s: compression results */
|
385 |
+
WP_CLI::line( sprintf( __( 'Thumbnail - %s', 'ewww-image-optimizer' ), html_entity_decode( $results_msg ) ) );
|
386 |
} else {
|
387 |
// Output savings for any other sizes, if they ever exist...
|
388 |
+
WP_CLI::line( ucfirst( $size ) . ' - ' . html_entity_decode( $results_msg ) );
|
389 |
}
|
390 |
}
|
391 |
+
$ewwwngg->bulk_sizes = array();
|
392 |
}
|
393 |
// Output how much time we spent.
|
394 |
$elapsed = microtime( true ) - $started;
|
395 |
/* translators: %s: number of seconds */
|
396 |
+
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed, 2 ) ) );
|
|
|
|
|
397 |
// Remove the first item.
|
398 |
if ( ! empty( $attachments ) ) {
|
399 |
array_shift( $attachments );
|
431 |
}
|
432 |
|
433 |
/**
|
434 |
+
* Bulk Optimize all Nextcellent uploads from WP-CLI.
|
435 |
*
|
436 |
* @param int $delay Number of seconds to pause between images.
|
437 |
* @param array $attachments A list of image IDs to optimize.
|
438 |
*/
|
439 |
function ewww_image_optimizer_bulk_next( $delay, $attachments ) {
|
440 |
+
global $ewwwngg;
|
441 |
+
global $ewww_defer;
|
442 |
+
$ewww_defer = false;
|
443 |
// Toggle the resume flag to indicate an operation is in progress.
|
444 |
update_option( 'ewww_image_optimizer_bulk_ngg_resume', 'true' );
|
445 |
// Need this file to work with metadata.
|
450 |
}
|
451 |
// Find out what time we started, in microseconds.
|
452 |
$started = microtime( true );
|
453 |
+
// Optimize by ID.
|
454 |
+
list( $fres, $tres ) = $ewwwngg->ewww_ngg_optimize( $id );
|
455 |
+
if ( $fres[0] ) {
|
456 |
+
// Output the results of the optimization.
|
457 |
+
WP_CLI::line( __( 'Optimized image:', 'ewww-image-optimizer' ) . $fres[0] );
|
458 |
+
}
|
|
|
|
|
|
|
|
|
459 |
/* translators: %s: compression results */
|
460 |
WP_CLI::line( sprintf( __( 'Full size - %s', 'ewww-image-optimizer' ), html_entity_decode( $fres[1] ) ) );
|
|
|
|
|
|
|
|
|
461 |
// Output the results of the thumb optimization.
|
462 |
/* translators: %s: compression results */
|
463 |
WP_CLI::line( sprintf( __( 'Thumbnail - %s', 'ewww-image-optimizer' ), html_entity_decode( $tres[1] ) ) );
|
464 |
// Output how much time we spent.
|
465 |
$elapsed = microtime( true ) - $started;
|
466 |
/* translators: %s: number of seconds */
|
467 |
+
WP_CLI::line( sprintf( _n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' ), number_format_i18n( $elapsed, 2 ) ) );
|
|
|
|
|
468 |
// Remove the first item.
|
469 |
if ( ! empty( $attachments ) ) {
|
470 |
array_shift( $attachments );
|
classes/class-exactdn.php
CHANGED
@@ -136,7 +136,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
136 |
$uri = add_query_arg( null, null );
|
137 |
$this->debug_message( "request uri is $uri" );
|
138 |
|
139 |
-
if ( '/robots.txt' === $uri ) {
|
140 |
return;
|
141 |
}
|
142 |
/**
|
@@ -2882,6 +2882,11 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2882 |
$args = wp_parse_args( $image_url_parts['query'], $args );
|
2883 |
}
|
2884 |
|
|
|
|
|
|
|
|
|
|
|
2885 |
if ( $args ) {
|
2886 |
if ( is_array( $args ) ) {
|
2887 |
$exactdn_url = add_query_arg( $args, $exactdn_url );
|
136 |
$uri = add_query_arg( null, null );
|
137 |
$this->debug_message( "request uri is $uri" );
|
138 |
|
139 |
+
if ( '/robots.txt' === $uri || '/sitemap.xml' === $uri ) {
|
140 |
return;
|
141 |
}
|
142 |
/**
|
2882 |
$args = wp_parse_args( $image_url_parts['query'], $args );
|
2883 |
}
|
2884 |
|
2885 |
+
// Clear out args for some files (like videos) that might go through image_downsize.
|
2886 |
+
if ( ! empty( $extension ) && in_array( $extension, array( 'mp4', 'm4p', 'm4v', 'mov', 'wvm', 'qt', 'webp', 'ogv', 'mpg', 'mpeg', 'mpv' ), true ) ) {
|
2887 |
+
$args = array();
|
2888 |
+
}
|
2889 |
+
|
2890 |
if ( $args ) {
|
2891 |
if ( is_array( $args ) ) {
|
2892 |
$exactdn_url = add_query_arg( $args, $exactdn_url );
|
common.php
CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
-
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
@@ -571,6 +571,7 @@ function ewww_image_optimizer_init() {
|
|
571 |
remove_filter( 'wp_image_editors', 'ewww_image_optimizer_load_editor', 60 );
|
572 |
remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
|
573 |
add_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_lr_sync_update' );
|
|
|
574 |
}
|
575 |
}
|
576 |
|
@@ -1049,6 +1050,7 @@ function ewww_image_optimizer_ajax_compat_check() {
|
|
1049 |
) {
|
1050 |
ewwwio_debug_message( 'doing regeneratethumbnail' );
|
1051 |
ewww_image_optimizer_image_sizes( false );
|
|
|
1052 |
return;
|
1053 |
}
|
1054 |
if ( 'mic_crop_image' === $action ) {
|
@@ -1056,6 +1058,7 @@ function ewww_image_optimizer_ajax_compat_check() {
|
|
1056 |
if ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) ) {
|
1057 |
define( 'EWWWIO_EDITOR_OVERWRITE', true );
|
1058 |
}
|
|
|
1059 |
return;
|
1060 |
}
|
1061 |
if ( false !== strpos( $action, 'wc_regenerate_images' ) ) {
|
@@ -1075,29 +1078,34 @@ function ewww_image_optimizer_ajax_compat_check() {
|
|
1075 |
remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
|
1076 |
add_action( 'iw_after_apply_watermark', 'ewww_image_optimizer_single_size_optimize', 10, 2 );
|
1077 |
}
|
|
|
1078 |
return;
|
1079 |
}
|
1080 |
// Check for other MLP actions, including multi-regen.
|
1081 |
if ( class_exists( 'MaxGalleriaMediaLib' ) && ( 'regen_mlp_thumbnails' === $action || 'move_media' === $action || 'copy_media' === $action || 'maxgalleria_rename_image' === $action ) ) {
|
1082 |
ewwwio_debug_message( 'doing regen_mlp_thumbnails' );
|
1083 |
ewww_image_optimizer_image_sizes( false );
|
|
|
1084 |
return;
|
1085 |
}
|
1086 |
// Check for MLP upload.
|
1087 |
if ( class_exists( 'MaxGalleriaMediaLib' ) && ! empty( $_REQUEST['nonce'] ) && 'upload_attachment' === $action ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1088 |
ewwwio_debug_message( 'doing maxgalleria upload' );
|
1089 |
ewww_image_optimizer_image_sizes( false );
|
|
|
1090 |
return;
|
1091 |
}
|
1092 |
// Check for Image Regenerate and Select Crop (better way).
|
1093 |
if ( defined( 'DOING_SIRSC' ) && DOING_SIRSC ) {
|
1094 |
ewwwio_debug_message( 'IRSC action/regen' );
|
1095 |
ewww_image_optimizer_image_sizes( false );
|
|
|
1096 |
return;
|
1097 |
} elseif ( 0 === strpos( $action, 'sirsc' ) ) {
|
1098 |
// Image Regenerate and Select Crop (old check).
|
1099 |
ewwwio_debug_message( 'IRSC action/regen (old)' );
|
1100 |
ewww_image_optimizer_image_sizes( false );
|
|
|
1101 |
return;
|
1102 |
}
|
1103 |
}
|
@@ -1242,6 +1250,7 @@ function ewww_image_optimizer_restapi_compat_check() {
|
|
1242 |
if ( ! empty( $GLOBALS['wp']->query_vars['rest_route'] ) && false !== strpos( $GLOBALS['wp']->query_vars['rest_route'], '/regenerate-thumbnails' ) ) {
|
1243 |
ewwwio_debug_message( 'doing regenerate-thumbnails via REST' );
|
1244 |
ewww_image_optimizer_image_sizes( false );
|
|
|
1245 |
return;
|
1246 |
}
|
1247 |
}
|
@@ -1747,9 +1756,15 @@ function ewww_image_optimizer_notice_exactdn_activation_error() {
|
|
1747 |
* Let the user know ExactDN setup was successful.
|
1748 |
*/
|
1749 |
function ewww_image_optimizer_notice_exactdn_activation_success() {
|
1750 |
-
|
1751 |
-
|
1752 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
1753 |
}
|
1754 |
|
1755 |
/**
|
@@ -1925,7 +1940,7 @@ function ewww_image_optimizer_notice_reoptimization() {
|
|
1925 |
$reoptimized = get_transient( 'ewww_image_optimizer_images_reoptimized' );
|
1926 |
if ( empty( $reoptimized ) ) {
|
1927 |
global $wpdb;
|
1928 |
-
$reoptimized = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->ewwwio_images WHERE updates >
|
1929 |
if ( empty( $reoptimized ) ) {
|
1930 |
set_transient( 'ewww_image_optimizer_images_reoptimized', 'zero', HOUR_IN_SECONDS );
|
1931 |
} else {
|
@@ -1937,7 +1952,7 @@ function ewww_image_optimizer_notice_reoptimization() {
|
|
1937 |
// Do a check for 10+ optimizations on 5+ images.
|
1938 |
if ( ! empty( $reoptimized ) && $reoptimized > 5 ) {
|
1939 |
$debugging_page = admin_url( 'tools.php?page=ewww-image-optimizer-tools' );
|
1940 |
-
$reset_page = wp_nonce_url(
|
1941 |
// Display an alert, and let the user reset the warning if they wish.
|
1942 |
echo "<div id='ewww-image-optimizer-warning-reoptimizations' class='error'><p>" .
|
1943 |
sprintf(
|
@@ -3256,6 +3271,7 @@ function ewww_image_optimizer_manual() {
|
|
3256 |
global $ewww_convert;
|
3257 |
global $ewww_defer;
|
3258 |
$ewww_defer = false;
|
|
|
3259 |
// Check permissions of current user.
|
3260 |
$permissions = apply_filters( 'ewww_image_optimizer_manual_permissions', '' );
|
3261 |
if ( ! current_user_can( $permissions ) ) {
|
@@ -4966,6 +4982,22 @@ function ewww_image_optimizer_check_table( $file, $orig_size ) {
|
|
4966 |
);
|
4967 |
}
|
4968 |
return $already_optimized;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4969 |
}
|
4970 |
return '';
|
4971 |
}
|
@@ -5052,8 +5084,10 @@ function ewww_image_optimizer_update_table( $attachment, $opt_size, $orig_size,
|
|
5052 |
$updates['orig_size'] = $orig_size;
|
5053 |
}
|
5054 |
ewwwio_debug_message( "updating existing record ({$already_optimized['id']}), path: $attachment, size: $opt_size" );
|
5055 |
-
if ( $already_optimized['updates'] ) {
|
5056 |
-
$updates['updates'] = $already_optimized['updates']
|
|
|
|
|
5057 |
}
|
5058 |
$updates['pending'] = 0;
|
5059 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && $already_optimized['updates'] > 1 ) {
|
@@ -5248,7 +5282,7 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
|
|
5248 |
/* translators: %s: number of seconds */
|
5249 |
_n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' )
|
5250 |
) . '</p>',
|
5251 |
-
number_format_i18n( $elapsed )
|
5252 |
);
|
5253 |
if ( get_site_option( 'ewww_image_optimizer_debug' ) ) {
|
5254 |
global $eio_debug;
|
@@ -9603,11 +9637,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9603 |
<div id='ewww-settings-wrap' class='wrap'>
|
9604 |
<h1>EWWW Image Optimizer</h1>
|
9605 |
<?php
|
9606 |
-
$
|
9607 |
-
$resize_score = 0;
|
9608 |
|
9609 |
-
$
|
9610 |
-
$resize_recommendations = array();
|
9611 |
|
9612 |
$free_exec = false;
|
9613 |
if (
|
@@ -9616,31 +9648,31 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9616 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
9617 |
! ewww_image_optimizer_easy_active()
|
9618 |
) {
|
9619 |
-
$free_exec
|
9620 |
-
$
|
9621 |
}
|
9622 |
$verify_cloud = '';
|
9623 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
9624 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', 0 );
|
9625 |
$verify_cloud = ewww_image_optimizer_cloud_verify( false );
|
9626 |
-
if ( false !== strpos( $verify_cloud, 'great' ) ) {
|
9627 |
-
$
|
9628 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 20 ) {
|
9629 |
-
$
|
9630 |
} else {
|
9631 |
-
$
|
9632 |
}
|
9633 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) > 20 ) {
|
9634 |
-
$
|
9635 |
} else {
|
9636 |
-
$
|
9637 |
}
|
9638 |
}
|
9639 |
$disable_level = false;
|
9640 |
} else {
|
9641 |
delete_option( 'ewww_image_optimizer_cloud_key_invalid' );
|
9642 |
if ( ! class_exists( 'ExactDN' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
9643 |
-
$
|
9644 |
}
|
9645 |
$disable_level = true;
|
9646 |
}
|
@@ -9651,10 +9683,13 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9651 |
update_option( 'ewww_image_optimizer_lazy_load', false );
|
9652 |
update_option( 'ewww_image_optimizer_webp_for_cdn', false );
|
9653 |
update_option( 'ewww_image_optimizer_picture_webp', false );
|
9654 |
-
$
|
9655 |
-
$resize_score += 50;
|
9656 |
if ( get_option( 'exactdn_lossy' ) ) {
|
9657 |
-
$
|
|
|
|
|
|
|
|
|
9658 |
}
|
9659 |
} elseif (
|
9660 |
( ! class_exists( 'Jetpack_Photon' ) || ! Jetpack::is_module_active( 'photon' ) ) &&
|
@@ -9662,19 +9697,20 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9662 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' )
|
9663 |
) {
|
9664 |
if ( $exactdn->get_exactdn_domain() && $exactdn->verify_domain( $exactdn->get_exactdn_domain() ) ) {
|
9665 |
-
|
9666 |
-
$compress_score = 50;
|
9667 |
-
}
|
9668 |
-
$resize_score += 50;
|
9669 |
if ( ewww_image_optimizer_get_option( 'exactdn_lossy' ) ) {
|
9670 |
-
$
|
9671 |
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) < 30 ) {
|
9672 |
-
$
|
|
|
|
|
9673 |
}
|
9674 |
$exactdn_enabled = true;
|
9675 |
}
|
9676 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
9677 |
-
|
|
|
|
|
9678 |
delete_option( 'ewww_image_optimizer_exactdn_domain' );
|
9679 |
delete_option( 'ewww_image_optimizer_exactdn_plan_id' );
|
9680 |
delete_option( 'ewww_image_optimizer_exactdn_failures' );
|
@@ -9704,19 +9740,27 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9704 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxotherwidth' ) ||
|
9705 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxotherheight' )
|
9706 |
) {
|
9707 |
-
$
|
9708 |
} elseif ( defined( 'IMSANITY_VERSION' ) ) {
|
9709 |
-
$
|
9710 |
} else {
|
9711 |
-
$
|
9712 |
}
|
9713 |
$jpg_quality = apply_filters( 'jpeg_quality', 82, 'image_resize' );
|
9714 |
if ( $jpg_quality < 91 && $jpg_quality > 49 ) {
|
9715 |
-
$
|
9716 |
} else {
|
9717 |
-
$
|
9718 |
}
|
9719 |
$skip = ewww_image_optimizer_skip_tools();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9720 |
if ( ! $skip['jpegtran'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9721 |
if ( EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
9722 |
$jpegtran_installed = ewww_image_optimizer_tool_found( EWWW_IMAGE_OPTIMIZER_JPEGTRAN, 'j' );
|
@@ -9725,9 +9769,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9725 |
}
|
9726 |
}
|
9727 |
if ( ! empty( $jpegtran_installed ) ) {
|
9728 |
-
$
|
9729 |
} else {
|
9730 |
-
$
|
9731 |
}
|
9732 |
}
|
9733 |
if ( ! $skip['optipng'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
@@ -9738,9 +9782,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9738 |
}
|
9739 |
}
|
9740 |
if ( ! empty( $optipng_version ) ) {
|
9741 |
-
$
|
9742 |
} else {
|
9743 |
-
$
|
9744 |
}
|
9745 |
}
|
9746 |
if ( ! $skip['pngout'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
@@ -9751,9 +9795,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9751 |
}
|
9752 |
}
|
9753 |
if ( ! empty( $pngout_version ) ) {
|
9754 |
-
$
|
9755 |
} else {
|
9756 |
-
$
|
9757 |
}
|
9758 |
}
|
9759 |
if ( ! $skip['pngquant'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
@@ -9764,9 +9808,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9764 |
}
|
9765 |
}
|
9766 |
if ( ! empty( $pngquant_version ) ) {
|
9767 |
-
$
|
9768 |
} else {
|
9769 |
-
$
|
9770 |
}
|
9771 |
}
|
9772 |
if ( ! $skip['gifsicle'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
@@ -9777,9 +9821,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9777 |
}
|
9778 |
}
|
9779 |
if ( ! empty( $gifsicle_version ) ) {
|
9780 |
-
$
|
9781 |
} else {
|
9782 |
-
$
|
9783 |
}
|
9784 |
}
|
9785 |
if ( EWWW_IMAGE_OPTIMIZER_CWEBP && ! $skip['webp'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
@@ -9790,30 +9834,49 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9790 |
}
|
9791 |
}
|
9792 |
if ( ! empty( $webp_version ) ) {
|
9793 |
-
$
|
9794 |
} else {
|
9795 |
-
$
|
9796 |
}
|
9797 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9798 |
if (
|
9799 |
( $free_exec || ! empty( $jpegtran_installed ) || ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) &&
|
9800 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_remove' )
|
9801 |
) {
|
9802 |
-
$
|
9803 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_remove' ) ) {
|
9804 |
-
$
|
9805 |
}
|
9806 |
if ( ! ewww_image_optimizer_easy_active() && ! $free_exec ) {
|
9807 |
if ( 0 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) ) {
|
9808 |
-
$
|
9809 |
}
|
9810 |
if ( 0 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
9811 |
-
$
|
9812 |
}
|
9813 |
if ( 0 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) ) {
|
9814 |
-
$
|
9815 |
}
|
9816 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9817 |
|
9818 |
// Check that an image library exists for converting resizes. Originals can be done via the API, but resizes are done locally for speed.
|
9819 |
$toolkit_found = false;
|
@@ -9865,12 +9928,15 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9865 |
ob_start();
|
9866 |
}
|
9867 |
// Begin building of status inside section.
|
9868 |
-
$
|
9869 |
-
$
|
9870 |
-
|
9871 |
-
|
9872 |
-
|
9873 |
-
|
|
|
|
|
|
|
9874 |
?>
|
9875 |
<div id='ewww-widgets' class='metabox-holder'>
|
9876 |
<div class='meta-box-sortables'>
|
@@ -9879,46 +9945,27 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9879 |
<div class='inside'>
|
9880 |
<div class="ewww-row"><ul class="ewww-blocks">
|
9881 |
<li><div id="ewww-compress" class="ewww-status-detail">
|
9882 |
-
<div id="ewww-compress-guage" class="ewww-guage" data-score="<?php echo (int) $
|
9883 |
<svg width="120" height="120">
|
9884 |
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
9885 |
-
<circle class="ewww-active" r="54" cy="60" cx="60" stroke-width="12" style="stroke-dasharray: <?php echo esc_attr( $guage_stroke_dasharray ); ?>px; stroke-dashoffset: <?php echo esc_attr( $
|
9886 |
</svg>
|
9887 |
-
<div class="ewww-score"><?php echo (int) $
|
9888 |
</div><!-- end .ewww-guage -->
|
9889 |
<div id="ewww-compress-recommend" class="ewww-recommend">
|
9890 |
-
<strong><?php echo ( (int) $
|
9891 |
-
<?php if ( $
|
9892 |
<ul class="ewww-tooltip">
|
9893 |
-
<?php foreach ( $
|
9894 |
-
<li><?php echo wp_kses( $
|
9895 |
<?php } ?>
|
9896 |
</ul>
|
9897 |
<?php endif; ?>
|
9898 |
</div><!-- end .ewww-recommend -->
|
9899 |
-
<p><strong><?php esc_html_e( '
|
9900 |
-
|
9901 |
-
|
9902 |
-
<li><div id="ewww-resize" class="ewww-status-detail">
|
9903 |
-
<div id="ewww-resize-guage" class="ewww-guage" data-score="<?php echo (int) $resize_score; ?>">
|
9904 |
-
<svg width="120" height="120">
|
9905 |
-
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
9906 |
-
<circle class="ewww-active" r="54" cy="60" cx="60" stroke-width="12" style="stroke-dasharray: <?php echo esc_attr( $guage_stroke_dasharray ); ?>px; stroke-dashoffset: <?php echo esc_attr( $resize_stroke_dashoffset ); ?>px;" />
|
9907 |
-
</svg>
|
9908 |
-
<div class="ewww-score"><?php echo (int) $resize_score; ?>%</div>
|
9909 |
-
</div><!-- end .ewww-guage -->
|
9910 |
-
<div id="ewww-resize-recommend" class="ewww-recommend">
|
9911 |
-
<strong><?php echo ( (int) $resize_score < 100 ? esc_html__( 'How do I get to 100%?', 'ewww-image-optimizer' ) : esc_html__( 'You got the perfect score!', 'ewww-image-optimizer' ) ); ?></strong>
|
9912 |
-
<?php if ( $resize_score < 100 ) : ?>
|
9913 |
-
<ul class="ewww-tooltip">
|
9914 |
-
<?php foreach ( $resize_recommendations as $r_recommend ) { ?>
|
9915 |
-
<li><?php echo wp_kses( $r_recommend, $allow_help_html ); ?></li>
|
9916 |
-
<?php } ?>
|
9917 |
-
</ul>
|
9918 |
<?php endif; ?>
|
9919 |
-
</div><!-- end .ewww-recommend -->
|
9920 |
-
<p><strong><?php esc_html_e( 'Resize', 'ewww-image-optimizer' ); ?></strong></p>
|
9921 |
-
<p><?php esc_html_e( 'Scale or reduce the dimensions of your images for more savings.', 'ewww-image-optimizer' ); ?></p>
|
9922 |
</div><!-- end .ewww-status-detail --></li>
|
9923 |
<?php
|
9924 |
if ( $total_savings > 0 ) {
|
@@ -11247,6 +11294,12 @@ function ewwwio_help_link( $link, $hsid = '' ) {
|
|
11247 |
$beacon_attr = 'data-beacon-article';
|
11248 |
$link_class = 'ewww-help-beacon-single';
|
11249 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
11250 |
echo '<a class="' . esc_attr( $link_class ) . '" href="' . esc_url( $link ) . '" target="_blank" ' . esc_attr( $beacon_attr ) . '="' . esc_attr( $hsid ) . '">' .
|
11251 |
'<img title="' . esc_attr__( 'Help', 'ewww-image-optimizer' ) . '" src="' . esc_url( $help_icon ) . '">' .
|
11252 |
'</a>';
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '561.0' );
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
571 |
remove_filter( 'wp_image_editors', 'ewww_image_optimizer_load_editor', 60 );
|
572 |
remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
|
573 |
add_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_lr_sync_update' );
|
574 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
575 |
}
|
576 |
}
|
577 |
|
1050 |
) {
|
1051 |
ewwwio_debug_message( 'doing regeneratethumbnail' );
|
1052 |
ewww_image_optimizer_image_sizes( false );
|
1053 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1054 |
return;
|
1055 |
}
|
1056 |
if ( 'mic_crop_image' === $action ) {
|
1058 |
if ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) ) {
|
1059 |
define( 'EWWWIO_EDITOR_OVERWRITE', true );
|
1060 |
}
|
1061 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1062 |
return;
|
1063 |
}
|
1064 |
if ( false !== strpos( $action, 'wc_regenerate_images' ) ) {
|
1078 |
remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
|
1079 |
add_action( 'iw_after_apply_watermark', 'ewww_image_optimizer_single_size_optimize', 10, 2 );
|
1080 |
}
|
1081 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1082 |
return;
|
1083 |
}
|
1084 |
// Check for other MLP actions, including multi-regen.
|
1085 |
if ( class_exists( 'MaxGalleriaMediaLib' ) && ( 'regen_mlp_thumbnails' === $action || 'move_media' === $action || 'copy_media' === $action || 'maxgalleria_rename_image' === $action ) ) {
|
1086 |
ewwwio_debug_message( 'doing regen_mlp_thumbnails' );
|
1087 |
ewww_image_optimizer_image_sizes( false );
|
1088 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1089 |
return;
|
1090 |
}
|
1091 |
// Check for MLP upload.
|
1092 |
if ( class_exists( 'MaxGalleriaMediaLib' ) && ! empty( $_REQUEST['nonce'] ) && 'upload_attachment' === $action ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1093 |
ewwwio_debug_message( 'doing maxgalleria upload' );
|
1094 |
ewww_image_optimizer_image_sizes( false );
|
1095 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1096 |
return;
|
1097 |
}
|
1098 |
// Check for Image Regenerate and Select Crop (better way).
|
1099 |
if ( defined( 'DOING_SIRSC' ) && DOING_SIRSC ) {
|
1100 |
ewwwio_debug_message( 'IRSC action/regen' );
|
1101 |
ewww_image_optimizer_image_sizes( false );
|
1102 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1103 |
return;
|
1104 |
} elseif ( 0 === strpos( $action, 'sirsc' ) ) {
|
1105 |
// Image Regenerate and Select Crop (old check).
|
1106 |
ewwwio_debug_message( 'IRSC action/regen (old)' );
|
1107 |
ewww_image_optimizer_image_sizes( false );
|
1108 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1109 |
return;
|
1110 |
}
|
1111 |
}
|
1250 |
if ( ! empty( $GLOBALS['wp']->query_vars['rest_route'] ) && false !== strpos( $GLOBALS['wp']->query_vars['rest_route'], '/regenerate-thumbnails' ) ) {
|
1251 |
ewwwio_debug_message( 'doing regenerate-thumbnails via REST' );
|
1252 |
ewww_image_optimizer_image_sizes( false );
|
1253 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1254 |
return;
|
1255 |
}
|
1256 |
}
|
1756 |
* Let the user know ExactDN setup was successful.
|
1757 |
*/
|
1758 |
function ewww_image_optimizer_notice_exactdn_activation_success() {
|
1759 |
+
?>
|
1760 |
+
<div id="ewww-image-optimizer-notice-exactdn-success" class="notice notice-success"><p>
|
1761 |
+
<strong><?php esc_html_e( 'Easy IO setup and verification is complete.', 'ewww-image-optimizer' ); ?></strong>
|
1762 |
+
<?php esc_html_e( 'If you have problems, try disabling Lazy Load and Include All Resources. Finally, disable Easy IO if problems remain.', 'ewww-image-optimizer' ); ?><br>
|
1763 |
+
<a class='ewww-docs-root' href='https://ewww.io/contact-us/'>
|
1764 |
+
<?php esc_html_e( 'Then, let us know so we can find a fix for the problem.', 'ewww-image-optimizer' ); ?>
|
1765 |
+
</a>
|
1766 |
+
</p></div>
|
1767 |
+
<?php
|
1768 |
}
|
1769 |
|
1770 |
/**
|
1940 |
$reoptimized = get_transient( 'ewww_image_optimizer_images_reoptimized' );
|
1941 |
if ( empty( $reoptimized ) ) {
|
1942 |
global $wpdb;
|
1943 |
+
$reoptimized = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->ewwwio_images WHERE updates > 5 AND path NOT LIKE '%wp-content/themes%' AND path NOT LIKE '%wp-content/plugins%' LIMIT 10" );
|
1944 |
if ( empty( $reoptimized ) ) {
|
1945 |
set_transient( 'ewww_image_optimizer_images_reoptimized', 'zero', HOUR_IN_SECONDS );
|
1946 |
} else {
|
1952 |
// Do a check for 10+ optimizations on 5+ images.
|
1953 |
if ( ! empty( $reoptimized ) && $reoptimized > 5 ) {
|
1954 |
$debugging_page = admin_url( 'tools.php?page=ewww-image-optimizer-tools' );
|
1955 |
+
$reset_page = wp_nonce_url( add_query_arg( null, null ), 'reset_reoptimization_counters', 'ewww_reset_reopt_nonce' );
|
1956 |
// Display an alert, and let the user reset the warning if they wish.
|
1957 |
echo "<div id='ewww-image-optimizer-warning-reoptimizations' class='error'><p>" .
|
1958 |
sprintf(
|
3271 |
global $ewww_convert;
|
3272 |
global $ewww_defer;
|
3273 |
$ewww_defer = false;
|
3274 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
3275 |
// Check permissions of current user.
|
3276 |
$permissions = apply_filters( 'ewww_image_optimizer_manual_permissions', '' );
|
3277 |
if ( ! current_user_can( $permissions ) ) {
|
4982 |
);
|
4983 |
}
|
4984 |
return $already_optimized;
|
4985 |
+
} elseif ( is_array( $image ) && ! empty( $image['updates'] ) && $image['updates'] > 5 ) {
|
4986 |
+
ewwwio_debug_message( "prevented excessive re-opt: {$image['path']}" );
|
4987 |
+
// Make sure the image isn't pending.
|
4988 |
+
if ( $image['pending'] ) {
|
4989 |
+
global $wpdb;
|
4990 |
+
$wpdb->update(
|
4991 |
+
$wpdb->ewwwio_images,
|
4992 |
+
array(
|
4993 |
+
'pending' => 0,
|
4994 |
+
),
|
4995 |
+
array(
|
4996 |
+
'id' => $image['id'],
|
4997 |
+
)
|
4998 |
+
);
|
4999 |
+
}
|
5000 |
+
return __( 'Re-optimize prevented', 'ewww-image-optimizer' );
|
5001 |
}
|
5002 |
return '';
|
5003 |
}
|
5084 |
$updates['orig_size'] = $orig_size;
|
5085 |
}
|
5086 |
ewwwio_debug_message( "updating existing record ({$already_optimized['id']}), path: $attachment, size: $opt_size" );
|
5087 |
+
if ( $already_optimized['updates'] && apply_filters( 'ewww_image_optimizer_allowed_reopt', false ) ) {
|
5088 |
+
$updates['updates'] = $already_optimized['updates'];
|
5089 |
+
} elseif ( $already_optimized['updates'] ) {
|
5090 |
+
$updates['updates'] = $already_optimized['updates'] + 1;
|
5091 |
}
|
5092 |
$updates['pending'] = 0;
|
5093 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) && $already_optimized['updates'] > 1 ) {
|
5282 |
/* translators: %s: number of seconds */
|
5283 |
_n( 'Elapsed: %s second', 'Elapsed: %s seconds', $elapsed, 'ewww-image-optimizer' )
|
5284 |
) . '</p>',
|
5285 |
+
number_format_i18n( $elapsed, 2 )
|
5286 |
);
|
5287 |
if ( get_site_option( 'ewww_image_optimizer_debug' ) ) {
|
5288 |
global $eio_debug;
|
9637 |
<div id='ewww-settings-wrap' class='wrap'>
|
9638 |
<h1>EWWW Image Optimizer</h1>
|
9639 |
<?php
|
9640 |
+
$speed_score = 0;
|
|
|
9641 |
|
9642 |
+
$speed_recommendations = array();
|
|
|
9643 |
|
9644 |
$free_exec = false;
|
9645 |
if (
|
9648 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
9649 |
! ewww_image_optimizer_easy_active()
|
9650 |
) {
|
9651 |
+
$free_exec = true;
|
9652 |
+
$speed_score += 5;
|
9653 |
}
|
9654 |
$verify_cloud = '';
|
9655 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
9656 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', 0 );
|
9657 |
$verify_cloud = ewww_image_optimizer_cloud_verify( false );
|
9658 |
+
if ( false !== strpos( $verify_cloud, 'great' ) && ! ewww_image_optimizer_easy_active() ) {
|
9659 |
+
$speed_score += 35;
|
9660 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 20 ) {
|
9661 |
+
$speed_score += 15;
|
9662 |
} else {
|
9663 |
+
$speed_recommendations[] = __( 'Enable premium compression for JPG images.', 'ewww-image-optimizer' );
|
9664 |
}
|
9665 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) > 20 ) {
|
9666 |
+
$speed_score += 5;
|
9667 |
} else {
|
9668 |
+
$speed_recommendations[] = __( 'Enable premium compression for PNG images.', 'ewww-image-optimizer' );
|
9669 |
}
|
9670 |
}
|
9671 |
$disable_level = false;
|
9672 |
} else {
|
9673 |
delete_option( 'ewww_image_optimizer_cloud_key_invalid' );
|
9674 |
if ( ! class_exists( 'ExactDN' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
9675 |
+
$speed_recommendations[] = __( 'Enable premium compression with an API key or Easy IO.', 'ewww-image-optimizer' );
|
9676 |
}
|
9677 |
$disable_level = true;
|
9678 |
}
|
9683 |
update_option( 'ewww_image_optimizer_lazy_load', false );
|
9684 |
update_option( 'ewww_image_optimizer_webp_for_cdn', false );
|
9685 |
update_option( 'ewww_image_optimizer_picture_webp', false );
|
9686 |
+
$speed_score += 55;
|
|
|
9687 |
if ( get_option( 'exactdn_lossy' ) ) {
|
9688 |
+
$speed_score += 20;
|
9689 |
+
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) < 30 ) {
|
9690 |
+
$speed_recommendations[] = __( 'Enable premium compression.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/47-getting-more-from-exactdn', '59de6631042863379ddc953c' );
|
9691 |
+
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 20 ) {
|
9692 |
+
$speed_score += 20;
|
9693 |
}
|
9694 |
} elseif (
|
9695 |
( ! class_exists( 'Jetpack_Photon' ) || ! Jetpack::is_module_active( 'photon' ) ) &&
|
9697 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' )
|
9698 |
) {
|
9699 |
if ( $exactdn->get_exactdn_domain() && $exactdn->verify_domain( $exactdn->get_exactdn_domain() ) ) {
|
9700 |
+
$speed_score += 55;
|
|
|
|
|
|
|
9701 |
if ( ewww_image_optimizer_get_option( 'exactdn_lossy' ) ) {
|
9702 |
+
$speed_score += 20;
|
9703 |
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) < 30 ) {
|
9704 |
+
$speed_recommendations[] = __( 'Enable premium compression.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/47-getting-more-from-exactdn', '59de6631042863379ddc953c' );
|
9705 |
+
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 20 ) {
|
9706 |
+
$speed_score += 20;
|
9707 |
}
|
9708 |
$exactdn_enabled = true;
|
9709 |
}
|
9710 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
9711 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
9712 |
+
$speed_recommendations[] = __( 'Enable Easy IO for automatic resizing.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/44-introduction-to-exactdn', '59bc5ad6042863033a1ce370,5c0042892c7d3a31944e88a4' );
|
9713 |
+
}
|
9714 |
delete_option( 'ewww_image_optimizer_exactdn_domain' );
|
9715 |
delete_option( 'ewww_image_optimizer_exactdn_plan_id' );
|
9716 |
delete_option( 'ewww_image_optimizer_exactdn_failures' );
|
9740 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxotherwidth' ) ||
|
9741 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxotherheight' )
|
9742 |
) {
|
9743 |
+
$speed_score += 5;
|
9744 |
} elseif ( defined( 'IMSANITY_VERSION' ) ) {
|
9745 |
+
$speed_score += 5;
|
9746 |
} else {
|
9747 |
+
$speed_recommendations[] = __( 'Configure maximum image dimensions in Resize settings.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/41-resize-settings', '59849911042863033a1ba5f9' );
|
9748 |
}
|
9749 |
$jpg_quality = apply_filters( 'jpeg_quality', 82, 'image_resize' );
|
9750 |
if ( $jpg_quality < 91 && $jpg_quality > 49 ) {
|
9751 |
+
$speed_score += 5;
|
9752 |
} else {
|
9753 |
+
$speed_recommendations[] = __( 'JPG quality level should be between 50 and 90 for optimal resizing.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,58543c69c697912ffd6c19a7' );
|
9754 |
}
|
9755 |
$skip = ewww_image_optimizer_skip_tools();
|
9756 |
+
if ( ewww_image_optimizer_easy_active() ) {
|
9757 |
+
$skip['jpegtran'] = true;
|
9758 |
+
$skip['optipng'] = true;
|
9759 |
+
$skip['gifsicle'] = true;
|
9760 |
+
$skip['pngout'] = true;
|
9761 |
+
$skip['pngquant'] = true;
|
9762 |
+
$skip['webp'] = true;
|
9763 |
+
}
|
9764 |
if ( ! $skip['jpegtran'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9765 |
if ( EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
9766 |
$jpegtran_installed = ewww_image_optimizer_tool_found( EWWW_IMAGE_OPTIMIZER_JPEGTRAN, 'j' );
|
9769 |
}
|
9770 |
}
|
9771 |
if ( ! empty( $jpegtran_installed ) ) {
|
9772 |
+
$speed_score += 5;
|
9773 |
} else {
|
9774 |
+
$speed_recommendations[] = __( 'Install jpegtran.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
9775 |
}
|
9776 |
}
|
9777 |
if ( ! $skip['optipng'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9782 |
}
|
9783 |
}
|
9784 |
if ( ! empty( $optipng_version ) ) {
|
9785 |
+
$speed_score += 5;
|
9786 |
} else {
|
9787 |
+
$speed_recommendations[] = __( 'Install optipng.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
9788 |
}
|
9789 |
}
|
9790 |
if ( ! $skip['pngout'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9795 |
}
|
9796 |
}
|
9797 |
if ( ! empty( $pngout_version ) ) {
|
9798 |
+
$speed_score += 1;
|
9799 |
} else {
|
9800 |
+
$speed_recommendations[] = __( 'Install pngout', 'ewww-image-optimizer' ) . ': <a href="' . admin_url( 'admin.php?action=ewww_image_optimizer_install_pngout' ) . '">' . esc_html__( 'automatically', 'ewww-image-optimizer' ) . '</a> | <a href="https://docs.ewww.io/article/13-installing-pngout" data-beacon-article="5854531bc697912ffd6c1afa">' . esc_html__( 'manually', 'ewww-image-optimizer' ) . '</a>';
|
9801 |
}
|
9802 |
}
|
9803 |
if ( ! $skip['pngquant'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9808 |
}
|
9809 |
}
|
9810 |
if ( ! empty( $pngquant_version ) ) {
|
9811 |
+
$speed_score += 5;
|
9812 |
} else {
|
9813 |
+
$speed_recommendations[] = __( 'Install pngquant.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
9814 |
}
|
9815 |
}
|
9816 |
if ( ! $skip['gifsicle'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9821 |
}
|
9822 |
}
|
9823 |
if ( ! empty( $gifsicle_version ) ) {
|
9824 |
+
$speed_score += 5;
|
9825 |
} else {
|
9826 |
+
$speed_recommendations[] = __( 'Install gifsicle.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
9827 |
}
|
9828 |
}
|
9829 |
if ( EWWW_IMAGE_OPTIMIZER_CWEBP && ! $skip['webp'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9834 |
}
|
9835 |
}
|
9836 |
if ( ! empty( $webp_version ) ) {
|
9837 |
+
$speed_score += 10;
|
9838 |
} else {
|
9839 |
+
$speed_recommendations[] = __( 'Install WebP.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
9840 |
}
|
9841 |
}
|
9842 |
+
if ( get_option( 'easyio_lazy_load' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
9843 |
+
$speed_score += 10;
|
9844 |
+
} else {
|
9845 |
+
$speed_recommendations[] = __( 'Enable Lazy Loading on the Easy Mode tab.', 'ewww-image-optimizer' );
|
9846 |
+
}
|
9847 |
+
if ( ! ewww_image_optimizer_easy_active() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
|
9848 |
+
$speed_recommendations[] = __( 'Enable WebP conversion.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' );
|
9849 |
+
} elseif ( ! ewww_image_optimizer_easy_active() && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
|
9850 |
+
$speed_score += 10;
|
9851 |
+
}
|
9852 |
if (
|
9853 |
( $free_exec || ! empty( $jpegtran_installed ) || ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) &&
|
9854 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_remove' )
|
9855 |
) {
|
9856 |
+
$speed_score += 5;
|
9857 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_remove' ) ) {
|
9858 |
+
$speed_recommendations[] = __( 'Remove metadata from JPG images.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2' );
|
9859 |
}
|
9860 |
if ( ! ewww_image_optimizer_easy_active() && ! $free_exec ) {
|
9861 |
if ( 0 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) ) {
|
9862 |
+
$speed_recommendations[] = __( 'Enable JPG compression.', 'ewww-image-optimizer' );
|
9863 |
}
|
9864 |
if ( 0 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
9865 |
+
$speed_recommendations[] = __( 'Enable PNG compression.', 'ewww-image-optimizer' );
|
9866 |
}
|
9867 |
if ( 0 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) ) {
|
9868 |
+
$speed_recommendations[] = __( 'Enable GIF compression.', 'ewww-image-optimizer' );
|
9869 |
}
|
9870 |
}
|
9871 |
+
if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID < 70200 ) {
|
9872 |
+
if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID < 70000 && $speed_score > 20 ) {
|
9873 |
+
$speed_score -= 20;
|
9874 |
+
} elseif ( $speed_score > 10 ) {
|
9875 |
+
$speed_score -= 10;
|
9876 |
+
}
|
9877 |
+
/* translators: %s: The server PHP version. */
|
9878 |
+
$speed_recommendations[] = sprintf( __( 'Your site is running an older version of PHP (%s), which should be updated.', 'ewww-image-optimizer' ), PHP_VERSION ) . ewwwio_get_help_link( 'https://wordpress.org/support/update-php/', '' );
|
9879 |
+
}
|
9880 |
|
9881 |
// Check that an image library exists for converting resizes. Originals can be done via the API, but resizes are done locally for speed.
|
9882 |
$toolkit_found = false;
|
9928 |
ob_start();
|
9929 |
}
|
9930 |
// Begin building of status inside section.
|
9931 |
+
$speed_score = min( $speed_score, 100 );
|
9932 |
+
$stroke_class = 'ewww-green';
|
9933 |
+
if ( $speed_score < 50 ) {
|
9934 |
+
$stroke_class = 'ewww-red';
|
9935 |
+
} elseif ( $speed_score < 90 ) {
|
9936 |
+
$stroke_class = 'ewww-orange';
|
9937 |
+
}
|
9938 |
+
$guage_stroke_dasharray = 2 * pi() * 54;
|
9939 |
+
$speed_stroke_dashoffset = $guage_stroke_dasharray * ( 1 - $speed_score / 100 );
|
9940 |
?>
|
9941 |
<div id='ewww-widgets' class='metabox-holder'>
|
9942 |
<div class='meta-box-sortables'>
|
9945 |
<div class='inside'>
|
9946 |
<div class="ewww-row"><ul class="ewww-blocks">
|
9947 |
<li><div id="ewww-compress" class="ewww-status-detail">
|
9948 |
+
<div id="ewww-compress-guage" class="ewww-guage" data-score="<?php echo (int) $speed_score; ?>">
|
9949 |
<svg width="120" height="120">
|
9950 |
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
9951 |
+
<circle class="ewww-active <?php echo esc_attr( $stroke_class ); ?>" r="54" cy="60" cx="60" stroke-width="12" style="stroke-dasharray: <?php echo esc_attr( $guage_stroke_dasharray ); ?>px; stroke-dashoffset: <?php echo esc_attr( $speed_stroke_dashoffset ); ?>px;" />
|
9952 |
</svg>
|
9953 |
+
<div class="ewww-score"><?php echo (int) $speed_score; ?>%</div>
|
9954 |
</div><!-- end .ewww-guage -->
|
9955 |
<div id="ewww-compress-recommend" class="ewww-recommend">
|
9956 |
+
<strong><?php echo ( (int) $speed_score < 100 ? esc_html__( 'How do I get to 100%?', 'ewww-image-optimizer' ) : esc_html__( 'You got the perfect score!', 'ewww-image-optimizer' ) ); ?></strong>
|
9957 |
+
<?php if ( $speed_score < 100 ) : ?>
|
9958 |
<ul class="ewww-tooltip">
|
9959 |
+
<?php foreach ( $speed_recommendations as $recommendation ) { ?>
|
9960 |
+
<li><?php echo wp_kses( $recommendation, $allow_help_html ); ?></li>
|
9961 |
<?php } ?>
|
9962 |
</ul>
|
9963 |
<?php endif; ?>
|
9964 |
</div><!-- end .ewww-recommend -->
|
9965 |
+
<p><strong><?php esc_html_e( 'Optimization Score', 'ewww-image-optimizer' ); ?></strong></p>
|
9966 |
+
<?php if ( $speed_score < 100 ) : ?>
|
9967 |
+
<p class="description"><?php esc_html_e( 'Hover over score for recommendations to improve the speed of your site.', 'ewww-image-optimizer' ); ?></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9968 |
<?php endif; ?>
|
|
|
|
|
|
|
9969 |
</div><!-- end .ewww-status-detail --></li>
|
9970 |
<?php
|
9971 |
if ( $total_savings > 0 ) {
|
11294 |
$beacon_attr = 'data-beacon-article';
|
11295 |
$link_class = 'ewww-help-beacon-single';
|
11296 |
}
|
11297 |
+
if ( empty( $hsid ) ) {
|
11298 |
+
echo '<a class="ewww-help-external" href="' . esc_url( $link ) . '" target="_blank">' .
|
11299 |
+
'<img title="' . esc_attr__( 'Help', 'ewww-image-optimizer' ) . '" src="' . esc_url( $help_icon ) . '">' .
|
11300 |
+
'</a>';
|
11301 |
+
return;
|
11302 |
+
}
|
11303 |
echo '<a class="' . esc_attr( $link_class ) . '" href="' . esc_url( $link ) . '" target="_blank" ' . esc_attr( $beacon_attr ) . '="' . esc_attr( $hsid ) . '">' .
|
11304 |
'<img title="' . esc_attr__( 'Help', 'ewww-image-optimizer' ) . '" src="' . esc_url( $help_icon ) . '">' .
|
11305 |
'</a>';
|
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: 5.6.
|
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: 5.6.1
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
includes/jquery-ui-1.10.1.custom.css
CHANGED
@@ -481,7 +481,7 @@ button.ewww-handlediv {
|
|
481 |
.ewww-tab-nav { list-style: none; margin: 10px 0 0; padding-left: 5px; border-bottom: 1px solid #ccc; }
|
482 |
/* optimization status section */
|
483 |
#ewww-widgets {
|
484 |
-
max-width:
|
485 |
}
|
486 |
#ewww-status .inside {
|
487 |
margin: 0;
|
@@ -528,20 +528,31 @@ ul.ewww-blocks li:first-child {
|
|
528 |
.ewww-inactive {
|
529 |
stroke: #e6e6e6;
|
530 |
}
|
|
|
|
|
|
|
531 |
#ewww-compress-guage .ewww-active {
|
532 |
-
stroke: #3eadc9;
|
533 |
stroke-linecap: round;
|
534 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
#ewww-resize-guage .ewww-active {
|
536 |
stroke: #1d3c71;
|
537 |
stroke-linecap: round;
|
538 |
}
|
539 |
#ewww-savings-guage .ewww-active {
|
540 |
-
stroke: #
|
541 |
stroke-linecap: round;
|
542 |
}
|
543 |
#ewww-compress-guage .ewww-score {
|
544 |
-
color: #
|
545 |
}
|
546 |
#ewww-resize-guage .ewww-score {
|
547 |
color: #1d3c71;
|
@@ -559,7 +570,7 @@ ul.ewww-blocks li:first-child {
|
|
559 |
}
|
560 |
#ewww-savings-guage .ewww-score {
|
561 |
font-size: 1rem;
|
562 |
-
color: #
|
563 |
white-space: nowrap;
|
564 |
}
|
565 |
.ewww-recommend {
|
@@ -602,7 +613,7 @@ h3 a.ewww-upgrade {
|
|
602 |
text-decoration: none;
|
603 |
color: #3eadc9;
|
604 |
}
|
605 |
-
.ewww-help-beacon-multi, .ewww-help-beacon-single {
|
606 |
margin: 3px;
|
607 |
}
|
608 |
/* iframe ewww.io */
|
481 |
.ewww-tab-nav { list-style: none; margin: 10px 0 0; padding-left: 5px; border-bottom: 1px solid #ccc; }
|
482 |
/* optimization status section */
|
483 |
#ewww-widgets {
|
484 |
+
max-width: 1000px;
|
485 |
}
|
486 |
#ewww-status .inside {
|
487 |
margin: 0;
|
528 |
.ewww-inactive {
|
529 |
stroke: #e6e6e6;
|
530 |
}
|
531 |
+
#ewww-compress {
|
532 |
+
max-width: 250px;
|
533 |
+
}
|
534 |
#ewww-compress-guage .ewww-active {
|
|
|
535 |
stroke-linecap: round;
|
536 |
}
|
537 |
+
#ewww-compress-guage .ewww-red {
|
538 |
+
stroke: #dc3232;
|
539 |
+
}
|
540 |
+
#ewww-compress-guage .ewww-orange {
|
541 |
+
stroke: #ffb900;
|
542 |
+
}
|
543 |
+
#ewww-compress-guage .ewww-green {
|
544 |
+
stroke: #46b450;
|
545 |
+
}
|
546 |
#ewww-resize-guage .ewww-active {
|
547 |
stroke: #1d3c71;
|
548 |
stroke-linecap: round;
|
549 |
}
|
550 |
#ewww-savings-guage .ewww-active {
|
551 |
+
stroke: #3eadc9;
|
552 |
stroke-linecap: round;
|
553 |
}
|
554 |
#ewww-compress-guage .ewww-score {
|
555 |
+
color: #444;
|
556 |
}
|
557 |
#ewww-resize-guage .ewww-score {
|
558 |
color: #1d3c71;
|
570 |
}
|
571 |
#ewww-savings-guage .ewww-score {
|
572 |
font-size: 1rem;
|
573 |
+
color: #3eadc9;
|
574 |
white-space: nowrap;
|
575 |
}
|
576 |
.ewww-recommend {
|
613 |
text-decoration: none;
|
614 |
color: #3eadc9;
|
615 |
}
|
616 |
+
.ewww-help-beacon-multi, .ewww-help-beacon-single, .ewww-help-external {
|
617 |
margin: 3px;
|
618 |
}
|
619 |
/* iframe ewww.io */
|
readme.txt
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
Contributors: nosilver4u
|
3 |
Donate link: https://ewww.io/donate/
|
4 |
Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale
|
5 |
-
Requires at least: 5.
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 5.6.
|
9 |
License: GPLv3
|
10 |
|
11 |
Speed up your website to better connect with your visitors. Properly compress and size/scale images. Includes lazy load and WebP convert.
|
@@ -30,8 +30,6 @@ EWWW I.O. will optimize images uploaded and created by any plugin, and features
|
|
30 |
|
31 |
Images can be optimized using tools on your own server for free (jpegtran, optipng, pngout, pngquant, gifsicle, cwebp), or can be optimized via specialized servers that utilize the best tools available in lossless or lossy mode. Our lossy compression uses unique algorithms to gain maximum compression while remaining visually lossless. Your images can even be converted to the most suitable file format using the appropriate options. Using the EWWW I.O. API will allow the plugin to work on any hosting platform, and can also be desirable if you cannot, or do not want to use the exec() function on your server, or prefer to offload the resource demands of optimization.
|
32 |
|
33 |
-
If you need a version of this plugin for API use only, see [EWWW Image Optimizer Cloud](https://wordpress.org/plugins/ewww-image-optimizer-cloud/). It is much more compact as it does not contain any binaries or any mention of the exec() function.
|
34 |
-
|
35 |
= Automatic Everything =
|
36 |
|
37 |
With Easy IO, images are automatically compressed, scaled to fit the page and device size, lazy loaded, and converted to the next-gen WebP format.
|
@@ -173,6 +171,15 @@ https://developers.google.com/web/tools/lighthouse/audits/optimize-images
|
|
173 |
* Feature requests can be viewed and submitted at https://feedback.ewww.io
|
174 |
* 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/
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
= 5.6.0 =
|
177 |
* added: if exec() is disabled, free cloud-based JPG compression will be enabled
|
178 |
* added: tool to remove originals for converted images
|
@@ -182,81 +189,6 @@ https://developers.google.com/web/tools/lighthouse/audits/optimize-images
|
|
182 |
* fixed: Easy IO hard crops images when requested height/width is 9999
|
183 |
* fixed: Lazy Load and WebP parsers running on customizer preview pane
|
184 |
|
185 |
-
= 5.5.0 =
|
186 |
-
* added: GIF to WebP conversion with API and Easy IO
|
187 |
-
* changed: plugin removed from disallowed list on WP Engine!
|
188 |
-
* changed: disable Lazy Load auto-scale by defining EIO_LL_AUTOSCALE as false
|
189 |
-
* fixed: async functions use of wp_die causes empty errors when wp_cron is run from WP-CLI
|
190 |
-
* fixed: big image size filter throws error when other plugins run the filter with fewer than 3 parameters
|
191 |
-
* fixed: styling broken for optimization info on Nextgen gallery pages
|
192 |
-
* fixed: broken link for network admin settings from single-site plugins page
|
193 |
-
|
194 |
-
= 5.4.1 =
|
195 |
-
* fixed: Bulk Optimizer sticks on stage 2 when there are no images to optimize
|
196 |
-
* fixed: transparency in PNG images with color type 0 or 2 not detected
|
197 |
-
* fixed: transparency false positives for PNG images with color types 4 and 6
|
198 |
-
* fixed: lazy load skips img elements with unquoted src attributes
|
199 |
-
* fixed: images converted by PNG to JPG (and friends) do not have restore links in library
|
200 |
-
|
201 |
-
= 5.4.0 =
|
202 |
-
* added: EXACTDN_DEFER_JQUERY_SAFE override for when inline scripts depend on jQuery
|
203 |
-
* changed: code rewrite to validate output escaping, input sanitization, and markup on settings page
|
204 |
-
* changed: use data-cfasync=false to prevent deferring inline JS WebP script
|
205 |
-
* changed: Easy IO uses better query-string fall-back for plugins
|
206 |
-
* changed: Easy IO enforces https if available rather than protocol-relative URLs
|
207 |
-
* changed: resize detection ignores images smaller than 25px
|
208 |
-
* changed: settings streamlined when using Easy IO
|
209 |
-
* fixed: parallel optimization on multisite fails due to missing db prefix
|
210 |
-
* fixed: error when saving JS WebP on network/multsite admin
|
211 |
-
* fixed: images not resized when Media File Renamer is active
|
212 |
-
* fixed: PHP warning while using <picture> WebP
|
213 |
-
* fixed: Lazy Load, JS WebP and <picture> WebP have nested fall-back img elements if an image is found multiple times in a page
|
214 |
-
* fixed: Easy IO mangles srcset URLs when src URL is relative instead of absolute
|
215 |
-
* fixed: Easy IO URLs leaking into block editor for new uploads
|
216 |
-
* fixed: WebP rewriting with WP Offload Media skips sub-domains of blog domain
|
217 |
-
* deprecated: support for Image Store plugin (abandoned)
|
218 |
-
|
219 |
-
= 5.3.2 =
|
220 |
-
* added: defer jQuery also with EXACTDN_DEFER_JQUERY override
|
221 |
-
* added: Lazy Load supports VC grid layouts retrieved via AJAX
|
222 |
-
* fixed: Lazy Load and JS WebP prevent loading of images in oEmbed endpoint
|
223 |
-
* fixed: jQuery exclusion was preventing deferral of jQuery extensions also
|
224 |
-
* fixed: Lazy Load parsing Owl Lazy images
|
225 |
-
* fixed: Easy IO adds srcset/sizes to feeds
|
226 |
-
* fixed: filename in attachment metadata not updated for duplicate thumbnails after conversion success
|
227 |
-
* fixed: notices for undefined variables during bulk optimize
|
228 |
-
|
229 |
-
= 5.3.1 =
|
230 |
-
* added: defer JS with Easy IO via EXACTDN_DEFER_SCRIPTS override
|
231 |
-
* fixed: warning related to user-defined exclusions in JS and picture WebP
|
232 |
-
* fixed: AMP compatiblity for Lazy Load and WebP rewriters was broken
|
233 |
-
* fixed: images not loading on WPURP/WPRM print recipe pages
|
234 |
-
|
235 |
-
= 5.3.0 =
|
236 |
-
* added: Easy IO replaces image URLs within style elements for page builders like Elementor and Divi
|
237 |
-
* added: option to use <picture> tags for WebP rewriting
|
238 |
-
* added: ability to define exclusions for JS WebP and <picture> WebP
|
239 |
-
* added: include .webp images when using WP Offload Media to copy images from bucket to server
|
240 |
-
* added: cleanup/migration tool for folks using EWWW IO 3+ years to remove old metadata entries
|
241 |
-
* added: fetch original_image for optimization when local images are removed (WP Offload Media and Microsoft Azure Storage for WordPress)
|
242 |
-
* changed: scheduled optimizer uses async/background mode to prevent timeouts
|
243 |
-
* changed: images that exceed the max resize dimensions will be queued by the bulk scanner even if previously compressed
|
244 |
-
* changed: for security, EWWW IO will only optimize images within the WP root folder, content folder, or uploads folder
|
245 |
-
* changed: WebP Only mode will bypass the check for TinyPNG compression
|
246 |
-
* changed: background/async mode uses better queueing system for speed and reliability
|
247 |
-
* changed: image queue information moved to Tools page
|
248 |
-
* changed: image re-opt troubleshooting moved to Tools page
|
249 |
-
* fixed: noresize in filename has no effect when using Media File Renamer
|
250 |
-
* fixed: debug_message() throws a warning with non-string values
|
251 |
-
* fixed: notices when uploading animated GIFs using GD
|
252 |
-
* fixed: notices when parsing JSON data from Envira
|
253 |
-
* fixed: fatal error when a WP_Error is passed from Envira to Easy IO
|
254 |
-
* fixed: executables could not be installed on Windows due to behavior of is_executable() on directories
|
255 |
-
* fixed: Include All Resources rewrites wrong URLs when quotes are html-encoded
|
256 |
-
* fixed: <picture> tags do not follow Lazy Load exclusions
|
257 |
-
* fixed: <picture> tags broken when exluding images from Lazy Load
|
258 |
-
* fixed: Azure storage plugin doesn't re-upload optimized images
|
259 |
-
|
260 |
= Earlier versions =
|
261 |
Please refer to the separate changelog.txt file.
|
262 |
|
2 |
Contributors: nosilver4u
|
3 |
Donate link: https://ewww.io/donate/
|
4 |
Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale
|
5 |
+
Requires at least: 5.1
|
6 |
+
Tested up to: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 5.6.1
|
9 |
License: GPLv3
|
10 |
|
11 |
Speed up your website to better connect with your visitors. Properly compress and size/scale images. Includes lazy load and WebP convert.
|
30 |
|
31 |
Images can be optimized using tools on your own server for free (jpegtran, optipng, pngout, pngquant, gifsicle, cwebp), or can be optimized via specialized servers that utilize the best tools available in lossless or lossy mode. Our lossy compression uses unique algorithms to gain maximum compression while remaining visually lossless. Your images can even be converted to the most suitable file format using the appropriate options. Using the EWWW I.O. API will allow the plugin to work on any hosting platform, and can also be desirable if you cannot, or do not want to use the exec() function on your server, or prefer to offload the resource demands of optimization.
|
32 |
|
|
|
|
|
33 |
= Automatic Everything =
|
34 |
|
35 |
With Easy IO, images are automatically compressed, scaled to fit the page and device size, lazy loaded, and converted to the next-gen WebP format.
|
171 |
* Feature requests can be viewed and submitted at https://feedback.ewww.io
|
172 |
* 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/
|
173 |
|
174 |
+
= 5.6.1 =
|
175 |
+
* changed: prevent unintentional image re-optimization from plugins with a threshold of 5x, indicate intential regen with ewww_image_optimizer_allowed_reopt filter
|
176 |
+
* changed: include lazy load and WebP in optimization score
|
177 |
+
* fixed: query paramaters added to videos via image_downsize filter
|
178 |
+
* fixed: WP-CLI command triggers async queueing
|
179 |
+
* fixed: WPML check skips too many images during bulk scanner
|
180 |
+
* fixed: WP-CLI command options for FlAGallery and NextGEN using outdated code
|
181 |
+
* fixed: re-optimization tracker not tracking
|
182 |
+
|
183 |
= 5.6.0 =
|
184 |
* added: if exec() is disabled, free cloud-based JPG compression will be enabled
|
185 |
* added: tool to remove originals for converted images
|
189 |
* fixed: Easy IO hard crops images when requested height/width is 9999
|
190 |
* fixed: Lazy Load and WebP parsers running on customizer preview pane
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
= Earlier versions =
|
193 |
Please refer to the separate changelog.txt file.
|
194 |
|
unique.php
CHANGED
@@ -1769,6 +1769,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1769 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) ) {
|
1770 |
ewww_image_optimizer_cloud_init();
|
1771 |
}
|
|
|
1772 |
if ( apply_filters( 'ewww_image_optimizer_bypass', false, $file ) ) {
|
1773 |
ewwwio_debug_message( "optimization bypassed: $file" );
|
1774 |
// Tell the user optimization was skipped.
|
@@ -1830,7 +1831,6 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1830 |
}
|
1831 |
$nice = '';
|
1832 |
if ( ! EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
1833 |
-
ewww_image_optimizer_define_noexec();
|
1834 |
if ( ! EWWW_IMAGE_OPTIMIZER_NOEXEC && PHP_OS !== 'WINNT' ) {
|
1835 |
// Check to see if 'nice' exists.
|
1836 |
$nice = ewww_image_optimizer_find_nix_binary( 'nice', 'n' );
|
1769 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) ) {
|
1770 |
ewww_image_optimizer_cloud_init();
|
1771 |
}
|
1772 |
+
ewww_image_optimizer_define_noexec();
|
1773 |
if ( apply_filters( 'ewww_image_optimizer_bypass', false, $file ) ) {
|
1774 |
ewwwio_debug_message( "optimization bypassed: $file" );
|
1775 |
// Tell the user optimization was skipped.
|
1831 |
}
|
1832 |
$nice = '';
|
1833 |
if ( ! EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
|
|
1834 |
if ( ! EWWW_IMAGE_OPTIMIZER_NOEXEC && PHP_OS !== 'WINNT' ) {
|
1835 |
// Check to see if 'nice' exists.
|
1836 |
$nice = ewww_image_optimizer_find_nix_binary( 'nice', 'n' );
|