Version Description
- fixed: bulk optimizer fails to initialize if the bulk_attachments array is set to an empty string
- fixed: misplaced parenthesis breaks option overrides
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 3.6.1 |
Comparing to | |
See all releases |
Code changes from version 3.5.1 to 3.6.1
- aux-optimize.php +71 -10
- bulk.php +264 -58
- changelog.txt +53 -0
- classes/class-ewww-flag.php +7 -7
- classes/class-ewww-image.php +10 -11
- classes/class-ewww-nextcellent.php +28 -24
- classes/class-ewww-nextgen.php +25 -21
- classes/class-ewwwio-cli.php +2 -1
- classes/class-ewwwio-media-background-process.php +2 -2
- common.php +264 -317
- ewww-image-optimizer.php +26 -2
- includes/eio.js +20 -4
- mwebp.php +4 -4
- readme.txt +38 -27
- tests/test-optimize.php +0 -21
- tests/test-resize.php +0 -30
- unique.php +79 -77
aux-optimize.php
CHANGED
@@ -69,14 +69,38 @@ function ewww_image_optimizer_aux_images() {
|
|
69 |
'<span id="ewww-pointer" style="display:none">0</span>' .
|
70 |
'</div>' .
|
71 |
'</div>';
|
|
|
|
|
72 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
73 |
ewww_image_optimizer_options( 'debug-silent' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
global $ewww_debug;
|
75 |
-
$output .= '<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
echo $output;
|
78 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
79 |
-
$help_instructions = esc_html__( 'Please turn on the Debugging option. Then copy and paste the Debug Information from the bottom of the settings page. This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
|
80 |
$current_user = wp_get_current_user();
|
81 |
$help_email = $current_user->user_email;
|
82 |
$hs_config = array(
|
@@ -91,8 +115,15 @@ function ewww_image_optimizer_aux_images() {
|
|
91 |
);
|
92 |
$hs_identify = array(
|
93 |
'email' => $help_email,
|
94 |
-
'debug_info' => $ewww_debug,
|
95 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
?>
|
97 |
<script type='text/javascript'>
|
98 |
!function(e,o,n){window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={},t.readyQueue=[],t.config=function(e){this.userConfig=e},t.ready=function(e){this.readyQueue.push(e)},o.config={docs:{enabled:!0,baseUrl:"//ewwwio.helpscoutdocs.com/"},contact:{enabled:!0,formId:"af75cf17-310a-11e7-9841-0ab63ef01522"}};var r=e.getElementsByTagName("script")[0],c=e.createElement("script");c.type="text/javascript",c.async=!0,c.src="https://djtflbt20bdde.cloudfront.net/",r.parentNode.insertBefore(c,r)}(document,window.HSCW||{},window.HS||{});
|
@@ -149,7 +180,14 @@ function ewww_image_optimizer_aux_images_table() {
|
|
149 |
$file_size = ewww_image_optimizer_size_format( $optimized_image['image_size'] );
|
150 |
/* translators: %s: human-readable filesize */
|
151 |
$size_string = sprintf( esc_html__( 'Image Size: %s', 'ewww-image-optimizer' ), $file_size );
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
<td style='width:80px' class='column-icon'> </td>
|
154 |
<td class='title'><?php echo $image_name; ?></td>
|
155 |
<td><?php echo $type; ?></td>
|
@@ -161,7 +199,8 @@ function ewww_image_optimizer_aux_images_table() {
|
|
161 |
<?php } ?>
|
162 |
</td>
|
163 |
</tr>
|
164 |
-
<?php
|
|
|
165 |
} elseif ( file_exists( $optimized_image['path'] ) ) {
|
166 |
// Retrieve the mimetype of the attachment.
|
167 |
$type = ewww_image_optimizer_mimetype( $optimized_image['path'], 'i' );
|
@@ -169,7 +208,14 @@ function ewww_image_optimizer_aux_images_table() {
|
|
169 |
$file_size = ewww_image_optimizer_size_format( $optimized_image['image_size'] );
|
170 |
/* translators: %s: human-readable filesize */
|
171 |
$size_string = sprintf( esc_html__( 'Image Size: %s', 'ewww-image-optimizer' ), $file_size );
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
<td style='width:80px' class='column-icon'><img width='50' height='50' src="<?php echo $image_url; ?>" /></td>
|
174 |
<td class='title'>...<?php echo $image_name; ?></td>
|
175 |
<td><?php echo $type; ?></td>
|
@@ -181,7 +227,8 @@ function ewww_image_optimizer_aux_images_table() {
|
|
181 |
<?php } ?>
|
182 |
</td>
|
183 |
</tr>
|
184 |
-
<?php
|
|
|
185 |
} // End if().
|
186 |
} // End foreach().
|
187 |
echo '</table>';
|
@@ -221,7 +268,7 @@ function ewww_image_optimizer_aux_images_remove() {
|
|
221 |
*
|
222 |
* @global object $wpdb
|
223 |
* @return int The total number of records in the images table that are not pending and have a
|
224 |
-
*
|
225 |
*/
|
226 |
function ewww_image_optimizer_aux_images_table_count() {
|
227 |
global $wpdb;
|
@@ -247,6 +294,20 @@ function ewww_image_optimizer_aux_images_table_count_pending() {
|
|
247 |
return $count;
|
248 |
}
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
/**
|
251 |
* Remove all un-optimized images from the ewwwio_images table.
|
252 |
*
|
@@ -273,7 +334,7 @@ function ewww_image_optimizer_delete_pending() {
|
|
273 |
*
|
274 |
* @global object $wpdb
|
275 |
* @global array|string $optimized_list An associative array containing information from the images
|
276 |
-
*
|
277 |
*
|
278 |
* @param string $dir The absolute path of the folder to be scanned for unoptimized images.
|
279 |
* @param int $started Optional. The number of seconds since the overall scanning process started. Default 0.
|
@@ -609,7 +670,7 @@ function ewww_image_optimizer_aux_images_script( $hook = '' ) {
|
|
609 |
}
|
610 |
// Scan images in two most recent media library folders if the option is enabled, and this is a scheduled optimization.
|
611 |
if ( 'ewww-image-optimizer-auto' == $hook && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' ) ) {
|
612 |
-
// Retrieve the location of the
|
613 |
$upload_dir = wp_upload_dir();
|
614 |
// Retrieve the path of the upload folder.
|
615 |
$upload_path = $upload_dir['basedir'];
|
69 |
'<span id="ewww-pointer" style="display:none">0</span>' .
|
70 |
'</div>' .
|
71 |
'</div>';
|
72 |
+
$help_instructions = esc_html__( 'Enable the Debugging option and refresh this page to include debugging information with your question.', 'ewww-image-optimizer' ) . ' ' .
|
73 |
+
esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
|
74 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
75 |
ewww_image_optimizer_options( 'debug-silent' );
|
76 |
+
?>
|
77 |
+
<script type="text/javascript">
|
78 |
+
function selectText(containerid) {
|
79 |
+
var debug_node = document.getElementById(containerid);
|
80 |
+
if (document.selection) {
|
81 |
+
var range = document.body.createTextRange();
|
82 |
+
range.moveToElementText(debug_node);
|
83 |
+
range.select();
|
84 |
+
} else if (window.getSelection) {
|
85 |
+
window.getSelection().selectAllChildren(debug_node);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
</script>
|
89 |
+
<?php
|
90 |
global $ewww_debug;
|
91 |
+
$output .= '<p style="clear:both"><b>' . esc_html__( 'Debugging Information', 'ewww-image-optimizer' ) . ':</b> <button onclick="selectText(' . "'ewww-debug-info'" . ')">' . esc_html__( 'Select All', 'ewww-image-optimizer' ) . '</button>';
|
92 |
+
if ( is_file( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) ) {
|
93 |
+
$debug_log_url = plugins_url( '/debug.log', __FILE__ );
|
94 |
+
$output .= " <a href='$debug_log_url'>" . esc_html( 'View Debug Log', 'ewww-image-optimizer' ) . "</a> - <a href='admin.php?action=ewww_image_optimizer_delete_debug_log'>" . esc_html( 'Remove Debug Log', 'ewww-image-optimizer' ) . '</a>';
|
95 |
+
}
|
96 |
+
$output .= '</p>';
|
97 |
+
$output .= '<div id="ewww-debug-info" style="background:#ffff99;margin-left:-20px;padding:10px" contenteditable="true">' . $ewww_debug . '</div>';
|
98 |
+
$help_instructions = esc_html__( 'Debugging information will be included with your message automatically.', 'ewww-image-optimizer' ) . ' ' .
|
99 |
+
esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
|
100 |
}
|
101 |
echo $output;
|
102 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
103 |
+
/* $help_instructions = esc_html__( 'Please turn on the Debugging option. Then copy and paste the Debug Information from the bottom of the settings page. This will allow us to assist you more quickly.', 'ewww-image-optimizer' ); */
|
104 |
$current_user = wp_get_current_user();
|
105 |
$help_email = $current_user->user_email;
|
106 |
$hs_config = array(
|
115 |
);
|
116 |
$hs_identify = array(
|
117 |
'email' => $help_email,
|
|
|
118 |
);
|
119 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
120 |
+
$ewww_debug_array = explode( '<br>', $ewww_debug );
|
121 |
+
$ewww_debug_i = 0;
|
122 |
+
foreach ( $ewww_debug_array as $ewww_debug_line ) {
|
123 |
+
$hs_identify[ 'debug_info_' . $ewww_debug_i ] = $ewww_debug_line;
|
124 |
+
$ewww_debug_i++;
|
125 |
+
}
|
126 |
+
}
|
127 |
?>
|
128 |
<script type='text/javascript'>
|
129 |
!function(e,o,n){window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={},t.readyQueue=[],t.config=function(e){this.userConfig=e},t.ready=function(e){this.readyQueue.push(e)},o.config={docs:{enabled:!0,baseUrl:"//ewwwio.helpscoutdocs.com/"},contact:{enabled:!0,formId:"af75cf17-310a-11e7-9841-0ab63ef01522"}};var r=e.getElementsByTagName("script")[0],c=e.createElement("script");c.type="text/javascript",c.async=!0,c.src="https://djtflbt20bdde.cloudfront.net/",r.parentNode.insertBefore(c,r)}(document,window.HSCW||{},window.HS||{});
|
180 |
$file_size = ewww_image_optimizer_size_format( $optimized_image['image_size'] );
|
181 |
/* translators: %s: human-readable filesize */
|
182 |
$size_string = sprintf( esc_html__( 'Image Size: %s', 'ewww-image-optimizer' ), $file_size );
|
183 |
+
?>
|
184 |
+
<tr
|
185 |
+
<?php
|
186 |
+
if ( $alternate ) {
|
187 |
+
echo " class='alternate' ";
|
188 |
+
}
|
189 |
+
?>
|
190 |
+
id="ewww-image-<?php echo $optimized_image['id']; ?>">
|
191 |
<td style='width:80px' class='column-icon'> </td>
|
192 |
<td class='title'><?php echo $image_name; ?></td>
|
193 |
<td><?php echo $type; ?></td>
|
199 |
<?php } ?>
|
200 |
</td>
|
201 |
</tr>
|
202 |
+
<?php
|
203 |
+
$alternate = ! $alternate;
|
204 |
} elseif ( file_exists( $optimized_image['path'] ) ) {
|
205 |
// Retrieve the mimetype of the attachment.
|
206 |
$type = ewww_image_optimizer_mimetype( $optimized_image['path'], 'i' );
|
208 |
$file_size = ewww_image_optimizer_size_format( $optimized_image['image_size'] );
|
209 |
/* translators: %s: human-readable filesize */
|
210 |
$size_string = sprintf( esc_html__( 'Image Size: %s', 'ewww-image-optimizer' ), $file_size );
|
211 |
+
?>
|
212 |
+
<tr
|
213 |
+
<?php
|
214 |
+
if ( $alternate ) {
|
215 |
+
echo " class='alternate' ";
|
216 |
+
}
|
217 |
+
?>
|
218 |
+
id="ewww-image-<?php echo $optimized_image['id']; ?>">
|
219 |
<td style='width:80px' class='column-icon'><img width='50' height='50' src="<?php echo $image_url; ?>" /></td>
|
220 |
<td class='title'>...<?php echo $image_name; ?></td>
|
221 |
<td><?php echo $type; ?></td>
|
227 |
<?php } ?>
|
228 |
</td>
|
229 |
</tr>
|
230 |
+
<?php
|
231 |
+
$alternate = ! $alternate;
|
232 |
} // End if().
|
233 |
} // End foreach().
|
234 |
echo '</table>';
|
268 |
*
|
269 |
* @global object $wpdb
|
270 |
* @return int The total number of records in the images table that are not pending and have a
|
271 |
+
* valid file-size.
|
272 |
*/
|
273 |
function ewww_image_optimizer_aux_images_table_count() {
|
274 |
global $wpdb;
|
294 |
return $count;
|
295 |
}
|
296 |
|
297 |
+
/**
|
298 |
+
* Find the number of un-optimized (media) images in the ewwwio_images table.
|
299 |
+
*
|
300 |
+
* This is useful to know if we need to alert the user when the bulk attachments array is empty.
|
301 |
+
*
|
302 |
+
* @global object $wpdb
|
303 |
+
* @return int Number of pending media images in queue.
|
304 |
+
*/
|
305 |
+
function ewww_image_optimizer_aux_images_table_count_pending_media() {
|
306 |
+
global $wpdb;
|
307 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->ewwwio_images WHERE pending=1 AND gallery='media'" );
|
308 |
+
return $count;
|
309 |
+
}
|
310 |
+
|
311 |
/**
|
312 |
* Remove all un-optimized images from the ewwwio_images table.
|
313 |
*
|
334 |
*
|
335 |
* @global object $wpdb
|
336 |
* @global array|string $optimized_list An associative array containing information from the images
|
337 |
+
* table, or 'low_memory', 'large_list', 'small_scan'.
|
338 |
*
|
339 |
* @param string $dir The absolute path of the folder to be scanned for unoptimized images.
|
340 |
* @param int $started Optional. The number of seconds since the overall scanning process started. Default 0.
|
670 |
}
|
671 |
// Scan images in two most recent media library folders if the option is enabled, and this is a scheduled optimization.
|
672 |
if ( 'ewww-image-optimizer-auto' == $hook && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_media_paths' ) ) {
|
673 |
+
// Retrieve the location of the WordPress upload folder.
|
674 |
$upload_dir = wp_upload_dir();
|
675 |
// Retrieve the path of the upload folder.
|
676 |
$upload_path = $upload_dir['basedir'];
|
bulk.php
CHANGED
@@ -117,23 +117,31 @@ function ewww_image_optimizer_bulk_head_output() {
|
|
117 |
* @param string $button_text Value for the button that starts the optimization (after scanning).
|
118 |
* @param int $fullsize_count The total number of images that need to be scanned.
|
119 |
* @param string $resume Optional. If a bulk operation was interrupted, indicates in which phase it
|
120 |
-
*
|
121 |
*/
|
122 |
function ewww_image_optimizer_bulk_action_output( $button_text, $fullsize_count, $resume = '' ) {
|
123 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
124 |
/* translators: %d: number of images */
|
125 |
$scanning_starter_message = sprintf( esc_html__( 'Stage 1, %d images left to scan.', 'ewww-image-optimizer' ), $fullsize_count );
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
|
139 |
/**
|
@@ -179,12 +187,12 @@ function ewww_image_optimizer_reduce_query_count( $max_query ) {
|
|
179 |
*
|
180 |
* @param string $gallery Bulk page that is calling the function. Accepts 'media', 'ngg', and 'flag'.
|
181 |
* @return int|array {
|
182 |
-
*
|
183 |
*
|
184 |
-
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
*
|
188 |
* }
|
189 |
*/
|
190 |
function ewww_image_optimizer_count_optimized( $gallery ) {
|
@@ -442,27 +450,27 @@ function ewww_image_optimizer_bulk_script( $hook ) {
|
|
442 |
// Submit a couple variables for our javascript to work with.
|
443 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
444 |
wp_localize_script('ewwwbulkscript', 'ewww_vars', array(
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
)
|
465 |
-
);
|
466 |
// Load the stylesheet for the jquery progressbar.
|
467 |
wp_enqueue_style( 'jquery-ui-progressbar', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ) );
|
468 |
ewwwio_memory( __FUNCTION__ );
|
@@ -475,7 +483,7 @@ function ewww_image_optimizer_bulk_script( $hook ) {
|
|
475 |
* a memory constraint, or the list of images is too large to be efficient.
|
476 |
*
|
477 |
* @global string|array $optimized_list A list of all images that have been optimized, or a string
|
478 |
-
*
|
479 |
* @global object $wpdb
|
480 |
*/
|
481 |
function ewww_image_optimizer_optimized_list() {
|
@@ -493,8 +501,15 @@ function ewww_image_optimizer_optimized_list() {
|
|
493 |
$offset = 0;
|
494 |
$max_query = (int) apply_filters( 'ewww_image_optimizer_count_optimized_queries', 4000 );
|
495 |
$optimized_list = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
if ( get_transient( 'ewww_image_optimizer_low_memory_mode' ) ) {
|
497 |
$optimized_list = get_transient( 'ewww_image_optimizer_low_memory_mode' );
|
|
|
498 |
return;
|
499 |
}
|
500 |
$starting_memory_usage = memory_get_usage( true );
|
@@ -522,13 +537,14 @@ function ewww_image_optimizer_optimized_list() {
|
|
522 |
ewwwio_debug_message( "estimated batch memory is $estimated_batch_memory" );
|
523 |
}
|
524 |
if ( ! ewwwio_check_memory_available( 3146000 + $estimated_batch_memory ) ) { // Initial batch storage used + 3MB.
|
|
|
525 |
$optimized_list = 'low_memory';
|
526 |
set_transient( 'ewww_image_optimizer_low_memory_mode', 'low_memory', 600 ); // Put it in low memory mode for at least 10 minutes so we don't abuse the db server with extra requests.
|
527 |
return;
|
528 |
}
|
529 |
$elapsed = microtime( true ) - $started;
|
530 |
ewwwio_debug_message( "loading optimized list took $elapsed seconds so far" );
|
531 |
-
if ( $elapsed >
|
532 |
ewwwio_debug_message( 'loading optimized list took too long' );
|
533 |
$optimized_list = 'large_list';
|
534 |
set_transient( 'ewww_image_optimizer_low_memory_mode', 'large_list', 600 ); // Use low memory mode so that we don't waste lots of time pulling a huge list of images repeatedly.
|
@@ -571,6 +587,8 @@ function ewww_image_optimizer_fetch_metadata_batch( $attachments_in ) {
|
|
571 |
$attachment_meta[ $attachment['post_id'] ]['type'] = $attachment['post_mime_type'];
|
572 |
}
|
573 |
continue;
|
|
|
|
|
574 |
}
|
575 |
if ( ! empty( $attachment['post_mime_type'] ) && empty( $attachment_meta[ $attachment['post_id'] ]['type'] ) ) {
|
576 |
$attachment_meta[ $attachment['post_id'] ]['type'] = $attachment['post_mime_type'];
|
@@ -590,7 +608,7 @@ function ewww_image_optimizer_fetch_metadata_batch( $attachments_in ) {
|
|
590 |
* @global object $wpdb
|
591 |
* @global object $ewwwdb A clone of $wpdb unless it is lacking utf8 connectivity.
|
592 |
* @global string|array $optimized_list A list of all images that have been optimized, or a string
|
593 |
-
*
|
594 |
*
|
595 |
* @param string $hook An indicator if this was not called from AJAX, like WP-CLI.
|
596 |
*/
|
@@ -609,7 +627,7 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
609 |
ewwwio_debug_message( 'bailing no nonce' );
|
610 |
ewww_image_optimizer_debug_log();
|
611 |
die( json_encode( array(
|
612 |
-
'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ),
|
613 |
) ) );
|
614 |
}
|
615 |
global $wpdb;
|
@@ -621,7 +639,6 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
621 |
}
|
622 |
global $optimized_list;
|
623 |
$image_count = 0;
|
624 |
-
$reset_count = 0;
|
625 |
$attachments_processed = 0;
|
626 |
$attachment_query = '';
|
627 |
$images = array();
|
@@ -638,7 +655,7 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
638 |
);
|
639 |
ewwwio_debug_message( 'scanning for media attachments' );
|
640 |
update_option( 'ewww_image_optimizer_bulk_resume', 'scanning' );
|
641 |
-
set_transient( 'ewww_image_optimizer_no_scheduled_optimization', true,
|
642 |
|
643 |
// Retrieve the time when the scan starts.
|
644 |
$started = microtime( true );
|
@@ -745,6 +762,10 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
745 |
clearstatcache();
|
746 |
$pending = false;
|
747 |
$remote_file = false;
|
|
|
|
|
|
|
|
|
748 |
if ( empty( $attachment_meta[ $selected_id ]['meta'] ) ) {
|
749 |
ewwwio_debug_message( "empty meta for $selected_id" );
|
750 |
$meta = array();
|
@@ -765,7 +786,6 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
765 |
ewwwio_debug_message( "missing mime for $selected_id" );
|
766 |
}
|
767 |
|
768 |
-
ewww_image_optimizer_debug_log();
|
769 |
if ( 'application/pdf' != $mime // NOT a pdf...
|
770 |
&& ! in_array( $selected_id, $bad_attachments ) // AND NOT a known broken attachment, which would mean we already tried this once before...
|
771 |
&& ( // AND...
|
@@ -1131,6 +1151,10 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
1131 |
if ( ! empty( $reset_images ) ) {
|
1132 |
$ewwwdb->query( "UPDATE $ewwwdb->ewwwio_images SET pending = 1, updated = updated WHERE id IN (" . implode( ',', $reset_images ) . ')' );
|
1133 |
}
|
|
|
|
|
|
|
|
|
1134 |
ewwwio_debug_message( 'storing remaining attachments in scanning_attachments' );
|
1135 |
ewww_image_optimizer_debug_log();
|
1136 |
update_option( 'ewww_image_optimizer_scanning_attachments', $attachment_ids, false );
|
@@ -1200,25 +1224,36 @@ function ewww_image_optimizer_bulk_initialize() {
|
|
1200 |
}
|
1201 |
session_write_close();
|
1202 |
$output = array();
|
1203 |
-
// Update the 'bulk resume' option to show that an operation is in progress.
|
1204 |
-
update_option( 'ewww_image_optimizer_bulk_resume', 'true' );
|
1205 |
$attachments = get_option( 'ewww_image_optimizer_bulk_attachments' );
|
1206 |
if ( ! is_array( $attachments ) && ! empty( $attachments ) ) {
|
1207 |
$attachments = unserialize( $attachments );
|
1208 |
}
|
1209 |
if ( ! is_array( $attachments ) ) {
|
1210 |
-
if
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1220 |
}
|
1221 |
}
|
|
|
|
|
1222 |
$attachment = (int) array_shift( $attachments );
|
1223 |
ewwwio_debug_message( "first image: $attachment" );
|
1224 |
$first_image = new EWWW_Image( $attachment, 'media' );
|
@@ -1236,6 +1271,165 @@ function ewww_image_optimizer_bulk_initialize() {
|
|
1236 |
die( json_encode( $output ) );
|
1237 |
}
|
1238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1239 |
/**
|
1240 |
* Called by AJAX to process each image in the queue.
|
1241 |
*
|
@@ -1263,7 +1457,7 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1263 |
// Retrieve the time when the optimizer starts.
|
1264 |
$started = microtime( true );
|
1265 |
// Prevent the scheduled optimizer from firing during a bulk optimization.
|
1266 |
-
set_transient( 'ewww_image_optimizer_no_scheduled_optimization', true,
|
1267 |
// Find out if our nonce is on it's last leg/tick.
|
1268 |
if ( ! empty( $_REQUEST['ewww_wpnonce'] ) ) {
|
1269 |
$tick = wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk' );
|
@@ -1288,6 +1482,7 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1288 |
'completed' => 0,
|
1289 |
) ) );
|
1290 |
}
|
|
|
1291 |
$output['results'] = '';
|
1292 |
$output['completed'] = 0;
|
1293 |
while ( $output['completed'] < $batch_image_limit && $image->file && microtime( true ) - $started + $time_adjustment < apply_filters( 'ewww_image_optimizer_timeout', 15 ) ) {
|
@@ -1311,6 +1506,11 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1311 |
if ( $image->resize && 'full' != $image->resize && ! is_file( $image->file ) ) {
|
1312 |
// TODO: Make sure this is optional, because of CDN offloading: resized image does not exist, regenerate it.
|
1313 |
}
|
|
|
|
|
|
|
|
|
|
|
1314 |
if ( 'full' === $image->resize && ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) && ! function_exists( 'imsanity_get_max_width_height' ) ) {
|
1315 |
if ( ! $meta || ! is_array( $meta ) ) {
|
1316 |
$meta = wp_get_attachment_metadata( $image->attachment_id );
|
@@ -1326,6 +1526,8 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1326 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
1327 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
1328 |
$output['error'] = esc_html__( 'License Exceeded', 'ewww-image-optimizer' );
|
|
|
|
|
1329 |
die( json_encode( $output ) );
|
1330 |
}
|
1331 |
// Delete a pending record if the optimization failed for whatever reason.
|
@@ -1422,10 +1624,14 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1422 |
} else {
|
1423 |
$output['done'] = 1;
|
1424 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
|
|
|
|
1425 |
return false;
|
1426 |
}
|
1427 |
}
|
1428 |
ewww_image_optimizer_debug_log();
|
|
|
|
|
1429 |
ewwwio_memory( __FUNCTION__ );
|
1430 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
1431 |
return true;
|
117 |
* @param string $button_text Value for the button that starts the optimization (after scanning).
|
118 |
* @param int $fullsize_count The total number of images that need to be scanned.
|
119 |
* @param string $resume Optional. If a bulk operation was interrupted, indicates in which phase it
|
120 |
+
* was operating. Accepts 'true', 'scanning', or ''.
|
121 |
*/
|
122 |
function ewww_image_optimizer_bulk_action_output( $button_text, $fullsize_count, $resume = '' ) {
|
123 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
124 |
/* translators: %d: number of images */
|
125 |
$scanning_starter_message = sprintf( esc_html__( 'Stage 1, %d images left to scan.', 'ewww-image-optimizer' ), $fullsize_count );
|
126 |
+
if ( 'true' == $resume ) {
|
127 |
+
$scan_hide = 'style="display:none"';
|
128 |
+
$start_hide = '';
|
129 |
+
} else {
|
130 |
+
$start_hide = 'style="display:none"';
|
131 |
+
$scan_hide = '';
|
132 |
+
|
133 |
+
}
|
134 |
+
?>
|
135 |
+
<p id="ewww-nothing" class="ewww-bulk-info" style="display:none"><?php echo esc_html_e( 'There are no images to optimize.', 'ewww-image-optimizer' ); ?></p>
|
136 |
+
<p id="ewww-scanning" class="ewww-bulk-info" style="display:none"><?php echo $scanning_starter_message; ?> <img src='<?php echo $loading_image; ?>' alt='loading'/></p>
|
137 |
+
<form id="ewww-aux-start" class="ewww-bulk-form" <?php echo $scan_hide; ?> method="post" action="">
|
138 |
+
<input id="ewww-aux-first" type="submit" class="button-primary action" value="<?php esc_attr_e( 'Scan for unoptimized images', 'ewww-image-optimizer' ); ?>" />
|
139 |
+
<input id="ewww-aux-again" type="submit" class="button-secondary action" style="display:none" value="<?php esc_attr_e( 'Scan Again', 'ewww-image-optimizer' ); ?>" />
|
140 |
+
</form>
|
141 |
+
<form id="ewww-bulk-start" class="ewww-bulk-form" <?php echo $start_hide; ?> method="post" action="">
|
142 |
+
<input id="ewww-aux-first" type="submit" class="button-primary action" value="<?php echo $button_text; ?>" />
|
143 |
+
</form>
|
144 |
+
<?php
|
145 |
}
|
146 |
|
147 |
/**
|
187 |
*
|
188 |
* @param string $gallery Bulk page that is calling the function. Accepts 'media', 'ngg', and 'flag'.
|
189 |
* @return int|array {
|
190 |
+
* The image count(s) found during the search.
|
191 |
*
|
192 |
+
* @type int $full_count The number of original uploads found.
|
193 |
+
* @type int $unoptimized_full The number of original uploads that have not been optimized.
|
194 |
+
* @type int $resize_count The number of thumbnails/resizes found.
|
195 |
+
* @type int $unoptimized_re The number of resizes that are not optimized.
|
196 |
* }
|
197 |
*/
|
198 |
function ewww_image_optimizer_count_optimized( $gallery ) {
|
450 |
// Submit a couple variables for our javascript to work with.
|
451 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
452 |
wp_localize_script('ewwwbulkscript', 'ewww_vars', array(
|
453 |
+
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-bulk' ),
|
454 |
+
'attachments' => ewww_image_optimizer_aux_images_table_count_pending(),
|
455 |
+
'image_count' => $image_count,
|
456 |
+
/* translators: %d: number of images */
|
457 |
+
'count_string' => sprintf( esc_html__( '%d images', 'ewww-image-optimizer' ), $image_count ),
|
458 |
+
'scan_fail' => esc_html__( 'Operation timed out, you may need to increase the max_execution_time or memory_limit for PHP', 'ewww-image-optimizer' ),
|
459 |
+
'scan_incomplete' => esc_html__( 'Scan did not complete, will try again', 'ewww-image-optimizer' ) . " <img src='$loading_image' />",
|
460 |
+
'operation_stopped' => esc_html__( 'Optimization stopped, reload page to resume.', 'ewww-image-optimizer' ),
|
461 |
+
'operation_interrupted' => esc_html__( 'Operation Interrupted', 'ewww-image-optimizer' ),
|
462 |
+
'temporary_failure' => esc_html__( 'Temporary failure, attempts remaining:', 'ewww-image-optimizer' ),
|
463 |
+
'invalid_response' => esc_html__( 'Received an invalid response from your website, please check for errors in the Developer Tools console of your browser.', 'ewww-image-optimizer' ),
|
464 |
+
'bad_attachment' => esc_html__( 'Previous failure due to broken/missing metadata, skipped resizes for attachment:', 'ewww-image-optimizer' ),
|
465 |
+
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
466 |
+
/* translators: used for Bulk Optimize progress bar, like so: Optimized 32/346 */
|
467 |
+
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
468 |
+
'last_image_header' => esc_html__( 'Last Image Optimized', 'ewww-image-optimizer' ),
|
469 |
+
'time_remaining' => esc_html__( 'remaining', 'ewww-image-optimizer' ),
|
470 |
+
'original_restored' => esc_html__( 'Original Restored', 'ewww-image-optimizer' ),
|
471 |
+
'restoring' => '<p>' . esc_html__( 'Restoring', 'ewww-image-optimizer' ) . " <img src='$loading_image' /></p>",
|
472 |
+
'bulk_fail_more' => '<a href="http://docs.ewww.io/article/39-bulk-optimizer-failure" target="_blank" data-beacon-article="596f84f72c7d3a73488b3ca7">' . esc_html__( 'more...', 'ewww-image-optimizer' ) . '</a>',
|
473 |
+
) );
|
474 |
// Load the stylesheet for the jquery progressbar.
|
475 |
wp_enqueue_style( 'jquery-ui-progressbar', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ) );
|
476 |
ewwwio_memory( __FUNCTION__ );
|
483 |
* a memory constraint, or the list of images is too large to be efficient.
|
484 |
*
|
485 |
* @global string|array $optimized_list A list of all images that have been optimized, or a string
|
486 |
+
* indicating why that is not a good idea.
|
487 |
* @global object $wpdb
|
488 |
*/
|
489 |
function ewww_image_optimizer_optimized_list() {
|
501 |
$offset = 0;
|
502 |
$max_query = (int) apply_filters( 'ewww_image_optimizer_count_optimized_queries', 4000 );
|
503 |
$optimized_list = array();
|
504 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_SCAN_MODE_B' ) && EWWW_IMAGE_OPTIMIZER_SCAN_MODE_B ) { // User manually enabled Plan B.
|
505 |
+
ewwwio_debug_message( 'user chose low memory mode' );
|
506 |
+
$optimized_list = 'user_configured';
|
507 |
+
set_transient( 'ewww_image_optimizer_low_memory_mode', 'user_configured', 90 ); // Put it in low memory mode for at least 10 minutes.
|
508 |
+
return;
|
509 |
+
}
|
510 |
if ( get_transient( 'ewww_image_optimizer_low_memory_mode' ) ) {
|
511 |
$optimized_list = get_transient( 'ewww_image_optimizer_low_memory_mode' );
|
512 |
+
ewwwio_debug_message( "staying in low memory mode: $optimized_list" );
|
513 |
return;
|
514 |
}
|
515 |
$starting_memory_usage = memory_get_usage( true );
|
537 |
ewwwio_debug_message( "estimated batch memory is $estimated_batch_memory" );
|
538 |
}
|
539 |
if ( ! ewwwio_check_memory_available( 3146000 + $estimated_batch_memory ) ) { // Initial batch storage used + 3MB.
|
540 |
+
ewwwio_debug_message( 'loading optimized list took too much memory' );
|
541 |
$optimized_list = 'low_memory';
|
542 |
set_transient( 'ewww_image_optimizer_low_memory_mode', 'low_memory', 600 ); // Put it in low memory mode for at least 10 minutes so we don't abuse the db server with extra requests.
|
543 |
return;
|
544 |
}
|
545 |
$elapsed = microtime( true ) - $started;
|
546 |
ewwwio_debug_message( "loading optimized list took $elapsed seconds so far" );
|
547 |
+
if ( $elapsed > 5 ) {
|
548 |
ewwwio_debug_message( 'loading optimized list took too long' );
|
549 |
$optimized_list = 'large_list';
|
550 |
set_transient( 'ewww_image_optimizer_low_memory_mode', 'large_list', 600 ); // Use low memory mode so that we don't waste lots of time pulling a huge list of images repeatedly.
|
587 |
$attachment_meta[ $attachment['post_id'] ]['type'] = $attachment['post_mime_type'];
|
588 |
}
|
589 |
continue;
|
590 |
+
} elseif ( 'tiny_compress_images' == $attachment['meta_key'] ) {
|
591 |
+
$attachment_meta[ $attachment['post_id'] ]['tinypng'] = true;
|
592 |
}
|
593 |
if ( ! empty( $attachment['post_mime_type'] ) && empty( $attachment_meta[ $attachment['post_id'] ]['type'] ) ) {
|
594 |
$attachment_meta[ $attachment['post_id'] ]['type'] = $attachment['post_mime_type'];
|
608 |
* @global object $wpdb
|
609 |
* @global object $ewwwdb A clone of $wpdb unless it is lacking utf8 connectivity.
|
610 |
* @global string|array $optimized_list A list of all images that have been optimized, or a string
|
611 |
+
* indicating why that is not a good idea.
|
612 |
*
|
613 |
* @param string $hook An indicator if this was not called from AJAX, like WP-CLI.
|
614 |
*/
|
627 |
ewwwio_debug_message( 'bailing no nonce' );
|
628 |
ewww_image_optimizer_debug_log();
|
629 |
die( json_encode( array(
|
630 |
+
'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ),
|
631 |
) ) );
|
632 |
}
|
633 |
global $wpdb;
|
639 |
}
|
640 |
global $optimized_list;
|
641 |
$image_count = 0;
|
|
|
642 |
$attachments_processed = 0;
|
643 |
$attachment_query = '';
|
644 |
$images = array();
|
655 |
);
|
656 |
ewwwio_debug_message( 'scanning for media attachments' );
|
657 |
update_option( 'ewww_image_optimizer_bulk_resume', 'scanning' );
|
658 |
+
set_transient( 'ewww_image_optimizer_no_scheduled_optimization', true, 60 * MINUTE_IN_SECONDS );
|
659 |
|
660 |
// Retrieve the time when the scan starts.
|
661 |
$started = microtime( true );
|
762 |
clearstatcache();
|
763 |
$pending = false;
|
764 |
$remote_file = false;
|
765 |
+
if ( ! empty( $attachment_meta[ $selected_id ]['tinypng'] ) ) {
|
766 |
+
ewwwio_debug_message( "TinyPNG already compressed $selected_id" );
|
767 |
+
continue;
|
768 |
+
}
|
769 |
if ( empty( $attachment_meta[ $selected_id ]['meta'] ) ) {
|
770 |
ewwwio_debug_message( "empty meta for $selected_id" );
|
771 |
$meta = array();
|
786 |
ewwwio_debug_message( "missing mime for $selected_id" );
|
787 |
}
|
788 |
|
|
|
789 |
if ( 'application/pdf' != $mime // NOT a pdf...
|
790 |
&& ! in_array( $selected_id, $bad_attachments ) // AND NOT a known broken attachment, which would mean we already tried this once before...
|
791 |
&& ( // AND...
|
1151 |
if ( ! empty( $reset_images ) ) {
|
1152 |
$ewwwdb->query( "UPDATE $ewwwdb->ewwwio_images SET pending = 1, updated = updated WHERE id IN (" . implode( ',', $reset_images ) . ')' );
|
1153 |
}
|
1154 |
+
if ( 250 > $attachments_processed ) { // in-memory table is too slow.
|
1155 |
+
ewwwio_debug_message( 'using in-memory table is too slow, switching to plan b' );
|
1156 |
+
set_transient( 'ewww_image_optimizer_low_memory_mode', 'slow_list', 600 ); // Put it in low memory mode for at least 10 minutes.
|
1157 |
+
}
|
1158 |
ewwwio_debug_message( 'storing remaining attachments in scanning_attachments' );
|
1159 |
ewww_image_optimizer_debug_log();
|
1160 |
update_option( 'ewww_image_optimizer_scanning_attachments', $attachment_ids, false );
|
1224 |
}
|
1225 |
session_write_close();
|
1226 |
$output = array();
|
|
|
|
|
1227 |
$attachments = get_option( 'ewww_image_optimizer_bulk_attachments' );
|
1228 |
if ( ! is_array( $attachments ) && ! empty( $attachments ) ) {
|
1229 |
$attachments = unserialize( $attachments );
|
1230 |
}
|
1231 |
if ( ! is_array( $attachments ) ) {
|
1232 |
+
// See if we care about the attachment list missing: resizing or converting to be done.
|
1233 |
+
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' ) ||
|
1234 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' ) ||
|
1235 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxotherwidth' ) ||
|
1236 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxotherheight' ) ||
|
1237 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_to_png' ) ||
|
1238 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) ||
|
1239 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) ) &&
|
1240 |
+
ewww_image_optimizer_aux_images_table_count_pending_media()
|
1241 |
+
) {
|
1242 |
+
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
1243 |
+
die( json_encode( array(
|
1244 |
+
'error' => esc_html__( 'Error retrieving list of images', 'ewww-image-optimizer' ),
|
1245 |
+
'data' => print_r( $attachments, true ),
|
1246 |
+
) ) );
|
1247 |
+
} else {
|
1248 |
+
die( json_encode( array(
|
1249 |
+
'error' => esc_html__( 'Error retrieving list of images', 'ewww-image-optimizer' ),
|
1250 |
+
'data' => 'print_r disabled',
|
1251 |
+
) ) );
|
1252 |
+
}
|
1253 |
}
|
1254 |
}
|
1255 |
+
// Update the 'bulk resume' option to show that an operation is in progress.
|
1256 |
+
update_option( 'ewww_image_optimizer_bulk_resume', 'true' );
|
1257 |
$attachment = (int) array_shift( $attachments );
|
1258 |
ewwwio_debug_message( "first image: $attachment" );
|
1259 |
$first_image = new EWWW_Image( $attachment, 'media' );
|
1271 |
die( json_encode( $output ) );
|
1272 |
}
|
1273 |
|
1274 |
+
/**
|
1275 |
+
* Skips an un-optimizable image after all counter-measures have been attempted.
|
1276 |
+
*
|
1277 |
+
* @param object $image The EWWW_Image object representing the image to skip.
|
1278 |
+
*/
|
1279 |
+
function ewww_image_optimizer_bulk_skip_image( $image ) {
|
1280 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
1281 |
+
ewww_image_optimizer_update_table( $image->file, filesize( $image->file ), filesize( $image->file ) );
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
* Checks if any optimization failures have been detected and attempts to react accordingly.
|
1286 |
+
*
|
1287 |
+
* @param object $image The EWWW_Image object representing the currently queued image.
|
1288 |
+
*/
|
1289 |
+
function ewww_image_optimizer_bulk_counter_measures( $image ) {
|
1290 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
1291 |
+
if ( ! empty( $_REQUEST['ewww_error_counter'] ) ) {
|
1292 |
+
$error_counter = (int) $_REQUEST['ewww_error_counter'];
|
1293 |
+
if ( 30 != $error_counter ) {
|
1294 |
+
$failed_file = get_transient( 'ewww_image_optimizer_failed_file' );
|
1295 |
+
$previous_incomplete_file = get_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1296 |
+
if ( is_array( get_transient( 'ewww_image_optimizer_bulk_counter_measures' ) ) ) {
|
1297 |
+
$previous_countermeasures = get_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1298 |
+
} else {
|
1299 |
+
$previous_countermeasures = array(
|
1300 |
+
'resize_existing' => false,
|
1301 |
+
'png50' => false,
|
1302 |
+
'png40' => false,
|
1303 |
+
'png2jpg' => false,
|
1304 |
+
'pngdefaults' => false,
|
1305 |
+
'jpg2png' => false,
|
1306 |
+
'jpg40' => false,
|
1307 |
+
'gif2png' => false,
|
1308 |
+
'pdf20' => false,
|
1309 |
+
);
|
1310 |
+
}
|
1311 |
+
if ( $failed_file == $image->file || $previous_incomplete_file == $image->file ) {
|
1312 |
+
ewwwio_debug_message( "failed file detected, taking evasive action: $failed_file" );
|
1313 |
+
// Use the constants for temporary overrides, while keeping track of which ones we've used.
|
1314 |
+
if ( 'image/png' == ewww_image_optimizer_quick_mimetype( $image->file ) ) {
|
1315 |
+
if ( empty( $previous_countermeasures['png50'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL' ) && 50 == ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
1316 |
+
ewwwio_debug_message( 'png50' );
|
1317 |
+
// If the file is a PNG and compression is 50, try 40.
|
1318 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL', 40 );
|
1319 |
+
$previous_countermeasures['png50'] = true;
|
1320 |
+
} elseif ( empty( $previous_countermeasures['png40'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL' ) && 40 <= ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
1321 |
+
ewwwio_debug_message( 'png40' );
|
1322 |
+
// If the file is a PNG and compression is 40 (or higher), try 20.
|
1323 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL', 20 );
|
1324 |
+
$previous_countermeasures['png40'] = true;
|
1325 |
+
} elseif ( empty( $previous_countermeasures['png2jpg'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_PNG_TO_JPG' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) ) {
|
1326 |
+
ewwwio_debug_message( 'png2jpg' );
|
1327 |
+
// If the file is a PNG and PNG2JPG is enabled.
|
1328 |
+
// also set png level to 20 if needed...
|
1329 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PNG_TO_JPG', false );
|
1330 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL' ) && 40 <= ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
1331 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL', 20 );
|
1332 |
+
}
|
1333 |
+
$previous_countermeasures['png2jpg'] = true;
|
1334 |
+
} elseif ( empty( $previous_countermeasures['pngdefaults'] )
|
1335 |
+
&& 10 == ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' )
|
1336 |
+
&& ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) > 2
|
1337 |
+
|| ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_pngout' ) )
|
1338 |
+
) {
|
1339 |
+
ewwwio_debug_message( 'pngdefaults' );
|
1340 |
+
// If PNG compression is 10 with pngout or optipng set higher than 2 or pngout enabled.
|
1341 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG_LEVEL' ) && 2 < ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) ) {
|
1342 |
+
define( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG_LEVEL', 2 );
|
1343 |
+
}
|
1344 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_DISABLE_PNGOUT' ) ) {
|
1345 |
+
define( 'EWWW_IMAGE_OPTIMIZER_DISABLE_PNGOUT', true );
|
1346 |
+
}
|
1347 |
+
$previous_countermeasures['pngdefaults'] = true;
|
1348 |
+
} elseif ( empty( $previous_countermeasures['resize_existing'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_RESIZE_EXISTING' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) ) {
|
1349 |
+
ewwwio_debug_message( 'resize_existing' );
|
1350 |
+
// If resizing is enabled, try to disable it.
|
1351 |
+
define( 'EWWW_IMAGE_OPTIMIZER_RESIZE_EXISTING', false );
|
1352 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL' ) && 40 <= ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
1353 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PNG_LEVEL', 20 );
|
1354 |
+
}
|
1355 |
+
if ( 10 == ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
1356 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG_LEVEL' ) && 2 < ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) ) {
|
1357 |
+
define( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG_LEVEL', 2 );
|
1358 |
+
}
|
1359 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_DISABLE_PNGOUT' ) ) {
|
1360 |
+
define( 'EWWW_IMAGE_OPTIMIZER_DISABLE_PNGOUT', true );
|
1361 |
+
}
|
1362 |
+
}
|
1363 |
+
$previous_countermeasures['resize_existing'] = true;
|
1364 |
+
} else {
|
1365 |
+
// If the file is a PNG and nothing else worked, skip it.
|
1366 |
+
ewww_image_optimizer_bulk_skip_image( $image );
|
1367 |
+
} // End if().
|
1368 |
+
} // End if().
|
1369 |
+
if ( 'image/jpeg' == ewww_image_optimizer_quick_mimetype( $image->file ) ) {
|
1370 |
+
if ( empty( $previous_countermeasures['jpg2png'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_to_png' ) ) {
|
1371 |
+
ewwwio_debug_message( 'jpg2png' );
|
1372 |
+
// If the file is a JPG and JPG2PNG is enabled.
|
1373 |
+
define( 'EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG', false );
|
1374 |
+
$previous_countermeasures['jpg2png'] = true;
|
1375 |
+
} elseif ( empty( $previous_countermeasures['jpg40'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_JPG_LEVEL' ) && 40 == ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) ) {
|
1376 |
+
ewwwio_debug_message( 'jpg40' );
|
1377 |
+
// If the file is a JPG and level 40 is enabled, drop it to 30 (and nuke jpg2png).
|
1378 |
+
define( 'EWWW_IMAGE_OPTIMIZER_JPG_LEVEL', 30 );
|
1379 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG' ) ) {
|
1380 |
+
define( 'EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG', false );
|
1381 |
+
}
|
1382 |
+
$previous_countermeasures['jpg40'] = true;
|
1383 |
+
} elseif ( empty( $previous_countermeasures['resize_existing'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_RESIZE_EXISTING' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) ) {
|
1384 |
+
ewwwio_debug_message( 'resize_existing' );
|
1385 |
+
// If resizing is enabled, try to disable it.
|
1386 |
+
define( 'EWWW_IMAGE_OPTIMIZER_RESIZE_EXISTING', false );
|
1387 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_JPG_LEVEL' ) && 40 == ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) ) {
|
1388 |
+
define( 'EWWW_IMAGE_OPTIMIZER_JPG_LEVEL', 30 );
|
1389 |
+
}
|
1390 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG' ) ) {
|
1391 |
+
define( 'EWWW_IMAGE_OPTIMIZER_JPG_TO_PNG', false );
|
1392 |
+
}
|
1393 |
+
$previous_countermeasures['resize_existing'] = true;
|
1394 |
+
} else {
|
1395 |
+
// If all else fails, skip it.
|
1396 |
+
ewww_image_optimizer_bulk_skip_image( $image );
|
1397 |
+
}
|
1398 |
+
}
|
1399 |
+
if ( 'image/gif' == ewww_image_optimizer_quick_mimetype( $image->file ) ) {
|
1400 |
+
if ( empty( $previous_countermeasures['gif2png'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_GIF_TO_PNG' ) && ewww_image_optimzer_get_option( 'ewww_image_optimizer_gif_to_png' ) ) {
|
1401 |
+
ewwwio_debug_message( 'gif2png' );
|
1402 |
+
// If the file is a GIF and GIF2PNG is enabled.
|
1403 |
+
define( 'EWWW_IMAGE_OPTIMIZER_GIF_TO_PNG', false );
|
1404 |
+
$previous_countermeasures['gif2png'] = true;
|
1405 |
+
} else {
|
1406 |
+
// If all else fails, skip it.
|
1407 |
+
ewww_image_optimizer_bulk_skip_image( $image );
|
1408 |
+
}
|
1409 |
+
}
|
1410 |
+
if ( 'application/pdf' == ewww_image_optimizer_quick_mimetype( $image->file ) ) {
|
1411 |
+
if ( empty( $previous_countermeasures['pdf20'] ) && ! defined( 'EWWW_IMAGE_OPTIMIZER_PDF_LEVEL' ) && 20 == ewww_image_optimzer_get_option( 'ewww_image_optimizer_pdf_level' ) ) {
|
1412 |
+
ewwwio_debug_message( 'pdf20' );
|
1413 |
+
// If lossy PDF is enabled, drop it down a notch.
|
1414 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PDF_LEVEL', 10 );
|
1415 |
+
$previous_countermeasures['pdf20'] = true;
|
1416 |
+
} else {
|
1417 |
+
// If all else fails, skip it.
|
1418 |
+
ewww_image_optimizer_bulk_skip_image( $image );
|
1419 |
+
}
|
1420 |
+
}
|
1421 |
+
set_transient( 'ewww_image_optimizer_bulk_counter_measures', $previous_countermeasures, 600 );
|
1422 |
+
// MAYBE:::In any of the cases, output some sort of warning to let the user know we took evasive action, and they might need to adjust their settings.
|
1423 |
+
} // End if().
|
1424 |
+
set_transient( 'ewww_image_optimizer_failed_file', $image->file, 600 );
|
1425 |
+
return $previous_countermeasures;
|
1426 |
+
} else {
|
1427 |
+
delete_transient( 'ewww_image_optimizer_failed_file' );
|
1428 |
+
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1429 |
+
} // End if().
|
1430 |
+
} // End if().
|
1431 |
+
return false;
|
1432 |
+
}
|
1433 |
/**
|
1434 |
* Called by AJAX to process each image in the queue.
|
1435 |
*
|
1457 |
// Retrieve the time when the optimizer starts.
|
1458 |
$started = microtime( true );
|
1459 |
// Prevent the scheduled optimizer from firing during a bulk optimization.
|
1460 |
+
set_transient( 'ewww_image_optimizer_no_scheduled_optimization', true, 10 * MINUTE_IN_SECONDS );
|
1461 |
// Find out if our nonce is on it's last leg/tick.
|
1462 |
if ( ! empty( $_REQUEST['ewww_wpnonce'] ) ) {
|
1463 |
$tick = wp_verify_nonce( $_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk' );
|
1482 |
'completed' => 0,
|
1483 |
) ) );
|
1484 |
}
|
1485 |
+
|
1486 |
$output['results'] = '';
|
1487 |
$output['completed'] = 0;
|
1488 |
while ( $output['completed'] < $batch_image_limit && $image->file && microtime( true ) - $started + $time_adjustment < apply_filters( 'ewww_image_optimizer_timeout', 15 ) ) {
|
1506 |
if ( $image->resize && 'full' != $image->resize && ! is_file( $image->file ) ) {
|
1507 |
// TODO: Make sure this is optional, because of CDN offloading: resized image does not exist, regenerate it.
|
1508 |
}
|
1509 |
+
$countermeasures = ewww_image_optimizer_bulk_counter_measures( $image );
|
1510 |
+
if ( $countermeasures ) {
|
1511 |
+
$batch_image_limit = 1;
|
1512 |
+
}
|
1513 |
+
set_transient( 'ewww_image_optimizer_bulk_current_image', $image->file, 600 );
|
1514 |
if ( 'full' === $image->resize && ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) && ! function_exists( 'imsanity_get_max_width_height' ) ) {
|
1515 |
if ( ! $meta || ! is_array( $meta ) ) {
|
1516 |
$meta = wp_get_attachment_metadata( $image->attachment_id );
|
1526 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
1527 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
1528 |
$output['error'] = esc_html__( 'License Exceeded', 'ewww-image-optimizer' );
|
1529 |
+
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1530 |
+
delete_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1531 |
die( json_encode( $output ) );
|
1532 |
}
|
1533 |
// Delete a pending record if the optimization failed for whatever reason.
|
1624 |
} else {
|
1625 |
$output['done'] = 1;
|
1626 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
1627 |
+
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1628 |
+
delete_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1629 |
return false;
|
1630 |
}
|
1631 |
}
|
1632 |
ewww_image_optimizer_debug_log();
|
1633 |
+
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1634 |
+
delete_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1635 |
ewwwio_memory( __FUNCTION__ );
|
1636 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
1637 |
return true;
|
changelog.txt
CHANGED
@@ -1,3 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 3.4.0 =
|
2 |
* added: optional usage tracking
|
3 |
* added: close sessions even earlier in background/async handling to prevent lock-ups
|
1 |
+
= 3.6.0 =
|
2 |
+
In an effort to simplify the settings page and make room for new features, many settings have been "hidden" and/or rearranged. It is my hope that this will make it easier for new users to get going with EWWW IO.
|
3 |
+
You can find more information about overriding options in the [Documentation](http://docs.ewww.io)
|
4 |
+
* added: ability to override any boolean/integer options by defining constant of the same name
|
5 |
+
* added: debug information included automatically with help beacon requests when debugging is enabled
|
6 |
+
* added: use wp_raise_memory_limit (WP 4.6+) to avoid memory issues
|
7 |
+
* added: use wp_is_ini_value_changeable (WP 4.6+) to avoid errors when raising max_execution_time
|
8 |
+
* added: notice to use cloud version on Kinsta sites
|
9 |
+
* changed: Better Lossless and Maximum Lossless have been combined for PNG images with more intelligent usage of advpng on the API
|
10 |
+
* changed: resize settings moved to new tab
|
11 |
+
* changed: various options have been removed from the settings page, but are still available via constants, see removals
|
12 |
+
* changed: bulk optimizer will auto-adjust settings if an image fails to optimize
|
13 |
+
* changed: bulk scanner will go into fall-back mode if the normal mode is too slow or if the image table takes longer than 5 seconds to load
|
14 |
+
* changed: images previously compressed by TinyPNG/JPG will be skipped during bulk optimization
|
15 |
+
* fixed: Optipng not working properly on Windows servers.
|
16 |
+
* fixed: notice on settings and bulk pages when debug mode is disabled
|
17 |
+
* removed: ewww_image_optimizer_delay (Bulk Delay), can be selected on the bulk page instead
|
18 |
+
* removed: ewww_image_optimizer_optipng_level (OptiPNG level) option
|
19 |
+
* removed: ewww_image_optimizer_pngout_level (PNGOUT level) option
|
20 |
+
* removed: ewww_image_optimizer_disable_pngout (Disable PNGOUT) option
|
21 |
+
* removed: ewww_image_optimizer_skip_size (Skip Small Images) option
|
22 |
+
* removed: ewww_image_optimizer_skip_png_size (Skip Large PNG Images) option
|
23 |
+
* removed: ewww_image_optimizer_lossy_skip_full (Exclude full-size images from lossy optimization) option
|
24 |
+
* removed: ewww_image_optimizer_metadata_skip_full (Exclude full-size images from metadata removal) option
|
25 |
+
* removed: ewww_image_optimizer_skip_bundle (Use System Paths) option
|
26 |
+
|
27 |
+
= 3.5.1 =
|
28 |
+
* added: optional help beacons on bulk and settings pages
|
29 |
+
* added: disable deferring of WP Offload S3 uploads with EWWW_IMAGE_OPTIMIZER_NO_DEFER_S3
|
30 |
+
* added: override use of wp_add_inline_script with non-standard jQuery by defining EWWW_IMAGE_OPTIMIZER_WEBP_INLINE_FALLBACK
|
31 |
+
* fixed: javascript for bulk optimizers in NextGEN, NextCellent and FlaGallery
|
32 |
+
|
33 |
+
= 3.5.0 =
|
34 |
+
* added: compatibility with S3 Uploads by Human Made
|
35 |
+
* added: MediaPress uploads fully optimized on upload
|
36 |
+
* changed: WebP .htaccess rewrite rule verifier more flexible
|
37 |
+
* changed: WebP .htaccess rewrite rules allow appending type=original to access non-WebP image
|
38 |
+
* changed: if an image is too small for resizing, but the dimensions in the metadata are incorrect, it will attempt to update them
|
39 |
+
* fixed: fatal error if image metadata cannot be read by PEL
|
40 |
+
* fixed: WebP .htaccess rewrite rules work better on LiteSpeed
|
41 |
+
* fixed: WP Symposium integration using old options, scanner now includes avatars folder by default
|
42 |
+
|
43 |
+
= 3.4.1 =
|
44 |
+
* added: move the Alt WebP script to an external resource by defining EWWW_IMAGE_OPTIMIZER_WEBP_EXTERNAL_SCRIPT
|
45 |
+
* changed: API keys are partially revealed, for easier verification
|
46 |
+
* changed: API key no longer uses password field to avoid problems with auto-fill
|
47 |
+
* changed: API key activation raises JPG and PNG to lossy and enables backups
|
48 |
+
* fixed: bulk delay setting not carried over to bulk optimizer
|
49 |
+
* fixed: WP Offload S3 uploads images prior to background optimization, resulting in a second upload afterwards
|
50 |
+
* fixed: single-site settings override not saving in certain cases on multisite
|
51 |
+
* fixed: AMP pages are broken when Alt WebP is enabled with old versions of libxml (less than 2.8.0)
|
52 |
+
* removed: unnecessary call to WP Offload S3 update function after optimization
|
53 |
+
|
54 |
= 3.4.0 =
|
55 |
* added: optional usage tracking
|
56 |
* added: close sessions even earlier in background/async handling to prevent lock-ups
|
classes/class-ewww-flag.php
CHANGED
@@ -98,7 +98,8 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
|
|
98 |
return;
|
99 |
}
|
100 |
?>
|
101 |
-
<div class="wrap"><h1>GRAND FlAGallery <?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1
|
|
|
102 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
103 |
ewww_image_optimizer_cloud_verify();
|
104 |
echo '<a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
|
@@ -124,20 +125,20 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
|
|
124 |
<div class="meta-box-sortables">
|
125 |
<div id="ewww-bulk-last" class="postbox">
|
126 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
127 |
-
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ) ?></span>
|
128 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
129 |
</button>
|
130 |
-
<h2 class="hndle"><span><?php esc_html_e( 'Last Image Optimized', 'ewww-image-optimizer' ) ?></span></h2>
|
131 |
<div class="inside"></div>
|
132 |
</div>
|
133 |
</div>
|
134 |
<div class="meta-box-sortables">
|
135 |
<div id="ewww-bulk-status" class="postbox">
|
136 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
137 |
-
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ) ?></span>
|
138 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
139 |
</button>
|
140 |
-
<h2 class="hndle"><span><?php esc_html_e( 'Optimization Log', 'ewww-image-optimizer' ) ?></span></h2>
|
141 |
<div class="inside"></div>
|
142 |
</div>
|
143 |
</div>
|
@@ -250,8 +251,7 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
|
|
250 |
'temporary_failure' => esc_html__( 'Temporary failure, seconds left to retry:', 'ewww-image-optimizer' ),
|
251 |
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
252 |
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
253 |
-
|
254 |
-
);
|
255 |
}
|
256 |
|
257 |
/**
|
98 |
return;
|
99 |
}
|
100 |
?>
|
101 |
+
<div class="wrap"><h1>GRAND FlAGallery <?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
102 |
+
<?php
|
103 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
104 |
ewww_image_optimizer_cloud_verify();
|
105 |
echo '<a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
|
125 |
<div class="meta-box-sortables">
|
126 |
<div id="ewww-bulk-last" class="postbox">
|
127 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
128 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ); ?></span>
|
129 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
130 |
</button>
|
131 |
+
<h2 class="hndle"><span><?php esc_html_e( 'Last Image Optimized', 'ewww-image-optimizer' ); ?></span></h2>
|
132 |
<div class="inside"></div>
|
133 |
</div>
|
134 |
</div>
|
135 |
<div class="meta-box-sortables">
|
136 |
<div id="ewww-bulk-status" class="postbox">
|
137 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
138 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ); ?></span>
|
139 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
140 |
</button>
|
141 |
+
<h2 class="hndle"><span><?php esc_html_e( 'Optimization Log', 'ewww-image-optimizer' ); ?></span></h2>
|
142 |
<div class="inside"></div>
|
143 |
</div>
|
144 |
</div>
|
251 |
'temporary_failure' => esc_html__( 'Temporary failure, seconds left to retry:', 'ewww-image-optimizer' ),
|
252 |
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
253 |
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
254 |
+
) );
|
|
|
255 |
}
|
256 |
|
257 |
/**
|
classes/class-ewww-image.php
CHANGED
@@ -166,15 +166,15 @@ class EWWW_Image {
|
|
166 |
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
167 |
ewwwio_debug_message( print_r( $new_image, true ) );
|
168 |
}
|
169 |
-
$this->id
|
170 |
-
$this->file
|
171 |
-
$this->attachment_id
|
172 |
-
$this->opt_size
|
173 |
-
$this->orig_size
|
174 |
-
$this->resize
|
175 |
-
$this->converted
|
176 |
-
$this->gallery
|
177 |
-
$this->backup
|
178 |
}
|
179 |
|
180 |
/**
|
@@ -210,8 +210,7 @@ class EWWW_Image {
|
|
210 |
wp_update_post( array(
|
211 |
'ID' => $this->attachment_id,
|
212 |
'post_mime_type' => $mime,
|
213 |
-
|
214 |
-
);
|
215 |
}
|
216 |
|
217 |
/**
|
166 |
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
167 |
ewwwio_debug_message( print_r( $new_image, true ) );
|
168 |
}
|
169 |
+
$this->id = $new_image['id'];
|
170 |
+
$this->file = ewww_image_optimizer_relative_path_replace( $new_image['path'] );
|
171 |
+
$this->attachment_id = $new_image['attachment_id'];
|
172 |
+
$this->opt_size = $new_image['image_size'];
|
173 |
+
$this->orig_size = $new_image['orig_size'];
|
174 |
+
$this->resize = $new_image['resize'];
|
175 |
+
$this->converted = ewww_image_optimizer_relative_path_replace( $new_image['converted'] );
|
176 |
+
$this->gallery = ( empty( $gallery ) ? $new_image['gallery'] : $gallery );
|
177 |
+
$this->backup = $new_image['backup'];
|
178 |
}
|
179 |
|
180 |
/**
|
210 |
wp_update_post( array(
|
211 |
'ID' => $this->attachment_id,
|
212 |
'post_mime_type' => $mime,
|
213 |
+
) );
|
|
|
214 |
}
|
215 |
|
216 |
/**
|
classes/class-ewww-nextcellent.php
CHANGED
@@ -251,10 +251,10 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
251 |
*
|
252 |
* @param int $id The ID number of the image.
|
253 |
* @return array {
|
254 |
-
*
|
255 |
*
|
256 |
-
*
|
257 |
-
*
|
258 |
* }
|
259 |
*/
|
260 |
function ewww_ngg_optimize( $id ) {
|
@@ -427,7 +427,8 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
427 |
}
|
428 |
?>
|
429 |
<div class="wrap">
|
430 |
-
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1
|
|
|
431 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
432 |
ewww_image_optimizer_cloud_verify();
|
433 |
echo '<a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
|
@@ -452,20 +453,20 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
452 |
<div class="meta-box-sortables">
|
453 |
<div id="ewww-bulk-last" class="postbox">
|
454 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
455 |
-
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ) ?></span>
|
456 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
457 |
</button>
|
458 |
-
<h2 class="hndle"><span><?php esc_html_e( 'Last Image Optimized', 'ewww-image-optimizer' ) ?></span></h2>
|
459 |
<div class="inside"></div>
|
460 |
</div>
|
461 |
</div>
|
462 |
<div class="meta-box-sortables">
|
463 |
<div id="ewww-bulk-status" class="postbox">
|
464 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
465 |
-
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ) ?></span>
|
466 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
467 |
</button>
|
468 |
-
<h2 class="hndle"><span><?php esc_html_e( 'Optimization Log', 'ewww-image-optimizer' ) ?></span></h2>
|
469 |
<div class="inside"></div>
|
470 |
</div>
|
471 |
</div>
|
@@ -479,14 +480,16 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
479 |
</form>
|
480 |
<?php
|
481 |
// If there is a previous bulk operation to resume, give the user the option to reset the resume flag.
|
482 |
-
if ( ! empty( $resume ) ) {
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
|
|
|
|
490 |
echo '</div></div>';
|
491 |
if ( ! empty( $_REQUEST['ewww_inline'] ) ) {
|
492 |
die();
|
@@ -586,8 +589,7 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
586 |
'temporary_failure' => esc_html__( 'Temporary failure, seconds left to retry:', 'ewww-image-optimizer' ),
|
587 |
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
588 |
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
589 |
-
|
590 |
-
);
|
591 |
}
|
592 |
|
593 |
/**
|
@@ -761,12 +763,14 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
761 |
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_bulk_permissions', '' ) ) ) {
|
762 |
return;
|
763 |
}
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
|
|
|
|
770 |
}
|
771 |
|
772 |
global $ewwwngg;
|
251 |
*
|
252 |
* @param int $id The ID number of the image.
|
253 |
* @return array {
|
254 |
+
* The optimization results for the image.
|
255 |
*
|
256 |
+
* @type array $fres The optimization results for the full-size image.
|
257 |
+
* @type array $tres The optimization results for the thumbnail.
|
258 |
* }
|
259 |
*/
|
260 |
function ewww_ngg_optimize( $id ) {
|
427 |
}
|
428 |
?>
|
429 |
<div class="wrap">
|
430 |
+
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
431 |
+
<?php
|
432 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
433 |
ewww_image_optimizer_cloud_verify();
|
434 |
echo '<a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
|
453 |
<div class="meta-box-sortables">
|
454 |
<div id="ewww-bulk-last" class="postbox">
|
455 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
456 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ); ?></span>
|
457 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
458 |
</button>
|
459 |
+
<h2 class="hndle"><span><?php esc_html_e( 'Last Image Optimized', 'ewww-image-optimizer' ); ?></span></h2>
|
460 |
<div class="inside"></div>
|
461 |
</div>
|
462 |
</div>
|
463 |
<div class="meta-box-sortables">
|
464 |
<div id="ewww-bulk-status" class="postbox">
|
465 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
466 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ); ?></span>
|
467 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
468 |
</button>
|
469 |
+
<h2 class="hndle"><span><?php esc_html_e( 'Optimization Log', 'ewww-image-optimizer' ); ?></span></h2>
|
470 |
<div class="inside"></div>
|
471 |
</div>
|
472 |
</div>
|
480 |
</form>
|
481 |
<?php
|
482 |
// If there is a previous bulk operation to resume, give the user the option to reset the resume flag.
|
483 |
+
if ( ! empty( $resume ) ) {
|
484 |
+
?>
|
485 |
+
<p class="ewww-bulk-info"><?php esc_html_e( 'If you would like to start over again, press the Reset Status button to reset the bulk operation status.', 'ewww-image-optimizer' ); ?></p>
|
486 |
+
<form id="ewww-bulk-reset" class="ewww-bulk-form" method="post" action="">
|
487 |
+
<?php wp_nonce_field( 'ewww-image-optimizer-bulk-reset', 'ewww_wpnonce' ); ?>
|
488 |
+
<input type="hidden" name="ewww_reset" value="1">
|
489 |
+
<input type="submit" class="button-secondary action" value="<?php esc_attr_e( 'Reset Status', 'ewww-image-optimizer' ); ?>" />
|
490 |
+
</form>
|
491 |
+
<?php
|
492 |
+
}
|
493 |
echo '</div></div>';
|
494 |
if ( ! empty( $_REQUEST['ewww_inline'] ) ) {
|
495 |
die();
|
589 |
'temporary_failure' => esc_html__( 'Temporary failure, seconds left to retry:', 'ewww-image-optimizer' ),
|
590 |
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
591 |
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
592 |
+
) );
|
|
|
593 |
}
|
594 |
|
595 |
/**
|
763 |
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_bulk_permissions', '' ) ) ) {
|
764 |
return;
|
765 |
}
|
766 |
+
?>
|
767 |
+
<script type="text/javascript">
|
768 |
+
jQuery(document).ready(function($){
|
769 |
+
$('select[name^="bulkaction"] option:last-child').after('<option value="bulk_optimize">Bulk Optimize</option>');
|
770 |
+
});
|
771 |
+
</script>
|
772 |
+
<?php
|
773 |
+
}
|
774 |
}
|
775 |
|
776 |
global $ewwwngg;
|
classes/class-ewww-nextgen.php
CHANGED
@@ -529,7 +529,8 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
529 |
}
|
530 |
?>
|
531 |
<div class="wrap">
|
532 |
-
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1
|
|
|
533 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
534 |
ewww_image_optimizer_cloud_verify();
|
535 |
echo '<a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
|
@@ -555,20 +556,20 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
555 |
<div class="meta-box-sortables">
|
556 |
<div id="ewww-bulk-last" class="postbox">
|
557 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
558 |
-
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ) ?></span>
|
559 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
560 |
</button>
|
561 |
-
<h2 class="hndle"><span><?php esc_html_e( 'Last Image Optimized', 'ewww-image-optimizer' ) ?></span></h2>
|
562 |
<div class="inside"></div>
|
563 |
</div>
|
564 |
</div>
|
565 |
<div class="meta-box-sortables">
|
566 |
<div id="ewww-bulk-status" class="postbox">
|
567 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
568 |
-
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ) ?></span>
|
569 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
570 |
</button>
|
571 |
-
<h2 class="hndle"><span><?php esc_html_e( 'Optimization Log', 'ewww-image-optimizer' ) ?></span></h2>
|
572 |
<div class="inside"></div>
|
573 |
</div>
|
574 |
</div>
|
@@ -586,14 +587,16 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
586 |
</form>
|
587 |
<?php
|
588 |
// If there is a previous bulk operation to resume, give the user the option to reset the resume flag.
|
589 |
-
if ( ! empty( $resume ) ) {
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
|
|
|
|
597 |
echo '</div></div>';
|
598 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
599 |
global $ewww_debug;
|
@@ -697,8 +700,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
697 |
'temporary_failure' => esc_html__( 'Temporary failure, seconds left to retry:', 'ewww-image-optimizer' ),
|
698 |
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
699 |
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
700 |
-
|
701 |
-
);
|
702 |
}
|
703 |
|
704 |
/**
|
@@ -861,12 +863,14 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
861 |
if ( ( strpos( $current_screen->id, 'nggallery-manage-images' ) === false && strpos( $current_screen->id, 'nggallery-manage-gallery' ) === false ) || ! current_user_can( apply_filters( 'ewww_image_optimizer_bulk_permissions', '' ) ) ) {
|
862 |
return;
|
863 |
}
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
|
|
|
|
870 |
}
|
871 |
// Initialize the plugin and the class.
|
872 |
global $ewwwngg;
|
529 |
}
|
530 |
?>
|
531 |
<div class="wrap">
|
532 |
+
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
533 |
+
<?php
|
534 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
535 |
ewww_image_optimizer_cloud_verify();
|
536 |
echo '<a id="ewww-bulk-credits-available" target="_blank" class="page-title-action" style="float:right;" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . ewww_image_optimizer_cloud_quota() . '</a>';
|
556 |
<div class="meta-box-sortables">
|
557 |
<div id="ewww-bulk-last" class="postbox">
|
558 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
559 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ); ?></span>
|
560 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
561 |
</button>
|
562 |
+
<h2 class="hndle"><span><?php esc_html_e( 'Last Image Optimized', 'ewww-image-optimizer' ); ?></span></h2>
|
563 |
<div class="inside"></div>
|
564 |
</div>
|
565 |
</div>
|
566 |
<div class="meta-box-sortables">
|
567 |
<div id="ewww-bulk-status" class="postbox">
|
568 |
<button type="button" class="handlediv button-link" aria-expanded="true">
|
569 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Click to toggle', 'ewww-image-optimizer' ); ?></span>
|
570 |
<span class="toggle-indicator" aria-hidden="true"></span>
|
571 |
</button>
|
572 |
+
<h2 class="hndle"><span><?php esc_html_e( 'Optimization Log', 'ewww-image-optimizer' ); ?></span></h2>
|
573 |
<div class="inside"></div>
|
574 |
</div>
|
575 |
</div>
|
587 |
</form>
|
588 |
<?php
|
589 |
// If there is a previous bulk operation to resume, give the user the option to reset the resume flag.
|
590 |
+
if ( ! empty( $resume ) ) {
|
591 |
+
?>
|
592 |
+
<p class="ewww-bulk-info"><?php esc_html_e( 'If you would like to start over again, press the Reset Status button to reset the bulk operation status.', 'ewww-image-optimizer' ); ?></p>
|
593 |
+
<form id="ewww-bulk-reset" class="ewww-bulk-form" method="post" action="">
|
594 |
+
<?php wp_nonce_field( 'ewww-image-optimizer-bulk-reset', 'ewww_wpnonce' ); ?>
|
595 |
+
<input type="hidden" name="ewww_reset" value="1">
|
596 |
+
<input type="submit" class="button-secondary action" value="<?php esc_attr_e( 'Reset Status', 'ewww-image-optimizer' ); ?>" />
|
597 |
+
</form>
|
598 |
+
<?php
|
599 |
+
}
|
600 |
echo '</div></div>';
|
601 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
602 |
global $ewww_debug;
|
700 |
'temporary_failure' => esc_html__( 'Temporary failure, seconds left to retry:', 'ewww-image-optimizer' ),
|
701 |
'remove_failed' => esc_html__( 'Could not remove image from table.', 'ewww-image-optimizer' ),
|
702 |
'optimized' => esc_html__( 'Optimized', 'ewww-image-optimizer' ),
|
703 |
+
) );
|
|
|
704 |
}
|
705 |
|
706 |
/**
|
863 |
if ( ( strpos( $current_screen->id, 'nggallery-manage-images' ) === false && strpos( $current_screen->id, 'nggallery-manage-gallery' ) === false ) || ! current_user_can( apply_filters( 'ewww_image_optimizer_bulk_permissions', '' ) ) ) {
|
864 |
return;
|
865 |
}
|
866 |
+
?>
|
867 |
+
<script type="text/javascript">
|
868 |
+
jQuery(document).ready(function($){
|
869 |
+
$('select[name^="bulkaction"] option:last-child').after('<option value="bulk_optimize"><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></option>');
|
870 |
+
});
|
871 |
+
</script>
|
872 |
+
<?php
|
873 |
+
}
|
874 |
}
|
875 |
// Initialize the plugin and the class.
|
876 |
global $ewwwngg;
|
classes/class-ewwwio-cli.php
CHANGED
@@ -54,7 +54,8 @@ class EWWWIO_CLI extends WP_CLI_Command {
|
|
54 |
global $ewww_defer;
|
55 |
$ewww_defer = false;
|
56 |
// because NextGEN hasn't flushed it's buffers...
|
57 |
-
while ( @ob_end_flush() ) {
|
|
|
58 |
$library = $args[0];
|
59 |
if ( empty( $args[1] ) ) {
|
60 |
$delay = ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' );
|
54 |
global $ewww_defer;
|
55 |
$ewww_defer = false;
|
56 |
// because NextGEN hasn't flushed it's buffers...
|
57 |
+
while ( @ob_end_flush() ) {
|
58 |
+
}
|
59 |
$library = $args[0];
|
60 |
if ( empty( $args[1] ) ) {
|
61 |
$delay = ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' );
|
classes/class-ewwwio-media-background-process.php
CHANGED
@@ -50,7 +50,7 @@ class EWWWIO_Media_Background_Process extends WP_Background_Process {
|
|
50 |
* @global bool $ewww_defer True to defer optimization, false otherwise.
|
51 |
*
|
52 |
* @param array $item The id of the attachment, how many attempts have been made to process
|
53 |
-
*
|
54 |
* @return bool|array If the item is not complete, return it. False indicates completion.
|
55 |
*/
|
56 |
protected function task( $item ) {
|
@@ -482,7 +482,7 @@ class EWWWIO_Async_Request extends WP_Async_Request {
|
|
482 |
if ( is_file( $file_path ) ) {
|
483 |
return $file_path;
|
484 |
}
|
485 |
-
// Retrieve the location of the
|
486 |
$upload_dir = wp_upload_dir();
|
487 |
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
488 |
$file = $upload_path . $file_path;
|
50 |
* @global bool $ewww_defer True to defer optimization, false otherwise.
|
51 |
*
|
52 |
* @param array $item The id of the attachment, how many attempts have been made to process
|
53 |
+
* the item, the type of attachment, and whether it is a new upload.
|
54 |
* @return bool|array If the item is not complete, return it. False indicates completion.
|
55 |
*/
|
56 |
protected function task( $item ) {
|
482 |
if ( is_file( $file_path ) ) {
|
483 |
return $file_path;
|
484 |
}
|
485 |
+
// Retrieve the location of the WordPress upload folder.
|
486 |
$upload_dir = wp_upload_dir();
|
487 |
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
488 |
$file = $upload_path . $file_path;
|
common.php
CHANGED
@@ -17,8 +17,6 @@
|
|
17 |
// TODO: use a transient to do health checks on the schedule optimizer.
|
18 |
// TODO: add a column to track compression level used for each image, and later implement a way to (re)compress at a specific compression level.
|
19 |
// TODO: might be able to use the Custom Bulk Actions in 4.7 to support the bulk optimize drop-down menu.
|
20 |
-
// TODO: see if there is a way to query the last couple months (or 30 days) worth of attachments, but only when the user is not using year/month folders. This way, they can catch extraneous images if possible. Use the post_date field, and do a media_scan followed by the folder scan to catch remaining images.
|
21 |
-
// TODO: move resizing options into their own sub-menu.
|
22 |
// TODO: need to make the scheduler so it can resume without having to re-run the queue population, and then we can probably also flush the queue when scheduled opt starts, but later it would be nice to implement the bulk_loop as the aux_loop so that it could handle media properly.
|
23 |
// TODO: implement a search for the bulk table, or maybe we should just move it to it's own page?
|
24 |
// TODO: port bulk changes to NextGEN and FlaGallery.
|
@@ -27,7 +25,6 @@
|
|
27 |
// TODO: write some tests for update_table and check_table, find_already_opt, and remove_dups.
|
28 |
// TODO: write some conversion tests.
|
29 |
// TODO: do a bottom paginator for the show optimized images table.
|
30 |
-
// TODO: use wp_http_supports( array( 'ssl' ) ) to detect whether we should use https.
|
31 |
// TODO: check this patch, to see if the use of 'full' causes any issues: https://core.trac.wordpress.org/ticket/37840 .
|
32 |
// TODO: perhaps have an optional footer thingy that says how many images have been optimized.
|
33 |
// TODO: integrate AGR, since it's "abandoned", but possibly using gifsicle for better GIFs.
|
@@ -35,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
35 |
exit;
|
36 |
}
|
37 |
|
38 |
-
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '
|
39 |
|
40 |
// Initialize a couple globals.
|
41 |
$ewww_debug = '';
|
@@ -528,7 +525,7 @@ function ewww_image_optimizer_filter_page_output( $buffer ) {
|
|
528 |
$libxml_previous_error_reporting = libxml_use_internal_errors( true );
|
529 |
$html->formatOutput = false;
|
530 |
$html->encoding = 'utf-8';
|
531 |
-
if ( defined( 'LIBXML_VERSION' ) && LIBXML_VERSION < 20800 ) {
|
532 |
ewwwio_debug_message( 'libxml version: ' . LIBXML_VERSION );
|
533 |
// Converts the buffer from utf-8 to html-entities.
|
534 |
$buffer = mb_convert_encoding( $buffer, 'HTML-ENTITIES', 'UTF-8' );
|
@@ -934,6 +931,10 @@ function ewww_image_optimizer_stl_check() {
|
|
934 |
ewwwio_debug_message( 'stl disabled by user' );
|
935 |
return false;
|
936 |
}
|
|
|
|
|
|
|
|
|
937 |
return ewww_image_optimizer_function_exists( 'set_time_limit' );
|
938 |
}
|
939 |
|
@@ -1095,10 +1096,12 @@ function ewww_image_optimizer_admin_init() {
|
|
1095 |
}
|
1096 |
if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
1097 |
// Set the common network settings if they have been POSTed.
|
1098 |
-
if ( isset( $_POST['
|
1099 |
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
1100 |
ewwwio_debug_message( print_r( $_POST, true ) );
|
1101 |
}
|
|
|
|
|
1102 |
$_POST['ewww_image_optimizer_debug'] = ( empty( $_POST['ewww_image_optimizer_debug'] ) ? false : true );
|
1103 |
update_site_option( 'ewww_image_optimizer_debug', $_POST['ewww_image_optimizer_debug'] );
|
1104 |
$_POST['ewww_image_optimizer_jpegtran_copy'] = ( empty( $_POST['ewww_image_optimizer_jpegtran_copy'] ) ? false : true );
|
@@ -1111,10 +1114,6 @@ function ewww_image_optimizer_admin_init() {
|
|
1111 |
update_site_option( 'ewww_image_optimizer_gif_level', (int) $_POST['ewww_image_optimizer_gif_level'] );
|
1112 |
$_POST['ewww_image_optimizer_pdf_level'] = empty( $_POST['ewww_image_optimizer_pdf_level'] ) ? '' : $_POST['ewww_image_optimizer_pdf_level'];
|
1113 |
update_site_option( 'ewww_image_optimizer_pdf_level', (int) $_POST['ewww_image_optimizer_pdf_level'] );
|
1114 |
-
$_POST['ewww_image_optimizer_lossy_skip_full'] = ( empty( $_POST['ewww_image_optimizer_lossy_skip_full'] ) ? false : true );
|
1115 |
-
update_site_option( 'ewww_image_optimizer_lossy_skip_full', $_POST['ewww_image_optimizer_lossy_skip_full'] );
|
1116 |
-
$_POST['ewww_image_optimizer_metadata_skip_full'] = ( empty( $_POST['ewww_image_optimizer_metadata_skip_full'] ) ? false : true );
|
1117 |
-
update_site_option( 'ewww_image_optimizer_metadata_skip_full', $_POST['ewww_image_optimizer_metadata_skip_full'] );
|
1118 |
$_POST['ewww_image_optimizer_delete_originals'] = ( empty( $_POST['ewww_image_optimizer_delete_originals'] ) ? false : true );
|
1119 |
update_site_option( 'ewww_image_optimizer_delete_originals', $_POST['ewww_image_optimizer_delete_originals'] );
|
1120 |
$_POST['ewww_image_optimizer_jpg_to_png'] = ( empty( $_POST['ewww_image_optimizer_jpg_to_png'] ) ? false : true );
|
@@ -1133,8 +1132,6 @@ function ewww_image_optimizer_admin_init() {
|
|
1133 |
update_site_option( 'ewww_image_optimizer_disable_convert_links', $_POST['ewww_image_optimizer_disable_convert_links'] );
|
1134 |
$_POST['ewww_image_optimizer_backup_files'] = ( empty( $_POST['ewww_image_optimizer_backup_files'] ) ? false : true );
|
1135 |
update_site_option( 'ewww_image_optimizer_backup_files', $_POST['ewww_image_optimizer_backup_files'] );
|
1136 |
-
$_POST['ewww_image_optimizer_cloud_key'] = empty( $_POST['ewww_image_optimizer_cloud_key'] ) ? '' : $_POST['ewww_image_optimizer_cloud_key'];
|
1137 |
-
update_site_option( 'ewww_image_optimizer_cloud_key', ewww_image_optimizer_cloud_key_sanitize( $_POST['ewww_image_optimizer_cloud_key'] ) );
|
1138 |
$_POST['ewww_image_optimizer_auto'] = ( empty( $_POST['ewww_image_optimizer_auto'] ) ? false : true );
|
1139 |
update_site_option( 'ewww_image_optimizer_auto', $_POST['ewww_image_optimizer_auto'] );
|
1140 |
$_POST['ewww_image_optimizer_aux_paths'] = empty( $_POST['ewww_image_optimizer_aux_paths'] ) ? '' : $_POST['ewww_image_optimizer_aux_paths'];
|
@@ -1143,8 +1140,6 @@ function ewww_image_optimizer_admin_init() {
|
|
1143 |
update_site_option( 'ewww_image_optimizer_exclude_paths', ewww_image_optimizer_exclude_paths_sanitize( $_POST['ewww_image_optimizer_exclude_paths'] ) );
|
1144 |
$_POST['ewww_image_optimizer_enable_cloudinary'] = ( empty( $_POST['ewww_image_optimizer_enable_cloudinary'] ) ? false : true );
|
1145 |
update_site_option( 'ewww_image_optimizer_enable_cloudinary', $_POST['ewww_image_optimizer_enable_cloudinary'] );
|
1146 |
-
$_POST['ewww_image_optimizer_delay'] = empty( $_POST['ewww_image_optimizer_delay'] ) ? '' : $_POST['ewww_image_optimizer_delay'];
|
1147 |
-
update_site_option( 'ewww_image_optimizer_delay', (int) $_POST['ewww_image_optimizer_delay'] );
|
1148 |
$_POST['ewww_image_optimizer_maxmediawidth'] = empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ? 0 : $_POST['ewww_image_optimizer_maxmediawidth'];
|
1149 |
update_site_option( 'ewww_image_optimizer_maxmediawidth', (int) $_POST['ewww_image_optimizer_maxmediawidth'] );
|
1150 |
$_POST['ewww_image_optimizer_maxmediaheight'] = empty( $_POST['ewww_image_optimizer_maxmediaheight'] ) ? 0 : $_POST['ewww_image_optimizer_maxmediaheight'];
|
@@ -1157,10 +1152,6 @@ function ewww_image_optimizer_admin_init() {
|
|
1157 |
update_site_option( 'ewww_image_optimizer_resize_detection', $_POST['ewww_image_optimizer_resize_detection'] );
|
1158 |
$_POST['ewww_image_optimizer_resize_existing'] = ( empty( $_POST['ewww_image_optimizer_resize_existing'] ) ? false : true );
|
1159 |
update_site_option( 'ewww_image_optimizer_resize_existing', $_POST['ewww_image_optimizer_resize_existing'] );
|
1160 |
-
$_POST['ewww_image_optimizer_skip_size'] = empty( $_POST['ewww_image_optimizer_skip_size'] ) ? '' : $_POST['ewww_image_optimizer_skip_size'];
|
1161 |
-
update_site_option( 'ewww_image_optimizer_skip_size', (int) $_POST['ewww_image_optimizer_skip_size'] );
|
1162 |
-
$_POST['ewww_image_optimizer_skip_png_size'] = empty( $_POST['ewww_image_optimizer_skip_png_size'] ) ? '' : $_POST['ewww_image_optimizer_skip_png_size'];
|
1163 |
-
update_site_option( 'ewww_image_optimizer_skip_png_size', (int) $_POST['ewww_image_optimizer_skip_png_size'] );
|
1164 |
$_POST['ewww_image_optimizer_parallel_optimization'] = ( empty( $_POST['ewww_image_optimizer_parallel_optimization'] ) ? false : true );
|
1165 |
update_site_option( 'ewww_image_optimizer_parallel_optimization', $_POST['ewww_image_optimizer_parallel_optimization'] );
|
1166 |
$_POST['ewww_image_optimizer_include_media_paths'] = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
|
@@ -1204,47 +1195,42 @@ function ewww_image_optimizer_admin_init() {
|
|
1204 |
update_option( 'ewww_image_optimizer_gif_level', '10' );
|
1205 |
}
|
1206 |
// Register all the common EWWW IO settings.
|
|
|
1207 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
|
1208 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpegtran_copy', 'boolval' );
|
1209 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
|
1210 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_level', 'intval' );
|
1211 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_level', 'intval' );
|
1212 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pdf_level', 'intval' );
|
1213 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_lossy_skip_full', 'boolval' );
|
1214 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_metadata_skip_full', 'boolval' );
|
1215 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_delete_originals', 'boolval' );
|
1216 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_to_png', 'boolval' );
|
1217 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_to_jpg', 'boolval' );
|
1218 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_to_png', 'boolval' );
|
1219 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp', 'boolval' );
|
1220 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_background', 'ewww_image_optimizer_jpg_background' );
|
1221 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_quality', 'ewww_image_optimizer_jpg_quality' );
|
1222 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_convert_links', 'boolval' );
|
1223 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_backup_files', 'boolval' );
|
1224 |
-
register_setting( 'ewww_image_optimizer_options', '
|
|
|
|
|
1225 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
|
|
|
1226 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_aux_paths', 'ewww_image_optimizer_aux_paths_sanitize' );
|
1227 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exclude_paths', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
1228 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_cloudinary', 'boolval' );
|
1229 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_delay', 'intval' );
|
1230 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediawidth', 'intval' );
|
1231 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediaheight', 'intval' );
|
1232 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxotherwidth', 'intval' );
|
1233 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxotherheight', 'intval' );
|
1234 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_detection', 'boolval' );
|
1235 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_existing', 'boolval' );
|
|
|
1236 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
1237 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes_opt', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
1238 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_skip_size', 'intval' );
|
1239 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_skip_png_size', 'intval' );
|
1240 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
|
1241 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
|
1242 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_for_cdn', 'boolval' );
|
1243 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_force', 'boolval' );
|
1244 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_paths', 'ewww_image_optimizer_webp_paths_sanitize' );
|
1245 |
global $ewwwio_tracking;
|
1246 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_allow_tracking', array( $ewwwio_tracking, 'check_for_settings_optin' ) );
|
1247 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_help', 'boolval' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1248 |
ewww_image_optimizer_exec_init();
|
1249 |
ewww_image_optimizer_cron_setup( 'ewww_image_optimizer_auto' );
|
1250 |
/**
|
@@ -1797,7 +1783,7 @@ function ewww_image_optimizer_retina_wrapper( $meta ) {
|
|
1797 |
}
|
1798 |
|
1799 |
/**
|
1800 |
-
* Filters image sizes generated by
|
1801 |
*
|
1802 |
* @param array $sizes A list of sizes to be generated.
|
1803 |
* @return array A list of sizes, minus any the user wants disabled.
|
@@ -1911,10 +1897,10 @@ function ewww_image_optimizer_handle_upload( $params ) {
|
|
1911 |
* Makes sure W3TC uploads all modified files to any configured CDNs.
|
1912 |
*
|
1913 |
* @global array $ewww_attachment {
|
1914 |
-
*
|
1915 |
*
|
1916 |
-
*
|
1917 |
-
*
|
1918 |
* }
|
1919 |
*
|
1920 |
* @param array $files Files being updated by W3TC.
|
@@ -2079,12 +2065,12 @@ function ewww_image_optimizer_network_admin_menu() {
|
|
2079 |
// Add options page to the settings menu.
|
2080 |
$permissions = apply_filters( 'ewww_image_optimizer_superadmin_permissions', '' );
|
2081 |
$ewww_network_options_page = add_submenu_page(
|
2082 |
-
'settings.php',
|
2083 |
-
'EWWW Image Optimizer',
|
2084 |
-
'EWWW Image Optimizer',
|
2085 |
-
$permissions,
|
2086 |
-
EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE,
|
2087 |
-
'ewww_image_optimizer_network_options'
|
2088 |
);
|
2089 |
}
|
2090 |
}
|
@@ -2122,20 +2108,20 @@ function ewww_image_optimizer_admin_menu() {
|
|
2122 |
if ( ! is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
2123 |
// Add options page to the settings menu.
|
2124 |
$ewww_options_page = add_options_page(
|
2125 |
-
'EWWW Image Optimizer',
|
2126 |
-
'EWWW Image Optimizer',
|
2127 |
-
apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ),
|
2128 |
-
EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE,
|
2129 |
-
'ewww_image_optimizer_options'
|
2130 |
);
|
2131 |
} else {
|
2132 |
// Add options page to the single-site settings menu.
|
2133 |
$ewww_options_page = add_options_page(
|
2134 |
-
'EWWW Image Optimizer',
|
2135 |
-
'EWWW Image Optimizer',
|
2136 |
-
apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ),
|
2137 |
-
EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE,
|
2138 |
-
'ewww_image_optimizer_network_singlesite_options'
|
2139 |
);
|
2140 |
}
|
2141 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
@@ -2242,8 +2228,16 @@ function ewww_image_optimizer_ims() {
|
|
2242 |
$image_name = get_the_title( $id );
|
2243 |
$gallery_name = get_the_title( $gid );
|
2244 |
$image_url = esc_url( $meta['sizes']['mini']['url'] );
|
2245 |
-
?>
|
2246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2247 |
echo "<td class='title'>$image_name</td>";
|
2248 |
echo "<td>$gallery_name</td><td>";
|
2249 |
ewww_image_optimizer_custom_column( 'ewww-image-optimizer', $id );
|
@@ -2318,7 +2312,8 @@ function ewww_image_optimizer_webp_inline_script() {
|
|
2318 |
<script>
|
2319 |
function check_webp_feature(a,b){var c={alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"},d=!1,e=new Image;e.onload=function(){var a=e.width>0&&e.height>0;d=!0,b(a)},e.onerror=function(){d=!1,b(!1)},e.src="data:image/webp;base64,"+c[a]}function ewww_load_images(a){jQuery(document).arrive(".ewww_webp",function(){ewww_load_images(a)}),function(b){function d(a,d){for(var e=["align","alt","border","crossorigin","height","hspace","ismap","longdesc","usemap","vspace","width","accesskey","class","contenteditable","contextmenu","dir","draggable","dropzone","hidden","id","lang","spellcheck","style","tabindex","title","translate","sizes","data-attachment-id","data-permalink","data-orig-size","data-comments-opened","data-image-meta","data-image-title","data-image-description"],f=0,g=e.length;f<g;f++){var h=b(a).attr(c+e[f]);void 0!==h&&!1!==h&&b(d).attr(e[f],h)}return d}var c="data-";a&&(b(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a").each(function(){var a=b(this).attr("data-webp");void 0!==a&&!1!==a&&b(this).attr("data-src",a);var a=b(this).attr("data-webp-thumbnail");void 0!==a&&!1!==a&&b(this).attr("data-thumbnail",a)}),b(".image-wrapper a, .ngg-pro-masonry-item a").each(function(){var a=b(this).attr("data-webp");void 0!==a&&!1!==a&&b(this).attr("href",a)}),b(".rev_slider ul li").each(function(){var a=b(this).attr("data-webp-thumb");void 0!==a&&!1!==a&&b(this).attr("data-thumb",a);for(var c=1;c<11;){var a=b(this).attr("data-webp-param"+c);void 0!==a&&!1!==a&&b(this).attr("data-param"+c,a),c++}}),b(".rev_slider img").each(function(){var a=b(this).attr("data-webp-lazyload");void 0!==a&&!1!==a&&b(this).attr("data-lazyload",a)})),b("img.ewww_webp_lazy_retina").each(function(){if(a){var c=b(this).attr("data-srcset-webp");void 0!==c&&!1!==c&&b(this).attr("data-srcset",c)}else{var c=b(this).attr("data-srcset-img");void 0!==c&&!1!==c&&b(this).attr("data-srcset",c)}b(this).removeClass("ewww_webp_lazy_retina")}),b("video").each(function(){if(a){var c=b(this).attr("data-poster-webp");void 0!==c&&!1!==c&&b(this).attr("poster",c)}else{var c=b(this).attr("data-poster-image");void 0!==c&&!1!==c&&b(this).attr("poster",c)}}),b("img.ewww_webp_lazy_load").each(function(){if(a){b(this).attr("data-lazy-src",b(this).attr("data-lazy-webp-src"));var c=b(this).attr("data-srcset-webp");void 0!==c&&!1!==c&&b(this).attr("srcset",c);var c=b(this).attr("data-lazy-srcset-webp");void 0!==c&&!1!==c&&b(this).attr("data-lazy-srcset",c)}else{b(this).attr("data-lazy-src",b(this).attr("data-lazy-img-src"));var c=b(this).attr("data-srcset");void 0!==c&&!1!==c&&b(this).attr("srcset",c);var c=b(this).attr("data-lazy-srcset-img");void 0!==c&&!1!==c&&b(ewww_img).attr("data-lazy-srcset",c)}b(this).removeClass("ewww_webp_lazy_load")}),b(".ewww_webp_lazy_hueman").each(function(){var c=document.createElement("img");if(b(c).attr("src",b(this).attr("data-src")),a){b(c).attr("data-src",b(this).attr("data-webp-src"));var e=b(this).attr("data-srcset-webp");void 0!==e&&!1!==e&&b(c).attr("data-srcset",e)}else{b(c).attr("data-src",b(this).attr("data-img"));var e=b(this).attr("data-srcset-img");void 0!==e&&!1!==e&&b(c).attr("data-srcset",e)}c=d(this,c),b(this).after(c),b(this).removeClass("ewww_webp_lazy_hueman")}),b(".ewww_webp").each(function(){var c=document.createElement("img");if(a){b(c).attr("src",b(this).attr("data-webp"));var e=b(this).attr("data-srcset-webp");void 0!==e&&!1!==e&&b(c).attr("srcset",e);var e=b(this).attr("data-webp-orig-file");void 0!==e&&!1!==e&&b(c).attr("data-orig-file",e);var e=b(this).attr("data-webp-medium-file");void 0!==e&&!1!==e&&b(c).attr("data-medium-file",e);var e=b(this).attr("data-webp-large-file");void 0!==e&&!1!==e&&b(c).attr("data-large-file",e)}else{b(c).attr("src",b(this).attr("data-img"));var e=b(this).attr("data-srcset-img");void 0!==e&&!1!==e&&b(c).attr("srcset",e)}c=d(this,c),b(this).after(c),b(this).removeClass("ewww_webp")})}(jQuery),jQuery.fn.isotope&&jQuery.fn.imagesLoaded&&(jQuery(".fusion-posts-container-infinite").imagesLoaded(function(){jQuery(".fusion-posts-container-infinite").hasClass("isotope")&&jQuery(".fusion-posts-container-infinite").isotope()}),jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").imagesLoaded(function(){jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").isotope()}))}var Arrive=function(a,b,c){"use strict";function l(a,b,c){e.addMethod(b,c,a.unbindEvent),e.addMethod(b,c,a.unbindEventWithSelectorOrCallback),e.addMethod(b,c,a.unbindEventWithSelectorAndCallback)}function m(a){a.arrive=j.bindEvent,l(j,a,"unbindArrive"),a.leave=k.bindEvent,l(k,a,"unbindLeave")}if(a.MutationObserver&&"undefined"!=typeof HTMLElement){var d=0,e=function(){var b=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;return{matchesSelector:function(a,c){return a instanceof HTMLElement&&b.call(a,c)},addMethod:function(a,b,c){var d=a[b];a[b]=function(){return c.length==arguments.length?c.apply(this,arguments):"function"==typeof d?d.apply(this,arguments):void 0}},callCallbacks:function(a){for(var c,b=0;c=a[b];b++)c.callback.call(c.elem)},checkChildNodesRecursively:function(a,b,c,d){for(var g,f=0;g=a[f];f++)c(g,b,d)&&d.push({callback:b.callback,elem:g}),g.childNodes.length>0&&e.checkChildNodesRecursively(g.childNodes,b,c,d)},mergeArrays:function(a,b){var d,c={};for(d in a)c[d]=a[d];for(d in b)c[d]=b[d];return c},toElementsArray:function(b){return void 0===b||"number"==typeof b.length&&b!==a||(b=[b]),b}}}(),f=function(){var a=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null};return a.prototype.addEvent=function(a,b,c,d){var e={target:a,selector:b,options:c,callback:d,firedElems:[]};return this._beforeAdding&&this._beforeAdding(e),this._eventsBucket.push(e),e},a.prototype.removeEvent=function(a){for(var c,b=this._eventsBucket.length-1;c=this._eventsBucket[b];b--)a(c)&&(this._beforeRemoving&&this._beforeRemoving(c),this._eventsBucket.splice(b,1))},a.prototype.beforeAdding=function(a){this._beforeAdding=a},a.prototype.beforeRemoving=function(a){this._beforeRemoving=a},a}(),g=function(b,d){var g=new f,h=this,i={fireOnAttributesModification:!1};return g.beforeAdding(function(c){var i,e=c.target;c.selector,c.callback;e!==a.document&&e!==a||(e=document.getElementsByTagName("html")[0]),i=new MutationObserver(function(a){d.call(this,a,c)});var j=b(c.options);i.observe(e,j),c.observer=i,c.me=h}),g.beforeRemoving(function(a){a.observer.disconnect()}),this.bindEvent=function(a,b,c){b=e.mergeArrays(i,b);for(var d=e.toElementsArray(this),f=0;f<d.length;f++)g.addEvent(d[f],a,b,c)},this.unbindEvent=function(){var a=e.toElementsArray(this);g.removeEvent(function(b){for(var d=0;d<a.length;d++)if(this===c||b.target===a[d])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(a){var f,b=e.toElementsArray(this),d=a;f="function"==typeof a?function(a){for(var e=0;e<b.length;e++)if((this===c||a.target===b[e])&&a.callback===d)return!0;return!1}:function(d){for(var e=0;e<b.length;e++)if((this===c||d.target===b[e])&&d.selector===a)return!0;return!1},g.removeEvent(f)},this.unbindEventWithSelectorAndCallback=function(a,b){var d=e.toElementsArray(this);g.removeEvent(function(e){for(var f=0;f<d.length;f++)if((this===c||e.target===d[f])&&e.selector===a&&e.callback===b)return!0;return!1})},this},h=function(){function h(a){var b={attributes:!1,childList:!0,subtree:!0};return a.fireOnAttributesModification&&(b.attributes=!0),b}function i(a,b){a.forEach(function(a){var c=a.addedNodes,d=a.target,f=[];null!==c&&c.length>0?e.checkChildNodesRecursively(c,b,k,f):"attributes"===a.type&&k(d,b,f)&&f.push({callback:b.callback,elem:node}),e.callCallbacks(f)})}function k(a,b,f){if(e.matchesSelector(a,b.selector)&&(a._id===c&&(a._id=d++),-1==b.firedElems.indexOf(a._id))){if(b.options.onceOnly){if(0!==b.firedElems.length)return;b.me.unbindEventWithSelectorAndCallback.call(b.target,b.selector,b.callback)}b.firedElems.push(a._id),f.push({callback:b.callback,elem:a})}}var f={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};j=new g(h,i);var l=j.bindEvent;return j.bindEvent=function(a,b,c){void 0===c?(c=b,b=f):b=e.mergeArrays(f,b);var d=e.toElementsArray(this);if(b.existing){for(var g=[],h=0;h<d.length;h++)for(var i=d[h].querySelectorAll(a),j=0;j<i.length;j++)g.push({callback:c,elem:i[j]});if(b.onceOnly&&g.length)return c.call(g[0].elem);setTimeout(e.callCallbacks,1,g)}l.call(this,a,b,c)},j},i=function(){function d(a){return{childList:!0,subtree:!0}}function f(a,b){a.forEach(function(a){var c=a.removedNodes,f=(a.target,[]);null!==c&&c.length>0&&e.checkChildNodesRecursively(c,b,h,f),e.callCallbacks(f)})}function h(a,b){return e.matchesSelector(a,b.selector)}var c={};k=new g(d,f);var i=k.bindEvent;return k.bindEvent=function(a,b,d){void 0===d?(d=b,b=c):b=e.mergeArrays(c,b),i.call(this,a,b,d)},k},j=new h,k=new i;b&&m(b.fn),m(HTMLElement.prototype),m(NodeList.prototype),m(HTMLCollection.prototype),m(HTMLDocument.prototype),m(Window.prototype);var n={};return l(j,n,"unbindAllArrive"),l(k,n,"unbindAllLeave"),n}}(window,"undefined"==typeof jQuery?null:jQuery,void 0);"undefined"!=typeof jQuery&&check_webp_feature("alpha",ewww_load_images);
|
2320 |
</script>
|
2321 |
-
<?php
|
|
|
2322 |
// Current length 9473.
|
2323 |
}
|
2324 |
|
@@ -2460,7 +2455,7 @@ function ewww_image_optimizer_aux_paths_sanitize( $input ) {
|
|
2460 |
$i++;
|
2461 |
$path = sanitize_text_field( $path );
|
2462 |
ewwwio_debug_message( "validating auxiliary path: $path" );
|
2463 |
-
// Retrieve the location of the
|
2464 |
$upload_dir = apply_filters( 'ewww_image_optimizer_folder_restriction', wp_upload_dir( null, false ) );
|
2465 |
// Retrieve the path of the upload folder from the array.
|
2466 |
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
@@ -2742,7 +2737,7 @@ function ewww_image_optimizer_manual() {
|
|
2742 |
// Retrieve the existing attachment metadata.
|
2743 |
$original_meta = wp_get_attachment_metadata( $attachment_id );
|
2744 |
// If the call was to optimize...
|
2745 |
-
if ( 'ewww_image_optimizer_manual_optimize' === $_REQUEST['action'] ||
|
2746 |
// Call the optimize from metadata function and store the resulting new metadata.
|
2747 |
$new_meta = ewww_image_optimizer_resize_from_meta_data( $original_meta, $attachment_id );
|
2748 |
} elseif ( 'ewww_image_optimizer_manual_restore' === $_REQUEST['action'] || 'ewww_manual_restore' === $_REQUEST['action'] ) {
|
@@ -2914,20 +2909,13 @@ function ewww_image_optimizer_cloud_restore_single_image( $image ) {
|
|
2914 |
if ( ! empty( $image['path'] ) ) {
|
2915 |
$image['path'] = ewww_image_optimizer_relative_path_replace( $image['path'] );
|
2916 |
}
|
2917 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
2918 |
-
if ( empty( $ewww_cloud_transport ) ) {
|
2919 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
2920 |
-
return false;
|
2921 |
-
} else {
|
2922 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
2923 |
-
}
|
2924 |
-
}
|
2925 |
-
if ( empty( $ewww_cloud_transport ) ) {
|
2926 |
-
$ewww_cloud_transport = 'https';
|
2927 |
-
}
|
2928 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
2929 |
$domain = parse_url( get_site_url(), PHP_URL_HOST );
|
2930 |
-
$url =
|
|
|
|
|
|
|
|
|
2931 |
$result = wp_remote_post( $url, array(
|
2932 |
'timeout' => 30,
|
2933 |
'sslverify' => false,
|
@@ -3121,7 +3109,7 @@ function ewww_image_optimizer_cloud_key_sanitize( $key ) {
|
|
3121 |
function ewww_image_optimizer_full_cloud() {
|
3122 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) > 10 ) {
|
3123 |
return true;
|
3124 |
-
} elseif (
|
3125 |
return true;
|
3126 |
}
|
3127 |
return false;
|
@@ -3133,7 +3121,7 @@ function ewww_image_optimizer_full_cloud() {
|
|
3133 |
function ewww_image_optimizer_cloud_enable() {
|
3134 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3135 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_jpg_level', 30 );
|
3136 |
-
ewww_image_optimizer_set_option( 'ewww_image_optimizer_png_level',
|
3137 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_gif_level', 10 );
|
3138 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_pdf_level', 10 );
|
3139 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_backup_files', 1 );
|
@@ -3191,9 +3179,7 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
3191 |
}
|
3192 |
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
3193 |
$ewww_cloud_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
3194 |
-
$
|
3195 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
3196 |
-
if ( ! ewww_image_optimizer_detect_wpsf_location_lock() && $cache && preg_match( '/^(\d{1,3}\.){3}\d{1,3}$/', $ewww_cloud_ip ) && preg_match( '/http/', $ewww_cloud_transport ) && preg_match( '/great/', $ewww_cloud_status ) ) {
|
3197 |
ewwwio_debug_message( 'using cached verification' );
|
3198 |
global $ewwwio_async_key_verification;
|
3199 |
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
@@ -3205,62 +3191,31 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
3205 |
$ewwwio_async_key_verification->dispatch();
|
3206 |
return $ewww_cloud_status;
|
3207 |
}
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
ewwwio_debug_message( 'using cached ip' );
|
3213 |
-
$result = ewww_image_optimizer_cloud_post_key( $ewww_cloud_ip, $ewww_cloud_transport, $api_key );
|
3214 |
-
if ( is_wp_error( $result ) ) {
|
3215 |
-
$ewww_cloud_transport = 'http';
|
3216 |
-
$error_message = $result->get_error_message();
|
3217 |
-
ewwwio_debug_message( "verification failed: $error_message" );
|
3218 |
-
$result = ewww_image_optimizer_cloud_post_key( $ewww_cloud_ip, $ewww_cloud_transport, $api_key );
|
3219 |
-
}
|
3220 |
-
if ( is_wp_error( $result ) ) {
|
3221 |
-
$error_message = $result->get_error_message();
|
3222 |
-
ewwwio_debug_message( "verification failed: $error_message" );
|
3223 |
-
} elseif ( ! empty( $result['body'] ) && preg_match( '/(great|exceeded)/', $result['body'] ) ) {
|
3224 |
-
$verified = $result['body'];
|
3225 |
-
ewwwio_debug_message( "verification success via: $ewww_cloud_transport://$ewww_cloud_ip" );
|
3226 |
-
} else {
|
3227 |
-
ewwwio_debug_message( "verification failed via: $ewww_cloud_ip" );
|
3228 |
-
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
3229 |
-
ewwwio_debug_message( print_r( $result, true ) );
|
3230 |
-
}
|
3231 |
-
}
|
3232 |
}
|
3233 |
-
|
3234 |
-
|
3235 |
-
$
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3239 |
}
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
$error_message = $result->get_error_message();
|
3246 |
-
ewwwio_debug_message( "verification failed via $ewww_cloud_transport://$ip: $error_message" );
|
3247 |
-
} elseif ( ! empty( $result['body'] ) && preg_match( '/(great|exceeded)/', $result['body'] ) ) {
|
3248 |
-
$verified = $result['body'];
|
3249 |
-
if ( preg_match( '/exceeded/', $verified ) ) {
|
3250 |
-
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', time() + 300 );
|
3251 |
-
}
|
3252 |
-
$ewww_cloud_ip = $ip;
|
3253 |
-
ewwwio_debug_message( "verification success via: $ewww_cloud_transport://$ewww_cloud_ip" );
|
3254 |
-
break;
|
3255 |
-
} else {
|
3256 |
-
ewwwio_debug_message( "verification failed via: $ip" );
|
3257 |
-
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
3258 |
-
ewwwio_debug_message( print_r( $result, true ) );
|
3259 |
-
}
|
3260 |
-
}
|
3261 |
-
}
|
3262 |
-
} else {
|
3263 |
-
ewwwio_debug_message( 'unable to parse server list' );
|
3264 |
}
|
3265 |
}
|
3266 |
if ( empty( $verified ) ) {
|
@@ -3268,8 +3223,6 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
3268 |
return false;
|
3269 |
} else {
|
3270 |
set_transient( 'ewww_image_optimizer_cloud_status', $verified, 3600 );
|
3271 |
-
set_transient( 'ewww_image_optimizer_cloud_ip', $ewww_cloud_ip, 3600 );
|
3272 |
-
set_transient( 'ewww_image_optimizer_cloud_transport', $ewww_cloud_transport, 3600 );
|
3273 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) < 20 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) < 20 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) < 20 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) == 0 ) {
|
3274 |
ewww_image_optimizer_cloud_enable();
|
3275 |
}
|
@@ -3282,13 +3235,12 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
3282 |
/**
|
3283 |
* POSTs the API key to the API for verification.
|
3284 |
*
|
3285 |
-
* @param string $
|
3286 |
-
* @param string $transport The transport to use: http or https.
|
3287 |
* @param string $key The API key to submit via POST.
|
3288 |
* @return array The results of the http POST request.
|
3289 |
*/
|
3290 |
-
function ewww_image_optimizer_cloud_post_key( $
|
3291 |
-
$result = wp_remote_post(
|
3292 |
'timeout' => 5,
|
3293 |
'sslverify' => false,
|
3294 |
'body' => array(
|
@@ -3305,20 +3257,12 @@ function ewww_image_optimizer_cloud_post_key( $ip, $transport, $key ) {
|
|
3305 |
*/
|
3306 |
function ewww_image_optimizer_cloud_quota() {
|
3307 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3308 |
-
// $ewww_cloud_ip = get_transient( 'ewww_image_optimizer_cloud_ip' );
|
3309 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
3310 |
-
if ( empty( $ewww_cloud_transport ) ) {
|
3311 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
3312 |
-
return '';
|
3313 |
-
} else {
|
3314 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
3315 |
-
}
|
3316 |
-
}
|
3317 |
-
if ( empty( $ewww_cloud_transport ) ) {
|
3318 |
-
$ewww_cloud_transport = 'https';
|
3319 |
-
}
|
3320 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
3321 |
-
$url =
|
|
|
|
|
|
|
|
|
3322 |
$result = wp_remote_post( $url, array(
|
3323 |
'timeout' => 5,
|
3324 |
'sslverify' => false,
|
@@ -3376,26 +3320,30 @@ function ewww_image_optimizer_cloud_quota() {
|
|
3376 |
* @param array $jpg_fill Optional. Fill color for PNG to JPG conversion in hex format.
|
3377 |
* @param int $jpg_quality Optional. JPG quality level. Default null. Accepts 1-100.
|
3378 |
* @return array {
|
3379 |
-
*
|
3380 |
*
|
3381 |
-
*
|
3382 |
-
*
|
3383 |
-
*
|
3384 |
-
*
|
3385 |
* }
|
3386 |
*/
|
3387 |
function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $newfile = null, $newtype = null, $fullsize = false, $jpg_fill = '', $jpg_quality = 82 ) {
|
3388 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3389 |
-
$
|
3390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3391 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
3392 |
$started = microtime( true );
|
3393 |
-
if (
|
3394 |
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
3395 |
return array( $file, false, 'key verification failed', 0, '' );
|
3396 |
-
} else {
|
3397 |
-
$ewww_cloud_ip = get_transient( 'ewww_image_optimizer_cloud_ip' );
|
3398 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
3399 |
}
|
3400 |
}
|
3401 |
// Calculate how much time has elapsed since we started.
|
@@ -3484,12 +3432,16 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
3484 |
ewwwio_debug_message( "jpg fill: $jpg_fill" );
|
3485 |
ewwwio_debug_message( "jpg quality: $jpg_quality" );
|
3486 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
3487 |
-
$url =
|
|
|
|
|
|
|
|
|
3488 |
$boundary = wp_generate_password( 24, false );
|
3489 |
|
3490 |
$headers = array(
|
3491 |
'content-type' => 'multipart/form-data; boundary=' . $boundary,
|
3492 |
-
'timeout' =>
|
3493 |
'httpversion' => '1.0',
|
3494 |
'blocking' => true,
|
3495 |
);
|
@@ -3532,7 +3484,7 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
3532 |
|
3533 |
// Retrieve the time when the optimizer starts.
|
3534 |
$response = wp_remote_post( $url, array(
|
3535 |
-
'timeout' =>
|
3536 |
'headers' => $headers,
|
3537 |
'sslverify' => false,
|
3538 |
'body' => $payload,
|
@@ -3585,17 +3537,21 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
3585 |
*/
|
3586 |
function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
|
3587 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3588 |
-
$
|
3589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3590 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
3591 |
$started = microtime( true );
|
3592 |
-
if (
|
3593 |
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
3594 |
ewwwio_debug_message( 'cloud verify failed, image not rotated' );
|
3595 |
return false;
|
3596 |
-
} else {
|
3597 |
-
$ewww_cloud_ip = get_transient( 'ewww_image_optimizer_cloud_ip' );
|
3598 |
-
$ewww_cloud_transport = get_transient( 'ewww_image_optimizer_cloud_transport' );
|
3599 |
}
|
3600 |
}
|
3601 |
// Calculate how much time has elapsed since we started.
|
@@ -3609,7 +3565,11 @@ function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
|
|
3609 |
ewwwio_debug_message( "file: $file " );
|
3610 |
ewwwio_debug_message( "type: $type" );
|
3611 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
3612 |
-
$url =
|
|
|
|
|
|
|
|
|
3613 |
$boundary = wp_generate_password( 24, false );
|
3614 |
|
3615 |
$headers = array(
|
@@ -3989,10 +3949,10 @@ function ewww_image_optimizer_size_format( $size, $precision = 1 ) {
|
|
3989 |
* @global string $ewww_debug Contains in-memory debug log.
|
3990 |
*
|
3991 |
* @param array $attachment {
|
3992 |
-
*
|
3993 |
*
|
3994 |
-
*
|
3995 |
-
*
|
3996 |
* }
|
3997 |
* @param bool $auto Optional. True if scheduled optimization is running. Default false.
|
3998 |
* @param bool $cli Optional. True if WP-CLI is running. Default false.
|
@@ -4053,7 +4013,7 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
|
|
4053 |
'id' => $id,
|
4054 |
),
|
4055 |
array(
|
4056 |
-
'%d'
|
4057 |
)
|
4058 |
);
|
4059 |
}
|
@@ -4353,7 +4313,7 @@ function ewww_image_optimizer_update_table_as3cf( $local_path, $s3_path ) {
|
|
4353 |
'id' => $s3_image['id'],
|
4354 |
),
|
4355 |
array(
|
4356 |
-
'%d'
|
4357 |
)
|
4358 |
);
|
4359 |
if ( $s3_image['orig_size'] > $found_local_image['orig_size'] ) {
|
@@ -4382,6 +4342,21 @@ function ewww_image_optimizer_update_table_as3cf( $local_path, $s3_path ) {
|
|
4382 |
} // End if().
|
4383 |
}
|
4384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4385 |
/**
|
4386 |
* If a JPG image is using the EXIF orientiation, correct the rotation, and reset the Orientation.
|
4387 |
*
|
@@ -4392,6 +4367,9 @@ function ewww_image_optimizer_autorotate( $file ) {
|
|
4392 |
if ( defined( 'EWWW_IMAGE_OPTIMIZER_NO_ROTATE' ) && EWWW_IMAGE_OPTIMIZER_NO_ROTATE ) {
|
4393 |
return;
|
4394 |
}
|
|
|
|
|
|
|
4395 |
$type = ewww_image_optimizer_mimetype( $file, 'i' );
|
4396 |
if ( 'image/jpeg' != $type ) {
|
4397 |
ewwwio_debug_message( 'not a JPG, no rotation needed' );
|
@@ -4442,6 +4420,9 @@ function ewww_image_optimizer_resize_upload( $file ) {
|
|
4442 |
if ( ! $file ) {
|
4443 |
return false;
|
4444 |
}
|
|
|
|
|
|
|
4445 |
if ( ! empty( $_REQUEST['post_id'] ) || ( ! empty( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) || ( ! empty( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], 'media-new.php' ) ) ) {
|
4446 |
$maxwidth = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' );
|
4447 |
$maxheight = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' );
|
@@ -4456,10 +4437,10 @@ function ewww_image_optimizer_resize_upload( $file ) {
|
|
4456 |
* Filters the dimensions to used for resizing uploaded images.
|
4457 |
*
|
4458 |
* @param array $args {
|
4459 |
-
*
|
4460 |
*
|
4461 |
-
*
|
4462 |
-
*
|
4463 |
* }
|
4464 |
* @param string $file The name of the file being resized.
|
4465 |
*/
|
@@ -4494,6 +4475,15 @@ function ewww_image_optimizer_resize_upload( $file ) {
|
|
4494 |
} else {
|
4495 |
list( $newwidth, $newheight ) = wp_constrain_dimensions( $oldwidth, $oldheight, $maxwidth, $maxheight );
|
4496 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4497 |
if ( ! function_exists( 'wp_get_image_editor' ) ) {
|
4498 |
ewwwio_debug_message( 'no image editor function' );
|
4499 |
return false;
|
@@ -4883,10 +4873,10 @@ function ewww_image_optimizer_rebuild_meta( $attachment_id ) {
|
|
4883 |
* @global object $ewwwio_media_background;
|
4884 |
* @global object $ewwwio_async_optimize_media;
|
4885 |
* @global array $ewww_attachment {
|
4886 |
-
*
|
4887 |
*
|
4888 |
-
*
|
4889 |
-
*
|
4890 |
* }
|
4891 |
* @global object $as3cf For working with the WP Offload S3 plugin.
|
4892 |
* @global object $dreamspeed For working with the Dreamspeed CDN plugin.
|
@@ -4902,7 +4892,7 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
|
|
4902 |
if ( ! is_array( $meta ) && empty( $meta ) ) {
|
4903 |
$meta = array();
|
4904 |
} elseif ( ! is_array( $meta ) ) {
|
4905 |
-
if ( is_string( $meta )
|
4906 |
ewwwio_debug_message( "attempting to rebuild attachment meta for $id" );
|
4907 |
$new_meta = ewww_image_optimizer_rebuild_meta( $id );
|
4908 |
if ( ! is_array( $new_meta ) ) {
|
@@ -4997,7 +4987,8 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
|
|
4997 |
),
|
4998 |
array(
|
4999 |
'id' => $already_optimized['id'],
|
5000 |
-
|
|
|
5001 |
}
|
5002 |
}
|
5003 |
// Resize here so long as this is not a new image AND resize existing is enabled, and imsanity isn't enabled with a max size.
|
@@ -5133,7 +5124,8 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
|
|
5133 |
),
|
5134 |
array(
|
5135 |
'id' => $already_optimized['id'],
|
5136 |
-
|
|
|
5137 |
}
|
5138 |
$base_dir = $base_ims_dir;
|
5139 |
}
|
@@ -5520,8 +5512,7 @@ function ewww_image_optimizer_update_attachment( $meta, $id ) {
|
|
5520 |
wp_update_post( array(
|
5521 |
'ID' => $id,
|
5522 |
'post_mime_type' => $mime,
|
5523 |
-
|
5524 |
-
);
|
5525 |
ewww_image_optimizer_debug_log();
|
5526 |
ewwwio_memory( __FUNCTION__ );
|
5527 |
return $meta;
|
@@ -5535,16 +5526,16 @@ function ewww_image_optimizer_update_attachment( $meta, $id ) {
|
|
5535 |
* @param string $file Optional. Path relative to the uploads folder. Default ''.
|
5536 |
* @param bool $refresh_cache Optional. True to flush cache prior to fetching path. Default true.
|
5537 |
* @return array {
|
5538 |
-
*
|
5539 |
*
|
5540 |
-
*
|
5541 |
-
*
|
5542 |
* }
|
5543 |
*/
|
5544 |
function ewww_image_optimizer_attachment_path( $meta, $id, $file = '', $refresh_cache = true ) {
|
5545 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
5546 |
|
5547 |
-
// Retrieve the location of the
|
5548 |
$upload_dir = wp_upload_dir( null, false, $refresh_cache );
|
5549 |
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
5550 |
if ( ! $file ) {
|
@@ -5716,10 +5707,10 @@ function ewww_image_optimizer_size_unformat( $formatted ) {
|
|
5716 |
* @param string $file The filename to test for uniqueness.
|
5717 |
* @param string $fileext An iterator to append to the base filename, starts empty usually.
|
5718 |
* @return array {
|
5719 |
-
*
|
5720 |
*
|
5721 |
-
*
|
5722 |
-
*
|
5723 |
* }
|
5724 |
*/
|
5725 |
function ewww_image_optimizer_unique_filename( $file, $fileext ) {
|
@@ -5991,7 +5982,7 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null, $r
|
|
5991 |
$msg = '<div>' . sprintf(
|
5992 |
/* translators: %s: name of a tool like jpegtran */
|
5993 |
esc_html__( '%s is missing', 'ewww-image-optimizer' ),
|
5994 |
-
'<em>optipng
|
5995 |
) . '</div>';
|
5996 |
} else {
|
5997 |
$convert_link = esc_html__( 'PNG to JPG', 'ewww-image-optimizer' );
|
@@ -6252,11 +6243,11 @@ function ewww_image_optimizer_count_unoptimized_sizes( $sizes ) {
|
|
6252 |
* @param int $id The ID number of the attachment.
|
6253 |
* @param array $optimized_images A list of image records related to $id.
|
6254 |
* @return array {
|
6255 |
-
*
|
6256 |
*
|
6257 |
-
*
|
6258 |
-
*
|
6259 |
-
*
|
6260 |
* }
|
6261 |
*/
|
6262 |
function ewww_image_optimizer_custom_column_results( $id, $optimized_images ) {
|
@@ -6566,10 +6557,17 @@ function ewww_image_optimizer_bulk_action_handler() {
|
|
6566 |
/**
|
6567 |
* Retrieve option: use 'site' setting if plugin is network activated, otherwise use 'blog' setting.
|
6568 |
*
|
|
|
|
|
|
|
6569 |
* @param string $option_name The name of the option to retrieve.
|
6570 |
* @return mixed The value of the option.
|
6571 |
*/
|
6572 |
function ewww_image_optimizer_get_option( $option_name ) {
|
|
|
|
|
|
|
|
|
6573 |
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
6574 |
// Need to include the plugin library for the is_plugin_active function.
|
6575 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
@@ -6606,10 +6604,10 @@ function ewww_image_optimizer_set_option( $option_name, $option_value ) {
|
|
6606 |
* Check for a list of attachments for which we do not rebuild meta.
|
6607 |
*
|
6608 |
* @return array {
|
6609 |
-
*
|
6610 |
*
|
6611 |
-
*
|
6612 |
-
*
|
6613 |
* }
|
6614 |
*/
|
6615 |
function ewww_image_optimizer_get_bad_attachments() {
|
@@ -6640,9 +6638,8 @@ function ewww_image_optimizer_settings_script( $hook ) {
|
|
6640 |
wp_enqueue_script( 'postbox' );
|
6641 |
wp_enqueue_script( 'dashboard' );
|
6642 |
wp_localize_script( 'ewwwbulkscript', 'ewww_vars', array(
|
6643 |
-
|
6644 |
-
|
6645 |
-
);
|
6646 |
ewwwio_memory( __FUNCTION__ );
|
6647 |
return;
|
6648 |
}
|
@@ -6915,22 +6912,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
6915 |
$network_class = 'network-multisite';
|
6916 |
}
|
6917 |
$output = array();
|
6918 |
-
if ( isset( $_REQUEST['ewww_pngout'] ) ) {
|
6919 |
-
if ( 'success' == $_REQUEST['ewww_pngout'] ) {
|
6920 |
-
$output[] = "<div id='ewww-image-optimizer-pngout-success' class='updated fade'>\n";
|
6921 |
-
$output[] = '<p>' . esc_html__( 'Pngout was successfully installed, check the Plugin Status area for version information.', 'ewww-image-optimizer' ) . "</p>\n";
|
6922 |
-
$output[] = "</div>\n";
|
6923 |
-
}
|
6924 |
-
if ( 'failed' == $_REQUEST['ewww_pngout'] ) {
|
6925 |
-
$output[] = "<div id='ewww-image-optimizer-pngout-failure' class='error'>\n";
|
6926 |
-
$output[] = '<p>' . sprintf(
|
6927 |
-
/* translators: 1: An error message 2: The folder where pngout should be installed */
|
6928 |
-
esc_html__( 'Pngout was not installed: %1$s. Make sure this folder is writable: %2$s', 'ewww-image-optimizer' ),
|
6929 |
-
sanitize_text_field( $_REQUEST['ewww_error'] ), EWWW_IMAGE_OPTIMIZER_TOOL_PATH
|
6930 |
-
) . "</p>\n";
|
6931 |
-
$output[] = "</div>\n";
|
6932 |
-
}
|
6933 |
-
}
|
6934 |
$output[] = "<script type='text/javascript'>\n" .
|
6935 |
'jQuery(document).ready(function($) {$(".fade").fadeTo(5000,1).fadeOut(3000);});' . "\n" .
|
6936 |
"</script>\n";
|
@@ -7002,7 +6983,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7002 |
}
|
7003 |
$skip = ewww_image_optimizer_skip_tools();
|
7004 |
$status_output .= "<p>\n";
|
7005 |
-
if ( ! $skip['jpegtran']
|
7006 |
$status_output .= '<b>jpegtran:</b> ';
|
7007 |
if ( EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
7008 |
$jpegtran_installed = ewww_image_optimizer_tool_found( EWWW_IMAGE_OPTIMIZER_JPEGTRAN, 'j' );
|
@@ -7047,9 +7028,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7047 |
$collapsible = false;
|
7048 |
}
|
7049 |
}
|
7050 |
-
if ( $skip['pngout'] && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) == 10 ) {
|
7051 |
-
$status_output .= '<b>pngout:</b> ' . esc_html__( 'Not installed, enable in Advanced Settings', 'ewww-image-optimizer' ) . "<br />\n";
|
7052 |
-
}
|
7053 |
if ( ! $skip['gifsicle'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
7054 |
$status_output .= '<b>gifsicle:</b> ';
|
7055 |
if ( EWWW_IMAGE_OPTIMIZER_GIFSICLE ) {
|
@@ -7228,6 +7206,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7228 |
$output[] = "<ul class='ewww-tab-nav'>\n" .
|
7229 |
"<li class='ewww-tab ewww-general-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Basic Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7230 |
"<li class='ewww-tab ewww-optimization-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Advanced Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
|
|
7231 |
"<li class='ewww-tab ewww-conversion-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Conversion Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7232 |
"<li class='ewww-tab ewww-webp-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'WebP Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7233 |
"</ul>\n";
|
@@ -7276,7 +7255,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7276 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_jpg_level'>" . esc_html__( 'JPG Optimization Level', 'ewww-image-optimizer' ) . "</label></th>\n" .
|
7277 |
"<td><span><select id='ewww_image_optimizer_jpg_level' name='ewww_image_optimizer_jpg_level'>\n" .
|
7278 |
"<option value='0'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ), 0, false ) . '>' . esc_html__( 'No Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7279 |
-
if (
|
7280 |
$output[] = "<option class='$network_class' value='10'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ), 10, false ) . '>' . esc_html__( 'Lossless Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7281 |
}
|
7282 |
$output[] = "<option class='$network_class' $disable_level value='20'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ), 20, false ) . '>' . esc_html__( 'Maximum Lossless Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
@@ -7287,11 +7266,11 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7287 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_png_level'>" . esc_html__( 'PNG Optimization Level', 'ewww-image-optimizer' ) . "</label></th>\n" .
|
7288 |
"<td><span><select id='ewww_image_optimizer_png_level' name='ewww_image_optimizer_png_level'>\n" .
|
7289 |
"<option value='0'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 0, false ) . '>' . esc_html__( 'No Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7290 |
-
if (
|
7291 |
$output[] = "<option class='$network_class' value='10'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 10, false ) . '>' . esc_html__( 'Lossless Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7292 |
}
|
7293 |
-
$output[] = "<option class='$network_class' $disable_level value='20'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 20, false ) .
|
7294 |
-
|
7295 |
"<option value='40'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 40, false ) . '>' . esc_html__( 'Lossy Compression', 'ewww-image-optimizer' ) . "</option>\n" .
|
7296 |
"<option $disable_level value='50'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 50, false ) . '>' . esc_html__( 'Maximum Lossy Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
7297 |
"</select></td></tr>\n";
|
@@ -7315,7 +7294,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7315 |
"<option $disable_pdf_level value='20'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ), 20, false ) . '>' . esc_html__( 'Lossy Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
7316 |
"</select></td></tr>\n";
|
7317 |
ewwwio_debug_message( 'pdf level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) );
|
7318 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_delay'>" . esc_html__( 'Bulk Delay', 'ewww-image-optimizer' ) . "</label></th><td><input type='text' id='ewww_image_optimizer_delay' name='ewww_image_optimizer_delay' size='5' value='" . ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' ) . "'> " . esc_html__( 'Choose how long to pause between images (in seconds, 0 = disabled)', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7319 |
ewwwio_debug_message( 'bulk delay: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' ) );
|
7320 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_backup_files'>" . esc_html__( 'Backup Originals', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_backup_files' name='ewww_image_optimizer_backup_files' value='true' " .
|
7321 |
( ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' ) ? "checked='true'" : '' ) . " $disable_level > " . esc_html__( 'Store a copy of your original images on our secure server for 30 days. *Requires an active API key.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
@@ -7327,48 +7305,11 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7327 |
$output[] = "</table>\n</div>\n";
|
7328 |
$output[] = "<div id='ewww-optimization-settings'>\n";
|
7329 |
$output[] = "<table class='form-table'>\n";
|
7330 |
-
if ( ewww_image_optimizer_full_cloud() ) {
|
7331 |
-
$output[] = "<input class='$network_class' id='ewww_image_optimizer_optipng_level' name='ewww_image_optimizer_optipng_level' type='hidden' value='2'>\n" .
|
7332 |
-
"<input id='ewww_image_optimizer_pngout_level' name='ewww_image_optimizer_pngout_level' type='hidden' value='2'>\n" .
|
7333 |
-
"<input id='ewww_image_optimizer_disable_pngout' name='ewww_image_optimizer_disable_pngout' type='hidden' value='true'/>\n";
|
7334 |
-
} else {
|
7335 |
-
$optipng_levels = array( 0, 1, 8, 16, 24, 48 );
|
7336 |
-
$optipng_levels_output = '';
|
7337 |
-
foreach ( $optipng_levels as $level => $trials ) {
|
7338 |
-
if ( empty( $level ) ) {
|
7339 |
-
continue;
|
7340 |
-
}
|
7341 |
-
/* translators: %d: a number 0-5 */
|
7342 |
-
$optipng_levels_output .= "<option value='$level'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ), $level, false ) . '>' . sprintf( esc_html__( 'Level %d', 'ewww-image-optimizer' ), $level ) . ': ' .
|
7343 |
-
/* translators: %d: a number 1-48 */
|
7344 |
-
sprintf( esc_html( _n( '%d trial', '%d trials', $trials, 'ewww-image-optimizer' ) ), $trials ) . "</option>\n";
|
7345 |
-
}
|
7346 |
-
$output[] = "<tr class='$network_class nocloud'><th><label for='ewww_image_optimizer_optipng_level'>" . esc_html__( 'optipng optimization level', 'ewww-image-optimizer' ) . "</label></th>\n" .
|
7347 |
-
"<td><span><select id='ewww_image_optimizer_optipng_level' name='ewww_image_optimizer_optipng_level'>\n" .
|
7348 |
-
$optipng_levels_output .
|
7349 |
-
'</select> (' . esc_html__( 'default', 'ewww-image-optimizer' ) . "=2)</span>\n" .
|
7350 |
-
"<p class='description'>" . esc_html__( 'Levels 4 and above are unlikely to yield any additional savings.', 'ewww-image-optimizer' ) . "</p></td></tr>\n";
|
7351 |
ewwwio_debug_message( 'optipng level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) );
|
7352 |
-
$output[] = "<tr class='$network_class nocloud'><th><label for='ewww_image_optimizer_disable_pngout'>" . esc_html__( 'disable', 'ewww-image-optimizer' ) . " pngout</label></th><td><input type='checkbox' id='ewww_image_optimizer_disable_pngout' name='ewww_image_optimizer_disable_pngout' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_pngout' ) == true ? "checked='true'" : '' ) . " /></td><tr>\n";
|
7353 |
ewwwio_debug_message( 'pngout disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_pngout' ) == true ? 'yes' : 'no' ) );
|
7354 |
-
$pngout_levels = array(
|
7355 |
-
esc_html__( 'Xtreme! (Slowest)', 'ewww-image-optimizer' ),
|
7356 |
-
esc_html__( 'Intense (Slow)', 'ewww-image-optimizer' ),
|
7357 |
-
esc_html__( 'Longest Match (Fast)', 'ewww-image-optimizer' ),
|
7358 |
-
esc_html__( 'Huffman Only (Faster)', 'ewww-image-optimizer' ),
|
7359 |
-
);
|
7360 |
-
$pngout_levels_output = '';
|
7361 |
-
foreach ( $pngout_levels as $level => $description ) {
|
7362 |
-
/* translators: %d: a number 0-5 */
|
7363 |
-
$pngout_levels_output .= "<option value='$level'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ), $level, false ) . '>' . sprintf( esc_html__( 'Level %d', 'ewww-image-optimizer' ), $level ) . ": $description</option>\n";
|
7364 |
-
}
|
7365 |
-
$output[] = "<tr class='$network_class nocloud'><th><label for='ewww_image_optimizer_pngout_level'>" . esc_html__( 'pngout optimization level', 'ewww-image-optimizer' ) . "</label></th>\n" .
|
7366 |
-
"<td><span><select id='ewww_image_optimizer_pngout_level' name='ewww_image_optimizer_pngout_level'>\n" .
|
7367 |
-
$pngout_levels_output .
|
7368 |
-
'</select> (' . esc_html__( 'default', 'ewww-image-optimizer' ) . "=2)</span>\n" .
|
7369 |
-
"<p class='description'>" . esc_html__( 'If you have CPU cycles to spare, go with level 0', 'ewww-image-optimizer' ) . "</p></td></tr>\n";
|
7370 |
ewwwio_debug_message( 'pngout level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ) );
|
7371 |
-
}
|
7372 |
$output[] = "<tr class='$network_class'><th><span><label for='ewww_image_optimizer_jpg_quality'>" . esc_html__( 'JPG quality level:', 'ewww-image-optimizer' ) . "</label></th><td><input type='text' id='ewww_image_optimizer_jpg_quality' name='ewww_image_optimizer_jpg_quality' class='small-text' value='" . ewww_image_optimizer_jpg_quality() . "' /> " . esc_html__( 'Valid values are 1-100.', 'ewww-image-optimizer' ) . "\n<p class='description'>" . esc_html__( 'Use this to override the default WordPress quality level of 82. Applies to image editing, resizing, PNG to JPG conversion, and JPG to WebP conversion. Does not affect the original uploaded image unless maximum dimensions are set and resizing occurs.', 'ewww-image-optimizer' ) . "</p></td></tr>\n";
|
7373 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_parallel_optimization'>" . esc_html__( 'Parallel optimization', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_parallel_optimization' name='ewww_image_optimizer_parallel_optimization' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'All resizes generated from a single upload are optimized in parallel for faster optimization. If this is causing performance issues, disable parallel optimization to reduce the load on your server.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7374 |
ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? 'on' : 'off' ) );
|
@@ -7398,7 +7339,20 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7398 |
"<p class='description'>" . esc_html__( 'A file that matches any pattern or path provided will not be optimized.', 'ewww-image-optimizer' ) . "</p></td></tr>\n";
|
7399 |
ewwwio_debug_message( 'folders to ignore:' );
|
7400 |
ewwwio_debug_message( $exclude_paths );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7401 |
|
|
|
|
|
7402 |
// $output[] = "<tr><th><label for='ewww_image_optimizer_resize_detection'>" . esc_html__( 'Resize Detection', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_resize_detection' name='ewww_image_optimizer_resize_detection' value='true' " . ( ewww_image_optimizer_get_option('ewww_image_optimizer_resize_detection') == TRUE ? "checked='true'" : "" ) . " /> " . esc_html__( 'Will highlight images that need to be resized because the browser is scaling them down. Only visible for Admin users and adds a button to the admin bar to detect scaled images that have been lazy loaded.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7403 |
// ewwwio_debug_message( 'resize detection: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_detection' ) == TRUE ? 'on' : 'off' ) );
|
7404 |
if ( function_exists( 'imsanity_get_max_width_height' ) ) {
|
@@ -7416,7 +7370,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7416 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_resize_existing'>" . esc_html__( 'Resize Existing Images', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_resize_existing' name='ewww_image_optimizer_resize_existing' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'Allow resizing of existing Media Library images.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7417 |
ewwwio_debug_message( 'resize existing images: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) == true ? 'on' : 'off' ) );
|
7418 |
|
7419 |
-
$output[] = '<tr class="network-singlesite"><th>' . esc_html__( 'Disable Resizes', 'ewww-image-optimizer' ) . '</th><td><p>' . esc_html__( '
|
7420 |
$image_sizes = ewww_image_optimizer_get_image_sizes();
|
7421 |
$disabled_sizes = get_option( 'ewww_image_optimizer_disable_resizes' );
|
7422 |
$disabled_sizes_opt = get_option( 'ewww_image_optimizer_disable_resizes_opt' );
|
@@ -7439,23 +7393,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7439 |
$output[] = '<tr><th>' . esc_html__( 'Disable Resizes', 'ewww-image-optimizer' ) . '</th><td>';
|
7440 |
$output[] = '<p><span style="color: green">' . esc_html__( '*Settings to disable creation and optimization of individual sizes must be configured for each individual site.', 'ewww-image-optimizer' ) . "</span></p></td></tr>\n";
|
7441 |
}
|
7442 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_skip_size'>" . esc_html__( 'Skip Small Images', 'ewww-image-optimizer' ) . "</label></th><td><input type='text' id='ewww_image_optimizer_skip_size' name='ewww_image_optimizer_skip_size' size='8' value='" . ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_size' ) . "'> " . esc_html__( 'Do not optimize images smaller than this (in bytes)', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7443 |
-
ewwwio_debug_message( 'skip images smaller than: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_size' ) . ' bytes' );
|
7444 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_skip_png_size'>" . esc_html__( 'Skip Large PNG Images', 'ewww-image-optimizer' ) . "</label></th><td><input type='text' id='ewww_image_optimizer_skip_png_size' name='ewww_image_optimizer_skip_png_size' size='8' value='" . ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_png_size' ) . "'> " . esc_html__( 'Do not optimize PNG images larger than this (in bytes)', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7445 |
-
ewwwio_debug_message( 'skip PNG images larger than: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_png_size' ) . ' bytes' );
|
7446 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_lossy_skip_full'>" . esc_html__( 'Exclude full-size images from lossy optimization', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_lossy_skip_full' name='ewww_image_optimizer_lossy_skip_full' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lossy_skip_full' ) == true ? "checked='true'" : '' ) . " /></td></tr>\n";
|
7447 |
-
ewwwio_debug_message( 'exclude originals from lossy: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lossy_skip_full' ) == true ? 'on' : 'off' ) );
|
7448 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_metadata_skip_full'>" . esc_html__( 'Exclude full-size images from metadata removal', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_metadata_skip_full' name='ewww_image_optimizer_metadata_skip_full' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_skip_full' ) == true ? "checked='true'" : '' ) . " /></td></tr>\n";
|
7449 |
-
ewwwio_debug_message( 'exclude originals from metadata removal: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_skip_full' ) == true ? 'on' : 'off' ) );
|
7450 |
-
$output[] = "<tr class='$network_class nocloud'><th><label for='ewww_image_optimizer_skip_bundle'>" . esc_html__( 'Use System Paths', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_skip_bundle' name='ewww_image_optimizer_skip_bundle' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_bundle' ) == true ? "checked='true'" : '' ) . ' /> ' .
|
7451 |
-
/* translators: 1: an example folder where system binaries/executables are installed 2: another example folder */
|
7452 |
-
sprintf( esc_html__( 'If you have already installed the utilities in a system location, such as %1$s or %2$s, use this to force the plugin to use those versions and skip the auto-installers.', 'ewww-image-optimizer' ), '/usr/local/bin', '/usr/bin' ) . "</td></tr>\n";
|
7453 |
-
ewwwio_debug_message( 'use system binaries: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_bundle' ) == true ? 'yes' : 'no' ) );
|
7454 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_enable_help'>" . esc_html__( 'Enable Embedded Help', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_enable_help' name='ewww_image_optimizer_enable_help' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) == true ? "checked='true'" : '' ) . ' /> ' .
|
7455 |
-
esc_html__( 'Enable the support beacon, which gives you access to documentation and our support team right from your WordPress dashboard. To assist you more efficiently, we may collect the current url, IP address, browser/device information, and debugging information.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7456 |
-
ewwwio_debug_message( 'enable help beacon: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) == true ? 'yes' : 'no' ) );
|
7457 |
-
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_allow_tracking'>" . esc_html__( 'Allow Usage Tracking?', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) == true ? "checked='true'" : '' ) . ' /> ' .
|
7458 |
-
esc_html__( 'Allow EWWW Image Optimizer to anonymously track how this plugin is used and help us make the plugin better. Opt-in to tracking and receive 500 API image credits free. No sensitive data is tracked.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7459 |
$output[] = "</table>\n</div>\n";
|
7460 |
$output[] = "<div id='ewww-conversion-settings'>\n";
|
7461 |
$output[] = '<p>' . esc_html__( 'Conversion is only available for images in the Media Library (except WebP). By default, all images have a link available in the Media Library for one-time conversion. Turning on individual conversion operations below will enable conversion filters any time an image is uploaded or modified.', 'ewww-image-optimizer' ) . "<br />\n" .
|
@@ -7579,36 +7516,36 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7579 |
ewww_image_optimizer_webp_inline_script();
|
7580 |
}
|
7581 |
|
7582 |
-
|
7583 |
-
|
7584 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
7585 |
-
|
7586 |
<script type="text/javascript">
|
7587 |
function selectText(containerid) {
|
|
|
7588 |
if (document.selection) {
|
7589 |
var range = document.body.createTextRange();
|
7590 |
-
range.moveToElementText(
|
7591 |
range.select();
|
7592 |
} else if (window.getSelection) {
|
7593 |
-
|
7594 |
-
range.selectNode(document.getElementById(containerid));
|
7595 |
-
window.getSelection().addRange(range);
|
7596 |
}
|
7597 |
}
|
7598 |
</script>
|
7599 |
<?php
|
7600 |
global $ewww_debug;
|
7601 |
-
$debug_log_url = plugins_url( '/debug.log', __FILE__ );
|
7602 |
echo '<p style="clear:both"><b>' . esc_html__( 'Debugging Information', 'ewww-image-optimizer' ) . ':</b> <button onclick="selectText(' . "'ewww-debug-info'" . ')">' . esc_html__( 'Select All', 'ewww-image-optimizer' ) . '</button>';
|
7603 |
if ( is_file( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) ) {
|
|
|
7604 |
echo " <a href='$debug_log_url'>" . esc_html( 'View Debug Log', 'ewww-image-optimizer' ) . "</a> - <a href='admin.php?action=ewww_image_optimizer_delete_debug_log'>" . esc_html( 'Remove Debug Log', 'ewww-image-optimizer' ) . '</a>';
|
7605 |
}
|
7606 |
echo '</p>';
|
7607 |
echo '<div id="ewww-debug-info" style="background:#ffff99;margin-left:-20px;padding:10px" contenteditable="true">' . $ewww_debug . '</div>';
|
7608 |
-
|
|
|
7609 |
}
|
7610 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
7611 |
-
$help_instructions = esc_html__( 'Please turn on the Debugging option. Then copy and paste the Debug Information from the bottom of the settings page. This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
|
7612 |
$current_user = wp_get_current_user();
|
7613 |
$help_email = $current_user->user_email;
|
7614 |
$hs_config = array(
|
@@ -7623,8 +7560,15 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7623 |
);
|
7624 |
$hs_identify = array(
|
7625 |
'email' => $help_email,
|
7626 |
-
'debug_info' => $ewww_debug,
|
7627 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7628 |
?>
|
7629 |
<script type='text/javascript'>
|
7630 |
!function(e,o,n){window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={},t.readyQueue=[],t.config=function(e){this.userConfig=e},t.ready=function(e){this.readyQueue.push(e)},o.config={docs:{enabled:!0,baseUrl:"//ewwwio.helpscoutdocs.com/"},contact:{enabled:!0,formId:"af75cf17-310a-11e7-9841-0ab63ef01522"}};var r=e.getElementsByTagName("script")[0],c=e.createElement("script");c.type="text/javascript",c.async=!0,c.src="https://djtflbt20bdde.cloudfront.net/",r.parentNode.insertBefore(c,r)}(document,window.HSCW||{},window.HS||{});
|
@@ -7650,7 +7594,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
7650 |
function ewww_image_optimizer_filter_settings_page( $input ) {
|
7651 |
$output = '';
|
7652 |
foreach ( $input as $line ) {
|
7653 |
-
if ( ewww_image_optimizer_full_cloud() && preg_match(
|
7654 |
continue;
|
7655 |
} else {
|
7656 |
$output .= $line;
|
@@ -7781,10 +7725,10 @@ function ewwwio_debug_message( $message ) {
|
|
7781 |
ewwwio_debug_version_info();
|
7782 |
$ewww_version_dumped = true;
|
7783 |
}
|
7784 |
-
$message = str_replace( "\n\n\n", '
|
7785 |
-
$message = str_replace( "\n\n", '
|
7786 |
-
$message = str_replace( "\n", '
|
7787 |
-
$ewww_debug .= "$message
|
7788 |
} else {
|
7789 |
global $ewww_debug;
|
7790 |
$ewww_debug = "not logging message, memory limit is $memory_limit";
|
@@ -7812,7 +7756,7 @@ function ewww_image_optimizer_debug_log() {
|
|
7812 |
}
|
7813 |
}
|
7814 |
if ( filesize( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) + strlen( $ewww_debug ) + 4000000 + memory_get_usage( true ) <= $memory_limit ) {
|
7815 |
-
$ewww_debug_log = str_replace( '
|
7816 |
file_put_contents( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log', $timestamp . $ewww_debug_log, FILE_APPEND );
|
7817 |
}
|
7818 |
}
|
@@ -7845,24 +7789,24 @@ function ewww_image_optimizer_delete_debug_log() {
|
|
7845 |
function ewwwio_debug_version_info() {
|
7846 |
global $ewww_debug;
|
7847 |
if ( ! extension_loaded( 'suhosin' ) && function_exists( 'get_current_user' ) ) {
|
7848 |
-
$ewww_debug .= get_current_user() . '
|
7849 |
}
|
7850 |
|
7851 |
-
$ewww_debug .= 'EWWW IO version: ' . EWWW_IMAGE_OPTIMIZER_VERSION . '
|
7852 |
|
7853 |
// Check the WP version.
|
7854 |
global $wp_version;
|
7855 |
$my_version = substr( $wp_version, 0, 3 );
|
7856 |
-
$ewww_debug .= "WP version: $wp_version
|
7857 |
|
7858 |
if ( defined( 'PHP_VERSION_ID' ) ) {
|
7859 |
-
$ewww_debug .= 'PHP version: ' . PHP_VERSION_ID . '
|
7860 |
}
|
7861 |
if ( defined( 'LIBXML_VERSION' ) ) {
|
7862 |
-
$ewww_debug .= 'libxml version: ' . LIBXML_VERSION . '
|
7863 |
}
|
7864 |
if ( ! empty( $_ENV['PANTHEON_ENVIRONMENT'] ) && in_array( $_ENV['PANTHEON_ENVIRONMENT'], array( 'test', 'live', 'dev' ) ) ) {
|
7865 |
-
$ewww_debug .= "detected pantheon env: {$_ENV['PANTHEON_ENVIRONMENT']}
|
7866 |
}
|
7867 |
}
|
7868 |
|
@@ -7997,15 +7941,18 @@ function ewww_image_optimizer_image_queue_debug() {
|
|
7997 |
$ids[] = $item['id'];
|
7998 |
}
|
7999 |
$ids = implode( ',', $ids );
|
8000 |
-
|
|
|
8001 |
<input type="hidden" id="ewww_nonce" name="ewww_nonce" value="<?php echo $nonce; ?>">
|
8002 |
<input type="hidden" name="ewww_image_optimizer_clear_queue" value="<?php echo $queue['option_name']; ?>">
|
8003 |
<input type="hidden" name="ids" value="<?php echo $ids; ?>">
|
8004 |
<button type="submit" class="button-secondary action"><?php esc_html_e( 'Clear this queue', 'ewww-image-optimizer' ); ?></button>
|
8005 |
</form>
|
8006 |
-
<?php
|
|
|
8007 |
$all_ids = implode( ',', $all_ids );
|
8008 |
-
?>
|
|
|
8009 |
<input type="hidden" id="ewww_nonce" name="ewww_nonce" value="<?php echo $nonce; ?>">
|
8010 |
<input type="hidden" name="ewww_image_optimizer_clear_queue" value="<?php echo count( $queues ); ?>">
|
8011 |
<input type="hidden" name="ids" value="<?php echo $all_ids; ?>">
|
17 |
// TODO: use a transient to do health checks on the schedule optimizer.
|
18 |
// TODO: add a column to track compression level used for each image, and later implement a way to (re)compress at a specific compression level.
|
19 |
// TODO: might be able to use the Custom Bulk Actions in 4.7 to support the bulk optimize drop-down menu.
|
|
|
|
|
20 |
// TODO: need to make the scheduler so it can resume without having to re-run the queue population, and then we can probably also flush the queue when scheduled opt starts, but later it would be nice to implement the bulk_loop as the aux_loop so that it could handle media properly.
|
21 |
// TODO: implement a search for the bulk table, or maybe we should just move it to it's own page?
|
22 |
// TODO: port bulk changes to NextGEN and FlaGallery.
|
25 |
// TODO: write some tests for update_table and check_table, find_already_opt, and remove_dups.
|
26 |
// TODO: write some conversion tests.
|
27 |
// TODO: do a bottom paginator for the show optimized images table.
|
|
|
28 |
// TODO: check this patch, to see if the use of 'full' causes any issues: https://core.trac.wordpress.org/ticket/37840 .
|
29 |
// TODO: perhaps have an optional footer thingy that says how many images have been optimized.
|
30 |
// TODO: integrate AGR, since it's "abandoned", but possibly using gifsicle for better GIFs.
|
32 |
exit;
|
33 |
}
|
34 |
|
35 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '361.0' );
|
36 |
|
37 |
// Initialize a couple globals.
|
38 |
$ewww_debug = '';
|
525 |
$libxml_previous_error_reporting = libxml_use_internal_errors( true );
|
526 |
$html->formatOutput = false;
|
527 |
$html->encoding = 'utf-8';
|
528 |
+
if ( defined( 'LIBXML_VERSION' ) && LIBXML_VERSION < 20800 && ewww_image_optimizer_function_exists( 'mb_convert_encoding' ) ) {
|
529 |
ewwwio_debug_message( 'libxml version: ' . LIBXML_VERSION );
|
530 |
// Converts the buffer from utf-8 to html-entities.
|
531 |
$buffer = mb_convert_encoding( $buffer, 'HTML-ENTITIES', 'UTF-8' );
|
931 |
ewwwio_debug_message( 'stl disabled by user' );
|
932 |
return false;
|
933 |
}
|
934 |
+
if ( function_exists( 'wp_is_ini_value_changeable' ) && ! wp_is_ini_value_changeable( 'max_execution_time' ) ) {
|
935 |
+
ewwwio_debug_message( 'max_execution_time not configurable' );
|
936 |
+
return false;
|
937 |
+
}
|
938 |
return ewww_image_optimizer_function_exists( 'set_time_limit' );
|
939 |
}
|
940 |
|
1096 |
}
|
1097 |
if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
1098 |
// Set the common network settings if they have been POSTed.
|
1099 |
+
if ( isset( $_POST['ewww_image_optimizer_jpg_level'] ) && current_user_can( 'manage_network_options' ) && ! get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'ewww_image_optimizer_options-options' ) ) {
|
1100 |
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
1101 |
ewwwio_debug_message( print_r( $_POST, true ) );
|
1102 |
}
|
1103 |
+
$_POST['ewww_image_optimizer_cloud_key'] = empty( $_POST['ewww_image_optimizer_cloud_key'] ) ? '' : $_POST['ewww_image_optimizer_cloud_key'];
|
1104 |
+
update_site_option( 'ewww_image_optimizer_cloud_key', ewww_image_optimizer_cloud_key_sanitize( $_POST['ewww_image_optimizer_cloud_key'] ) );
|
1105 |
$_POST['ewww_image_optimizer_debug'] = ( empty( $_POST['ewww_image_optimizer_debug'] ) ? false : true );
|
1106 |
update_site_option( 'ewww_image_optimizer_debug', $_POST['ewww_image_optimizer_debug'] );
|
1107 |
$_POST['ewww_image_optimizer_jpegtran_copy'] = ( empty( $_POST['ewww_image_optimizer_jpegtran_copy'] ) ? false : true );
|
1114 |
update_site_option( 'ewww_image_optimizer_gif_level', (int) $_POST['ewww_image_optimizer_gif_level'] );
|
1115 |
$_POST['ewww_image_optimizer_pdf_level'] = empty( $_POST['ewww_image_optimizer_pdf_level'] ) ? '' : $_POST['ewww_image_optimizer_pdf_level'];
|
1116 |
update_site_option( 'ewww_image_optimizer_pdf_level', (int) $_POST['ewww_image_optimizer_pdf_level'] );
|
|
|
|
|
|
|
|
|
1117 |
$_POST['ewww_image_optimizer_delete_originals'] = ( empty( $_POST['ewww_image_optimizer_delete_originals'] ) ? false : true );
|
1118 |
update_site_option( 'ewww_image_optimizer_delete_originals', $_POST['ewww_image_optimizer_delete_originals'] );
|
1119 |
$_POST['ewww_image_optimizer_jpg_to_png'] = ( empty( $_POST['ewww_image_optimizer_jpg_to_png'] ) ? false : true );
|
1132 |
update_site_option( 'ewww_image_optimizer_disable_convert_links', $_POST['ewww_image_optimizer_disable_convert_links'] );
|
1133 |
$_POST['ewww_image_optimizer_backup_files'] = ( empty( $_POST['ewww_image_optimizer_backup_files'] ) ? false : true );
|
1134 |
update_site_option( 'ewww_image_optimizer_backup_files', $_POST['ewww_image_optimizer_backup_files'] );
|
|
|
|
|
1135 |
$_POST['ewww_image_optimizer_auto'] = ( empty( $_POST['ewww_image_optimizer_auto'] ) ? false : true );
|
1136 |
update_site_option( 'ewww_image_optimizer_auto', $_POST['ewww_image_optimizer_auto'] );
|
1137 |
$_POST['ewww_image_optimizer_aux_paths'] = empty( $_POST['ewww_image_optimizer_aux_paths'] ) ? '' : $_POST['ewww_image_optimizer_aux_paths'];
|
1140 |
update_site_option( 'ewww_image_optimizer_exclude_paths', ewww_image_optimizer_exclude_paths_sanitize( $_POST['ewww_image_optimizer_exclude_paths'] ) );
|
1141 |
$_POST['ewww_image_optimizer_enable_cloudinary'] = ( empty( $_POST['ewww_image_optimizer_enable_cloudinary'] ) ? false : true );
|
1142 |
update_site_option( 'ewww_image_optimizer_enable_cloudinary', $_POST['ewww_image_optimizer_enable_cloudinary'] );
|
|
|
|
|
1143 |
$_POST['ewww_image_optimizer_maxmediawidth'] = empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ? 0 : $_POST['ewww_image_optimizer_maxmediawidth'];
|
1144 |
update_site_option( 'ewww_image_optimizer_maxmediawidth', (int) $_POST['ewww_image_optimizer_maxmediawidth'] );
|
1145 |
$_POST['ewww_image_optimizer_maxmediaheight'] = empty( $_POST['ewww_image_optimizer_maxmediaheight'] ) ? 0 : $_POST['ewww_image_optimizer_maxmediaheight'];
|
1152 |
update_site_option( 'ewww_image_optimizer_resize_detection', $_POST['ewww_image_optimizer_resize_detection'] );
|
1153 |
$_POST['ewww_image_optimizer_resize_existing'] = ( empty( $_POST['ewww_image_optimizer_resize_existing'] ) ? false : true );
|
1154 |
update_site_option( 'ewww_image_optimizer_resize_existing', $_POST['ewww_image_optimizer_resize_existing'] );
|
|
|
|
|
|
|
|
|
1155 |
$_POST['ewww_image_optimizer_parallel_optimization'] = ( empty( $_POST['ewww_image_optimizer_parallel_optimization'] ) ? false : true );
|
1156 |
update_site_option( 'ewww_image_optimizer_parallel_optimization', $_POST['ewww_image_optimizer_parallel_optimization'] );
|
1157 |
$_POST['ewww_image_optimizer_include_media_paths'] = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
|
1195 |
update_option( 'ewww_image_optimizer_gif_level', '10' );
|
1196 |
}
|
1197 |
// Register all the common EWWW IO settings.
|
1198 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_cloud_key', 'ewww_image_optimizer_cloud_key_sanitize' );
|
1199 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
|
1200 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpegtran_copy', 'boolval' );
|
1201 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
|
1202 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_level', 'intval' );
|
1203 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_level', 'intval' );
|
1204 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pdf_level', 'intval' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1205 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_backup_files', 'boolval' );
|
1206 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_cloudinary', 'boolval' );
|
1207 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_quality', 'ewww_image_optimizer_jpg_quality' );
|
1208 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
|
1209 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
|
1210 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
|
1211 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_aux_paths', 'ewww_image_optimizer_aux_paths_sanitize' );
|
1212 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exclude_paths', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
|
|
|
|
1213 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediawidth', 'intval' );
|
1214 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediaheight', 'intval' );
|
1215 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxotherwidth', 'intval' );
|
1216 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxotherheight', 'intval' );
|
|
|
1217 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_existing', 'boolval' );
|
1218 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_detection', 'boolval' );
|
1219 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
1220 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes_opt', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1221 |
global $ewwwio_tracking;
|
1222 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_allow_tracking', array( $ewwwio_tracking, 'check_for_settings_optin' ) );
|
1223 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_help', 'boolval' );
|
1224 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_convert_links', 'boolval' );
|
1225 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_delete_originals', 'boolval' );
|
1226 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_to_png', 'boolval' );
|
1227 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_to_jpg', 'boolval' );
|
1228 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_to_png', 'boolval' );
|
1229 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_background', 'ewww_image_optimizer_jpg_background' );
|
1230 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp', 'boolval' );
|
1231 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_force', 'boolval' );
|
1232 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_paths', 'ewww_image_optimizer_webp_paths_sanitize' );
|
1233 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_for_cdn', 'boolval' );
|
1234 |
ewww_image_optimizer_exec_init();
|
1235 |
ewww_image_optimizer_cron_setup( 'ewww_image_optimizer_auto' );
|
1236 |
/**
|
1783 |
}
|
1784 |
|
1785 |
/**
|
1786 |
+
* Filters image sizes generated by WordPress, themes, and plugins allowing users to disable sizes.
|
1787 |
*
|
1788 |
* @param array $sizes A list of sizes to be generated.
|
1789 |
* @return array A list of sizes, minus any the user wants disabled.
|
1897 |
* Makes sure W3TC uploads all modified files to any configured CDNs.
|
1898 |
*
|
1899 |
* @global array $ewww_attachment {
|
1900 |
+
* Stores the ID and meta for later use with W3TC.
|
1901 |
*
|
1902 |
+
* @type int $id The attachment ID number.
|
1903 |
+
* @type array $meta The attachment metadata from the postmeta table.
|
1904 |
* }
|
1905 |
*
|
1906 |
* @param array $files Files being updated by W3TC.
|
2065 |
// Add options page to the settings menu.
|
2066 |
$permissions = apply_filters( 'ewww_image_optimizer_superadmin_permissions', '' );
|
2067 |
$ewww_network_options_page = add_submenu_page(
|
2068 |
+
'settings.php', // Slug of parent
|
2069 |
+
'EWWW Image Optimizer', // Page Title
|
2070 |
+
'EWWW Image Optimizer', // Menu title
|
2071 |
+
$permissions, // Capability
|
2072 |
+
EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE, // Slug
|
2073 |
+
'ewww_image_optimizer_network_options' // Function to call.
|
2074 |
);
|
2075 |
}
|
2076 |
}
|
2108 |
if ( ! is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
2109 |
// Add options page to the settings menu.
|
2110 |
$ewww_options_page = add_options_page(
|
2111 |
+
'EWWW Image Optimizer', // Page title
|
2112 |
+
'EWWW Image Optimizer', // Menu title
|
2113 |
+
apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability
|
2114 |
+
EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE, // Slug
|
2115 |
+
'ewww_image_optimizer_options' // Function to call.
|
2116 |
);
|
2117 |
} else {
|
2118 |
// Add options page to the single-site settings menu.
|
2119 |
$ewww_options_page = add_options_page(
|
2120 |
+
'EWWW Image Optimizer', // Page title
|
2121 |
+
'EWWW Image Optimizer', // Menu title
|
2122 |
+
apply_filters( 'ewww_image_optimizer_admin_permissions', 'manage_options' ), // Capability
|
2123 |
+
EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE, // Slug
|
2124 |
+
'ewww_image_optimizer_network_singlesite_options' // Function to call.
|
2125 |
);
|
2126 |
}
|
2127 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
2228 |
$image_name = get_the_title( $id );
|
2229 |
$gallery_name = get_the_title( $gid );
|
2230 |
$image_url = esc_url( $meta['sizes']['mini']['url'] );
|
2231 |
+
?>
|
2232 |
+
<tr
|
2233 |
+
<?php
|
2234 |
+
if ( $alternate ) {
|
2235 |
+
echo " class='alternate'";
|
2236 |
+
}
|
2237 |
+
?>
|
2238 |
+
><td><?php echo $id; ?></td>
|
2239 |
+
<?php
|
2240 |
+
echo "<td style='width:80px' class='column-icon'><img src='$image_url' /></td>";
|
2241 |
echo "<td class='title'>$image_name</td>";
|
2242 |
echo "<td>$gallery_name</td><td>";
|
2243 |
ewww_image_optimizer_custom_column( 'ewww-image-optimizer', $id );
|
2312 |
<script>
|
2313 |
function check_webp_feature(a,b){var c={alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"},d=!1,e=new Image;e.onload=function(){var a=e.width>0&&e.height>0;d=!0,b(a)},e.onerror=function(){d=!1,b(!1)},e.src="data:image/webp;base64,"+c[a]}function ewww_load_images(a){jQuery(document).arrive(".ewww_webp",function(){ewww_load_images(a)}),function(b){function d(a,d){for(var e=["align","alt","border","crossorigin","height","hspace","ismap","longdesc","usemap","vspace","width","accesskey","class","contenteditable","contextmenu","dir","draggable","dropzone","hidden","id","lang","spellcheck","style","tabindex","title","translate","sizes","data-attachment-id","data-permalink","data-orig-size","data-comments-opened","data-image-meta","data-image-title","data-image-description"],f=0,g=e.length;f<g;f++){var h=b(a).attr(c+e[f]);void 0!==h&&!1!==h&&b(d).attr(e[f],h)}return d}var c="data-";a&&(b(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a").each(function(){var a=b(this).attr("data-webp");void 0!==a&&!1!==a&&b(this).attr("data-src",a);var a=b(this).attr("data-webp-thumbnail");void 0!==a&&!1!==a&&b(this).attr("data-thumbnail",a)}),b(".image-wrapper a, .ngg-pro-masonry-item a").each(function(){var a=b(this).attr("data-webp");void 0!==a&&!1!==a&&b(this).attr("href",a)}),b(".rev_slider ul li").each(function(){var a=b(this).attr("data-webp-thumb");void 0!==a&&!1!==a&&b(this).attr("data-thumb",a);for(var c=1;c<11;){var a=b(this).attr("data-webp-param"+c);void 0!==a&&!1!==a&&b(this).attr("data-param"+c,a),c++}}),b(".rev_slider img").each(function(){var a=b(this).attr("data-webp-lazyload");void 0!==a&&!1!==a&&b(this).attr("data-lazyload",a)})),b("img.ewww_webp_lazy_retina").each(function(){if(a){var c=b(this).attr("data-srcset-webp");void 0!==c&&!1!==c&&b(this).attr("data-srcset",c)}else{var c=b(this).attr("data-srcset-img");void 0!==c&&!1!==c&&b(this).attr("data-srcset",c)}b(this).removeClass("ewww_webp_lazy_retina")}),b("video").each(function(){if(a){var c=b(this).attr("data-poster-webp");void 0!==c&&!1!==c&&b(this).attr("poster",c)}else{var c=b(this).attr("data-poster-image");void 0!==c&&!1!==c&&b(this).attr("poster",c)}}),b("img.ewww_webp_lazy_load").each(function(){if(a){b(this).attr("data-lazy-src",b(this).attr("data-lazy-webp-src"));var c=b(this).attr("data-srcset-webp");void 0!==c&&!1!==c&&b(this).attr("srcset",c);var c=b(this).attr("data-lazy-srcset-webp");void 0!==c&&!1!==c&&b(this).attr("data-lazy-srcset",c)}else{b(this).attr("data-lazy-src",b(this).attr("data-lazy-img-src"));var c=b(this).attr("data-srcset");void 0!==c&&!1!==c&&b(this).attr("srcset",c);var c=b(this).attr("data-lazy-srcset-img");void 0!==c&&!1!==c&&b(ewww_img).attr("data-lazy-srcset",c)}b(this).removeClass("ewww_webp_lazy_load")}),b(".ewww_webp_lazy_hueman").each(function(){var c=document.createElement("img");if(b(c).attr("src",b(this).attr("data-src")),a){b(c).attr("data-src",b(this).attr("data-webp-src"));var e=b(this).attr("data-srcset-webp");void 0!==e&&!1!==e&&b(c).attr("data-srcset",e)}else{b(c).attr("data-src",b(this).attr("data-img"));var e=b(this).attr("data-srcset-img");void 0!==e&&!1!==e&&b(c).attr("data-srcset",e)}c=d(this,c),b(this).after(c),b(this).removeClass("ewww_webp_lazy_hueman")}),b(".ewww_webp").each(function(){var c=document.createElement("img");if(a){b(c).attr("src",b(this).attr("data-webp"));var e=b(this).attr("data-srcset-webp");void 0!==e&&!1!==e&&b(c).attr("srcset",e);var e=b(this).attr("data-webp-orig-file");void 0!==e&&!1!==e&&b(c).attr("data-orig-file",e);var e=b(this).attr("data-webp-medium-file");void 0!==e&&!1!==e&&b(c).attr("data-medium-file",e);var e=b(this).attr("data-webp-large-file");void 0!==e&&!1!==e&&b(c).attr("data-large-file",e)}else{b(c).attr("src",b(this).attr("data-img"));var e=b(this).attr("data-srcset-img");void 0!==e&&!1!==e&&b(c).attr("srcset",e)}c=d(this,c),b(this).after(c),b(this).removeClass("ewww_webp")})}(jQuery),jQuery.fn.isotope&&jQuery.fn.imagesLoaded&&(jQuery(".fusion-posts-container-infinite").imagesLoaded(function(){jQuery(".fusion-posts-container-infinite").hasClass("isotope")&&jQuery(".fusion-posts-container-infinite").isotope()}),jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").imagesLoaded(function(){jQuery(".fusion-portfolio:not(.fusion-recent-works) .fusion-portfolio-wrapper").isotope()}))}var Arrive=function(a,b,c){"use strict";function l(a,b,c){e.addMethod(b,c,a.unbindEvent),e.addMethod(b,c,a.unbindEventWithSelectorOrCallback),e.addMethod(b,c,a.unbindEventWithSelectorAndCallback)}function m(a){a.arrive=j.bindEvent,l(j,a,"unbindArrive"),a.leave=k.bindEvent,l(k,a,"unbindLeave")}if(a.MutationObserver&&"undefined"!=typeof HTMLElement){var d=0,e=function(){var b=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;return{matchesSelector:function(a,c){return a instanceof HTMLElement&&b.call(a,c)},addMethod:function(a,b,c){var d=a[b];a[b]=function(){return c.length==arguments.length?c.apply(this,arguments):"function"==typeof d?d.apply(this,arguments):void 0}},callCallbacks:function(a){for(var c,b=0;c=a[b];b++)c.callback.call(c.elem)},checkChildNodesRecursively:function(a,b,c,d){for(var g,f=0;g=a[f];f++)c(g,b,d)&&d.push({callback:b.callback,elem:g}),g.childNodes.length>0&&e.checkChildNodesRecursively(g.childNodes,b,c,d)},mergeArrays:function(a,b){var d,c={};for(d in a)c[d]=a[d];for(d in b)c[d]=b[d];return c},toElementsArray:function(b){return void 0===b||"number"==typeof b.length&&b!==a||(b=[b]),b}}}(),f=function(){var a=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null};return a.prototype.addEvent=function(a,b,c,d){var e={target:a,selector:b,options:c,callback:d,firedElems:[]};return this._beforeAdding&&this._beforeAdding(e),this._eventsBucket.push(e),e},a.prototype.removeEvent=function(a){for(var c,b=this._eventsBucket.length-1;c=this._eventsBucket[b];b--)a(c)&&(this._beforeRemoving&&this._beforeRemoving(c),this._eventsBucket.splice(b,1))},a.prototype.beforeAdding=function(a){this._beforeAdding=a},a.prototype.beforeRemoving=function(a){this._beforeRemoving=a},a}(),g=function(b,d){var g=new f,h=this,i={fireOnAttributesModification:!1};return g.beforeAdding(function(c){var i,e=c.target;c.selector,c.callback;e!==a.document&&e!==a||(e=document.getElementsByTagName("html")[0]),i=new MutationObserver(function(a){d.call(this,a,c)});var j=b(c.options);i.observe(e,j),c.observer=i,c.me=h}),g.beforeRemoving(function(a){a.observer.disconnect()}),this.bindEvent=function(a,b,c){b=e.mergeArrays(i,b);for(var d=e.toElementsArray(this),f=0;f<d.length;f++)g.addEvent(d[f],a,b,c)},this.unbindEvent=function(){var a=e.toElementsArray(this);g.removeEvent(function(b){for(var d=0;d<a.length;d++)if(this===c||b.target===a[d])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(a){var f,b=e.toElementsArray(this),d=a;f="function"==typeof a?function(a){for(var e=0;e<b.length;e++)if((this===c||a.target===b[e])&&a.callback===d)return!0;return!1}:function(d){for(var e=0;e<b.length;e++)if((this===c||d.target===b[e])&&d.selector===a)return!0;return!1},g.removeEvent(f)},this.unbindEventWithSelectorAndCallback=function(a,b){var d=e.toElementsArray(this);g.removeEvent(function(e){for(var f=0;f<d.length;f++)if((this===c||e.target===d[f])&&e.selector===a&&e.callback===b)return!0;return!1})},this},h=function(){function h(a){var b={attributes:!1,childList:!0,subtree:!0};return a.fireOnAttributesModification&&(b.attributes=!0),b}function i(a,b){a.forEach(function(a){var c=a.addedNodes,d=a.target,f=[];null!==c&&c.length>0?e.checkChildNodesRecursively(c,b,k,f):"attributes"===a.type&&k(d,b,f)&&f.push({callback:b.callback,elem:node}),e.callCallbacks(f)})}function k(a,b,f){if(e.matchesSelector(a,b.selector)&&(a._id===c&&(a._id=d++),-1==b.firedElems.indexOf(a._id))){if(b.options.onceOnly){if(0!==b.firedElems.length)return;b.me.unbindEventWithSelectorAndCallback.call(b.target,b.selector,b.callback)}b.firedElems.push(a._id),f.push({callback:b.callback,elem:a})}}var f={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};j=new g(h,i);var l=j.bindEvent;return j.bindEvent=function(a,b,c){void 0===c?(c=b,b=f):b=e.mergeArrays(f,b);var d=e.toElementsArray(this);if(b.existing){for(var g=[],h=0;h<d.length;h++)for(var i=d[h].querySelectorAll(a),j=0;j<i.length;j++)g.push({callback:c,elem:i[j]});if(b.onceOnly&&g.length)return c.call(g[0].elem);setTimeout(e.callCallbacks,1,g)}l.call(this,a,b,c)},j},i=function(){function d(a){return{childList:!0,subtree:!0}}function f(a,b){a.forEach(function(a){var c=a.removedNodes,f=(a.target,[]);null!==c&&c.length>0&&e.checkChildNodesRecursively(c,b,h,f),e.callCallbacks(f)})}function h(a,b){return e.matchesSelector(a,b.selector)}var c={};k=new g(d,f);var i=k.bindEvent;return k.bindEvent=function(a,b,d){void 0===d?(d=b,b=c):b=e.mergeArrays(c,b),i.call(this,a,b,d)},k},j=new h,k=new i;b&&m(b.fn),m(HTMLElement.prototype),m(NodeList.prototype),m(HTMLCollection.prototype),m(HTMLDocument.prototype),m(Window.prototype);var n={};return l(j,n,"unbindAllArrive"),l(k,n,"unbindAllLeave"),n}}(window,"undefined"==typeof jQuery?null:jQuery,void 0);"undefined"!=typeof jQuery&&check_webp_feature("alpha",ewww_load_images);
|
2314 |
</script>
|
2315 |
+
<?php
|
2316 |
+
} // End if().
|
2317 |
// Current length 9473.
|
2318 |
}
|
2319 |
|
2455 |
$i++;
|
2456 |
$path = sanitize_text_field( $path );
|
2457 |
ewwwio_debug_message( "validating auxiliary path: $path" );
|
2458 |
+
// Retrieve the location of the WordPress upload folder.
|
2459 |
$upload_dir = apply_filters( 'ewww_image_optimizer_folder_restriction', wp_upload_dir( null, false ) );
|
2460 |
// Retrieve the path of the upload folder from the array.
|
2461 |
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
2737 |
// Retrieve the existing attachment metadata.
|
2738 |
$original_meta = wp_get_attachment_metadata( $attachment_id );
|
2739 |
// If the call was to optimize...
|
2740 |
+
if ( 'ewww_image_optimizer_manual_optimize' === $_REQUEST['action'] || 'ewww_manual_optimize' === $_REQUEST['action'] ) {
|
2741 |
// Call the optimize from metadata function and store the resulting new metadata.
|
2742 |
$new_meta = ewww_image_optimizer_resize_from_meta_data( $original_meta, $attachment_id );
|
2743 |
} elseif ( 'ewww_image_optimizer_manual_restore' === $_REQUEST['action'] || 'ewww_manual_restore' === $_REQUEST['action'] ) {
|
2909 |
if ( ! empty( $image['path'] ) ) {
|
2910 |
$image['path'] = ewww_image_optimizer_relative_path_replace( $image['path'] );
|
2911 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2912 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
2913 |
$domain = parse_url( get_site_url(), PHP_URL_HOST );
|
2914 |
+
$url = 'http://optimize.exactlywww.com/backup/restore.php';
|
2915 |
+
$ssl = wp_http_supports( array( 'ssl' ) );
|
2916 |
+
if ( $ssl ) {
|
2917 |
+
$url = set_url_scheme( $url, 'https' );
|
2918 |
+
}
|
2919 |
$result = wp_remote_post( $url, array(
|
2920 |
'timeout' => 30,
|
2921 |
'sslverify' => false,
|
3109 |
function ewww_image_optimizer_full_cloud() {
|
3110 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) > 10 ) {
|
3111 |
return true;
|
3112 |
+
} elseif ( ! defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
|
3113 |
return true;
|
3114 |
}
|
3115 |
return false;
|
3121 |
function ewww_image_optimizer_cloud_enable() {
|
3122 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3123 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_jpg_level', 30 );
|
3124 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_png_level', 20 );
|
3125 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_gif_level', 10 );
|
3126 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_pdf_level', 10 );
|
3127 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_backup_files', 1 );
|
3179 |
}
|
3180 |
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
3181 |
$ewww_cloud_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
3182 |
+
if ( ! ewww_image_optimizer_detect_wpsf_location_lock() && $cache && preg_match( '/great/', $ewww_cloud_status ) ) {
|
|
|
|
|
3183 |
ewwwio_debug_message( 'using cached verification' );
|
3184 |
global $ewwwio_async_key_verification;
|
3185 |
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
3191 |
$ewwwio_async_key_verification->dispatch();
|
3192 |
return $ewww_cloud_status;
|
3193 |
}
|
3194 |
+
$url = 'http://optimize.exactlywww.com/verify/';
|
3195 |
+
$ssl = wp_http_supports( array( 'ssl' ) );
|
3196 |
+
if ( $ssl ) {
|
3197 |
+
$url = set_url_scheme( $url, 'https' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3198 |
}
|
3199 |
+
$result = ewww_image_optimizer_cloud_post_key( $url, $api_key );
|
3200 |
+
if ( is_wp_error( $result ) ) {
|
3201 |
+
$url = set_url_scheme( $url, 'http' );
|
3202 |
+
$error_message = $result->get_error_message();
|
3203 |
+
ewwwio_debug_message( "verification failed: $error_message" );
|
3204 |
+
$result = ewww_image_optimizer_cloud_post_key( $url, $api_key );
|
3205 |
+
}
|
3206 |
+
if ( is_wp_error( $result ) ) {
|
3207 |
+
$error_message = $result->get_error_message();
|
3208 |
+
ewwwio_debug_message( "verification failed via $url: $error_message" );
|
3209 |
+
} elseif ( ! empty( $result['body'] ) && preg_match( '/(great|exceeded)/', $result['body'] ) ) {
|
3210 |
+
$verified = $result['body'];
|
3211 |
+
if ( preg_match( '/exceeded/', $verified ) ) {
|
3212 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', time() + 300 );
|
3213 |
}
|
3214 |
+
ewwwio_debug_message( "verification success via: $url" );
|
3215 |
+
} else {
|
3216 |
+
ewwwio_debug_message( "verification failed via: $url" );
|
3217 |
+
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
3218 |
+
ewwwio_debug_message( print_r( $result, true ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3219 |
}
|
3220 |
}
|
3221 |
if ( empty( $verified ) ) {
|
3223 |
return false;
|
3224 |
} else {
|
3225 |
set_transient( 'ewww_image_optimizer_cloud_status', $verified, 3600 );
|
|
|
|
|
3226 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) < 20 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) < 20 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) < 20 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) == 0 ) {
|
3227 |
ewww_image_optimizer_cloud_enable();
|
3228 |
}
|
3235 |
/**
|
3236 |
* POSTs the API key to the API for verification.
|
3237 |
*
|
3238 |
+
* @param string $url The address of the server to use.
|
|
|
3239 |
* @param string $key The API key to submit via POST.
|
3240 |
* @return array The results of the http POST request.
|
3241 |
*/
|
3242 |
+
function ewww_image_optimizer_cloud_post_key( $url, $key ) {
|
3243 |
+
$result = wp_remote_post( $url, array(
|
3244 |
'timeout' => 5,
|
3245 |
'sslverify' => false,
|
3246 |
'body' => array(
|
3257 |
*/
|
3258 |
function ewww_image_optimizer_cloud_quota() {
|
3259 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3260 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
3261 |
+
$url = 'http://optimize.exactlywww.com/quota/';
|
3262 |
+
$ssl = wp_http_supports( array( 'ssl' ) );
|
3263 |
+
if ( $ssl ) {
|
3264 |
+
$url = set_url_scheme( $url, 'https' );
|
3265 |
+
}
|
3266 |
$result = wp_remote_post( $url, array(
|
3267 |
'timeout' => 5,
|
3268 |
'sslverify' => false,
|
3320 |
* @param array $jpg_fill Optional. Fill color for PNG to JPG conversion in hex format.
|
3321 |
* @param int $jpg_quality Optional. JPG quality level. Default null. Accepts 1-100.
|
3322 |
* @return array {
|
3323 |
+
* Information about the cloud optimization.
|
3324 |
*
|
3325 |
+
* @type string Filename of the optimized version.
|
3326 |
+
* @type bool True if the image was converted.
|
3327 |
+
* @type string Set to 'exceeded' if the API key is out of credits.
|
3328 |
+
* @type int File size of the (new) image.
|
3329 |
* }
|
3330 |
*/
|
3331 |
function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $newfile = null, $newtype = null, $fullsize = false, $jpg_fill = '', $jpg_quality = 82 ) {
|
3332 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3333 |
+
if ( ! ewwwio_check_memory_available( filesize( $file ) * 2.2 ) ) { // 2.2 = upload buffer + download buffer (2) multiplied by a factor of 1.1 for extra wiggle room.
|
3334 |
+
$memory_required = filesize( $file ) * 2.2;
|
3335 |
+
ewwwio_debug_message( "possibly insufficient memory for cloud (optimize) operation: $memory_required" );
|
3336 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
3337 |
+
add_filter( 'image_memory_limit', 'ewww_image_optimizer_raise_memory_limit' );
|
3338 |
+
wp_raise_memory_limit( 'image' );
|
3339 |
+
}
|
3340 |
+
ewww_image_optimizer_debug_log();
|
3341 |
+
}
|
3342 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
3343 |
$started = microtime( true );
|
3344 |
+
if ( preg_match( '/exceeded/', $ewww_status ) ) {
|
3345 |
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
3346 |
return array( $file, false, 'key verification failed', 0, '' );
|
|
|
|
|
|
|
3347 |
}
|
3348 |
}
|
3349 |
// Calculate how much time has elapsed since we started.
|
3432 |
ewwwio_debug_message( "jpg fill: $jpg_fill" );
|
3433 |
ewwwio_debug_message( "jpg quality: $jpg_quality" );
|
3434 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
3435 |
+
$url = 'http://optimize.exactlywww.com/v2/';
|
3436 |
+
$ssl = wp_http_supports( array( 'ssl' ) );
|
3437 |
+
if ( $ssl ) {
|
3438 |
+
$url = set_url_scheme( $url, 'https' );
|
3439 |
+
}
|
3440 |
$boundary = wp_generate_password( 24, false );
|
3441 |
|
3442 |
$headers = array(
|
3443 |
'content-type' => 'multipart/form-data; boundary=' . $boundary,
|
3444 |
+
'timeout' => 300,
|
3445 |
'httpversion' => '1.0',
|
3446 |
'blocking' => true,
|
3447 |
);
|
3484 |
|
3485 |
// Retrieve the time when the optimizer starts.
|
3486 |
$response = wp_remote_post( $url, array(
|
3487 |
+
'timeout' => 300,
|
3488 |
'headers' => $headers,
|
3489 |
'sslverify' => false,
|
3490 |
'body' => $payload,
|
3537 |
*/
|
3538 |
function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
|
3539 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3540 |
+
if ( ! ewwwio_check_memory_available( filesize( $file ) * 2.2 ) ) { // 2.2 = upload buffer + download buffer (2) multiplied by a factor of 1.1 for extra wiggle room.
|
3541 |
+
$memory_required = filesize( $file ) * 2.2;
|
3542 |
+
ewwwio_debug_message( "possibly insufficient memory for cloud (rotate) operation: $memory_required" );
|
3543 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
3544 |
+
add_filter( 'image_memory_limit', 'ewww_image_optimizer_raise_memory_limit' );
|
3545 |
+
wp_raise_memory_limit( 'image' );
|
3546 |
+
}
|
3547 |
+
ewww_image_optimizer_debug_log();
|
3548 |
+
}
|
3549 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
3550 |
$started = microtime( true );
|
3551 |
+
if ( preg_match( '/exceeded/', $ewww_status ) ) {
|
3552 |
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
3553 |
ewwwio_debug_message( 'cloud verify failed, image not rotated' );
|
3554 |
return false;
|
|
|
|
|
|
|
3555 |
}
|
3556 |
}
|
3557 |
// Calculate how much time has elapsed since we started.
|
3565 |
ewwwio_debug_message( "file: $file " );
|
3566 |
ewwwio_debug_message( "type: $type" );
|
3567 |
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
3568 |
+
$url = 'http://optimize.exactlywww.com/rotate/';
|
3569 |
+
$ssl = wp_http_supports( array( 'ssl' ) );
|
3570 |
+
if ( $ssl ) {
|
3571 |
+
$url = set_url_scheme( $url, 'https' );
|
3572 |
+
}
|
3573 |
$boundary = wp_generate_password( 24, false );
|
3574 |
|
3575 |
$headers = array(
|
3949 |
* @global string $ewww_debug Contains in-memory debug log.
|
3950 |
*
|
3951 |
* @param array $attachment {
|
3952 |
+
* Optional. The file to optimize. Default null.
|
3953 |
*
|
3954 |
+
* @type int $id The id number in the ewwwio_images table.
|
3955 |
+
* @type string $path The filename of the image.
|
3956 |
* }
|
3957 |
* @param bool $auto Optional. True if scheduled optimization is running. Default false.
|
3958 |
* @param bool $cli Optional. True if WP-CLI is running. Default false.
|
4013 |
'id' => $id,
|
4014 |
),
|
4015 |
array(
|
4016 |
+
'%d',
|
4017 |
)
|
4018 |
);
|
4019 |
}
|
4313 |
'id' => $s3_image['id'],
|
4314 |
),
|
4315 |
array(
|
4316 |
+
'%d',
|
4317 |
)
|
4318 |
);
|
4319 |
if ( $s3_image['orig_size'] > $found_local_image['orig_size'] ) {
|
4342 |
} // End if().
|
4343 |
}
|
4344 |
|
4345 |
+
/**
|
4346 |
+
* Raise the memory limit even higher (to 512M) than WP default of 256M if necessary.
|
4347 |
+
*
|
4348 |
+
* @param int|string $memory_limit The amount of memory to allocate.
|
4349 |
+
* @return int|string The new amount of memory to allocate, if it was only 256M or lower.
|
4350 |
+
*/
|
4351 |
+
function ewww_image_optimizer_raise_memory_limit( $memory_limit ) {
|
4352 |
+
if ( ( is_string( $memory_limit ) && '256M' == $memory_limit ) || ( is_int( $memory_limit ) && 270000000 > $memory_limit ) ) {
|
4353 |
+
ewwwio_debug_message( 'raising the roof' );
|
4354 |
+
return '512M';
|
4355 |
+
} else {
|
4356 |
+
return $memory_limit;
|
4357 |
+
}
|
4358 |
+
}
|
4359 |
+
|
4360 |
/**
|
4361 |
* If a JPG image is using the EXIF orientiation, correct the rotation, and reset the Orientation.
|
4362 |
*
|
4367 |
if ( defined( 'EWWW_IMAGE_OPTIMIZER_NO_ROTATE' ) && EWWW_IMAGE_OPTIMIZER_NO_ROTATE ) {
|
4368 |
return;
|
4369 |
}
|
4370 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
4371 |
+
wp_raise_memory_limit( 'image' );
|
4372 |
+
}
|
4373 |
$type = ewww_image_optimizer_mimetype( $file, 'i' );
|
4374 |
if ( 'image/jpeg' != $type ) {
|
4375 |
ewwwio_debug_message( 'not a JPG, no rotation needed' );
|
4420 |
if ( ! $file ) {
|
4421 |
return false;
|
4422 |
}
|
4423 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
4424 |
+
wp_raise_memory_limit( 'image' );
|
4425 |
+
}
|
4426 |
if ( ! empty( $_REQUEST['post_id'] ) || ( ! empty( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) || ( ! empty( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], 'media-new.php' ) ) ) {
|
4427 |
$maxwidth = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' );
|
4428 |
$maxheight = ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' );
|
4437 |
* Filters the dimensions to used for resizing uploaded images.
|
4438 |
*
|
4439 |
* @param array $args {
|
4440 |
+
* The dimensions to be used in resizing.
|
4441 |
*
|
4442 |
+
* @type int $maxwidth The maximum width of the image.
|
4443 |
+
* @type int $maxheight The maximum height of the image.
|
4444 |
* }
|
4445 |
* @param string $file The name of the file being resized.
|
4446 |
*/
|
4475 |
} else {
|
4476 |
list( $newwidth, $newheight ) = wp_constrain_dimensions( $oldwidth, $oldheight, $maxwidth, $maxheight );
|
4477 |
}
|
4478 |
+
if ( ! ewwwio_check_memory_available( ( $oldwidth * $oldwidth + $newwidth * $newheight ) * 4.8 ) ) { // 4.8 = 24-bit or 3 bytes per pixel multiplied by a factor of 1.6 for extra wiggle room.
|
4479 |
+
$memory_required = ( $oldwidth * $oldwidth + $newwidth * $newheight ) * 4.8;
|
4480 |
+
ewwwio_debug_message( "possibly insufficient memory for resizing operation: $memory_required" );
|
4481 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
4482 |
+
add_filter( 'image_memory_limit', 'ewww_image_optimizer_raise_memory_limit' );
|
4483 |
+
wp_raise_memory_limit( 'image' );
|
4484 |
+
}
|
4485 |
+
ewww_image_optimizer_debug_log();
|
4486 |
+
}
|
4487 |
if ( ! function_exists( 'wp_get_image_editor' ) ) {
|
4488 |
ewwwio_debug_message( 'no image editor function' );
|
4489 |
return false;
|
4873 |
* @global object $ewwwio_media_background;
|
4874 |
* @global object $ewwwio_async_optimize_media;
|
4875 |
* @global array $ewww_attachment {
|
4876 |
+
* Stores the ID and meta for later use with W3TC.
|
4877 |
*
|
4878 |
+
* @type int $id The attachment ID number.
|
4879 |
+
* @type array $meta The attachment metadata from the postmeta table.
|
4880 |
* }
|
4881 |
* @global object $as3cf For working with the WP Offload S3 plugin.
|
4882 |
* @global object $dreamspeed For working with the Dreamspeed CDN plugin.
|
4892 |
if ( ! is_array( $meta ) && empty( $meta ) ) {
|
4893 |
$meta = array();
|
4894 |
} elseif ( ! is_array( $meta ) ) {
|
4895 |
+
if ( is_string( $meta ) && is_numeric( $id ) && 'processing' == $meta ) {
|
4896 |
ewwwio_debug_message( "attempting to rebuild attachment meta for $id" );
|
4897 |
$new_meta = ewww_image_optimizer_rebuild_meta( $id );
|
4898 |
if ( ! is_array( $new_meta ) ) {
|
4987 |
),
|
4988 |
array(
|
4989 |
'id' => $already_optimized['id'],
|
4990 |
+
)
|
4991 |
+
);
|
4992 |
}
|
4993 |
}
|
4994 |
// Resize here so long as this is not a new image AND resize existing is enabled, and imsanity isn't enabled with a max size.
|
5124 |
),
|
5125 |
array(
|
5126 |
'id' => $already_optimized['id'],
|
5127 |
+
)
|
5128 |
+
);
|
5129 |
}
|
5130 |
$base_dir = $base_ims_dir;
|
5131 |
}
|
5512 |
wp_update_post( array(
|
5513 |
'ID' => $id,
|
5514 |
'post_mime_type' => $mime,
|
5515 |
+
) );
|
|
|
5516 |
ewww_image_optimizer_debug_log();
|
5517 |
ewwwio_memory( __FUNCTION__ );
|
5518 |
return $meta;
|
5526 |
* @param string $file Optional. Path relative to the uploads folder. Default ''.
|
5527 |
* @param bool $refresh_cache Optional. True to flush cache prior to fetching path. Default true.
|
5528 |
* @return array {
|
5529 |
+
* Information about the file.
|
5530 |
*
|
5531 |
+
* @type string The full path to the image.
|
5532 |
+
* @type string The path to the uploads folder.
|
5533 |
* }
|
5534 |
*/
|
5535 |
function ewww_image_optimizer_attachment_path( $meta, $id, $file = '', $refresh_cache = true ) {
|
5536 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
5537 |
|
5538 |
+
// Retrieve the location of the WordPress upload folder.
|
5539 |
$upload_dir = wp_upload_dir( null, false, $refresh_cache );
|
5540 |
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
5541 |
if ( ! $file ) {
|
5707 |
* @param string $file The filename to test for uniqueness.
|
5708 |
* @param string $fileext An iterator to append to the base filename, starts empty usually.
|
5709 |
* @return array {
|
5710 |
+
* Filename information.
|
5711 |
*
|
5712 |
+
* @type string A unique filename for converting an image.
|
5713 |
+
* @type int|string The iterator used for uniqueness.
|
5714 |
* }
|
5715 |
*/
|
5716 |
function ewww_image_optimizer_unique_filename( $file, $fileext ) {
|
5982 |
$msg = '<div>' . sprintf(
|
5983 |
/* translators: %s: name of a tool like jpegtran */
|
5984 |
esc_html__( '%s is missing', 'ewww-image-optimizer' ),
|
5985 |
+
'<em>optipng</em>'
|
5986 |
) . '</div>';
|
5987 |
} else {
|
5988 |
$convert_link = esc_html__( 'PNG to JPG', 'ewww-image-optimizer' );
|
6243 |
* @param int $id The ID number of the attachment.
|
6244 |
* @param array $optimized_images A list of image records related to $id.
|
6245 |
* @return array {
|
6246 |
+
* Information compiled from the database records.
|
6247 |
*
|
6248 |
+
* @type string $output The image results plus a table of individual image results in a modal.
|
6249 |
+
* @type string|bool $converted The original image if the attachment was converted or false.
|
6250 |
+
* @type string|bool $backup_available The backup hash if available or false.
|
6251 |
* }
|
6252 |
*/
|
6253 |
function ewww_image_optimizer_custom_column_results( $id, $optimized_images ) {
|
6557 |
/**
|
6558 |
* Retrieve option: use 'site' setting if plugin is network activated, otherwise use 'blog' setting.
|
6559 |
*
|
6560 |
+
* Retrieves multi-site and single-site options as appropriate as well as allowing overrides with
|
6561 |
+
* same-named constant. Overrides are only available for integer and boolean options.
|
6562 |
+
*
|
6563 |
* @param string $option_name The name of the option to retrieve.
|
6564 |
* @return mixed The value of the option.
|
6565 |
*/
|
6566 |
function ewww_image_optimizer_get_option( $option_name ) {
|
6567 |
+
$constant_name = strtoupper( $option_name );
|
6568 |
+
if ( defined( $constant_name ) && ( is_int( constant( $constant_name ) ) || is_bool( constant( $constant_name ) ) ) ) {
|
6569 |
+
return constant( $constant_name );
|
6570 |
+
}
|
6571 |
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
6572 |
// Need to include the plugin library for the is_plugin_active function.
|
6573 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
6604 |
* Check for a list of attachments for which we do not rebuild meta.
|
6605 |
*
|
6606 |
* @return array {
|
6607 |
+
* Information regarding attachments with broken metadata that could not be rebuilt.
|
6608 |
*
|
6609 |
+
* @type array A list of all know 'bad' attachments.
|
6610 |
+
* @type string The most recent 'bad' attachment.
|
6611 |
* }
|
6612 |
*/
|
6613 |
function ewww_image_optimizer_get_bad_attachments() {
|
6638 |
wp_enqueue_script( 'postbox' );
|
6639 |
wp_enqueue_script( 'dashboard' );
|
6640 |
wp_localize_script( 'ewwwbulkscript', 'ewww_vars', array(
|
6641 |
+
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-settings' ),
|
6642 |
+
) );
|
|
|
6643 |
ewwwio_memory( __FUNCTION__ );
|
6644 |
return;
|
6645 |
}
|
6912 |
$network_class = 'network-multisite';
|
6913 |
}
|
6914 |
$output = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6915 |
$output[] = "<script type='text/javascript'>\n" .
|
6916 |
'jQuery(document).ready(function($) {$(".fade").fadeTo(5000,1).fadeOut(3000);});' . "\n" .
|
6917 |
"</script>\n";
|
6983 |
}
|
6984 |
$skip = ewww_image_optimizer_skip_tools();
|
6985 |
$status_output .= "<p>\n";
|
6986 |
+
if ( ! $skip['jpegtran'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
6987 |
$status_output .= '<b>jpegtran:</b> ';
|
6988 |
if ( EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
6989 |
$jpegtran_installed = ewww_image_optimizer_tool_found( EWWW_IMAGE_OPTIMIZER_JPEGTRAN, 'j' );
|
7028 |
$collapsible = false;
|
7029 |
}
|
7030 |
}
|
|
|
|
|
|
|
7031 |
if ( ! $skip['gifsicle'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
7032 |
$status_output .= '<b>gifsicle:</b> ';
|
7033 |
if ( EWWW_IMAGE_OPTIMIZER_GIFSICLE ) {
|
7206 |
$output[] = "<ul class='ewww-tab-nav'>\n" .
|
7207 |
"<li class='ewww-tab ewww-general-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Basic Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7208 |
"<li class='ewww-tab ewww-optimization-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Advanced Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7209 |
+
"<li class='ewww-tab ewww-resize-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Resize Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7210 |
"<li class='ewww-tab ewww-conversion-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'Conversion Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7211 |
"<li class='ewww-tab ewww-webp-nav'><span class='ewww-tab-hidden'>" . esc_html__( 'WebP Settings', 'ewww-image-optimizer' ) . "</span></li>\n" .
|
7212 |
"</ul>\n";
|
7255 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_jpg_level'>" . esc_html__( 'JPG Optimization Level', 'ewww-image-optimizer' ) . "</label></th>\n" .
|
7256 |
"<td><span><select id='ewww_image_optimizer_jpg_level' name='ewww_image_optimizer_jpg_level'>\n" .
|
7257 |
"<option value='0'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ), 0, false ) . '>' . esc_html__( 'No Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7258 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
|
7259 |
$output[] = "<option class='$network_class' value='10'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ), 10, false ) . '>' . esc_html__( 'Lossless Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7260 |
}
|
7261 |
$output[] = "<option class='$network_class' $disable_level value='20'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ), 20, false ) . '>' . esc_html__( 'Maximum Lossless Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
7266 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_png_level'>" . esc_html__( 'PNG Optimization Level', 'ewww-image-optimizer' ) . "</label></th>\n" .
|
7267 |
"<td><span><select id='ewww_image_optimizer_png_level' name='ewww_image_optimizer_png_level'>\n" .
|
7268 |
"<option value='0'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 0, false ) . '>' . esc_html__( 'No Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7269 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
|
7270 |
$output[] = "<option class='$network_class' value='10'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 10, false ) . '>' . esc_html__( 'Lossless Compression', 'ewww-image-optimizer' ) . "</option>\n";
|
7271 |
}
|
7272 |
+
$output[] = "<option class='$network_class' $disable_level value='20' " . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 20, false ) .
|
7273 |
+
selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 30, false ) . '>' . esc_html__( 'Maximum Lossless Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
7274 |
"<option value='40'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 40, false ) . '>' . esc_html__( 'Lossy Compression', 'ewww-image-optimizer' ) . "</option>\n" .
|
7275 |
"<option $disable_level value='50'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ), 50, false ) . '>' . esc_html__( 'Maximum Lossy Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
7276 |
"</select></td></tr>\n";
|
7294 |
"<option $disable_pdf_level value='20'" . selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ), 20, false ) . '>' . esc_html__( 'Lossy Compression', 'ewww-image-optimizer' ) . " *</option>\n" .
|
7295 |
"</select></td></tr>\n";
|
7296 |
ewwwio_debug_message( 'pdf level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) );
|
|
|
7297 |
ewwwio_debug_message( 'bulk delay: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' ) );
|
7298 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_backup_files'>" . esc_html__( 'Backup Originals', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_backup_files' name='ewww_image_optimizer_backup_files' value='true' " .
|
7299 |
( ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' ) ? "checked='true'" : '' ) . " $disable_level > " . esc_html__( 'Store a copy of your original images on our secure server for 30 days. *Requires an active API key.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7305 |
$output[] = "</table>\n</div>\n";
|
7306 |
$output[] = "<div id='ewww-optimization-settings'>\n";
|
7307 |
$output[] = "<table class='form-table'>\n";
|
7308 |
+
if ( ! ewww_image_optimizer_full_cloud() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7309 |
ewwwio_debug_message( 'optipng level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) );
|
|
|
7310 |
ewwwio_debug_message( 'pngout disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_pngout' ) == true ? 'yes' : 'no' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7311 |
ewwwio_debug_message( 'pngout level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ) );
|
7312 |
+
}
|
7313 |
$output[] = "<tr class='$network_class'><th><span><label for='ewww_image_optimizer_jpg_quality'>" . esc_html__( 'JPG quality level:', 'ewww-image-optimizer' ) . "</label></th><td><input type='text' id='ewww_image_optimizer_jpg_quality' name='ewww_image_optimizer_jpg_quality' class='small-text' value='" . ewww_image_optimizer_jpg_quality() . "' /> " . esc_html__( 'Valid values are 1-100.', 'ewww-image-optimizer' ) . "\n<p class='description'>" . esc_html__( 'Use this to override the default WordPress quality level of 82. Applies to image editing, resizing, PNG to JPG conversion, and JPG to WebP conversion. Does not affect the original uploaded image unless maximum dimensions are set and resizing occurs.', 'ewww-image-optimizer' ) . "</p></td></tr>\n";
|
7314 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_parallel_optimization'>" . esc_html__( 'Parallel optimization', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_parallel_optimization' name='ewww_image_optimizer_parallel_optimization' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'All resizes generated from a single upload are optimized in parallel for faster optimization. If this is causing performance issues, disable parallel optimization to reduce the load on your server.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7315 |
ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) == true ? 'on' : 'off' ) );
|
7339 |
"<p class='description'>" . esc_html__( 'A file that matches any pattern or path provided will not be optimized.', 'ewww-image-optimizer' ) . "</p></td></tr>\n";
|
7340 |
ewwwio_debug_message( 'folders to ignore:' );
|
7341 |
ewwwio_debug_message( $exclude_paths );
|
7342 |
+
ewwwio_debug_message( 'skip images smaller than: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_size' ) . ' bytes' );
|
7343 |
+
ewwwio_debug_message( 'skip PNG images larger than: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_png_size' ) . ' bytes' );
|
7344 |
+
ewwwio_debug_message( 'exclude originals from lossy: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lossy_skip_full' ) == true ? 'on' : 'off' ) );
|
7345 |
+
ewwwio_debug_message( 'exclude originals from metadata removal: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_skip_full' ) == true ? 'on' : 'off' ) );
|
7346 |
+
ewwwio_debug_message( 'use system binaries: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_skip_bundle' ) == true ? 'yes' : 'no' ) );
|
7347 |
+
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_enable_help'>" . esc_html__( 'Enable Embedded Help', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_enable_help' name='ewww_image_optimizer_enable_help' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) == true ? "checked='true'" : '' ) . ' /> ' .
|
7348 |
+
esc_html__( 'Enable the support beacon, which gives you access to documentation and our support team right from your WordPress dashboard. To assist you more efficiently, we may collect the current url, IP address, browser/device information, and debugging information.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7349 |
+
ewwwio_debug_message( 'enable help beacon: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) == true ? 'yes' : 'no' ) );
|
7350 |
+
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_allow_tracking'>" . esc_html__( 'Allow Usage Tracking?', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) == true ? "checked='true'" : '' ) . ' /> ' .
|
7351 |
+
esc_html__( 'Allow EWWW Image Optimizer to anonymously track how this plugin is used and help us make the plugin better. Opt-in to tracking and receive 500 API image credits free. No sensitive data is tracked.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7352 |
+
$output[] = "</table>\n</div>\n";
|
7353 |
|
7354 |
+
$output[] = "<div id='ewww-resize-settings'>\n";
|
7355 |
+
$output[] = "<table class='form-table'>\n";
|
7356 |
// $output[] = "<tr><th><label for='ewww_image_optimizer_resize_detection'>" . esc_html__( 'Resize Detection', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_resize_detection' name='ewww_image_optimizer_resize_detection' value='true' " . ( ewww_image_optimizer_get_option('ewww_image_optimizer_resize_detection') == TRUE ? "checked='true'" : "" ) . " /> " . esc_html__( 'Will highlight images that need to be resized because the browser is scaling them down. Only visible for Admin users and adds a button to the admin bar to detect scaled images that have been lazy loaded.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7357 |
// ewwwio_debug_message( 'resize detection: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_detection' ) == TRUE ? 'on' : 'off' ) );
|
7358 |
if ( function_exists( 'imsanity_get_max_width_height' ) ) {
|
7370 |
$output[] = "<tr class='$network_class'><th><label for='ewww_image_optimizer_resize_existing'>" . esc_html__( 'Resize Existing Images', 'ewww-image-optimizer' ) . "</label></th><td><input type='checkbox' id='ewww_image_optimizer_resize_existing' name='ewww_image_optimizer_resize_existing' value='true' " . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) == true ? "checked='true'" : '' ) . ' /> ' . esc_html__( 'Allow resizing of existing Media Library images.', 'ewww-image-optimizer' ) . "</td></tr>\n";
|
7371 |
ewwwio_debug_message( 'resize existing images: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_resize_existing' ) == true ? 'on' : 'off' ) );
|
7372 |
|
7373 |
+
$output[] = '<tr class="network-singlesite"><th>' . esc_html__( 'Disable Resizes', 'ewww-image-optimizer' ) . '</th><td><p>' . esc_html__( 'WordPress, your theme, and other plugins generate various image sizes. You may disable optimization for certain sizes, or completely prevent those sizes from being created.', 'ewww-image-optimizer' ) . "</p>\n";
|
7374 |
$image_sizes = ewww_image_optimizer_get_image_sizes();
|
7375 |
$disabled_sizes = get_option( 'ewww_image_optimizer_disable_resizes' );
|
7376 |
$disabled_sizes_opt = get_option( 'ewww_image_optimizer_disable_resizes_opt' );
|
7393 |
$output[] = '<tr><th>' . esc_html__( 'Disable Resizes', 'ewww-image-optimizer' ) . '</th><td>';
|
7394 |
$output[] = '<p><span style="color: green">' . esc_html__( '*Settings to disable creation and optimization of individual sizes must be configured for each individual site.', 'ewww-image-optimizer' ) . "</span></p></td></tr>\n";
|
7395 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7396 |
$output[] = "</table>\n</div>\n";
|
7397 |
$output[] = "<div id='ewww-conversion-settings'>\n";
|
7398 |
$output[] = '<p>' . esc_html__( 'Conversion is only available for images in the Media Library (except WebP). By default, all images have a link available in the Media Library for one-time conversion. Turning on individual conversion operations below will enable conversion filters any time an image is uploaded or modified.', 'ewww-image-optimizer' ) . "<br />\n" .
|
7516 |
ewww_image_optimizer_webp_inline_script();
|
7517 |
}
|
7518 |
|
7519 |
+
$help_instructions = esc_html__( 'Enable the Debugging option and refresh this page to include debugging information with your question.', 'ewww-image-optimizer' ) . ' ' .
|
7520 |
+
esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
|
7521 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
7522 |
+
?>
|
7523 |
<script type="text/javascript">
|
7524 |
function selectText(containerid) {
|
7525 |
+
var debug_node = document.getElementById(containerid);
|
7526 |
if (document.selection) {
|
7527 |
var range = document.body.createTextRange();
|
7528 |
+
range.moveToElementText(debug_node);
|
7529 |
range.select();
|
7530 |
} else if (window.getSelection) {
|
7531 |
+
window.getSelection().selectAllChildren(debug_node);
|
|
|
|
|
7532 |
}
|
7533 |
}
|
7534 |
</script>
|
7535 |
<?php
|
7536 |
global $ewww_debug;
|
|
|
7537 |
echo '<p style="clear:both"><b>' . esc_html__( 'Debugging Information', 'ewww-image-optimizer' ) . ':</b> <button onclick="selectText(' . "'ewww-debug-info'" . ')">' . esc_html__( 'Select All', 'ewww-image-optimizer' ) . '</button>';
|
7538 |
if ( is_file( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) ) {
|
7539 |
+
$debug_log_url = plugins_url( '/debug.log', __FILE__ );
|
7540 |
echo " <a href='$debug_log_url'>" . esc_html( 'View Debug Log', 'ewww-image-optimizer' ) . "</a> - <a href='admin.php?action=ewww_image_optimizer_delete_debug_log'>" . esc_html( 'Remove Debug Log', 'ewww-image-optimizer' ) . '</a>';
|
7541 |
}
|
7542 |
echo '</p>';
|
7543 |
echo '<div id="ewww-debug-info" style="background:#ffff99;margin-left:-20px;padding:10px" contenteditable="true">' . $ewww_debug . '</div>';
|
7544 |
+
$help_instructions = esc_html__( 'Debugging information will be included with your message automatically.', 'ewww-image-optimizer' ) . ' ' .
|
7545 |
+
esc_html__( 'This will allow us to assist you more quickly.', 'ewww-image-optimizer' );
|
7546 |
}
|
7547 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
7548 |
+
/* $help_instructions = esc_html__( 'Please turn on the Debugging option. Then copy and paste the Debug Information from the bottom of the settings page. This will allow us to assist you more quickly.', 'ewww-image-optimizer' ); */
|
7549 |
$current_user = wp_get_current_user();
|
7550 |
$help_email = $current_user->user_email;
|
7551 |
$hs_config = array(
|
7560 |
);
|
7561 |
$hs_identify = array(
|
7562 |
'email' => $help_email,
|
|
|
7563 |
);
|
7564 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_debug' ) ) {
|
7565 |
+
$ewww_debug_array = explode( '<br>', $ewww_debug );
|
7566 |
+
$ewww_debug_i = 0;
|
7567 |
+
foreach ( $ewww_debug_array as $ewww_debug_line ) {
|
7568 |
+
$hs_identify[ 'debug_info_' . $ewww_debug_i ] = $ewww_debug_line;
|
7569 |
+
$ewww_debug_i++;
|
7570 |
+
}
|
7571 |
+
}
|
7572 |
?>
|
7573 |
<script type='text/javascript'>
|
7574 |
!function(e,o,n){window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={},t.readyQueue=[],t.config=function(e){this.userConfig=e},t.ready=function(e){this.readyQueue.push(e)},o.config={docs:{enabled:!0,baseUrl:"//ewwwio.helpscoutdocs.com/"},contact:{enabled:!0,formId:"af75cf17-310a-11e7-9841-0ab63ef01522"}};var r=e.getElementsByTagName("script")[0],c=e.createElement("script");c.type="text/javascript",c.async=!0,c.src="https://djtflbt20bdde.cloudfront.net/",r.parentNode.insertBefore(c,r)}(document,window.HSCW||{},window.HS||{});
|
7594 |
function ewww_image_optimizer_filter_settings_page( $input ) {
|
7595 |
$output = '';
|
7596 |
foreach ( $input as $line ) {
|
7597 |
+
if ( ewww_image_optimizer_full_cloud() && preg_match( '/nocloud/', $line ) ) {
|
7598 |
continue;
|
7599 |
} else {
|
7600 |
$output .= $line;
|
7725 |
ewwwio_debug_version_info();
|
7726 |
$ewww_version_dumped = true;
|
7727 |
}
|
7728 |
+
$message = str_replace( "\n\n\n", '<br>', $message );
|
7729 |
+
$message = str_replace( "\n\n", '<br>', $message );
|
7730 |
+
$message = str_replace( "\n", '<br>', $message );
|
7731 |
+
$ewww_debug .= "$message<br>";
|
7732 |
} else {
|
7733 |
global $ewww_debug;
|
7734 |
$ewww_debug = "not logging message, memory limit is $memory_limit";
|
7756 |
}
|
7757 |
}
|
7758 |
if ( filesize( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log' ) + strlen( $ewww_debug ) + 4000000 + memory_get_usage( true ) <= $memory_limit ) {
|
7759 |
+
$ewww_debug_log = str_replace( '<br>', "\n", $ewww_debug );
|
7760 |
file_put_contents( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'debug.log', $timestamp . $ewww_debug_log, FILE_APPEND );
|
7761 |
}
|
7762 |
}
|
7789 |
function ewwwio_debug_version_info() {
|
7790 |
global $ewww_debug;
|
7791 |
if ( ! extension_loaded( 'suhosin' ) && function_exists( 'get_current_user' ) ) {
|
7792 |
+
$ewww_debug .= get_current_user() . '<br>';
|
7793 |
}
|
7794 |
|
7795 |
+
$ewww_debug .= 'EWWW IO version: ' . EWWW_IMAGE_OPTIMIZER_VERSION . '<br>';
|
7796 |
|
7797 |
// Check the WP version.
|
7798 |
global $wp_version;
|
7799 |
$my_version = substr( $wp_version, 0, 3 );
|
7800 |
+
$ewww_debug .= "WP version: $wp_version<br>" ;
|
7801 |
|
7802 |
if ( defined( 'PHP_VERSION_ID' ) ) {
|
7803 |
+
$ewww_debug .= 'PHP version: ' . PHP_VERSION_ID . '<br>';
|
7804 |
}
|
7805 |
if ( defined( 'LIBXML_VERSION' ) ) {
|
7806 |
+
$ewww_debug .= 'libxml version: ' . LIBXML_VERSION . '<br>';
|
7807 |
}
|
7808 |
if ( ! empty( $_ENV['PANTHEON_ENVIRONMENT'] ) && in_array( $_ENV['PANTHEON_ENVIRONMENT'], array( 'test', 'live', 'dev' ) ) ) {
|
7809 |
+
$ewww_debug .= "detected pantheon env: {$_ENV['PANTHEON_ENVIRONMENT']}<br>";
|
7810 |
}
|
7811 |
}
|
7812 |
|
7941 |
$ids[] = $item['id'];
|
7942 |
}
|
7943 |
$ids = implode( ',', $ids );
|
7944 |
+
?>
|
7945 |
+
<form id="ewww-queue-clear-<?php echo $queue['option_id']; ?>" method="post" style="margin-bottom: 1.5em;" action="">
|
7946 |
<input type="hidden" id="ewww_nonce" name="ewww_nonce" value="<?php echo $nonce; ?>">
|
7947 |
<input type="hidden" name="ewww_image_optimizer_clear_queue" value="<?php echo $queue['option_name']; ?>">
|
7948 |
<input type="hidden" name="ids" value="<?php echo $ids; ?>">
|
7949 |
<button type="submit" class="button-secondary action"><?php esc_html_e( 'Clear this queue', 'ewww-image-optimizer' ); ?></button>
|
7950 |
</form>
|
7951 |
+
<?php
|
7952 |
+
}
|
7953 |
$all_ids = implode( ',', $all_ids );
|
7954 |
+
?>
|
7955 |
+
<form id="ewww-queue-clear-all" method="post" style="margin: 2em 0;" action="">
|
7956 |
<input type="hidden" id="ewww_nonce" name="ewww_nonce" value="<?php echo $nonce; ?>">
|
7957 |
<input type="hidden" name="ewww_image_optimizer_clear_queue" value="<?php echo count( $queues ); ?>">
|
7958 |
<input type="hidden" name="ids" value="<?php echo $all_ids; ?>">
|
ewww-image-optimizer.php
CHANGED
@@ -14,7 +14,7 @@ Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
|
|
14 |
Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
|
15 |
Author: Shane Bishop
|
16 |
Text Domain: ewww-image-optimizer
|
17 |
-
Version: 3.
|
18 |
Author URI: https://ewww.io/
|
19 |
License: GPLv3
|
20 |
*/
|
@@ -49,6 +49,16 @@ if ( ! defined( 'PHP_VERSION_ID' ) || PHP_VERSION_ID < 50300 ) {
|
|
49 |
add_action( 'admin_notices', 'ewww_image_optimizer_dual_plugin' );
|
50 |
// Loads the plugin translations.
|
51 |
add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
} else {
|
53 |
/**
|
54 |
* The full path of the plugin file (this file).
|
@@ -61,7 +71,7 @@ if ( ! defined( 'PHP_VERSION_ID' ) || PHP_VERSION_ID < 50300 ) {
|
|
61 |
*
|
62 |
* @var string EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL
|
63 |
*/
|
64 |
-
define( 'EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL', '
|
65 |
/**
|
66 |
* This is the full system path to the plugin folder.
|
67 |
*
|
@@ -129,3 +139,17 @@ if ( ! function_exists( 'ewww_image_optimizer_unsupported_php' ) ) {
|
|
129 |
load_plugin_textdomain( 'ewww-image-optimizer', false, EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'languages/' );
|
130 |
}
|
131 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
|
15 |
Author: Shane Bishop
|
16 |
Text Domain: ewww-image-optimizer
|
17 |
+
Version: 3.6.1
|
18 |
Author URI: https://ewww.io/
|
19 |
License: GPLv3
|
20 |
*/
|
49 |
add_action( 'admin_notices', 'ewww_image_optimizer_dual_plugin' );
|
50 |
// Loads the plugin translations.
|
51 |
add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
|
52 |
+
} elseif ( defined( 'KINSTAMU_VERSION' ) ) {
|
53 |
+
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_kinsta' );
|
54 |
+
add_action( 'admin_notices', 'ewww_image_optimizer_notice_kinsta' );
|
55 |
+
// Loads the plugin translations.
|
56 |
+
add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
|
57 |
+
} elseif ( defined( 'WPE_PLUGIN_VERSION' ) ) {
|
58 |
+
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_wpengine' );
|
59 |
+
add_action( 'admin_notices', 'ewww_image_optimizer_notice_wpengine' );
|
60 |
+
// Loads the plugin translations.
|
61 |
+
add_action( 'plugins_loaded', 'ewww_image_optimizer_false_init' );
|
62 |
} else {
|
63 |
/**
|
64 |
* The full path of the plugin file (this file).
|
71 |
*
|
72 |
* @var string EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL
|
73 |
*/
|
74 |
+
define( 'EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL', basename( plugin_dir_path( __FILE__ ) ) . '/' . basename( __FILE__ ) );
|
75 |
/**
|
76 |
* This is the full system path to the plugin folder.
|
77 |
*
|
139 |
load_plugin_textdomain( 'ewww-image-optimizer', false, EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'languages/' );
|
140 |
}
|
141 |
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Inform the user that only ewww-image-optimizer-cloud is permitted on WP Engine.
|
145 |
+
*/
|
146 |
+
function ewww_image_optimizer_notice_wpengine() {
|
147 |
+
echo "<div id='ewww-image-optimizer-warning-wpengine' class='error'><p>" . esc_html__( 'The regular version of the EWWW Image Optimizer plugin is not permitted on WP Engine sites. However, the cloud version has been approved by WP Engine. Please deactivate EWWW Image Optimizer and install EWWW Image Optimizer Cloud to optimize your images.', 'ewww-image-optimizer' ) . '</p></div>';
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Inform the user that only ewww-image-optimizer-cloud is permitted on Kinsta.
|
152 |
+
*/
|
153 |
+
function ewww_image_optimizer_notice_kinsta() {
|
154 |
+
echo "<div id='ewww-image-optimizer-warning-kinsta' class='error'><p>" . esc_html__( 'The regular version of the EWWW Image Optimizer plugin is not permitted on Kinsta sites. Please deactivate EWWW Image Optimizer and install EWWW Image Optimizer Cloud to optimize your images.', 'ewww-image-optimizer' ) . '</p></div>';
|
155 |
+
}
|
includes/eio.js
CHANGED
@@ -28,9 +28,10 @@ jQuery(document).ready(function($) {
|
|
28 |
$('#ewww-general-settings').show();
|
29 |
$('li.ewww-general-nav').addClass('ewww-selected');
|
30 |
if($('#ewww_image_optimizer_cloud_key').length){
|
31 |
-
$('#ewww-
|
32 |
console.log($('#ewww-general-settings').length);
|
33 |
}
|
|
|
34 |
$('#ewww-conversion-settings').hide();
|
35 |
$('.ewww-webp-nav').click(function() {
|
36 |
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
@@ -39,6 +40,7 @@ jQuery(document).ready(function($) {
|
|
39 |
$('#ewww-webp-settings').show();
|
40 |
$('#ewww-general-settings').hide();
|
41 |
$('#ewww-optimization-settings').hide();
|
|
|
42 |
$('#ewww-conversion-settings').hide();
|
43 |
});
|
44 |
$('.ewww-general-nav').click(function() {
|
@@ -48,6 +50,7 @@ jQuery(document).ready(function($) {
|
|
48 |
$('#ewww-webp-settings').hide();
|
49 |
$('#ewww-general-settings').show();
|
50 |
$('#ewww-optimization-settings').hide();
|
|
|
51 |
$('#ewww-conversion-settings').hide();
|
52 |
});
|
53 |
$('.ewww-optimization-nav').click(function() {
|
@@ -57,6 +60,17 @@ jQuery(document).ready(function($) {
|
|
57 |
$('#ewww-webp-settings').hide();
|
58 |
$('#ewww-general-settings').hide();
|
59 |
$('#ewww-optimization-settings').show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
$('#ewww-conversion-settings').hide();
|
61 |
});
|
62 |
$('.ewww-conversion-nav').click(function() {
|
@@ -66,6 +80,7 @@ jQuery(document).ready(function($) {
|
|
66 |
$('#ewww-webp-settings').hide();
|
67 |
$('#ewww-general-settings').hide();
|
68 |
$('#ewww-optimization-settings').hide();
|
|
|
69 |
$('#ewww-conversion-settings').show();
|
70 |
});
|
71 |
return false;
|
@@ -229,7 +244,7 @@ jQuery(document).ready(function($) {
|
|
229 |
.fail(function() {
|
230 |
ewww_scan_failures++;
|
231 |
if (ewww_scan_failures > 10) {
|
232 |
-
$('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_fail + '</
|
233 |
} else {
|
234 |
$('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_incomplete + '</b></span>');
|
235 |
setTimeout(function() {
|
@@ -411,6 +426,7 @@ jQuery(document).ready(function($) {
|
|
411 |
ewww_wpnonce: ewww_vars._wpnonce,
|
412 |
ewww_force: ewww_force,
|
413 |
ewww_batch_limit: ewww_batch_limit,
|
|
|
414 |
};
|
415 |
var ewww_jqxhr = $.post(ajaxurl, ewww_loop_data, function(response) {
|
416 |
var is_json = true;
|
@@ -493,9 +509,9 @@ jQuery(document).ready(function($) {
|
|
493 |
})
|
494 |
.fail(function() {
|
495 |
if (ewww_error_counter == 0) {
|
496 |
-
$('#ewww-bulk-loading').html('<p style="color: red"><b>' + ewww_vars.operation_interrupted + '</
|
497 |
} else {
|
498 |
-
$('#ewww-bulk-loading').html('<p style="color: red"><b>' + ewww_vars.temporary_failure + ' ' + ewww_error_counter + '</b></p>');
|
499 |
ewww_error_counter--;
|
500 |
setTimeout(function() {
|
501 |
ewwwProcessImage();
|
28 |
$('#ewww-general-settings').show();
|
29 |
$('li.ewww-general-nav').addClass('ewww-selected');
|
30 |
if($('#ewww_image_optimizer_cloud_key').length){
|
31 |
+
$('#ewww-resize-settings').hide();
|
32 |
console.log($('#ewww-general-settings').length);
|
33 |
}
|
34 |
+
$('#ewww-optimization-settings').hide();
|
35 |
$('#ewww-conversion-settings').hide();
|
36 |
$('.ewww-webp-nav').click(function() {
|
37 |
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
40 |
$('#ewww-webp-settings').show();
|
41 |
$('#ewww-general-settings').hide();
|
42 |
$('#ewww-optimization-settings').hide();
|
43 |
+
$('#ewww-resize-settings').hide();
|
44 |
$('#ewww-conversion-settings').hide();
|
45 |
});
|
46 |
$('.ewww-general-nav').click(function() {
|
50 |
$('#ewww-webp-settings').hide();
|
51 |
$('#ewww-general-settings').show();
|
52 |
$('#ewww-optimization-settings').hide();
|
53 |
+
$('#ewww-resize-settings').hide();
|
54 |
$('#ewww-conversion-settings').hide();
|
55 |
});
|
56 |
$('.ewww-optimization-nav').click(function() {
|
60 |
$('#ewww-webp-settings').hide();
|
61 |
$('#ewww-general-settings').hide();
|
62 |
$('#ewww-optimization-settings').show();
|
63 |
+
$('#ewww-resize-settings').hide();
|
64 |
+
$('#ewww-conversion-settings').hide();
|
65 |
+
});
|
66 |
+
$('.ewww-resize-nav').click(function() {
|
67 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
68 |
+
$('li.ewww-resize-nav').addClass('ewww-selected');
|
69 |
+
$('.ewww-tab a').blur();
|
70 |
+
$('#ewww-webp-settings').hide();
|
71 |
+
$('#ewww-general-settings').hide();
|
72 |
+
$('#ewww-optimization-settings').hide();
|
73 |
+
$('#ewww-resize-settings').show();
|
74 |
$('#ewww-conversion-settings').hide();
|
75 |
});
|
76 |
$('.ewww-conversion-nav').click(function() {
|
80 |
$('#ewww-webp-settings').hide();
|
81 |
$('#ewww-general-settings').hide();
|
82 |
$('#ewww-optimization-settings').hide();
|
83 |
+
$('#ewww-resize-settings').hide();
|
84 |
$('#ewww-conversion-settings').show();
|
85 |
});
|
86 |
return false;
|
244 |
.fail(function() {
|
245 |
ewww_scan_failures++;
|
246 |
if (ewww_scan_failures > 10) {
|
247 |
+
$('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_fail + ':</b> ' + ewww_vars.bulk_fail_more + '</span>');
|
248 |
} else {
|
249 |
$('#ewww-scanning').html('<span style="color: red"><b>' + ewww_vars.scan_incomplete + '</b></span>');
|
250 |
setTimeout(function() {
|
426 |
ewww_wpnonce: ewww_vars._wpnonce,
|
427 |
ewww_force: ewww_force,
|
428 |
ewww_batch_limit: ewww_batch_limit,
|
429 |
+
ewww_error_counter: ewww_error_counter,
|
430 |
};
|
431 |
var ewww_jqxhr = $.post(ajaxurl, ewww_loop_data, function(response) {
|
432 |
var is_json = true;
|
509 |
})
|
510 |
.fail(function() {
|
511 |
if (ewww_error_counter == 0) {
|
512 |
+
$('#ewww-bulk-loading').html('<p style="color: red"><b>' + ewww_vars.operation_interrupted + ':</b> ' + ewww_vars.bulk_fail_more + '</p>');
|
513 |
} else {
|
514 |
+
$('#ewww-bulk-loading').html('<p style="color: red"><b>' + ewww_vars.temporary_failure + ' ' + ewww_error_counter + ' (' + ewww_vars.bulk_fail_more + ')</b></p>');
|
515 |
ewww_error_counter--;
|
516 |
setTimeout(function() {
|
517 |
ewwwProcessImage();
|
mwebp.php
CHANGED
@@ -16,7 +16,8 @@ function ewww_image_optimizer_webp_migrate_preview() {
|
|
16 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
17 |
?> <div class="wrap">
|
18 |
<h1><?php esc_html_e( 'Migrate WebP Images', 'ewww-image-optimizer' ); ?></h1>
|
19 |
-
<?php
|
|
|
20 |
$button_text = esc_attr__( 'Start Migration', 'ewww-image-optimizer' );
|
21 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
22 |
// Create the html for the migration form and status divs.
|
@@ -93,9 +94,8 @@ function ewww_image_optimizer_webp_script( $hook ) {
|
|
93 |
$image_count = count( $images );
|
94 |
// Submit a couple variables to the javascript to work with.
|
95 |
wp_localize_script( 'ewwwwebpscript', 'ewww_vars', array(
|
96 |
-
|
97 |
-
|
98 |
-
);
|
99 |
}
|
100 |
|
101 |
/**
|
16 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
17 |
?> <div class="wrap">
|
18 |
<h1><?php esc_html_e( 'Migrate WebP Images', 'ewww-image-optimizer' ); ?></h1>
|
19 |
+
<?php
|
20 |
+
esc_html_e( 'The migration is split into two parts. First, the plugin needs to scan all folders for webp images. Once it has obtained the list of images to rename, it will proceed with the renaming' );
|
21 |
$button_text = esc_attr__( 'Start Migration', 'ewww-image-optimizer' );
|
22 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
23 |
// Create the html for the migration form and status divs.
|
94 |
$image_count = count( $images );
|
95 |
// Submit a couple variables to the javascript to work with.
|
96 |
wp_localize_script( 'ewwwwebpscript', 'ewww_vars', array(
|
97 |
+
'ewww_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-webp' ),
|
98 |
+
) );
|
|
|
99 |
}
|
100 |
|
101 |
/**
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: nosilver4u
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
|
4 |
Tags: image, compress, optimize, optimization, lossless, lossy, photo, picture, seo, jpegmini, tinyjpg, tinypng, webp, wp-cli
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to: 4.8
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv3
|
9 |
|
10 |
Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales.
|
@@ -147,6 +147,7 @@ Webhosts where the plugin will only work in cloud mode or only some tools are in
|
|
147 |
* Hostwinds
|
148 |
* ipage (JPG only)
|
149 |
* ipower
|
|
|
150 |
* one.com - may not even work in cloud mode
|
151 |
* WP Engine - use EWWW Image Optimizer Cloud fork: https://wordpress.org/plugins/ewww-image-optimizer-cloud/
|
152 |
|
@@ -214,6 +215,36 @@ Pngout, TinyJPG/TinyPNG, JPEGmini, and Pngquant were recommended by EWWW IO user
|
|
214 |
* Feature requests can be submitted via https://ewww.io/contact-us/ and commented on here: https://trello.com/b/Fp81dWof/ewww-image-optimizer
|
215 |
* 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/
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
= 3.5.1 =
|
218 |
* added: optional help beacons on bulk and settings pages
|
219 |
* added: disable deferring of WP Offload S3 uploads with EWWW_IMAGE_OPTIMIZER_NO_DEFER_S3
|
@@ -230,35 +261,15 @@ Pngout, TinyJPG/TinyPNG, JPEGmini, and Pngquant were recommended by EWWW IO user
|
|
230 |
* fixed: WebP .htaccess rewrite rules work better on LiteSpeed
|
231 |
* fixed: WP Symposium integration using old options, scanner now includes avatars folder by default
|
232 |
|
233 |
-
= 3.4.1 =
|
234 |
-
* added: move the Alt WebP script to an external resource by defining EWWW_IMAGE_OPTIMIZER_WEBP_EXTERNAL_SCRIPT
|
235 |
-
* changed: API keys are partially revealed, for easier verification
|
236 |
-
* changed: API key no longer uses password field to avoid problems with auto-fill
|
237 |
-
* changed: API key activation raises JPG and PNG to lossy and enables backups
|
238 |
-
* fixed: bulk delay setting not carried over to bulk optimizer
|
239 |
-
* fixed: WP Offload S3 uploads images prior to background optimization, resulting in a second upload afterwards
|
240 |
-
* fixed: single-site settings override not saving in certain cases on multisite
|
241 |
-
* fixed: AMP pages are broken when Alt WebP is enabled with old versions of libxml (less than 2.8.0)
|
242 |
-
* removed: unnecessary call to WP Offload S3 update function after optimization
|
243 |
-
|
244 |
-
= 3.4.0 =
|
245 |
-
* added: optional usage tracking
|
246 |
-
* added: close sessions even earlier in background/async handling to prevent lock-ups
|
247 |
-
* added: multisite option to network activate and allow individual site configuration
|
248 |
-
* changed: disabling resizes must be done on individual sites even when network activated
|
249 |
-
* changed: PNG files with empty alpha channels can be converted to JPG without setting a background/fill color
|
250 |
-
* fixed: webp migration script sending wrong nonce variable
|
251 |
-
* fixed: wp-cli help text was not being parsed properly
|
252 |
-
* updated: bundled cwebp to version 0.6.0
|
253 |
-
* updated: bundled pngquant to version 2.9.1 (2.8.1 for Windows)
|
254 |
-
* deprecated: cwebp will not be updated for Mac OS X 10.9 past 0.5.1
|
255 |
-
* obsoleted: FreeBSD 9 and CentOS 5 are "End of Life" and will no longer be tested
|
256 |
-
|
257 |
= Earlier versions =
|
258 |
Please refer to the separate changelog.txt file.
|
259 |
|
260 |
== Upgrade Notice ==
|
261 |
|
|
|
|
|
|
|
|
|
262 |
= 3.4.0 =
|
263 |
* Multisite change: disabling resizes must be done on individual sites even when network activated, as those settings are heavily theme-specific.
|
264 |
|
2 |
Contributors: nosilver4u
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
|
4 |
Tags: image, compress, optimize, optimization, lossless, lossy, photo, picture, seo, jpegmini, tinyjpg, tinypng, webp, wp-cli
|
5 |
+
Requires at least: 4.6
|
6 |
+
Tested up to: 4.8.1
|
7 |
+
Stable tag: 3.6.1
|
8 |
License: GPLv3
|
9 |
|
10 |
Speed up your website and improve your visitors' experience by automatically compressing and resizing images and PDFs. Boost SEO and improve sales.
|
147 |
* Hostwinds
|
148 |
* ipage (JPG only)
|
149 |
* ipower
|
150 |
+
* Kinsta - use EWWW Image Optimizer Cloud fork: https://wordpress.org/plugins/ewww-image-optimizer-cloud/
|
151 |
* one.com - may not even work in cloud mode
|
152 |
* WP Engine - use EWWW Image Optimizer Cloud fork: https://wordpress.org/plugins/ewww-image-optimizer-cloud/
|
153 |
|
215 |
* Feature requests can be submitted via https://ewww.io/contact-us/ and commented on here: https://trello.com/b/Fp81dWof/ewww-image-optimizer
|
216 |
* 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/
|
217 |
|
218 |
+
= 3.6.1 =
|
219 |
+
* fixed: bulk optimizer fails to initialize if the bulk_attachments array is set to an empty string
|
220 |
+
* fixed: misplaced parenthesis breaks option overrides
|
221 |
+
|
222 |
+
= 3.6.0 =
|
223 |
+
In an effort to simplify the settings page and make room for new features, many settings have been "hidden" and/or rearranged. It is my hope that this will make it easier for new users to get going with EWWW IO.
|
224 |
+
You can find more information about overriding options in the [Documentation](http://docs.ewww.io)
|
225 |
+
* added: ability to override any boolean/integer options by defining constant of the same name
|
226 |
+
* added: debug information included automatically with help beacon requests when debugging is enabled
|
227 |
+
* added: use wp_raise_memory_limit (WP 4.6+) to avoid memory issues
|
228 |
+
* added: use wp_is_ini_value_changeable (WP 4.6+) to avoid errors when raising max_execution_time
|
229 |
+
* added: notice to use cloud version on Kinsta sites
|
230 |
+
* changed: Better Lossless and Maximum Lossless have been combined for PNG images with more intelligent usage of advpng on the API
|
231 |
+
* changed: resize settings moved to new tab
|
232 |
+
* changed: various options have been removed from the settings page, but are still available via constants, see removals
|
233 |
+
* changed: bulk optimizer will auto-adjust settings if an image fails to optimize
|
234 |
+
* changed: bulk scanner will go into fall-back mode if the normal mode is too slow or if the image table takes longer than 5 seconds to load
|
235 |
+
* changed: images previously compressed by TinyPNG/JPG will be skipped during bulk optimization
|
236 |
+
* fixed: Optipng not working properly on Windows servers.
|
237 |
+
* fixed: notice on settings and bulk pages when debug mode is disabled
|
238 |
+
* removed: ewww_image_optimizer_delay (Bulk Delay), can be selected on the bulk page instead
|
239 |
+
* removed: ewww_image_optimizer_optipng_level (OptiPNG level) option
|
240 |
+
* removed: ewww_image_optimizer_pngout_level (PNGOUT level) option
|
241 |
+
* removed: ewww_image_optimizer_disable_pngout (Disable PNGOUT) option
|
242 |
+
* removed: ewww_image_optimizer_skip_size (Skip Small Images) option
|
243 |
+
* removed: ewww_image_optimizer_skip_png_size (Skip Large PNG Images) option
|
244 |
+
* removed: ewww_image_optimizer_lossy_skip_full (Exclude full-size images from lossy optimization) option
|
245 |
+
* removed: ewww_image_optimizer_metadata_skip_full (Exclude full-size images from metadata removal) option
|
246 |
+
* removed: ewww_image_optimizer_skip_bundle (Use System Paths) option
|
247 |
+
|
248 |
= 3.5.1 =
|
249 |
* added: optional help beacons on bulk and settings pages
|
250 |
* added: disable deferring of WP Offload S3 uploads with EWWW_IMAGE_OPTIMIZER_NO_DEFER_S3
|
261 |
* fixed: WebP .htaccess rewrite rules work better on LiteSpeed
|
262 |
* fixed: WP Symposium integration using old options, scanner now includes avatars folder by default
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
= Earlier versions =
|
265 |
Please refer to the separate changelog.txt file.
|
266 |
|
267 |
== Upgrade Notice ==
|
268 |
|
269 |
+
= 3.6.0 =
|
270 |
+
* API functions have been rewritten to use core WP detection for https capability, please report any errors right away.
|
271 |
+
* Several options have been removed from the user interface, see the changelog for details.
|
272 |
+
|
273 |
= 3.4.0 =
|
274 |
* Multisite change: disabling resizes must be done on individual sites even when network activated, as those settings are heavily theme-specific.
|
275 |
|
tests/test-optimize.php
CHANGED
@@ -355,27 +355,6 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
355 |
unlink( $results[0] );
|
356 |
}
|
357 |
|
358 |
-
/**
|
359 |
-
* Test max lossless PNG with API.
|
360 |
-
*/
|
361 |
-
function test_optimize_png_30() {
|
362 |
-
update_option( 'ewww_image_optimizer_png_level', 30 );
|
363 |
-
update_option( 'ewww_image_optimizer_jpegtran_copy', true );
|
364 |
-
update_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
365 |
-
update_site_option( 'ewww_image_optimizer_png_level', 30 );
|
366 |
-
update_site_option( 'ewww_image_optimizer_jpegtran_copy', true );
|
367 |
-
update_site_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
368 |
-
$test_png = self::$test_png;
|
369 |
-
self::$test_png = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/Opera_512x512.png' );
|
370 |
-
$results = $this->optimize_png();
|
371 |
-
update_option( 'ewww_image_optimizer_cloud_key', '' );
|
372 |
-
update_site_option( 'ewww_image_optimizer_cloud_key', '' );
|
373 |
-
$this->assertEquals( 37461, filesize( $results[0] ) );
|
374 |
-
unlink( self::$test_png );
|
375 |
-
self::$test_png = $test_png;
|
376 |
-
unlink( $results[0] );
|
377 |
-
}
|
378 |
-
|
379 |
/**
|
380 |
* Test regular lossy PNG with API.
|
381 |
*/
|
355 |
unlink( $results[0] );
|
356 |
}
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
/**
|
359 |
* Test regular lossy PNG with API.
|
360 |
*/
|
tests/test-resize.php
CHANGED
@@ -39,22 +39,9 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
39 |
self::$test_jpg = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/20170314_174658.jpg' );
|
40 |
copy( self::$test_jpg, self::$test_jpg . '.jpg' );
|
41 |
self::$test_jpg .= '.jpg';
|
42 |
-
//self::$test_png = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/books.png' );
|
43 |
-
//self::$test_gif = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/gifsiclelogo.gif' );
|
44 |
ewww_image_optimizer_set_defaults();
|
45 |
update_option( 'ewww_image_optimizer_jpg_level', '10' );
|
46 |
-
//update_option( 'ewww_image_optimizer_png_level', '10' );
|
47 |
-
//update_option( 'ewww_image_optimizer_gif_level', '10' );
|
48 |
-
//update_option( 'ewww_image_optimizer_webp', true );
|
49 |
-
//update_option( 'ewww_image_optimizer_png_level', 40 );
|
50 |
-
//update_site_option( 'ewww_image_optimizer_webp', true );
|
51 |
-
//update_site_option( 'ewww_image_optimizer_png_level', 40 );
|
52 |
ewww_image_optimizer_install_tools();
|
53 |
-
//ewww_image_optimizer_install_pngout();
|
54 |
-
/*update_option( 'ewww_image_optimizer_webp', '' );
|
55 |
-
update_option( 'ewww_image_optimizer_png_level', 10 );
|
56 |
-
update_site_option( 'ewww_image_optimizer_webp', '' );
|
57 |
-
update_site_option( 'ewww_image_optimizer_png_level', 10 );*/
|
58 |
}
|
59 |
|
60 |
/**
|
@@ -77,10 +64,6 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
77 |
update_site_option( 'ewww_image_optimizer_jpg_level', 10 );
|
78 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
79 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
80 |
-
// update_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
81 |
-
// update_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
82 |
-
//update_site_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
83 |
-
//update_site_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
84 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
85 |
$meta = wp_get_attachment_metadata( $id );
|
86 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
@@ -99,10 +82,6 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
99 |
update_site_option( 'ewww_image_optimizer_jpg_level', 10 );
|
100 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
101 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
102 |
-
// update_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
103 |
-
// update_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
104 |
-
//update_site_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
105 |
-
//update_site_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
106 |
add_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
107 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
108 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
@@ -124,10 +103,6 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
124 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
125 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
126 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
127 |
-
// update_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
128 |
-
// update_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
129 |
-
//update_site_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
130 |
-
//update_site_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
131 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
132 |
$meta = wp_get_attachment_metadata( $id );
|
133 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
@@ -147,10 +122,6 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
147 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
148 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
149 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
150 |
-
// update_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
151 |
-
// update_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
152 |
-
//update_site_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
153 |
-
//update_site_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
154 |
add_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
155 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
156 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
@@ -174,6 +145,5 @@ class EWWWIO_Resize_Tests extends WP_UnitTestCase {
|
|
174 |
if ( is_file( self::$test_gif ) ) {
|
175 |
unlink( self::$test_gif );
|
176 |
}
|
177 |
-
// ewww_image_optimizer_remove_binaries();
|
178 |
}
|
179 |
}
|
39 |
self::$test_jpg = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/20170314_174658.jpg' );
|
40 |
copy( self::$test_jpg, self::$test_jpg . '.jpg' );
|
41 |
self::$test_jpg .= '.jpg';
|
|
|
|
|
42 |
ewww_image_optimizer_set_defaults();
|
43 |
update_option( 'ewww_image_optimizer_jpg_level', '10' );
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
ewww_image_optimizer_install_tools();
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
/**
|
64 |
update_site_option( 'ewww_image_optimizer_jpg_level', 10 );
|
65 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
66 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
|
|
|
|
|
|
|
|
67 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
68 |
$meta = wp_get_attachment_metadata( $id );
|
69 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
82 |
update_site_option( 'ewww_image_optimizer_jpg_level', 10 );
|
83 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
84 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
|
|
|
|
|
|
|
|
85 |
add_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
86 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
87 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
103 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
104 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
105 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
|
|
|
|
|
|
|
|
106 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
107 |
$meta = wp_get_attachment_metadata( $id );
|
108 |
list( $file_path, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, $id );
|
122 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
123 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherwidth', 1024 );
|
124 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxotherheight', 1024 );
|
|
|
|
|
|
|
|
|
125 |
add_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
126 |
$id = $this->factory->attachment->create_upload_object( self::$test_jpg );
|
127 |
remove_filter( 'ewww_image_optimizer_crop_image', '__return_true' );
|
145 |
if ( is_file( self::$test_gif ) ) {
|
146 |
unlink( self::$test_gif );
|
147 |
}
|
|
|
148 |
}
|
149 |
}
|
unique.php
CHANGED
@@ -42,37 +42,12 @@ function ewww_image_optimizer_cloud_init() {
|
|
42 |
*/
|
43 |
function ewww_image_optimizer_exec_init() {
|
44 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
45 |
-
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
46 |
-
// Need to include the plugin library for the is_plugin_active function.
|
47 |
-
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
48 |
-
}
|
49 |
-
if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
50 |
-
// Set the binary-specific network settings if they have been POSTed.
|
51 |
-
if ( isset( $_POST['ewww_image_optimizer_delay'] ) && current_user_can( 'manage_options' ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'ewww_image_optimizer_options-options' ) ) {
|
52 |
-
if ( empty( $_POST['ewww_image_optimizer_skip_bundle'] ) ) {
|
53 |
-
update_site_option( 'ewww_image_optimizer_skip_bundle', false );
|
54 |
-
} else {
|
55 |
-
update_site_option( 'ewww_image_optimizer_skip_bundle', true );
|
56 |
-
}
|
57 |
-
if ( ! empty( $_POST['ewww_image_optimizer_optipng_level'] ) ) {
|
58 |
-
update_site_option( 'ewww_image_optimizer_optipng_level', (int) $_POST['ewww_image_optimizer_optipng_level'] );
|
59 |
-
update_site_option( 'ewww_image_optimizer_pngout_level', (int) $_POST['ewww_image_optimizer_pngout_level'] );
|
60 |
-
}
|
61 |
-
if ( empty( $_POST['ewww_image_optimizer_disable_pngout'] ) ) {
|
62 |
-
update_site_option( 'ewww_image_optimizer_disable_pngout', false );
|
63 |
-
} else {
|
64 |
-
update_site_option( 'ewww_image_optimizer_disable_pngout', true );
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
// Register all the binary-specific EWWW IO settings.
|
69 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_skip_bundle', 'boolval' );
|
70 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_optipng_level', 'intval' );
|
71 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pngout_level', 'intval' );
|
72 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_pngout', 'boolval' );
|
73 |
if ( defined( 'WPE_PLUGIN_VERSION' ) ) {
|
74 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_wpengine' );
|
75 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_wpengine' );
|
|
|
|
|
|
|
76 |
}
|
77 |
// If cloud is fully enabled, we're going to skip all the checks related to the bundled tools.
|
78 |
if ( EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
@@ -90,7 +65,7 @@ function ewww_image_optimizer_exec_init() {
|
|
90 |
add_action( 'load-upload.php', 'ewww_image_optimizer_tool_init', 9 );
|
91 |
add_action( 'load-media-new.php', 'ewww_image_optimizer_tool_init' );
|
92 |
add_action( 'load-media_page_ewww-image-optimizer-bulk', 'ewww_image_optimizer_tool_init' );
|
93 |
-
add_action( 'load-
|
94 |
add_action( 'load-plugins.php', 'ewww_image_optimizer_tool_init' );
|
95 |
add_action( 'load-ims_gallery_page_ewww-ims-optimize', 'ewww_image_optimizer_tool_init' );
|
96 |
add_action( 'load-media_page_ewww-image-optimizer-unoptimized', 'ewww_image_optimizer_tool_init' );
|
@@ -142,14 +117,6 @@ function ewww_image_optimizer_notice_os() {
|
|
142 |
sprintf( esc_html__( 'Unfortunately, the EWWW Image Optimizer plugin does not work with %s', 'ewww-image-optimizer' ), htmlentities( PHP_OS ) ) . '.</p></div>';
|
143 |
}
|
144 |
|
145 |
-
/**
|
146 |
-
* Inform the user that only ewww-image-optimizer-cloud is permitted on WP Engine.
|
147 |
-
*/
|
148 |
-
function ewww_image_optimizer_notice_wpengine() {
|
149 |
-
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
150 |
-
echo "<div id='ewww-image-optimizer-warning-wpengine' class='error'><p>" . esc_html__( 'The regular version of the EWWW Image Optimizer plugin is not permitted on WP Engine sites. However, the cloud version has been approved by WP Engine. Please deactivate EWWW Image Optimizer and install EWWW Image Optimizer Cloud to optimize your images.', 'ewww-image-optimizer' ) . '</p></div>';
|
151 |
-
}
|
152 |
-
|
153 |
/**
|
154 |
* Generates the source and destination paths for the executables that we bundle with the plugin.
|
155 |
*
|
@@ -422,14 +389,14 @@ function ewww_image_optimizer_install_tools() {
|
|
422 |
* Checks which tools should be skipped.
|
423 |
*
|
424 |
* @return array {
|
425 |
-
*
|
426 |
*
|
427 |
-
*
|
428 |
-
*
|
429 |
-
*
|
430 |
-
*
|
431 |
-
*
|
432 |
-
*
|
433 |
* }
|
434 |
*/
|
435 |
function ewww_image_optimizer_skip_tools() {
|
@@ -666,7 +633,7 @@ function ewww_image_optimizer_safemode_check() {
|
|
666 |
* @param bool $q True to check pngquant.
|
667 |
* @param bool $w True to check cwebp.
|
668 |
* @return array Path for each tool (indexes JPEGTRAN, OPTIPNG, GIFSICLE, PNGOUT, PNGQUANT, WEBP),
|
669 |
-
*
|
670 |
*/
|
671 |
function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p = true, $q = true, $w = true ) {
|
672 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
@@ -700,7 +667,7 @@ function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p =
|
|
700 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG' ) ) {
|
701 |
$optipng = ewww_image_optimizer_find_win_binary( 'optipng', 'o' );
|
702 |
ewwwio_debug_message( 'defining EWWW_IMAGE_OPTIMIZER_OPTIPNG' );
|
703 |
-
define( '
|
704 |
} else {
|
705 |
$optipng = EWWW_IMAGE_OPTIMIZER_OPTIPNG;
|
706 |
}
|
@@ -822,12 +789,24 @@ function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p =
|
|
822 |
}
|
823 |
}
|
824 |
} // End if().
|
825 |
-
if ( $jpegtran ) {
|
826 |
-
|
827 |
-
|
828 |
-
if ( $
|
829 |
-
|
830 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
ewwwio_memory( __FUNCTION__ );
|
832 |
return array(
|
833 |
'JPEGTRAN' => $jpegtran,
|
@@ -1026,7 +1005,7 @@ function ewww_image_optimizer_md5check( $path ) {
|
|
1026 |
*
|
1027 |
* @param string $path The absolute path to the file.
|
1028 |
* @param string $case The type of file we are checking. Accepts 'i' for
|
1029 |
-
*
|
1030 |
* @return bool|string A valid mime-type or false.
|
1031 |
*/
|
1032 |
function ewww_image_optimizer_mimetype( $path, $case ) {
|
@@ -1114,7 +1093,7 @@ function ewww_image_optimizer_escapeshellcmd( $path ) {
|
|
1114 |
*
|
1115 |
* @param string $path The absolute path to a binary file.
|
1116 |
* @param string $tool The specific tool to test. Accepts j, o, g, p, q, w or append a b for blind
|
1117 |
-
*
|
1118 |
* @return bool True (or truthy) if found.
|
1119 |
*/
|
1120 |
function ewww_image_optimizer_tool_found( $path, $tool ) {
|
@@ -1124,7 +1103,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1124 |
switch ( $tool ) {
|
1125 |
case 'j': // jpegtran.
|
1126 |
exec( $path . ' -v ' . EWWW_IMAGE_OPTIMIZER_IMAGES_PATH . 'sample.jpg 2>&1', $jpegtran_version );
|
1127 |
-
if ( ! empty( $jpegtran_version ) ) {
|
|
|
|
|
1128 |
foreach ( $jpegtran_version as $jout ) {
|
1129 |
if ( preg_match( '/Independent JPEG Group/', $jout ) ) {
|
1130 |
ewwwio_debug_message( 'optimizer found' );
|
@@ -1148,7 +1129,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1148 |
break;
|
1149 |
case 'o': // optipng.
|
1150 |
exec( $path . ' -v 2>&1', $optipng_version );
|
1151 |
-
if ( ! empty( $optipng_version ) ) {
|
|
|
|
|
1152 |
if ( ! empty( $optipng_version ) && strpos( $optipng_version[0], 'OptiPNG' ) === 0 ) {
|
1153 |
ewwwio_debug_message( 'optimizer found' );
|
1154 |
return $optipng_version[0];
|
@@ -1170,7 +1153,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1170 |
break;
|
1171 |
case 'g': // gifsicle.
|
1172 |
exec( $path . ' --version 2>&1', $gifsicle_version );
|
1173 |
-
if ( ! empty( $gifsicle_version ) ) {
|
|
|
|
|
1174 |
if ( ! empty( $gifsicle_version ) && strpos( $gifsicle_version[0], 'LCDF Gifsicle' ) === 0 ) {
|
1175 |
ewwwio_debug_message( 'optimizer found' );
|
1176 |
return $gifsicle_version[0];
|
@@ -1192,7 +1177,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1192 |
break;
|
1193 |
case 'p': // pngout.
|
1194 |
exec( "$path 2>&1", $pngout_version );
|
1195 |
-
if ( ! empty( $pngout_version ) ) {
|
|
|
|
|
1196 |
if ( ! empty( $pngout_version ) && strpos( $pngout_version[0], 'PNGOUT' ) === 0 ) {
|
1197 |
ewwwio_debug_message( 'optimizer found' );
|
1198 |
return $pngout_version[0];
|
@@ -1214,7 +1201,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1214 |
break;
|
1215 |
case 'q': // pngquant.
|
1216 |
exec( $path . ' -V 2>&1', $pngquant_version );
|
1217 |
-
if ( ! empty( $pngquant_version ) ) {
|
|
|
|
|
1218 |
if ( ! empty( $pngquant_version ) && substr( $pngquant_version[0], 0, 3 ) >= 2.0 ) {
|
1219 |
ewwwio_debug_message( 'optimizer found' );
|
1220 |
return $pngquant_version[0];
|
@@ -1236,7 +1225,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1236 |
break;
|
1237 |
case 'i': // ImageMagick.
|
1238 |
exec( "$path -version 2>&1", $convert_version );
|
1239 |
-
if ( ! empty( $convert_version ) ) {
|
|
|
|
|
1240 |
if ( ! empty( $convert_version ) && strpos( $convert_version[0], 'ImageMagick' ) ) {
|
1241 |
ewwwio_debug_message( 'imagemagick found' );
|
1242 |
return $convert_version[0];
|
@@ -1244,7 +1235,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1244 |
break;
|
1245 |
case 'f': // file.
|
1246 |
exec( "$path -v 2>&1", $file_version );
|
1247 |
-
if ( ! empty( $file_version[1] ) ) {
|
|
|
|
|
1248 |
if ( ! empty( $file_version[1] ) && preg_match( '/magic/', $file_version[1] ) ) {
|
1249 |
ewwwio_debug_message( 'file binary found' );
|
1250 |
return $file_version[0];
|
@@ -1255,7 +1248,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1255 |
break;
|
1256 |
case 'n': // nice.
|
1257 |
exec( "$path 2>&1", $nice_output );
|
1258 |
-
if ( is_array( $nice_output ) && isset( $nice_output[0] ) ) {
|
|
|
|
|
1259 |
if ( is_array( $nice_output ) && isset( $nice_output[0] ) && preg_match( '/usage/', $nice_output[0] ) ) {
|
1260 |
ewwwio_debug_message( 'nice found' );
|
1261 |
return true;
|
@@ -1266,7 +1261,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1266 |
break;
|
1267 |
case 't': // tar.
|
1268 |
exec( "$path --version 2>&1", $tar_version );
|
1269 |
-
if ( ! empty( $tar_version[0] ) ) {
|
|
|
|
|
1270 |
if ( ! empty( $tar_version[0] ) && preg_match( '/bsdtar/', $tar_version[0] ) ) {
|
1271 |
ewwwio_debug_message( 'tar found' );
|
1272 |
return $tar_version[0];
|
@@ -1277,7 +1274,9 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1277 |
break;
|
1278 |
case 'w': // cwebp.
|
1279 |
exec( "$path -version 2>&1", $webp_version );
|
1280 |
-
if ( ! empty( $webp_version ) ) {
|
|
|
|
|
1281 |
if ( ! empty( $webp_version ) && preg_match( '/0.\d.\d/', $webp_version[0] ) ) {
|
1282 |
ewwwio_debug_message( 'optimizer found' );
|
1283 |
return $webp_version[0];
|
@@ -1507,29 +1506,32 @@ function ewww_image_optimizer_jpegtran_autorotate( $file, $type, $orientation )
|
|
1507 |
* Process an image.
|
1508 |
*
|
1509 |
* @param string $file Full absolute path to the image file.
|
1510 |
-
* @param int $gallery_type 1=
|
1511 |
-
*
|
1512 |
* @param bool $converted True if this is a resize and the full image was converted to a
|
1513 |
-
*
|
1514 |
* @param bool $new True if this is a new image, so it should attempt conversion regardless of
|
1515 |
-
*
|
1516 |
* @param bool $fullsize True if this is a full size (original) image.
|
1517 |
* @return array {
|
1518 |
-
*
|
1519 |
*
|
1520 |
-
*
|
1521 |
-
*
|
1522 |
-
*
|
1523 |
-
*
|
1524 |
* }
|
1525 |
*/
|
1526 |
function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $new = false, $fullsize = false ) {
|
1527 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
|
|
|
|
|
|
|
|
1528 |
// If the plugin gets here without initializing, we need to run through some things first.
|
1529 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) ) {
|
1530 |
ewww_image_optimizer_cloud_init();
|
1531 |
}
|
1532 |
-
session_write_close();
|
1533 |
$bypass_optimization = apply_filters( 'ewww_image_optimizer_bypass', false, $file );
|
1534 |
if ( true === $bypass_optimization ) {
|
1535 |
ewwwio_debug_message( "optimization bypassed: $file" );
|
@@ -1691,7 +1693,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1691 |
switch ( $type ) {
|
1692 |
case 'image/jpeg':
|
1693 |
$png_size = 0;
|
1694 |
-
// If jpg2png conversion is enabled, and this image is in the
|
1695 |
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_to_png' ) && 1 == $gallery_type ) || ! empty( $_REQUEST['ewww_convert'] ) ) {
|
1696 |
// Generate the filename for a PNG:
|
1697 |
// If this is a resize version.
|
@@ -1922,7 +1924,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1922 |
break;
|
1923 |
case 'image/png':
|
1924 |
$jpg_size = 0;
|
1925 |
-
// Png2jpg conversion is turned on, and the image is in the
|
1926 |
// We check for transparency later, after optimization, because optipng might fix an empty alpha channel.
|
1927 |
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) || ! empty( $_REQUEST['ewww_convert'] ) )
|
1928 |
&& 1 == $gallery_type && ! $skip_lossy ) {
|
@@ -2244,7 +2246,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2244 |
ewww_image_optimizer_webp_create( $file, $new_size, $type, $tools['WEBP'], $orig_size != $new_size );
|
2245 |
break;
|
2246 |
case 'image/gif':
|
2247 |
-
// If gif2png is turned on, and the image is in the
|
2248 |
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) || ! empty( $_REQUEST['ewww_convert'] ) )
|
2249 |
&& 1 == $gallery_type && ! ewww_image_optimizer_is_animated( $file ) ) {
|
2250 |
// Generate the filename for a PNG:
|
42 |
*/
|
43 |
function ewww_image_optimizer_exec_init() {
|
44 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
if ( defined( 'WPE_PLUGIN_VERSION' ) ) {
|
46 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_wpengine' );
|
47 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_wpengine' );
|
48 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) ) {
|
49 |
+
define( 'EWWW_IMAGE_OPTIMIZER_NOEXEC', true );
|
50 |
+
}
|
51 |
}
|
52 |
// If cloud is fully enabled, we're going to skip all the checks related to the bundled tools.
|
53 |
if ( EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
65 |
add_action( 'load-upload.php', 'ewww_image_optimizer_tool_init', 9 );
|
66 |
add_action( 'load-media-new.php', 'ewww_image_optimizer_tool_init' );
|
67 |
add_action( 'load-media_page_ewww-image-optimizer-bulk', 'ewww_image_optimizer_tool_init' );
|
68 |
+
add_action( 'load-settings_page_' . str_replace( '.php', '', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ), 'ewww_image_optimizer_tool_init' );
|
69 |
add_action( 'load-plugins.php', 'ewww_image_optimizer_tool_init' );
|
70 |
add_action( 'load-ims_gallery_page_ewww-ims-optimize', 'ewww_image_optimizer_tool_init' );
|
71 |
add_action( 'load-media_page_ewww-image-optimizer-unoptimized', 'ewww_image_optimizer_tool_init' );
|
117 |
sprintf( esc_html__( 'Unfortunately, the EWWW Image Optimizer plugin does not work with %s', 'ewww-image-optimizer' ), htmlentities( PHP_OS ) ) . '.</p></div>';
|
118 |
}
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
/**
|
121 |
* Generates the source and destination paths for the executables that we bundle with the plugin.
|
122 |
*
|
389 |
* Checks which tools should be skipped.
|
390 |
*
|
391 |
* @return array {
|
392 |
+
* A list of tools to skip.
|
393 |
*
|
394 |
+
* @type bool $jpegtran
|
395 |
+
* @type bool $optipng
|
396 |
+
* @type bool $gifsicle
|
397 |
+
* @type bool $pngout
|
398 |
+
* @type bool $pngquant
|
399 |
+
* @type bool $webp
|
400 |
* }
|
401 |
*/
|
402 |
function ewww_image_optimizer_skip_tools() {
|
633 |
* @param bool $q True to check pngquant.
|
634 |
* @param bool $w True to check cwebp.
|
635 |
* @return array Path for each tool (indexes JPEGTRAN, OPTIPNG, GIFSICLE, PNGOUT, PNGQUANT, WEBP),
|
636 |
+
* or false for disabled/missing tools.
|
637 |
*/
|
638 |
function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p = true, $q = true, $w = true ) {
|
639 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
667 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG' ) ) {
|
668 |
$optipng = ewww_image_optimizer_find_win_binary( 'optipng', 'o' );
|
669 |
ewwwio_debug_message( 'defining EWWW_IMAGE_OPTIMIZER_OPTIPNG' );
|
670 |
+
define( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG', $optipng );
|
671 |
} else {
|
672 |
$optipng = EWWW_IMAGE_OPTIMIZER_OPTIPNG;
|
673 |
}
|
789 |
}
|
790 |
}
|
791 |
} // End if().
|
792 |
+
if ( $jpegtran ) {
|
793 |
+
ewwwio_debug_message( "using: $jpegtran" );
|
794 |
+
}
|
795 |
+
if ( $optipng ) {
|
796 |
+
ewwwio_debug_message( "using: $optipng" );
|
797 |
+
}
|
798 |
+
if ( $gifsicle ) {
|
799 |
+
ewwwio_debug_message( "using: $gifsicle" );
|
800 |
+
}
|
801 |
+
if ( $pngout ) {
|
802 |
+
ewwwio_debug_message( "using: $pngout" );
|
803 |
+
}
|
804 |
+
if ( $pngquant ) {
|
805 |
+
ewwwio_debug_message( "using: $pngquant" );
|
806 |
+
}
|
807 |
+
if ( $webp ) {
|
808 |
+
ewwwio_debug_message( "using: $webp" );
|
809 |
+
}
|
810 |
ewwwio_memory( __FUNCTION__ );
|
811 |
return array(
|
812 |
'JPEGTRAN' => $jpegtran,
|
1005 |
*
|
1006 |
* @param string $path The absolute path to the file.
|
1007 |
* @param string $case The type of file we are checking. Accepts 'i' for
|
1008 |
+
* images/pdfs or 'b' for binary.
|
1009 |
* @return bool|string A valid mime-type or false.
|
1010 |
*/
|
1011 |
function ewww_image_optimizer_mimetype( $path, $case ) {
|
1093 |
*
|
1094 |
* @param string $path The absolute path to a binary file.
|
1095 |
* @param string $tool The specific tool to test. Accepts j, o, g, p, q, w or append a b for blind
|
1096 |
+
* test like jb.
|
1097 |
* @return bool True (or truthy) if found.
|
1098 |
*/
|
1099 |
function ewww_image_optimizer_tool_found( $path, $tool ) {
|
1103 |
switch ( $tool ) {
|
1104 |
case 'j': // jpegtran.
|
1105 |
exec( $path . ' -v ' . EWWW_IMAGE_OPTIMIZER_IMAGES_PATH . 'sample.jpg 2>&1', $jpegtran_version );
|
1106 |
+
if ( ! empty( $jpegtran_version ) ) {
|
1107 |
+
ewwwio_debug_message( "$path: {$jpegtran_version[0]}" );
|
1108 |
+
}
|
1109 |
foreach ( $jpegtran_version as $jout ) {
|
1110 |
if ( preg_match( '/Independent JPEG Group/', $jout ) ) {
|
1111 |
ewwwio_debug_message( 'optimizer found' );
|
1129 |
break;
|
1130 |
case 'o': // optipng.
|
1131 |
exec( $path . ' -v 2>&1', $optipng_version );
|
1132 |
+
if ( ! empty( $optipng_version ) ) {
|
1133 |
+
ewwwio_debug_message( "$path: {$optipng_version[0]}" );
|
1134 |
+
}
|
1135 |
if ( ! empty( $optipng_version ) && strpos( $optipng_version[0], 'OptiPNG' ) === 0 ) {
|
1136 |
ewwwio_debug_message( 'optimizer found' );
|
1137 |
return $optipng_version[0];
|
1153 |
break;
|
1154 |
case 'g': // gifsicle.
|
1155 |
exec( $path . ' --version 2>&1', $gifsicle_version );
|
1156 |
+
if ( ! empty( $gifsicle_version ) ) {
|
1157 |
+
ewwwio_debug_message( "$path: {$gifsicle_version[0]}" );
|
1158 |
+
}
|
1159 |
if ( ! empty( $gifsicle_version ) && strpos( $gifsicle_version[0], 'LCDF Gifsicle' ) === 0 ) {
|
1160 |
ewwwio_debug_message( 'optimizer found' );
|
1161 |
return $gifsicle_version[0];
|
1177 |
break;
|
1178 |
case 'p': // pngout.
|
1179 |
exec( "$path 2>&1", $pngout_version );
|
1180 |
+
if ( ! empty( $pngout_version ) ) {
|
1181 |
+
ewwwio_debug_message( "$path: {$pngout_version[0]}" );
|
1182 |
+
}
|
1183 |
if ( ! empty( $pngout_version ) && strpos( $pngout_version[0], 'PNGOUT' ) === 0 ) {
|
1184 |
ewwwio_debug_message( 'optimizer found' );
|
1185 |
return $pngout_version[0];
|
1201 |
break;
|
1202 |
case 'q': // pngquant.
|
1203 |
exec( $path . ' -V 2>&1', $pngquant_version );
|
1204 |
+
if ( ! empty( $pngquant_version ) ) {
|
1205 |
+
ewwwio_debug_message( "$path: {$pngquant_version[0]}" );
|
1206 |
+
}
|
1207 |
if ( ! empty( $pngquant_version ) && substr( $pngquant_version[0], 0, 3 ) >= 2.0 ) {
|
1208 |
ewwwio_debug_message( 'optimizer found' );
|
1209 |
return $pngquant_version[0];
|
1225 |
break;
|
1226 |
case 'i': // ImageMagick.
|
1227 |
exec( "$path -version 2>&1", $convert_version );
|
1228 |
+
if ( ! empty( $convert_version ) ) {
|
1229 |
+
ewwwio_debug_message( "$path: {$convert_version[0]}" );
|
1230 |
+
}
|
1231 |
if ( ! empty( $convert_version ) && strpos( $convert_version[0], 'ImageMagick' ) ) {
|
1232 |
ewwwio_debug_message( 'imagemagick found' );
|
1233 |
return $convert_version[0];
|
1235 |
break;
|
1236 |
case 'f': // file.
|
1237 |
exec( "$path -v 2>&1", $file_version );
|
1238 |
+
if ( ! empty( $file_version[1] ) ) {
|
1239 |
+
ewwwio_debug_message( "$path: {$file_version[1]}" );
|
1240 |
+
}
|
1241 |
if ( ! empty( $file_version[1] ) && preg_match( '/magic/', $file_version[1] ) ) {
|
1242 |
ewwwio_debug_message( 'file binary found' );
|
1243 |
return $file_version[0];
|
1248 |
break;
|
1249 |
case 'n': // nice.
|
1250 |
exec( "$path 2>&1", $nice_output );
|
1251 |
+
if ( is_array( $nice_output ) && isset( $nice_output[0] ) ) {
|
1252 |
+
ewwwio_debug_message( "$path: {$nice_output[0]}" );
|
1253 |
+
}
|
1254 |
if ( is_array( $nice_output ) && isset( $nice_output[0] ) && preg_match( '/usage/', $nice_output[0] ) ) {
|
1255 |
ewwwio_debug_message( 'nice found' );
|
1256 |
return true;
|
1261 |
break;
|
1262 |
case 't': // tar.
|
1263 |
exec( "$path --version 2>&1", $tar_version );
|
1264 |
+
if ( ! empty( $tar_version[0] ) ) {
|
1265 |
+
ewwwio_debug_message( "$path: {$tar_version[0]}" );
|
1266 |
+
}
|
1267 |
if ( ! empty( $tar_version[0] ) && preg_match( '/bsdtar/', $tar_version[0] ) ) {
|
1268 |
ewwwio_debug_message( 'tar found' );
|
1269 |
return $tar_version[0];
|
1274 |
break;
|
1275 |
case 'w': // cwebp.
|
1276 |
exec( "$path -version 2>&1", $webp_version );
|
1277 |
+
if ( ! empty( $webp_version ) ) {
|
1278 |
+
ewwwio_debug_message( "$path: {$webp_version[0]}" );
|
1279 |
+
}
|
1280 |
if ( ! empty( $webp_version ) && preg_match( '/0.\d.\d/', $webp_version[0] ) ) {
|
1281 |
ewwwio_debug_message( 'optimizer found' );
|
1282 |
return $webp_version[0];
|
1506 |
* Process an image.
|
1507 |
*
|
1508 |
* @param string $file Full absolute path to the image file.
|
1509 |
+
* @param int $gallery_type 1=WordPress, 2=nextgen, 3=flagallery, 4=aux_images, 5=image editor,
|
1510 |
+
* 6=imagestore.
|
1511 |
* @param bool $converted True if this is a resize and the full image was converted to a
|
1512 |
+
* new format.
|
1513 |
* @param bool $new True if this is a new image, so it should attempt conversion regardless of
|
1514 |
+
* previous results.
|
1515 |
* @param bool $fullsize True if this is a full size (original) image.
|
1516 |
* @return array {
|
1517 |
+
* Status of the optimization attempt.
|
1518 |
*
|
1519 |
+
* @type string $file The filename or false on error.
|
1520 |
+
* @type string $results The results of the optimization.
|
1521 |
+
* @type bool $converted True if an image changes formats.
|
1522 |
+
* @type string The original filename if converted.
|
1523 |
* }
|
1524 |
*/
|
1525 |
function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $new = false, $fullsize = false ) {
|
1526 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
1527 |
+
session_write_close();
|
1528 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
1529 |
+
wp_raise_memory_limit( 'image' );
|
1530 |
+
}
|
1531 |
// If the plugin gets here without initializing, we need to run through some things first.
|
1532 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) ) {
|
1533 |
ewww_image_optimizer_cloud_init();
|
1534 |
}
|
|
|
1535 |
$bypass_optimization = apply_filters( 'ewww_image_optimizer_bypass', false, $file );
|
1536 |
if ( true === $bypass_optimization ) {
|
1537 |
ewwwio_debug_message( "optimization bypassed: $file" );
|
1693 |
switch ( $type ) {
|
1694 |
case 'image/jpeg':
|
1695 |
$png_size = 0;
|
1696 |
+
// If jpg2png conversion is enabled, and this image is in the WordPress media library.
|
1697 |
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_to_png' ) && 1 == $gallery_type ) || ! empty( $_REQUEST['ewww_convert'] ) ) {
|
1698 |
// Generate the filename for a PNG:
|
1699 |
// If this is a resize version.
|
1924 |
break;
|
1925 |
case 'image/png':
|
1926 |
$jpg_size = 0;
|
1927 |
+
// Png2jpg conversion is turned on, and the image is in the WordPress media library.
|
1928 |
// We check for transparency later, after optimization, because optipng might fix an empty alpha channel.
|
1929 |
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) || ! empty( $_REQUEST['ewww_convert'] ) )
|
1930 |
&& 1 == $gallery_type && ! $skip_lossy ) {
|
2246 |
ewww_image_optimizer_webp_create( $file, $new_size, $type, $tools['WEBP'], $orig_size != $new_size );
|
2247 |
break;
|
2248 |
case 'image/gif':
|
2249 |
+
// If gif2png is turned on, and the image is in the WordPress media library.
|
2250 |
if ( ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_to_png' ) || ! empty( $_REQUEST['ewww_convert'] ) )
|
2251 |
&& 1 == $gallery_type && ! ewww_image_optimizer_is_animated( $file ) ) {
|
2252 |
// Generate the filename for a PNG:
|