Version Description
- added: tool to delete originals from WP 5.3+ auto-scaling behavior (Tools menu)
- added: JS WebP recognizes video elements added via JS (e.g. infinite scroll)
- added: automatically convert GIF to PNG during new uploads, unless animated
- added: JS WebP and picture WebP auto-detect configuration for S3 Uploads and WP Stateless
- added: Lazy Load for external CSS and separate style blocks (div elements only for now)
- added: Easy IO/CDN rewriting for Ultimate Member AJAX-powered activity wall
- changed: settings UI revamped with wizard for first-time installs
- changed: automatic PNG to JPG threshold lowered to 250kb
- changed: extensions for WP_Image_Editor now disabled by default, use EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR constant to enable them
- changed: JS WebP can be used with picture WebP + Lazy Load to support CSS background images
- changed: better compatibility with Theia Smart Thumbnails
- changed: Lazy Load auto-sizing will no longer decrease the image size, only increasing is allowed
- changed: filter to include additional HTML element types via eio_allowed_background_image_elements filter for Lazy Load and Easy IO
- fixed: compatibility between Easy IO and Autoptimize
- fixed: Easy IO uses hard crop when constraining an image via a width/height found in the style attribute
- fixed: Easy IO uses hard-coded wp-content/ and wp-includes/ paths in some cases
- fixed: Easy IO not activating properly when plugin is activated network-wide for multi-site installs
- fixed: database upgrade throws errors on MariaDB 10.4.x
- fixed: WebP .htaccess error in Vary header rule
- fixed: Easy IO doubles part of image URL when there are no thumbnails, but one is requested by a plugin or theme
- fixed: Easy IO minifier breaks Beaver Builder
- fixed: Lazy Load breaks Beaver Builder text editor
- removed: JS defer with Easy IO, use SWIS Performance instead: https://ewww.io/swis/
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 6.0.0 |
Comparing to | |
See all releases |
Code changes from version 5.8.2 to 6.0.0
- aux-optimize.php +37 -8
- bulk.php +25 -12
- changelog.txt +25 -0
- classes/class-eio-alt-webp.php +77 -5
- classes/class-eio-hs-beacon.php +1 -3
- classes/class-eio-lazy-load.php +37 -10
- classes/class-eio-page-parser.php +13 -15
- classes/class-eio-picture-webp.php +33 -0
- classes/class-ewww-flag.php +1 -1
- classes/class-ewww-nextcellent.php +1 -1
- classes/class-ewww-nextgen.php +2 -2
- classes/class-ewwwio-gd-editor.php +14 -99
- classes/class-ewwwio-gmagick-editor.php +1 -1
- classes/class-ewwwio-imagick-editor.php +22 -76
- classes/class-ewwwio-media-background-process.php +1 -1
- classes/class-ewwwio-tracking.php +1 -0
- classes/class-exactdn.php +98 -120
- common.php +2150 -1107
- ewww-image-optimizer.php +1 -25
- includes/eio-beacon.js +64 -0
- includes/eio-bulk.js +445 -0
- includes/eio-settings.js +460 -0
- includes/eio-tools.js +136 -74
- includes/eio.js +0 -725
- includes/flag.js +2 -2
- includes/jquery-ui-1.10.1.custom.css +257 -23
- includes/lazysizes-post.js +11 -3
- includes/lazysizes.js +1 -0
- includes/lazysizes.min.js +1 -1
- includes/load_webp.js +85 -12
- includes/load_webp.min.js +1 -1
- includes/media.js +4 -4
- includes/nextcellent.js +2 -2
- includes/nextgen.js +2 -2
- readme.txt +27 -2
- unique.php +46 -20
aux-optimize.php
CHANGED
@@ -207,8 +207,8 @@ function ewww_image_optimizer_aux_images_table() {
|
|
207 |
$output['table'] .= "<td>$type</td>";
|
208 |
$output['table'] .= "<td>$last_updated</td>";
|
209 |
$output['table'] .= "<td>$savings<br>$size_string<br>" .
|
210 |
-
'<a class="
|
211 |
-
( $optimized_image['backup'] ? '<br><a class="
|
212 |
'</td>';
|
213 |
$output['table'] .= '</tr>';
|
214 |
$alternate = ! $alternate;
|
@@ -259,9 +259,9 @@ function ewww_image_optimizer_aux_images_table() {
|
|
259 |
$webp_info = "<br>WebP: <a href=\"$webpurl\">$webp_size</a>";
|
260 |
}
|
261 |
$output['table'] .= "<td>$savings<br>$size_string<br>" .
|
262 |
-
'<a class="
|
263 |
$webp_info .
|
264 |
-
( $optimized_image['backup'] ? '<br><a class="
|
265 |
'</td>';
|
266 |
$output['table'] .= '</tr>';
|
267 |
$alternate = ! $alternate;
|
@@ -298,7 +298,7 @@ function ewww_image_optimizer_aux_images_table() {
|
|
298 |
$output['table'] .= "<td>$type</td>";
|
299 |
$output['table'] .= "<td>$last_updated</td>";
|
300 |
$output['table'] .= "<td>$savings<br>$size_string<br>" .
|
301 |
-
'<a class="
|
302 |
'</td>';
|
303 |
$output['table'] .= '</tr>';
|
304 |
$alternate = ! $alternate;
|
@@ -649,6 +649,34 @@ function ewww_image_optimizer_delete_webp() {
|
|
649 |
die( wp_json_encode( array( 'completed' => 1 ) ) );
|
650 |
}
|
651 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
652 |
/**
|
653 |
* Cleanup duplicate and unreferenced records from the images table.
|
654 |
*
|
@@ -1135,12 +1163,12 @@ function ewww_image_optimizer_image_scan( $dir, $started = 0 ) {
|
|
1135 |
'ewww_scan' => 'scheduled',
|
1136 |
)
|
1137 |
)->dispatch();
|
1138 |
-
|
1139 |
} elseif ( 'scheduled' === $ewww_scan && get_option( 'ewwwio_stop_scheduled_scan' ) ) {
|
1140 |
ewwwio_debug_message( 'ending current scan iteration because of stop_scan' );
|
1141 |
delete_option( 'ewwwio_stop_scheduled_scan' );
|
1142 |
ewww_image_optimizer_debug_log();
|
1143 |
-
|
1144 |
}
|
1145 |
if ( $ewww_scan && 0 === $file_counter % 100 && ! ewwwio_check_memory_available( 2097000 ) ) {
|
1146 |
ewwwio_debug_message( 'ending current scan iteration because of memory constraints' );
|
@@ -1459,7 +1487,7 @@ function ewww_image_optimizer_aux_images_script( $hook = '' ) {
|
|
1459 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
1460 |
ewww_image_optimizer_debug_log();
|
1461 |
if ( wp_doing_ajax() && 'ewww-image-optimizer-auto' !== $hook && ( ! defined( 'WP_CLI' ) || ! WP_CLI ) ) {
|
1462 |
-
$verify_cloud = ewww_image_optimizer_cloud_verify( false );
|
1463 |
$usage = false;
|
1464 |
if ( preg_match( '/great/', $verify_cloud ) ) {
|
1465 |
$usage = ewww_image_optimizer_cloud_quota( true );
|
@@ -1544,5 +1572,6 @@ add_action( 'wp_ajax_bulk_aux_images_table_clean', 'ewww_image_optimizer_aux_ima
|
|
1544 |
add_action( 'wp_ajax_bulk_aux_images_meta_clean', 'ewww_image_optimizer_aux_meta_clean' );
|
1545 |
add_action( 'wp_ajax_bulk_aux_images_webp_clean', 'ewww_image_optimizer_aux_images_webp_clean' );
|
1546 |
add_action( 'wp_ajax_bulk_aux_images_delete_webp', 'ewww_image_optimizer_delete_webp' );
|
|
|
1547 |
add_action( 'wp_ajax_ewwwio_get_all_attachments', 'ewww_image_optimizer_get_all_attachments' );
|
1548 |
?>
|
207 |
$output['table'] .= "<td>$type</td>";
|
208 |
$output['table'] .= "<td>$last_updated</td>";
|
209 |
$output['table'] .= "<td>$savings<br>$size_string<br>" .
|
210 |
+
'<a class="ewww-remove-image" data-id="' . (int) $optimized_image['id'] . '">' . esc_html__( 'Remove from history', 'ewww-image-optimizer' ) . '</a>' .
|
211 |
+
( $optimized_image['backup'] ? '<br><a class="ewww-restore-image" data-id="' . (int) $optimized_image['id'] . '">' . esc_html__( 'Restore original', 'ewww-image-optimizer' ) . '</a>' : '' ) .
|
212 |
'</td>';
|
213 |
$output['table'] .= '</tr>';
|
214 |
$alternate = ! $alternate;
|
259 |
$webp_info = "<br>WebP: <a href=\"$webpurl\">$webp_size</a>";
|
260 |
}
|
261 |
$output['table'] .= "<td>$savings<br>$size_string<br>" .
|
262 |
+
'<a class="ewww-remove-image" data-id="' . (int) $optimized_image['id'] . '">' . esc_html__( 'Remove from history', 'ewww-image-optimizer' ) . '</a>' .
|
263 |
$webp_info .
|
264 |
+
( $optimized_image['backup'] ? '<br><a class="ewww-restore-image" data-id="' . (int) $optimized_image['id'] . '">' . esc_html__( 'Restore original', 'ewww-image-optimizer' ) . '</a>' : '' ) .
|
265 |
'</td>';
|
266 |
$output['table'] .= '</tr>';
|
267 |
$alternate = ! $alternate;
|
298 |
$output['table'] .= "<td>$type</td>";
|
299 |
$output['table'] .= "<td>$last_updated</td>";
|
300 |
$output['table'] .= "<td>$savings<br>$size_string<br>" .
|
301 |
+
'<a class="ewww-remove-image" data-id="' . (int) $optimized_image['id'] . '">' . esc_html__( 'Remove from history', 'ewww-image-optimizer' ) . '</a>' .
|
302 |
'</td>';
|
303 |
$output['table'] .= '</tr>';
|
304 |
$alternate = ! $alternate;
|
649 |
die( wp_json_encode( array( 'completed' => 1 ) ) );
|
650 |
}
|
651 |
|
652 |
+
/**
|
653 |
+
* Cleans up original_image via AJAX for a particular attachment.
|
654 |
+
*/
|
655 |
+
function ewww_image_optimizer_ajax_delete_original() {
|
656 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
657 |
+
// Verify that an authorized user has called function.
|
658 |
+
$permissions = apply_filters( 'ewww_image_optimizer_admin_permissions', '' );
|
659 |
+
if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['ewww_wpnonce'] ), 'ewww-image-optimizer-tools' ) || ! current_user_can( $permissions ) ) {
|
660 |
+
ewwwio_ob_clean();
|
661 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) ) ) );
|
662 |
+
}
|
663 |
+
if ( empty( $_POST['attachment_id'] ) ) {
|
664 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'Missing attachment ID number.', 'ewww-image-optimizer' ) ) ) );
|
665 |
+
}
|
666 |
+
|
667 |
+
// Because some plugins might have loose filters (looking at you WPML).
|
668 |
+
remove_all_filters( 'wp_delete_file' );
|
669 |
+
|
670 |
+
$id = (int) $_POST['attachment_id'];
|
671 |
+
|
672 |
+
$new_meta = ewwwio_remove_original_image( $id );
|
673 |
+
if ( ewww_image_optimizer_iterable( $new_meta ) ) {
|
674 |
+
wp_update_attachment_metadata( $id, $new_meta );
|
675 |
+
}
|
676 |
+
sleep( 1 );
|
677 |
+
die( wp_json_encode( array( 'completed' => 1 ) ) );
|
678 |
+
}
|
679 |
+
|
680 |
/**
|
681 |
* Cleanup duplicate and unreferenced records from the images table.
|
682 |
*
|
1163 |
'ewww_scan' => 'scheduled',
|
1164 |
)
|
1165 |
)->dispatch();
|
1166 |
+
die();
|
1167 |
} elseif ( 'scheduled' === $ewww_scan && get_option( 'ewwwio_stop_scheduled_scan' ) ) {
|
1168 |
ewwwio_debug_message( 'ending current scan iteration because of stop_scan' );
|
1169 |
delete_option( 'ewwwio_stop_scheduled_scan' );
|
1170 |
ewww_image_optimizer_debug_log();
|
1171 |
+
die();
|
1172 |
}
|
1173 |
if ( $ewww_scan && 0 === $file_counter % 100 && ! ewwwio_check_memory_available( 2097000 ) ) {
|
1174 |
ewwwio_debug_message( 'ending current scan iteration because of memory constraints' );
|
1487 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
1488 |
ewww_image_optimizer_debug_log();
|
1489 |
if ( wp_doing_ajax() && 'ewww-image-optimizer-auto' !== $hook && ( ! defined( 'WP_CLI' ) || ! WP_CLI ) ) {
|
1490 |
+
$verify_cloud = ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ), false );
|
1491 |
$usage = false;
|
1492 |
if ( preg_match( '/great/', $verify_cloud ) ) {
|
1493 |
$usage = ewww_image_optimizer_cloud_quota( true );
|
1572 |
add_action( 'wp_ajax_bulk_aux_images_meta_clean', 'ewww_image_optimizer_aux_meta_clean' );
|
1573 |
add_action( 'wp_ajax_bulk_aux_images_webp_clean', 'ewww_image_optimizer_aux_images_webp_clean' );
|
1574 |
add_action( 'wp_ajax_bulk_aux_images_delete_webp', 'ewww_image_optimizer_delete_webp' );
|
1575 |
+
add_action( 'wp_ajax_bulk_aux_images_delete_original', 'ewww_image_optimizer_ajax_delete_original' );
|
1576 |
add_action( 'wp_ajax_ewwwio_get_all_attachments', 'ewww_image_optimizer_get_all_attachments' );
|
1577 |
?>
|
bulk.php
CHANGED
@@ -90,6 +90,15 @@ function ewww_image_optimizer_display_tools() {
|
|
90 |
"<input type='submit' class='button-secondary action' value='" . esc_attr__( 'Erase Optimization History', 'ewww-image-optimizer' ) . "' />\n" .
|
91 |
"</form>\n</div>\n";
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
echo '<hr class="ewww-tool-divider">';
|
94 |
echo "<div>\n<p id='ewww-clean-converted-info' class='ewww-tool-info'>" .
|
95 |
esc_html__( 'If you have converted images (PNG to JPG and friends) without deleting the originals, you may remove them when ready.', 'ewww-image-optimizer' ) . "<br>\n" .
|
@@ -184,7 +193,7 @@ function ewww_image_optimizer_tool_script( $hook ) {
|
|
184 |
if ( 'tools_page_ewww-image-optimizer-tools' !== $hook ) {
|
185 |
return;
|
186 |
}
|
187 |
-
wp_enqueue_script( '
|
188 |
// Number of images in the ewwwio_table (previously optimized images).
|
189 |
$image_count = ewww_image_optimizer_aux_images_table_count();
|
190 |
// Submit a couple variables for our javascript to work with.
|
@@ -196,7 +205,7 @@ function ewww_image_optimizer_tool_script( $hook ) {
|
|
196 |
global $wpdb;
|
197 |
$attachment_count = $wpdb->get_var( "SELECT count(ID) FROM $wpdb->posts WHERE (post_type = 'attachment' OR post_type = 'ims_image') AND (post_mime_type LIKE '%%image%%' OR post_mime_type LIKE '%%pdf%%') ORDER BY ID DESC" );
|
198 |
wp_localize_script(
|
199 |
-
'
|
200 |
'ewww_vars',
|
201 |
array(
|
202 |
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-tools' ),
|
@@ -216,6 +225,7 @@ function ewww_image_optimizer_tool_script( $hook ) {
|
|
216 |
/* translators: used for Table Cleanup progress bar, like so: batch 32/346 */
|
217 |
'batch' => esc_html__( 'batch', 'ewww-image-optimizer' ),
|
218 |
'erase_warning' => $erase_warning,
|
|
|
219 |
)
|
220 |
);
|
221 |
// Load the stylesheet for the jquery progressbar.
|
@@ -350,7 +360,7 @@ function ewww_image_optimizer_bulk_head_output() {
|
|
350 |
<?php ewww_image_optimizer_bulk_variant_option(); ?>
|
351 |
<?php ewww_image_optimizer_bulk_webp_only(); ?>
|
352 |
<p>
|
353 |
-
<label for="ewww-delay" style="font-weight: bold"><?php esc_html_e( 'Pause between images', 'ewww-image-optimizer' ); ?></label> <input type="text" id="ewww-delay" name="ewww-delay" value="<?php echo (int) $delay; ?>"> <?php esc_html_e( 'in seconds, 0 = disabled', 'ewww-image-
|
354 |
</p>
|
355 |
<div id="ewww-delay-slider"></div>
|
356 |
</form>
|
@@ -703,13 +713,14 @@ function ewww_image_optimizer_bulk_script( $hook ) {
|
|
703 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
704 |
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
705 |
}
|
706 |
-
wp_enqueue_script( '
|
|
|
707 |
// Number of images in the ewwwio_table (previously optimized images).
|
708 |
$image_count = ewww_image_optimizer_aux_images_table_count();
|
709 |
// Submit a couple variables for our javascript to work with.
|
710 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
711 |
wp_localize_script(
|
712 |
-
'
|
713 |
'ewww_vars',
|
714 |
array(
|
715 |
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-bulk' ),
|
@@ -1897,13 +1908,15 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1897 |
}
|
1898 |
list( $file, $msg, $converted, $original ) = ewww_image_optimizer( $image->file, 1, false, false, 'full' === $image->resize );
|
1899 |
// Gotta make sure we don't delete a pending record if the license is exceeded, so the license check goes first.
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
|
|
|
|
1907 |
}
|
1908 |
// Delete a pending record if the optimization failed for whatever reason.
|
1909 |
if ( ! $file && $image->id ) {
|
90 |
"<input type='submit' class='button-secondary action' value='" . esc_attr__( 'Erase Optimization History', 'ewww-image-optimizer' ) . "' />\n" .
|
91 |
"</form>\n</div>\n";
|
92 |
|
93 |
+
echo '<hr class="ewww-tool-divider">';
|
94 |
+
echo "<div>\n<p id='ewww-clean-originals-info' class='ewww-tool-info'>" .
|
95 |
+
esc_html__( 'When WordPress scales down large images, it keeps the original on disk for thumbnail generation. You may delete them to save disk space.', 'ewww-image-optimizer' ) . "</p>\n";
|
96 |
+
echo "<form id='ewww-clean-originals' class='ewww-tool-form' method='post' action=''>\n" .
|
97 |
+
"<input type='submit' class='button-secondary action' value='" . esc_attr__( 'Delete Originals', 'ewww-image-optimizer' ) . "' />\n" .
|
98 |
+
"</form>\n</div>\n";
|
99 |
+
echo "<div id='ewww-clean-originals-progressbar' style='display:none;'></div>";
|
100 |
+
echo "<div id='ewww-clean-originals-progress' style='display:none;'></div>";
|
101 |
+
|
102 |
echo '<hr class="ewww-tool-divider">';
|
103 |
echo "<div>\n<p id='ewww-clean-converted-info' class='ewww-tool-info'>" .
|
104 |
esc_html__( 'If you have converted images (PNG to JPG and friends) without deleting the originals, you may remove them when ready.', 'ewww-image-optimizer' ) . "<br>\n" .
|
193 |
if ( 'tools_page_ewww-image-optimizer-tools' !== $hook ) {
|
194 |
return;
|
195 |
}
|
196 |
+
wp_enqueue_script( 'ewww-tool-script', plugins_url( '/includes/eio-tools.js', __FILE__ ), array( 'jquery', 'jquery-ui-progressbar' ), EWWW_IMAGE_OPTIMIZER_VERSION, true );
|
197 |
// Number of images in the ewwwio_table (previously optimized images).
|
198 |
$image_count = ewww_image_optimizer_aux_images_table_count();
|
199 |
// Submit a couple variables for our javascript to work with.
|
205 |
global $wpdb;
|
206 |
$attachment_count = $wpdb->get_var( "SELECT count(ID) FROM $wpdb->posts WHERE (post_type = 'attachment' OR post_type = 'ims_image') AND (post_mime_type LIKE '%%image%%' OR post_mime_type LIKE '%%pdf%%') ORDER BY ID DESC" );
|
207 |
wp_localize_script(
|
208 |
+
'ewww-tool-script',
|
209 |
'ewww_vars',
|
210 |
array(
|
211 |
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-tools' ),
|
225 |
/* translators: used for Table Cleanup progress bar, like so: batch 32/346 */
|
226 |
'batch' => esc_html__( 'batch', 'ewww-image-optimizer' ),
|
227 |
'erase_warning' => $erase_warning,
|
228 |
+
'tool_warning' => esc_html__( 'Please be sure to backup your site before proceeding. Do you wish to continue?', 'ewww-image-optimizer' ),
|
229 |
)
|
230 |
);
|
231 |
// Load the stylesheet for the jquery progressbar.
|
360 |
<?php ewww_image_optimizer_bulk_variant_option(); ?>
|
361 |
<?php ewww_image_optimizer_bulk_webp_only(); ?>
|
362 |
<p>
|
363 |
+
<label for="ewww-delay" style="font-weight: bold"><?php esc_html_e( 'Pause between images', 'ewww-image-optimizer' ); ?></label> <input type="text" id="ewww-delay" name="ewww-delay" value="<?php echo (int) $delay; ?>"> <?php esc_html_e( 'in seconds, 0 = disabled', 'ewww-image-optimizer' ); ?>
|
364 |
</p>
|
365 |
<div id="ewww-delay-slider"></div>
|
366 |
</form>
|
713 |
update_option( 'ewww_image_optimizer_bulk_resume', '' );
|
714 |
update_option( 'ewww_image_optimizer_aux_resume', '' );
|
715 |
}
|
716 |
+
wp_enqueue_script( 'ewww-beacon-script', plugins_url( '/includes/eio-beacon.js', __FILE__ ), array( 'jquery' ), EWWW_IMAGE_OPTIMIZER_VERSION );
|
717 |
+
wp_enqueue_script( 'ewww-bulk-script', plugins_url( '/includes/eio-bulk.js', __FILE__ ), array( 'jquery', 'jquery-ui-slider', 'jquery-ui-progressbar', 'postbox', 'dashboard' ), EWWW_IMAGE_OPTIMIZER_VERSION );
|
718 |
// Number of images in the ewwwio_table (previously optimized images).
|
719 |
$image_count = ewww_image_optimizer_aux_images_table_count();
|
720 |
// Submit a couple variables for our javascript to work with.
|
721 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
722 |
wp_localize_script(
|
723 |
+
'ewww-bulk-script',
|
724 |
'ewww_vars',
|
725 |
array(
|
726 |
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-bulk' ),
|
1908 |
}
|
1909 |
list( $file, $msg, $converted, $original ) = ewww_image_optimizer( $image->file, 1, false, false, 'full' === $image->resize );
|
1910 |
// Gotta make sure we don't delete a pending record if the license is exceeded, so the license check goes first.
|
1911 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
1912 |
+
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
1913 |
+
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
1914 |
+
$output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
|
1915 |
+
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1916 |
+
delete_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1917 |
+
ewwwio_ob_clean();
|
1918 |
+
die( wp_json_encode( $output ) );
|
1919 |
+
}
|
1920 |
}
|
1921 |
// Delete a pending record if the optimization failed for whatever reason.
|
1922 |
if ( ! $file && $image->id ) {
|
changelog.txt
CHANGED
@@ -1,3 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 5.8.2 =
|
2 |
* security: improper nonce verification for Nextgen bulk optimizer initialization (minor severity)
|
3 |
* changed: Easy IO verification performed via API for better reliability
|
1 |
+
= 6.0.0 =
|
2 |
+
* added: tool to delete originals from WP 5.3+ auto-scaling behavior (Tools menu)
|
3 |
+
* added: JS WebP recognizes video elements added via JS (e.g. infinite scroll)
|
4 |
+
* added: automatically convert GIF to PNG during new uploads, unless animated
|
5 |
+
* added: JS WebP and picture WebP auto-detect configuration for S3 Uploads and WP Stateless
|
6 |
+
* added: Lazy Load for external CSS and separate style blocks (div elements only for now)
|
7 |
+
* added: Easy IO/CDN rewriting for Ultimate Member AJAX-powered activity wall
|
8 |
+
* changed: settings UI revamped with wizard for first-time installs
|
9 |
+
* changed: automatic PNG to JPG threshold lowered to 250kb
|
10 |
+
* changed: extensions for WP_Image_Editor now disabled by default, use EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR constant to enable them
|
11 |
+
* changed: JS WebP can be used with picture WebP + Lazy Load to support CSS background images
|
12 |
+
* changed: better compatibility with Theia Smart Thumbnails
|
13 |
+
* changed: Lazy Load auto-sizing will no longer decrease the image size, only increasing is allowed
|
14 |
+
* changed: filter to include additional HTML element types via eio_allowed_background_image_elements filter for Lazy Load and Easy IO
|
15 |
+
* fixed: compatibility between Easy IO and Autoptimize
|
16 |
+
* fixed: Easy IO uses hard crop when constraining an image via a width/height found in the style attribute
|
17 |
+
* fixed: Easy IO uses hard-coded wp-content/ and wp-includes/ paths in some cases
|
18 |
+
* fixed: Easy IO not activating properly when plugin is activated network-wide for multi-site installs
|
19 |
+
* fixed: database upgrade throws errors on MariaDB 10.4.x
|
20 |
+
* fixed: WebP .htaccess error in Vary header rule
|
21 |
+
* fixed: Easy IO doubles part of image URL when there are no thumbnails, but one is requested by a plugin or theme
|
22 |
+
* fixed: Easy IO minifier breaks Beaver Builder
|
23 |
+
* fixed: Lazy Load breaks Beaver Builder text editor
|
24 |
+
* removed: JS defer with Easy IO, use SWIS Performance instead: https://ewww.io/swis/
|
25 |
+
|
26 |
= 5.8.2 =
|
27 |
* security: improper nonce verification for Nextgen bulk optimizer initialization (minor severity)
|
28 |
* changed: Easy IO verification performed via API for better reliability
|
classes/class-eio-alt-webp.php
CHANGED
@@ -78,8 +78,10 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
|
|
78 |
// Start an output buffer before any output starts.
|
79 |
/* add_action( 'template_redirect', array( $this, 'buffer_start' ), 0 ); */
|
80 |
add_filter( 'ewww_image_optimizer_filter_page_output', array( $this, 'filter_page_output' ), 20 );
|
81 |
-
// Filter for NextGEN image urls within
|
82 |
add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ), 11 );
|
|
|
|
|
83 |
|
84 |
// Load up the minified script so we can inline it.
|
85 |
$this->inline_script = file_get_contents( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'includes/load_webp.min.js' );
|
@@ -131,9 +133,33 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
|
|
131 |
}
|
132 |
}
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
if ( function_exists( 'swis' ) && swis()->settings->get_option( 'cdn_domain' ) ) {
|
135 |
$this->webp_paths[] = swis()->settings->get_option( 'cdn_domain' );
|
136 |
}
|
|
|
137 |
foreach ( $this->webp_paths as $webp_path ) {
|
138 |
$webp_domain = $this->parse_url( $webp_path, PHP_URL_HOST );
|
139 |
if ( $webp_domain ) {
|
@@ -164,6 +190,14 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
|
|
164 |
$this->validate_user_exclusions();
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
/**
|
169 |
* Starts an output buffer and registers the callback function to do WebP replacement.
|
@@ -821,8 +855,8 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
|
|
821 |
* @return array The array of images with WebP versions added.
|
822 |
*/
|
823 |
function ngg_pro_lightbox_images_queue( $images ) {
|
824 |
-
|
825 |
-
if (
|
826 |
foreach ( $images as $index => $image ) {
|
827 |
if ( ! empty( $image['image'] ) && $this->validate_image_url( $image['image'] ) ) {
|
828 |
$images[ $index ]['image-webp'] = $this->generate_url( $image['image'] );
|
@@ -833,14 +867,14 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
|
|
833 |
if ( ! empty( $image['full_image'] ) && $this->validate_image_url( $image['full_image'] ) ) {
|
834 |
$images[ $index ]['full_image_webp'] = $this->generate_url( $image['full_image'] );
|
835 |
}
|
836 |
-
if (
|
837 |
foreach ( $image['srcsets'] as $size => $srcset ) {
|
838 |
if ( $this->validate_image_url( $srcset ) ) {
|
839 |
$images[ $index ]['srcsets'][ $size . '-webp' ] = $this->generate_url( $srcset );
|
840 |
}
|
841 |
}
|
842 |
}
|
843 |
-
if (
|
844 |
foreach ( $image['full_srcsets'] as $size => $srcset ) {
|
845 |
if ( $this->validate_image_url( $srcset ) ) {
|
846 |
$images[ $index ]['full_srcsets'][ $size . '-webp' ] = $this->generate_url( $srcset );
|
@@ -852,6 +886,44 @@ class EIO_Alt_Webp extends EIO_Page_Parser {
|
|
852 |
return $images;
|
853 |
}
|
854 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
/**
|
856 |
* Attempts to reverse a CDN URL to a local path to test for file existence.
|
857 |
*
|
78 |
// Start an output buffer before any output starts.
|
79 |
/* add_action( 'template_redirect', array( $this, 'buffer_start' ), 0 ); */
|
80 |
add_filter( 'ewww_image_optimizer_filter_page_output', array( $this, 'filter_page_output' ), 20 );
|
81 |
+
// Filter for NextGEN image urls within JSON.
|
82 |
add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ), 11 );
|
83 |
+
// Filter for WooCommerce product variations JSON.
|
84 |
+
add_filter( 'woocommerce_pre_json_available_variations', array( $this, 'woocommerce_pre_json_available_variations' ) );
|
85 |
|
86 |
// Load up the minified script so we can inline it.
|
87 |
$this->inline_script = file_get_contents( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'includes/load_webp.min.js' );
|
133 |
}
|
134 |
}
|
135 |
|
136 |
+
if (
|
137 |
+
class_exists( 'S3_Uploads' ) &&
|
138 |
+
function_exists( 's3_uploads_enabled' ) && s3_uploads_enabled() &&
|
139 |
+
method_exists( 'S3_Uploads', 'get_instance' ) && method_exists( 'S3_Uploads', 'get_s3_url' )
|
140 |
+
) {
|
141 |
+
$s3_uploads_instance = \S3_Uploads::get_instance();
|
142 |
+
$s3_uploads_url = $s3_uploads_instance->get_s3_url();
|
143 |
+
$this->webp_paths[] = $s3_uploads_url;
|
144 |
+
$this->debug_message( "found S3 URL from S3_Uploads: $s3_uploads_url" );
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( class_exists( 'wpCloud\StatelessMedia\EWWW' ) && function_exists( 'ud_get_stateless_media' ) ) {
|
148 |
+
$sm = ud_get_stateless_media();
|
149 |
+
if ( method_exists( $sm, 'get' ) && method_exists( $sm, 'get_gs_host' ) ) {
|
150 |
+
$sm_mode = $sm->get( 'sm.mode' );
|
151 |
+
if ( 'disabled' !== $sm_mode ) {
|
152 |
+
$sm_host = $sm->get_gs_host();
|
153 |
+
$this->debug_message( $sm_host );
|
154 |
+
$this->webp_paths[] = $sm_host;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
if ( function_exists( 'swis' ) && swis()->settings->get_option( 'cdn_domain' ) ) {
|
160 |
$this->webp_paths[] = swis()->settings->get_option( 'cdn_domain' );
|
161 |
}
|
162 |
+
|
163 |
foreach ( $this->webp_paths as $webp_path ) {
|
164 |
$webp_domain = $this->parse_url( $webp_path, PHP_URL_HOST );
|
165 |
if ( $webp_domain ) {
|
190 |
$this->validate_user_exclusions();
|
191 |
}
|
192 |
|
193 |
+
/**
|
194 |
+
* Grant read-only access to allowed WebP domains.
|
195 |
+
*
|
196 |
+
* @return array A list of WebP domains.
|
197 |
+
*/
|
198 |
+
function get_webp_domains() {
|
199 |
+
return $this->webp_domains;
|
200 |
+
}
|
201 |
|
202 |
/**
|
203 |
* Starts an output buffer and registers the callback function to do WebP replacement.
|
855 |
* @return array The array of images with WebP versions added.
|
856 |
*/
|
857 |
function ngg_pro_lightbox_images_queue( $images ) {
|
858 |
+
$this->debug_message( '<b>' . __METHOD__ . '()</b>' );
|
859 |
+
if ( $this->is_iterable( $images ) ) {
|
860 |
foreach ( $images as $index => $image ) {
|
861 |
if ( ! empty( $image['image'] ) && $this->validate_image_url( $image['image'] ) ) {
|
862 |
$images[ $index ]['image-webp'] = $this->generate_url( $image['image'] );
|
867 |
if ( ! empty( $image['full_image'] ) && $this->validate_image_url( $image['full_image'] ) ) {
|
868 |
$images[ $index ]['full_image_webp'] = $this->generate_url( $image['full_image'] );
|
869 |
}
|
870 |
+
if ( $this->is_iterable( $image['srcsets'] ) ) {
|
871 |
foreach ( $image['srcsets'] as $size => $srcset ) {
|
872 |
if ( $this->validate_image_url( $srcset ) ) {
|
873 |
$images[ $index ]['srcsets'][ $size . '-webp' ] = $this->generate_url( $srcset );
|
874 |
}
|
875 |
}
|
876 |
}
|
877 |
+
if ( $this->is_iterable( $image['full_srcsets'] ) ) {
|
878 |
foreach ( $image['full_srcsets'] as $size => $srcset ) {
|
879 |
if ( $this->validate_image_url( $srcset ) ) {
|
880 |
$images[ $index ]['full_srcsets'][ $size . '-webp' ] = $this->generate_url( $srcset );
|
886 |
return $images;
|
887 |
}
|
888 |
|
889 |
+
/**
|
890 |
+
* Adds WebP URLs to the product variations data before it is JSON-encoded.
|
891 |
+
*
|
892 |
+
* @param array $variations The product variations with all the associated data.
|
893 |
+
* @return array The product variations with WebP image URLs added.
|
894 |
+
*/
|
895 |
+
function woocommerce_pre_json_available_variations( $variations ) {
|
896 |
+
$this->debug_message( '<b>' . __METHOD__ . '()</b>' );
|
897 |
+
if ( $this->is_iterable( $variations ) ) {
|
898 |
+
foreach ( $variations as $index => $variation ) {
|
899 |
+
if ( $this->is_iterable( $variation['image'] ) ) {
|
900 |
+
if ( ! empty( $variation['image']['src'] ) && $this->validate_image_url( $variation['image']['src'] ) ) {
|
901 |
+
$variations[ $index ]['image']['src_webp'] = $this->generate_url( $variation['image']['src'] );
|
902 |
+
}
|
903 |
+
if ( ! empty( $variation['image']['full_src'] ) && $this->validate_image_url( $variation['image']['full_src'] ) ) {
|
904 |
+
$variations[ $index ]['image']['full_src_webp'] = $this->generate_url( $variation['image']['full_src'] );
|
905 |
+
}
|
906 |
+
if ( ! empty( $variation['image']['gallery_thumbnail_src'] ) && $this->validate_image_url( $variation['image']['gallery_thumbnail_src'] ) ) {
|
907 |
+
$variations[ $index ]['image']['gallery_thumbnail_src_webp'] = $this->generate_url( $variation['image']['gallery_thumbnail_src'] );
|
908 |
+
}
|
909 |
+
if ( ! empty( $variation['image']['thumb_src'] ) && $this->validate_image_url( $variation['image']['thumb_src'] ) ) {
|
910 |
+
$variations[ $index ]['image']['thumb_src_webp'] = $this->generate_url( $variation['image']['thumb_src'] );
|
911 |
+
}
|
912 |
+
if ( ! empty( $variation['image']['srcset'] ) ) {
|
913 |
+
$webp_srcset = $this->srcset_replace( $variation['image']['srcset'] );
|
914 |
+
if ( $webp_srcset ) {
|
915 |
+
$variations[ $index ]['image']['srcset_webp'] = $webp_srcset;
|
916 |
+
}
|
917 |
+
}
|
918 |
+
}
|
919 |
+
}
|
920 |
+
if ( $this->function_exists( 'print_r' ) ) {
|
921 |
+
$this->debug_message( print_r( $variations, true ) );
|
922 |
+
}
|
923 |
+
}
|
924 |
+
return $variations;
|
925 |
+
}
|
926 |
+
|
927 |
/**
|
928 |
* Attempts to reverse a CDN URL to a local path to test for file existence.
|
929 |
*
|
classes/class-eio-hs-beacon.php
CHANGED
@@ -89,9 +89,7 @@ if ( ! class_exists( 'EIO_HS_Beacon' ) ) {
|
|
89 |
) {
|
90 |
return;
|
91 |
}
|
92 |
-
if ( strpos( __FILE__, 'plugins/
|
93 |
-
ewww_image_optimizer_notice_beacon();
|
94 |
-
} elseif ( strpos( __FILE__, 'plugins/easy' ) ) {
|
95 |
easyio_notice_beacon();
|
96 |
}
|
97 |
}
|
89 |
) {
|
90 |
return;
|
91 |
}
|
92 |
+
if ( strpos( __FILE__, 'plugins/easy' ) ) {
|
|
|
|
|
93 |
easyio_notice_beacon();
|
94 |
}
|
95 |
}
|
classes/class-eio-lazy-load.php
CHANGED
@@ -173,6 +173,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
173 |
'/print/' === substr( $uri, -7 ) ||
|
174 |
strpos( $uri, 'elementor-preview=' ) !== false ||
|
175 |
strpos( $uri, 'et_fb=' ) !== false ||
|
|
|
176 |
strpos( $uri, 'tatsu=' ) !== false ||
|
177 |
( ! empty( $_POST['action'] ) && 'tatsu_get_concepts' === sanitize_text_field( wp_unslash( $_POST['action'] ) ) ) || // phpcs:ignore WordPress.Security.NonceVerification
|
178 |
! apply_filters( 'eio_do_lazyload', true ) ||
|
@@ -207,6 +208,9 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
207 |
if ( strpos( $uri, 'et_fb=' ) !== false ) {
|
208 |
$this->debug_message( 'et_fb' );
|
209 |
}
|
|
|
|
|
|
|
210 |
if ( strpos( $uri, 'tatsu=' ) !== false || ( ! empty( $_POST['action'] ) && 'tatsu_get_concepts' === $_POST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
211 |
$this->debug_message( 'tatsu' );
|
212 |
}
|
@@ -268,16 +272,11 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
268 |
}
|
269 |
} // End foreach().
|
270 |
} // End if().
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
$buffer = $this->parse_background_images( $buffer, 'span' );
|
277 |
-
// Process background images on section elements.
|
278 |
-
$buffer = $this->parse_background_images( $buffer, 'section' );
|
279 |
-
// Process background images on a/link elements.
|
280 |
-
$buffer = $this->parse_background_images( $buffer, 'a' );
|
281 |
if ( in_array( 'picture', $this->user_element_exclusions, true ) ) {
|
282 |
$pictures = '';
|
283 |
} else {
|
@@ -503,6 +502,13 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
503 |
foreach ( $elements as $index => $element ) {
|
504 |
$this->debug_message( "parsing a $tag_type" );
|
505 |
if ( false === strpos( $element, 'background:' ) && false === strpos( $element, 'background-image:' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
continue;
|
507 |
}
|
508 |
$this->debug_message( 'element contains background/background-image:' );
|
@@ -535,6 +541,26 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
535 |
return $buffer;
|
536 |
}
|
537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
/**
|
539 |
* Validate the user-defined exclusions.
|
540 |
*/
|
@@ -794,6 +820,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
794 |
*/
|
795 |
function no_js_css() {
|
796 |
echo '<noscript><style>.lazyload[data-src]{display:none !important;}</style></noscript>';
|
|
|
797 |
}
|
798 |
|
799 |
/**
|
173 |
'/print/' === substr( $uri, -7 ) ||
|
174 |
strpos( $uri, 'elementor-preview=' ) !== false ||
|
175 |
strpos( $uri, 'et_fb=' ) !== false ||
|
176 |
+
strpos( $uri, '?fl_builder' ) !== false ||
|
177 |
strpos( $uri, 'tatsu=' ) !== false ||
|
178 |
( ! empty( $_POST['action'] ) && 'tatsu_get_concepts' === sanitize_text_field( wp_unslash( $_POST['action'] ) ) ) || // phpcs:ignore WordPress.Security.NonceVerification
|
179 |
! apply_filters( 'eio_do_lazyload', true ) ||
|
208 |
if ( strpos( $uri, 'et_fb=' ) !== false ) {
|
209 |
$this->debug_message( 'et_fb' );
|
210 |
}
|
211 |
+
if ( strpos( $uri, '?fl_builder' ) !== false ) {
|
212 |
+
$this->debug_message( 'beaver builder' );
|
213 |
+
}
|
214 |
if ( strpos( $uri, 'tatsu=' ) !== false || ( ! empty( $_POST['action'] ) && 'tatsu_get_concepts' === $_POST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
215 |
$this->debug_message( 'tatsu' );
|
216 |
}
|
272 |
}
|
273 |
} // End foreach().
|
274 |
} // End if().
|
275 |
+
$element_types = apply_filters( 'eio_allowed_background_image_elements', array( 'div', 'li', 'span', 'section', 'a' ) );
|
276 |
+
foreach ( $element_types as $element_type ) {
|
277 |
+
// Process background images on HTML elements.
|
278 |
+
$buffer = $this->parse_background_images( $buffer, $element_type );
|
279 |
+
}
|
|
|
|
|
|
|
|
|
|
|
280 |
if ( in_array( 'picture', $this->user_element_exclusions, true ) ) {
|
281 |
$pictures = '';
|
282 |
} else {
|
502 |
foreach ( $elements as $index => $element ) {
|
503 |
$this->debug_message( "parsing a $tag_type" );
|
504 |
if ( false === strpos( $element, 'background:' ) && false === strpos( $element, 'background-image:' ) ) {
|
505 |
+
if ( 'div' === $tag_type ) {
|
506 |
+
$element = $this->lazify_element( $element );
|
507 |
+
}
|
508 |
+
if ( $element !== $elements[ $index ] ) {
|
509 |
+
$this->debug_message( "$tag_type lazified, replacing in html source" );
|
510 |
+
$buffer = str_replace( $elements[ $index ], $element, $buffer );
|
511 |
+
}
|
512 |
continue;
|
513 |
}
|
514 |
$this->debug_message( 'element contains background/background-image:' );
|
541 |
return $buffer;
|
542 |
}
|
543 |
|
544 |
+
/**
|
545 |
+
* Add lazyload class to any element that doesn't have a direct-attached background image.
|
546 |
+
*
|
547 |
+
* @param string $element The HTML element/tag to parse.
|
548 |
+
* @return string The (maybe) modified element.
|
549 |
+
*/
|
550 |
+
function lazify_element( $element ) {
|
551 |
+
if ( defined( 'EIO_EXTERNAL_CSS_LAZY_LOAD' ) && ! EIO_EXTERNAL_CSS_LAZY_LOAD ) {
|
552 |
+
return $element;
|
553 |
+
}
|
554 |
+
if ( false === strpos( $element, 'background:' ) && false === strpos( $element, 'background-image:' ) && false === strpos( $element, 'style=' ) ) {
|
555 |
+
if ( false !== strpos( $element, 'id=' ) || false !== strpos( $element, 'class=' ) ) {
|
556 |
+
if ( $this->validate_bgimage_tag( $element ) ) {
|
557 |
+
$this->set_attribute( $element, 'class', $this->get_attribute( $element, 'class' ) . ' lazyload', true );
|
558 |
+
}
|
559 |
+
}
|
560 |
+
}
|
561 |
+
return $element;
|
562 |
+
}
|
563 |
+
|
564 |
/**
|
565 |
* Validate the user-defined exclusions.
|
566 |
*/
|
820 |
*/
|
821 |
function no_js_css() {
|
822 |
echo '<noscript><style>.lazyload[data-src]{display:none !important;}</style></noscript>';
|
823 |
+
echo '<style>.lazyload{background-image:none !important;}</style>';
|
824 |
}
|
825 |
|
826 |
/**
|
classes/class-eio-page-parser.php
CHANGED
@@ -226,20 +226,19 @@ if ( ! class_exists( 'EIO_Page_Parser' ) ) {
|
|
226 |
* @param string $img The full image element.
|
227 |
* @return string The width found or an empty string.
|
228 |
*/
|
229 |
-
public function
|
230 |
-
|
231 |
-
// Then check for an inline max-width directive.
|
232 |
$style = $this->get_attribute( $img, 'style' );
|
233 |
if ( $style && preg_match( '#max-width:\s?(\d+)px#', $style, $max_width_string ) ) {
|
234 |
-
if ( $max_width_string[1] && (
|
235 |
-
|
236 |
}
|
237 |
} elseif ( $style && preg_match( '#width:\s?(\d+)px#', $style, $width_string ) ) {
|
238 |
-
if ( $width_string[1] && (
|
239 |
-
|
240 |
}
|
241 |
}
|
242 |
-
return
|
243 |
}
|
244 |
|
245 |
/**
|
@@ -248,20 +247,19 @@ if ( ! class_exists( 'EIO_Page_Parser' ) ) {
|
|
248 |
* @param string $img The full image element.
|
249 |
* @return string The height found or an empty string.
|
250 |
*/
|
251 |
-
public function
|
252 |
-
$height = $this->get_attribute( $img, 'height' );
|
253 |
// Then check for an inline max-height directive.
|
254 |
$style = $this->get_attribute( $img, 'style' );
|
255 |
if ( $style && preg_match( '#max-height:\s?(\d+)px#', $style, $max_height_string ) ) {
|
256 |
-
if ( $max_height_string[1] && (
|
257 |
-
|
258 |
}
|
259 |
} elseif ( $style && preg_match( '#height:\s?(\d+)px#', $style, $height_string ) ) {
|
260 |
-
if ( $height_string[1] && (
|
261 |
-
|
262 |
}
|
263 |
}
|
264 |
-
return
|
265 |
}
|
266 |
|
267 |
/**
|
226 |
* @param string $img The full image element.
|
227 |
* @return string The width found or an empty string.
|
228 |
*/
|
229 |
+
public function get_img_style_width( $img ) {
|
230 |
+
// Check for an inline max-width directive.
|
|
|
231 |
$style = $this->get_attribute( $img, 'style' );
|
232 |
if ( $style && preg_match( '#max-width:\s?(\d+)px#', $style, $max_width_string ) ) {
|
233 |
+
if ( $max_width_string[1] && is_numeric( $max_width_string ) ) {
|
234 |
+
return (int) $max_width_string[1];
|
235 |
}
|
236 |
} elseif ( $style && preg_match( '#width:\s?(\d+)px#', $style, $width_string ) ) {
|
237 |
+
if ( $width_string[1] && is_numeric( $width_string[1] ) ) {
|
238 |
+
return (int) $width_string[1];
|
239 |
}
|
240 |
}
|
241 |
+
return false;
|
242 |
}
|
243 |
|
244 |
/**
|
247 |
* @param string $img The full image element.
|
248 |
* @return string The height found or an empty string.
|
249 |
*/
|
250 |
+
public function get_img_style_height( $img ) {
|
|
|
251 |
// Then check for an inline max-height directive.
|
252 |
$style = $this->get_attribute( $img, 'style' );
|
253 |
if ( $style && preg_match( '#max-height:\s?(\d+)px#', $style, $max_height_string ) ) {
|
254 |
+
if ( $max_height_string[1] && is_numeric( $max_height_string[1] ) ) {
|
255 |
+
return (int) $max_height_string[1];
|
256 |
}
|
257 |
} elseif ( $style && preg_match( '#height:\s?(\d+)px#', $style, $height_string ) ) {
|
258 |
+
if ( $height_string[1] && is_numeric( $height_string[1] ) ) {
|
259 |
+
return (int) $height_string[1];
|
260 |
}
|
261 |
}
|
262 |
+
return false;
|
263 |
}
|
264 |
|
265 |
/**
|
classes/class-eio-picture-webp.php
CHANGED
@@ -119,9 +119,33 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
|
|
119 |
}
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
if ( function_exists( 'swis' ) && swis()->settings->get_option( 'cdn_domain' ) ) {
|
123 |
$this->webp_paths[] = swis()->settings->get_option( 'cdn_domain' );
|
124 |
}
|
|
|
125 |
foreach ( $this->webp_paths as $webp_path ) {
|
126 |
$webp_domain = $this->parse_url( $webp_path, PHP_URL_HOST );
|
127 |
if ( $webp_domain ) {
|
@@ -133,6 +157,15 @@ class EIO_Picture_Webp extends EIO_Page_Parser {
|
|
133 |
$this->validate_user_exclusions();
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
/**
|
137 |
* Replaces images within a srcset attribute with their .webp derivatives.
|
138 |
*
|
119 |
}
|
120 |
}
|
121 |
|
122 |
+
if (
|
123 |
+
class_exists( 'S3_Uploads' ) &&
|
124 |
+
function_exists( 's3_uploads_enabled' ) && s3_uploads_enabled() &&
|
125 |
+
method_exists( 'S3_Uploads', 'get_instance' ) && method_exists( 'S3_Uploads', 'get_s3_url' )
|
126 |
+
) {
|
127 |
+
$s3_uploads_instance = \S3_Uploads::get_instance();
|
128 |
+
$s3_uploads_url = $s3_uploads_instance->get_s3_url();
|
129 |
+
$this->webp_paths[] = $s3_uploads_url;
|
130 |
+
$this->debug_message( "found S3 URL from S3_Uploads: $s3_uploads_url" );
|
131 |
+
}
|
132 |
+
|
133 |
+
if ( class_exists( 'wpCloud\StatelessMedia\EWWW' ) && function_exists( 'ud_get_stateless_media' ) ) {
|
134 |
+
$sm = ud_get_stateless_media();
|
135 |
+
if ( method_exists( $sm, 'get' ) && method_exists( $sm, 'get_gs_host' ) ) {
|
136 |
+
$sm_mode = $sm->get( 'sm.mode' );
|
137 |
+
if ( 'disabled' !== $sm_mode ) {
|
138 |
+
$sm_host = $sm->get_gs_host();
|
139 |
+
$this->debug_message( $sm_host );
|
140 |
+
$this->webp_paths[] = $sm_host;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
if ( function_exists( 'swis' ) && swis()->settings->get_option( 'cdn_domain' ) ) {
|
146 |
$this->webp_paths[] = swis()->settings->get_option( 'cdn_domain' );
|
147 |
}
|
148 |
+
|
149 |
foreach ( $this->webp_paths as $webp_path ) {
|
150 |
$webp_domain = $this->parse_url( $webp_path, PHP_URL_HOST );
|
151 |
if ( $webp_domain ) {
|
157 |
$this->validate_user_exclusions();
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* Grant read-only access to allowed WebP domains.
|
162 |
+
*
|
163 |
+
* @return array A list of WebP domains.
|
164 |
+
*/
|
165 |
+
function get_webp_domains() {
|
166 |
+
return $this->webp_domains;
|
167 |
+
}
|
168 |
+
|
169 |
/**
|
170 |
* Replaces images within a srcset attribute with their .webp derivatives.
|
171 |
*
|
classes/class-ewww-flag.php
CHANGED
@@ -111,7 +111,7 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
|
|
111 |
<div class="wrap"><h1>GRAND FlAGallery <?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
112 |
<?php
|
113 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
114 |
-
ewww_image_optimizer_cloud_verify();
|
115 |
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' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
116 |
}
|
117 |
echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Bulk Optimization will alter your original images and cannot be undone. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
|
111 |
<div class="wrap"><h1>GRAND FlAGallery <?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
112 |
<?php
|
113 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
114 |
+
ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) );
|
115 |
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' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
116 |
}
|
117 |
echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Bulk Optimization will alter your original images and cannot be undone. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
|
classes/class-ewww-nextcellent.php
CHANGED
@@ -406,7 +406,7 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
406 |
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
407 |
<?php
|
408 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
409 |
-
ewww_image_optimizer_cloud_verify();
|
410 |
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' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
411 |
}
|
412 |
// Retrieve the value of the 'bulk resume' option and set the button text for the form to use.
|
406 |
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
407 |
<?php
|
408 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
409 |
+
ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) );
|
410 |
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' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
411 |
}
|
412 |
// Retrieve the value of the 'bulk resume' option and set the button text for the form to use.
|
classes/class-ewww-nextgen.php
CHANGED
@@ -642,7 +642,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
642 |
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
643 |
<?php
|
644 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
645 |
-
ewww_image_optimizer_cloud_verify();
|
646 |
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' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
647 |
}
|
648 |
echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Bulk Optimization will alter your original images and cannot be undone. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
|
@@ -692,7 +692,7 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
692 |
<a href="tools.php?page=ewww-image-optimizer-tools"><?php esc_html_e( 'View optimization history.', 'ewww-image-optimizer' ); ?></a>
|
693 |
</p>
|
694 |
<p>
|
695 |
-
<label for="ewww-delay" style="font-weight: bold"><?php esc_html_e( 'Pause between images', 'ewww-image-optimizer' ); ?></label> <input type="text" id="ewww-delay" name="ewww-delay" value="<?php echo (int) $delay; ?>"> <?php esc_html_e( 'in seconds, 0 = disabled', 'ewww-image-
|
696 |
</p>
|
697 |
<div id="ewww-delay-slider"></div>
|
698 |
</form>
|
642 |
<h1><?php esc_html_e( 'Bulk Optimize', 'ewww-image-optimizer' ); ?></h1>
|
643 |
<?php
|
644 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
645 |
+
ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) );
|
646 |
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' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
647 |
}
|
648 |
echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Bulk Optimization will alter your original images and cannot be undone. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
|
692 |
<a href="tools.php?page=ewww-image-optimizer-tools"><?php esc_html_e( 'View optimization history.', 'ewww-image-optimizer' ); ?></a>
|
693 |
</p>
|
694 |
<p>
|
695 |
+
<label for="ewww-delay" style="font-weight: bold"><?php esc_html_e( 'Pause between images', 'ewww-image-optimizer' ); ?></label> <input type="text" id="ewww-delay" name="ewww-delay" value="<?php echo (int) $delay; ?>"> <?php esc_html_e( 'in seconds, 0 = disabled', 'ewww-image-optimizer' ); ?>
|
696 |
</p>
|
697 |
<div id="ewww-delay-slider"></div>
|
698 |
</form>
|
classes/class-ewwwio-gd-editor.php
CHANGED
@@ -10,97 +10,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
10 |
exit;
|
11 |
}
|
12 |
if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
13 |
-
|
14 |
-
* Extension of the WP_Image_Editor_GD class to auto-compress edited images.
|
15 |
-
*
|
16 |
-
* @see WP_Image_Editor_GD
|
17 |
-
*/
|
18 |
-
class EWWWIO_GD_Editor extends Bbpp_Animated_Gif {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Saves a file from the image editor.
|
22 |
-
*
|
23 |
-
* @param resource $image A GD image object.
|
24 |
-
* @param string $filename Optional. The name of the file to be saved to.
|
25 |
-
* @param string $mime_type Optional. The mimetype of the file.
|
26 |
-
* @return WP_Error| array The full path, base filename, width, height, and mimetype.
|
27 |
-
*/
|
28 |
-
protected function _save( $image, $filename = null, $mime_type = null ) {
|
29 |
-
ewwwio_debug_message( '<b>(agr)' . __METHOD__ . '()</b>' );
|
30 |
-
global $ewww_defer;
|
31 |
-
global $ewww_preempt_editor;
|
32 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
33 |
-
return parent::_save( $image, $filename, $mime_type );
|
34 |
-
}
|
35 |
-
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
36 |
-
if ( ! $filename ) {
|
37 |
-
$filename = $this->generate_filename( null, null, $extension );
|
38 |
-
}
|
39 |
-
if ( ( ! defined( 'EWWWIO_EDITOR_OVERWRITE' ) || ! EWWWIO_EDITOR_OVERWRITE ) && ewwwio_is_file( $filename ) ) {
|
40 |
-
ewwwio_debug_message( "detected existing file: $filename" );
|
41 |
-
$current_size = getimagesize( $filename );
|
42 |
-
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
|
43 |
-
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
|
44 |
-
return array(
|
45 |
-
'path' => $filename,
|
46 |
-
'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
|
47 |
-
'width' => $this->size['width'],
|
48 |
-
'height' => $this->size['height'],
|
49 |
-
'mime-type' => $mime_type,
|
50 |
-
);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) ) {
|
54 |
-
ewww_image_optimizer_cloud_init();
|
55 |
-
}
|
56 |
-
$saved = parent::_save( $image, $filename, $mime_type );
|
57 |
-
if ( ! is_wp_error( $saved ) ) {
|
58 |
-
if ( ! $filename ) {
|
59 |
-
$filename = $saved['path'];
|
60 |
-
}
|
61 |
-
if ( file_exists( $filename ) ) {
|
62 |
-
ewww_image_optimizer( $filename );
|
63 |
-
ewwwio_debug_message( "image editor (AGR gd) saved: $filename" );
|
64 |
-
$image_size = ewww_image_optimizer_filesize( $filename );
|
65 |
-
ewwwio_debug_message( "image editor size: $image_size" );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
ewwwio_memory( __METHOD__ );
|
69 |
-
return $saved;
|
70 |
-
}
|
71 |
-
/**
|
72 |
-
* Resize multiple images from a single source.
|
73 |
-
*
|
74 |
-
* @param array $sizes An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
|
75 |
-
* @return array An array of resized images' metadata by size.
|
76 |
-
*/
|
77 |
-
public function multi_resize( $sizes ) {
|
78 |
-
global $ewww_defer;
|
79 |
-
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) ) {
|
80 |
-
ewww_image_optimizer_cloud_init();
|
81 |
-
}
|
82 |
-
$metadata = parent::multi_resize( $sizes );
|
83 |
-
ewwwio_debug_message( 'image editor (AGR gd) multi resize' );
|
84 |
-
$info = pathinfo( $this->file );
|
85 |
-
$dir = $info['dirname'];
|
86 |
-
if ( ewww_image_optimizer_iterable( $metadata ) ) {
|
87 |
-
foreach ( $metadata as $size ) {
|
88 |
-
$filename = trailingslashit( $dir ) . $size['file'];
|
89 |
-
if ( file_exists( $filename ) ) {
|
90 |
-
ewww_image_optimizer( $filename );
|
91 |
-
ewwwio_debug_message( "image editor (AGR gd) saved: $filename" );
|
92 |
-
$image_size = ewww_image_optimizer_filesize( $filename );
|
93 |
-
ewwwio_debug_message( "image editor size: $image_size" );
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
ewwwio_memory( __METHOD__ );
|
98 |
-
return $metadata;
|
99 |
-
}
|
100 |
-
}
|
101 |
} elseif ( class_exists( 'WP_Thumb_Image_Editor_GD' ) ) {
|
102 |
/**
|
103 |
-
* Extension of the
|
|
|
104 |
*
|
105 |
* @see WP_Image_Editor_GD
|
106 |
*/
|
@@ -117,7 +31,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
117 |
ewwwio_debug_message( '<b>(wpthumb)' . __METHOD__ . '()</b>' );
|
118 |
global $ewww_defer;
|
119 |
global $ewww_preempt_editor;
|
120 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
121 |
return parent::_save( $image, $filename, $mime_type );
|
122 |
}
|
123 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
@@ -159,7 +73,8 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
159 |
}
|
160 |
} elseif ( class_exists( 'BFI_Image_Editor_GD' ) ) {
|
161 |
/**
|
162 |
-
* Extension of the
|
|
|
163 |
*
|
164 |
* @see WP_Image_Editor_GD
|
165 |
*/
|
@@ -176,7 +91,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
176 |
ewwwio_debug_message( '<b>(bfi)::' . __METHOD__ . '()</b>' );
|
177 |
global $ewww_defer;
|
178 |
global $ewww_preempt_editor;
|
179 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
180 |
return parent::_save( $image, $filename, $mime_type );
|
181 |
}
|
182 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
@@ -206,10 +121,10 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
206 |
$filename = $saved['path'];
|
207 |
}
|
208 |
if ( file_exists( $filename ) ) {
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
}
|
214 |
}
|
215 |
ewwwio_memory( __METHOD__ );
|
@@ -263,14 +178,14 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
263 |
}
|
264 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
265 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
266 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
267 |
ewwwio_debug_message( 'no gifsicle or API to resize an animated GIF' );
|
268 |
return parent::_resize( $max_w, $max_h, $crop );
|
269 |
}
|
270 |
}
|
271 |
}
|
272 |
if ( 'image/gif' !== $this->mime_type && false === strpos( $ewww_status, 'great' ) ) {
|
273 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
274 |
ewwwio_debug_message( 'no API to resize the image' );
|
275 |
return parent::_resize( $max_w, $max_h, $crop );
|
276 |
}
|
@@ -594,7 +509,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
594 |
if ( ! empty( $this->ewww_image ) && empty( $this->modified ) ) {
|
595 |
return $this->_save_ewwwio_file( $this->ewww_image, $filename, $mime_type );
|
596 |
}
|
597 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
598 |
return parent::_save( $image, $filename, $mime_type );
|
599 |
}
|
600 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
10 |
exit;
|
11 |
}
|
12 |
if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
13 |
+
// Do nothing, they should just get rid of that unsupported plugin.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
} elseif ( class_exists( 'WP_Thumb_Image_Editor_GD' ) ) {
|
15 |
/**
|
16 |
+
* Extension of the WP_Thumb_Image_Editor_GD class to auto-compress edited images.
|
17 |
+
* The parent class is from the WPThumb library, developed at Human Made, but no longer maintained.
|
18 |
*
|
19 |
* @see WP_Image_Editor_GD
|
20 |
*/
|
31 |
ewwwio_debug_message( '<b>(wpthumb)' . __METHOD__ . '()</b>' );
|
32 |
global $ewww_defer;
|
33 |
global $ewww_preempt_editor;
|
34 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
35 |
return parent::_save( $image, $filename, $mime_type );
|
36 |
}
|
37 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
73 |
}
|
74 |
} elseif ( class_exists( 'BFI_Image_Editor_GD' ) ) {
|
75 |
/**
|
76 |
+
* Extension of the BFI_Image_Editor_GD class to auto-compress edited images.
|
77 |
+
* Also no longer maintained, if you're using this, update your code!.
|
78 |
*
|
79 |
* @see WP_Image_Editor_GD
|
80 |
*/
|
91 |
ewwwio_debug_message( '<b>(bfi)::' . __METHOD__ . '()</b>' );
|
92 |
global $ewww_defer;
|
93 |
global $ewww_preempt_editor;
|
94 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
95 |
return parent::_save( $image, $filename, $mime_type );
|
96 |
}
|
97 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
121 |
$filename = $saved['path'];
|
122 |
}
|
123 |
if ( file_exists( $filename ) ) {
|
124 |
+
ewww_image_optimizer( $filename );
|
125 |
+
ewwwio_debug_message( "image editor (BFI GD) saved: $filename" );
|
126 |
+
$image_size = ewww_image_optimizer_filesize( $filename );
|
127 |
+
ewwwio_debug_message( "image editor size: $image_size" );
|
128 |
}
|
129 |
}
|
130 |
ewwwio_memory( __METHOD__ );
|
178 |
}
|
179 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
180 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
181 |
+
if ( ! ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) ) {
|
182 |
ewwwio_debug_message( 'no gifsicle or API to resize an animated GIF' );
|
183 |
return parent::_resize( $max_w, $max_h, $crop );
|
184 |
}
|
185 |
}
|
186 |
}
|
187 |
if ( 'image/gif' !== $this->mime_type && false === strpos( $ewww_status, 'great' ) ) {
|
188 |
+
if ( ! ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) ) {
|
189 |
ewwwio_debug_message( 'no API to resize the image' );
|
190 |
return parent::_resize( $max_w, $max_h, $crop );
|
191 |
}
|
509 |
if ( ! empty( $this->ewww_image ) && empty( $this->modified ) ) {
|
510 |
return $this->_save_ewwwio_file( $this->ewww_image, $filename, $mime_type );
|
511 |
}
|
512 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
513 |
return parent::_save( $image, $filename, $mime_type );
|
514 |
}
|
515 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
classes/class-ewwwio-gmagick-editor.php
CHANGED
@@ -27,7 +27,7 @@ if ( class_exists( 'WP_Image_Editor_Gmagick' ) ) {
|
|
27 |
protected function _save( $image, $filename = null, $mime_type = null ) {
|
28 |
global $ewww_defer;
|
29 |
global $ewww_preempt_editor;
|
30 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
31 |
return parent::_save( $image, $filename, $mime_type );
|
32 |
}
|
33 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
27 |
protected function _save( $image, $filename = null, $mime_type = null ) {
|
28 |
global $ewww_defer;
|
29 |
global $ewww_preempt_editor;
|
30 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
31 |
return parent::_save( $image, $filename, $mime_type );
|
32 |
}
|
33 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
classes/class-ewwwio-imagick-editor.php
CHANGED
@@ -11,7 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
11 |
}
|
12 |
if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
13 |
/**
|
14 |
-
* Extension of the
|
|
|
15 |
*
|
16 |
* @see WP_Image_Editor_Imagick
|
17 |
*/
|
@@ -28,7 +29,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
28 |
ewwwio_debug_message( '<b>wp_image_editor_imagick(wpthumb)::' . __FUNCTION__ . '()</b>' );
|
29 |
global $ewww_defer;
|
30 |
global $ewww_preempt_editor;
|
31 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
32 |
return parent::_save( $image, $filename, $mime_type );
|
33 |
}
|
34 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
@@ -58,29 +59,11 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
58 |
$filename = $saved['path'];
|
59 |
}
|
60 |
if ( file_exists( $filename ) ) {
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
ewwwio_debug_message( "image editor size: $image_size" );
|
66 |
-
|
67 |
-
/*
|
68 |
-
} else {
|
69 |
-
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
70 |
-
global $ewwwio_image_background;
|
71 |
-
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
72 |
-
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'background.php' );
|
73 |
-
}
|
74 |
-
if ( ! is_object( $ewwwio_image_background ) ) {
|
75 |
-
$ewwwio_image_background = new EWWWIO_Image_Background_Process();
|
76 |
-
}
|
77 |
-
$ewwwio_image_background->push_to_queue( $filename );
|
78 |
-
$ewwwio_image_background->save()->dispatch();
|
79 |
-
ewwwio_debug_message( "image editor (wpthumb imagick) queued: $filename" );
|
80 |
-
}
|
81 |
-
*/
|
82 |
}
|
83 |
-
ewww_image_optimizer_debug_log();
|
84 |
}
|
85 |
ewwwio_memory( __FUNCTION__ );
|
86 |
return $saved;
|
@@ -88,9 +71,8 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
88 |
}
|
89 |
} elseif ( class_exists( 'BFI_Image_Editor_Imagick' ) ) {
|
90 |
/**
|
91 |
-
* Extension of the
|
92 |
-
*
|
93 |
-
* @see WP_Image_Editor_Imagick
|
94 |
*/
|
95 |
class EWWWIO_Imagick_Editor extends BFI_Image_Editor_Imagick {
|
96 |
/**
|
@@ -105,7 +87,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
105 |
ewwwio_debug_message( '<b>wp_image_editor_imagick(bfi)::' . __FUNCTION__ . '()</b>' );
|
106 |
global $ewww_defer;
|
107 |
global $ewww_preempt_editor;
|
108 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
109 |
return parent::_save( $image, $filename, $mime_type );
|
110 |
}
|
111 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
@@ -135,29 +117,11 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
135 |
$filename = $saved['path'];
|
136 |
}
|
137 |
if ( file_exists( $filename ) ) {
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
ewwwio_debug_message( "image editor size: $image_size" );
|
143 |
-
|
144 |
-
/*
|
145 |
-
} else {
|
146 |
-
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
147 |
-
global $ewwwio_image_background;
|
148 |
-
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
149 |
-
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'background.php' );
|
150 |
-
}
|
151 |
-
if ( ! is_object( $ewwwio_image_background ) ) {
|
152 |
-
$ewwwio_image_background = new EWWWIO_Image_Background_Process();
|
153 |
-
}
|
154 |
-
$ewwwio_image_background->push_to_queue( $filename );
|
155 |
-
$ewwwio_image_background->save()->dispatch();
|
156 |
-
ewwwio_debug_message( "image editor (BFI imagick) queued: $filename" );
|
157 |
-
}
|
158 |
-
*/
|
159 |
}
|
160 |
-
ewww_image_optimizer_debug_log();
|
161 |
}
|
162 |
ewwwio_memory( __FUNCTION__ );
|
163 |
return $saved;
|
@@ -182,7 +146,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
182 |
ewwwio_debug_message( '<b>wp_image_editor_imagick(respimg)::' . __FUNCTION__ . '()</b>' );
|
183 |
global $ewww_defer;
|
184 |
global $ewww_preempt_editor;
|
185 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
186 |
return parent::_save( $image, $filename, $mime_type );
|
187 |
}
|
188 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
@@ -318,14 +282,14 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
318 |
}
|
319 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
320 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
321 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
322 |
ewwwio_debug_message( 'no gifsicle or API to resize an animated GIF' );
|
323 |
$return_parent = true;
|
324 |
}
|
325 |
}
|
326 |
}
|
327 |
if ( 'image/gif' !== $this->mime_type && false === strpos( $ewww_status, 'great' ) ) {
|
328 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
329 |
ewwwio_debug_message( 'no API to resize the image' );
|
330 |
$return_parent = true;
|
331 |
}
|
@@ -591,7 +555,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
591 |
if ( ! empty( $this->ewww_image ) && empty( $this->modified ) ) {
|
592 |
return $this->_save_ewwwio_file( $this->ewww_image, $filename, $mime_type );
|
593 |
}
|
594 |
-
if ( ! empty( $ewww_preempt_editor ) ) {
|
595 |
return parent::_save( $image, $filename, $mime_type );
|
596 |
}
|
597 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
@@ -621,29 +585,11 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
621 |
$filename = $saved['path'];
|
622 |
}
|
623 |
if ( file_exists( $filename ) ) {
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
ewwwio_debug_message( "image editor size: $image_size" );
|
629 |
-
|
630 |
-
/*
|
631 |
-
} else {
|
632 |
-
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
633 |
-
global $ewwwio_image_background;
|
634 |
-
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
635 |
-
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'background.php' );
|
636 |
-
}
|
637 |
-
if ( ! is_object( $ewwwio_image_background ) ) {
|
638 |
-
$ewwwio_image_background = new EWWWIO_Image_Background_Process();
|
639 |
-
}
|
640 |
-
$ewwwio_image_background->push_to_queue( $filename );
|
641 |
-
$ewwwio_image_background->save()->dispatch();
|
642 |
-
ewwwio_debug_message( "image editor (imagick) queued: $filename" );
|
643 |
-
}
|
644 |
-
*/
|
645 |
}
|
646 |
-
ewww_image_optimizer_debug_log();
|
647 |
}
|
648 |
ewwwio_memory( __FUNCTION__ );
|
649 |
return $saved;
|
11 |
}
|
12 |
if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
13 |
/**
|
14 |
+
* Extension of the WP_Thumb_Image_Editor_Imagick class to auto-compress edited images.
|
15 |
+
* Note that WPThumb is no longer maintained and you should update your code.
|
16 |
*
|
17 |
* @see WP_Image_Editor_Imagick
|
18 |
*/
|
29 |
ewwwio_debug_message( '<b>wp_image_editor_imagick(wpthumb)::' . __FUNCTION__ . '()</b>' );
|
30 |
global $ewww_defer;
|
31 |
global $ewww_preempt_editor;
|
32 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
33 |
return parent::_save( $image, $filename, $mime_type );
|
34 |
}
|
35 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
59 |
$filename = $saved['path'];
|
60 |
}
|
61 |
if ( file_exists( $filename ) ) {
|
62 |
+
ewww_image_optimizer( $filename );
|
63 |
+
ewwwio_debug_message( "image editor (wpthumb imagick) saved: $filename" );
|
64 |
+
$image_size = ewww_image_optimizer_filesize( $filename );
|
65 |
+
ewwwio_debug_message( "image editor size: $image_size" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
|
|
67 |
}
|
68 |
ewwwio_memory( __FUNCTION__ );
|
69 |
return $saved;
|
71 |
}
|
72 |
} elseif ( class_exists( 'BFI_Image_Editor_Imagick' ) ) {
|
73 |
/**
|
74 |
+
* Extension of the BFI_Image_Editor_Imagick class to auto-compress edited images.
|
75 |
+
* The BFI project is no longer maintained, stop using it and update your code!
|
|
|
76 |
*/
|
77 |
class EWWWIO_Imagick_Editor extends BFI_Image_Editor_Imagick {
|
78 |
/**
|
87 |
ewwwio_debug_message( '<b>wp_image_editor_imagick(bfi)::' . __FUNCTION__ . '()</b>' );
|
88 |
global $ewww_defer;
|
89 |
global $ewww_preempt_editor;
|
90 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
91 |
return parent::_save( $image, $filename, $mime_type );
|
92 |
}
|
93 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
117 |
$filename = $saved['path'];
|
118 |
}
|
119 |
if ( file_exists( $filename ) ) {
|
120 |
+
ewww_image_optimizer( $filename );
|
121 |
+
ewwwio_debug_message( "image editor (BFI imagick) saved: $filename" );
|
122 |
+
$image_size = ewww_image_optimizer_filesize( $filename );
|
123 |
+
ewwwio_debug_message( "image editor size: $image_size" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
|
|
125 |
}
|
126 |
ewwwio_memory( __FUNCTION__ );
|
127 |
return $saved;
|
146 |
ewwwio_debug_message( '<b>wp_image_editor_imagick(respimg)::' . __FUNCTION__ . '()</b>' );
|
147 |
global $ewww_defer;
|
148 |
global $ewww_preempt_editor;
|
149 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
150 |
return parent::_save( $image, $filename, $mime_type );
|
151 |
}
|
152 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
282 |
}
|
283 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
284 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
285 |
+
if ( ! ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) ) {
|
286 |
ewwwio_debug_message( 'no gifsicle or API to resize an animated GIF' );
|
287 |
$return_parent = true;
|
288 |
}
|
289 |
}
|
290 |
}
|
291 |
if ( 'image/gif' !== $this->mime_type && false === strpos( $ewww_status, 'great' ) ) {
|
292 |
+
if ( ! ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) ) {
|
293 |
ewwwio_debug_message( 'no API to resize the image' );
|
294 |
$return_parent = true;
|
295 |
}
|
555 |
if ( ! empty( $this->ewww_image ) && empty( $this->modified ) ) {
|
556 |
return $this->_save_ewwwio_file( $this->ewww_image, $filename, $mime_type );
|
557 |
}
|
558 |
+
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
|
559 |
return parent::_save( $image, $filename, $mime_type );
|
560 |
}
|
561 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
|
585 |
$filename = $saved['path'];
|
586 |
}
|
587 |
if ( file_exists( $filename ) ) {
|
588 |
+
ewww_image_optimizer( $filename );
|
589 |
+
ewwwio_debug_message( "image editor (imagick) saved: $filename" );
|
590 |
+
$image_size = ewww_image_optimizer_filesize( $filename );
|
591 |
+
ewwwio_debug_message( "image editor size: $image_size" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
592 |
}
|
|
|
593 |
}
|
594 |
ewwwio_memory( __FUNCTION__ );
|
595 |
return $saved;
|
classes/class-ewwwio-media-background-process.php
CHANGED
@@ -623,7 +623,7 @@ class EWWWIO_Async_Key_Verification extends WP_Async_Request {
|
|
623 |
session_write_close();
|
624 |
ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
|
625 |
check_ajax_referer( $this->identifier, 'nonce' );
|
626 |
-
ewww_image_optimizer_cloud_verify( false );
|
627 |
}
|
628 |
}
|
629 |
global $ewwwio_async_key_verification;
|
623 |
session_write_close();
|
624 |
ewwwio_debug_message( '<b>' . __METHOD__ . '()</b>' );
|
625 |
check_ajax_referer( $this->identifier, 'nonce' );
|
626 |
+
ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ), false );
|
627 |
}
|
628 |
}
|
629 |
global $ewwwio_async_key_verification;
|
classes/class-ewwwio-tracking.php
CHANGED
@@ -323,6 +323,7 @@ class EWWWIO_Tracking {
|
|
323 |
* @return void
|
324 |
*/
|
325 |
public function admin_notice() {
|
|
|
326 |
// If network-active and network notice is hidden, or single-active and single site notice has been hidden, don't show it again.
|
327 |
$hide_notice = ewww_image_optimizer_get_option( 'ewww_image_optimizer_tracking_notice' );
|
328 |
// But what if they allow overrides? Then the above was checking single-site settings, so we need to check the network admin.
|
323 |
* @return void
|
324 |
*/
|
325 |
public function admin_notice() {
|
326 |
+
return;
|
327 |
// If network-active and network notice is hidden, or single-active and single site notice has been hidden, don't show it again.
|
328 |
$hide_notice = ewww_image_optimizer_get_option( 'ewww_image_optimizer_tracking_notice' );
|
329 |
// But what if they allow overrides? Then the above was checking single-site settings, so we need to check the network admin.
|
classes/class-exactdn.php
CHANGED
@@ -192,6 +192,8 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
192 |
add_filter( 'wp_calculate_image_srcset', array( $this, 'filter_srcset_array' ), 1001, 5 );
|
193 |
add_filter( 'wp_calculate_image_sizes', array( $this, 'filter_sizes' ), 1, 2 ); // Early so themes can still filter.
|
194 |
|
|
|
|
|
195 |
// Filter for NextGEN image URLs within JS.
|
196 |
add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ) );
|
197 |
add_filter( 'ngg_get_image_url', array( $this, 'plugin_get_image_url' ) );
|
@@ -210,9 +212,6 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
210 |
if ( $this->get_option( 'exactdn_all_the_things' ) && $this->plan_id > 1 ) {
|
211 |
add_filter( 'style_loader_src', array( $this, 'parse_enqueue' ), 9999 );
|
212 |
add_filter( 'script_loader_src', array( $this, 'parse_enqueue' ), 9999 );
|
213 |
-
if ( defined( 'EXACTDN_DEFER_SCRIPTS' ) && EXACTDN_DEFER_SCRIPTS ) {
|
214 |
-
add_filter( 'script_loader_tag', array( $this, 'defer_scripts' ), 20 );
|
215 |
-
}
|
216 |
}
|
217 |
$this->set_option( 'exactdn_prevent_db_queries', true );
|
218 |
|
@@ -274,6 +273,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
274 |
$this->allowed_domains[] = $this->exactdn_domain;
|
275 |
$this->allowed_domains = apply_filters( 'exactdn_allowed_domains', $this->allowed_domains );
|
276 |
$this->debug_message( 'allowed domains: ' . implode( ',', $this->allowed_domains ) );
|
|
|
277 |
$this->validate_user_exclusions();
|
278 |
}
|
279 |
|
@@ -559,8 +559,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
559 |
$this->set_exactdn_option( 'verify_method', 1, false );
|
560 |
return;
|
561 |
}
|
|
|
|
|
562 |
}
|
563 |
-
$this->debug_message( 'exactdn (simulated) verification request failed, error unknown' );
|
564 |
$this->set_exactdn_option( 'verify_method', -1, false );
|
565 |
}
|
566 |
}
|
@@ -706,6 +707,29 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
706 |
return false;
|
707 |
}
|
708 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
709 |
/**
|
710 |
* Validate the user-defined exclusions for "all the things" rewriting.
|
711 |
*/
|
@@ -720,8 +744,8 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
720 |
if ( ! is_string( $exclusion ) ) {
|
721 |
continue;
|
722 |
}
|
723 |
-
if ( false !== strpos( $exclusion,
|
724 |
-
$exclusion = preg_replace( '#([^"\'?>]+?)?
|
725 |
}
|
726 |
$this->user_exclusions[] = ltrim( $exclusion, '/' );
|
727 |
}
|
@@ -743,6 +767,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
743 |
if ( function_exists( 'twentynineteen_setup' ) && 640 === (int) $content_width ) {
|
744 |
$content_width = 932;
|
745 |
}
|
|
|
|
|
|
|
746 |
/**
|
747 |
* Filter the Content Width value.
|
748 |
*
|
@@ -957,12 +984,14 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
957 |
$this->debug_message( 'url validated' );
|
958 |
|
959 |
// Find the width and height attributes.
|
960 |
-
$width = $this->
|
961 |
-
$height = $this->
|
962 |
|
963 |
// Can't pass both a relative width and height, so unset the dimensions in favor of not breaking the horizontal layout.
|
964 |
-
if ( false !== strpos( $width, '%' )
|
965 |
-
$width
|
|
|
|
|
966 |
$height = false;
|
967 |
}
|
968 |
|
@@ -970,6 +999,20 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
970 |
$width = $width && is_numeric( $width ) ? $width : false;
|
971 |
$height = $height && is_numeric( $height ) ? $height : false;
|
972 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
973 |
// Detect WP registered image size from HTML class.
|
974 |
if ( preg_match( '#class=["|\']?[^"\']*size-([^"\'\s]+)[^"\']*["|\']?#i', $images['img_tag'][ $index ], $size ) ) {
|
975 |
$size = array_pop( $size );
|
@@ -1200,7 +1243,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1200 |
} elseif ( ! $lazy && $this->validate_image_url( $src, true ) ) {
|
1201 |
$this->debug_message( "found a potential exactdn src url to insert into srcset: $src" );
|
1202 |
// Find the width attribute.
|
1203 |
-
$width = $this->
|
1204 |
if ( $width ) {
|
1205 |
$this->debug_message( 'found the width' );
|
1206 |
// Insert new image src into the srcset as well, if we have a width.
|
@@ -1256,7 +1299,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1256 |
}
|
1257 |
}
|
1258 |
if ( empty( $width ) || ! is_numeric( $width ) ) {
|
1259 |
-
$width = $this->
|
1260 |
}
|
1261 |
list( $filename_width, $discard_height ) = $this->get_dimensions_from_filename( $src );
|
1262 |
if ( empty( $width ) || ! is_numeric( $width ) ) {
|
@@ -1285,11 +1328,11 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1285 |
}
|
1286 |
} // End foreach().
|
1287 |
} // End if();
|
1288 |
-
$
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
if ( $this->filtering_the_page ) {
|
1294 |
$content = $this->filter_prz_thumb( $content );
|
1295 |
}
|
@@ -1464,18 +1507,18 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1464 |
$escaped_upload_domain = str_replace( '.', '\.', $upload_domain );
|
1465 |
$this->debug_message( $escaped_upload_domain );
|
1466 |
if ( ! empty( $this->user_exclusions ) ) {
|
1467 |
-
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)?/
|
1468 |
}
|
1469 |
if ( strpos( $content, '<use ' ) ) {
|
1470 |
// Pre-empt rewriting of files within <use> tags, particularly to prevent security errors for SVGs.
|
1471 |
-
$content = preg_replace( '#(<use.+?href=["\'])(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)/
|
1472 |
}
|
1473 |
// Pre-empt rewriting of wp-includes and wp-content if the extension is not allowed by using a temporary placeholder.
|
1474 |
-
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)?/
|
1475 |
// Pre-empt partial paths that are used by JS to build other URLs.
|
1476 |
-
$content = str_replace( '
|
1477 |
-
$content = str_replace( '
|
1478 |
-
$content = str_replace( '
|
1479 |
if (
|
1480 |
false !== strpos( $this->upload_domain, 'amazonaws.com' ) ||
|
1481 |
false !== strpos( $this->upload_domain, 'digitaloceanspaces.com' ) ||
|
@@ -1484,19 +1527,10 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1484 |
$this->debug_message( 'searching for #(https?:)?//(?:www\.)?' . $escaped_upload_domain . $this->remove_path . '/#i and replacing with $1//' . $this->exactdn_domain . '/' );
|
1485 |
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . $this->remove_path . '/#i', '$1//' . $this->exactdn_domain . '/', $content );
|
1486 |
} else {
|
1487 |
-
$this->debug_message( 'searching for #(https?:)?//(?:www\.)?' . $escaped_upload_domain . '/([^"\'?&>]+?)?(nextgen-image|
|
1488 |
-
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '/([^"\'?>]+?)?(nextgen-image|
|
1489 |
-
}
|
1490 |
-
$content = str_replace( '?wpcontent-bypass?', 'wp-content', $content );
|
1491 |
-
if ( defined( 'EXACTDN_DEFER_JQUERY_SAFE' ) && EXACTDN_DEFER_JQUERY_SAFE && false === strpos( $content, 'jQuery' ) ) {
|
1492 |
-
preg_match( "#<script\s+type='text/javascript'\s+src='[^']+?/jquery\.js[^']*?'[^>]*?>#is", $content, $jquery_tags );
|
1493 |
-
if ( ! empty( $jquery_tags[0] ) && false === strpos( $jquery_tags[0], 'defer' ) && false === strpos( $jquery_tags[0], 'async' ) ) {
|
1494 |
-
$deferred_jquery = str_replace( '>', ' defer>', $jquery_tags[0] );
|
1495 |
-
if ( $deferred_jquery && $deferred_jquery !== $jquery_tags[0] ) {
|
1496 |
-
$content = str_replace( $jquery_tags[0], $deferred_jquery, $content );
|
1497 |
-
}
|
1498 |
-
}
|
1499 |
}
|
|
|
1500 |
}
|
1501 |
return $content;
|
1502 |
}
|
@@ -1512,22 +1546,25 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1512 |
if ( ! wp_doing_ajax() ) {
|
1513 |
return $allow;
|
1514 |
}
|
|
|
|
|
|
|
1515 |
if ( ! empty( $_POST['action'] ) && 'eddvbugm_viewport_downloads' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1516 |
return true;
|
1517 |
}
|
1518 |
-
if ( ! empty( $_POST['action'] ) && '
|
1519 |
return true;
|
1520 |
}
|
1521 |
if ( ! empty( $_POST['action'] ) && 'filter_listing' === $_POST['action'] && ! empty( $_POST['layout'] ) && ! empty( $_POST['paged'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1522 |
return true;
|
1523 |
}
|
1524 |
-
if ( ! empty( $_POST['action'] ) && '
|
1525 |
return true;
|
1526 |
}
|
1527 |
-
if ( ! empty( $_POST['action'] ) && '
|
1528 |
return true;
|
1529 |
}
|
1530 |
-
if ( ! empty( $
|
1531 |
return true;
|
1532 |
}
|
1533 |
return $allow;
|
@@ -1647,6 +1684,8 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1647 |
}
|
1648 |
// Set this to true later when we know we have size meta.
|
1649 |
$has_size_meta = false;
|
|
|
|
|
1650 |
|
1651 |
if ( $image_url ) {
|
1652 |
// Check if image URL should be used with ExactDN.
|
@@ -1671,11 +1710,13 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1671 |
if ( 'full' === $size ) {
|
1672 |
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
1673 |
$intermediate = false;
|
|
|
1674 |
} elseif ( ! $image_meta ) {
|
1675 |
$this->debug_message( 'still do not have meta, getting it now' );
|
1676 |
// If we still don't have any image meta at this point, it's probably from a custom thumbnail size
|
1677 |
// for an image that was uploaded before the custom image was added to the theme. Try to determine the size manually.
|
1678 |
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
|
|
1679 |
|
1680 |
if ( isset( $image_meta['width'], $image_meta['height'] ) ) {
|
1681 |
$image_resized = image_resize_dimensions( $image_meta['width'], $image_meta['height'], $image_args['width'], $image_args['height'], $image_args['crop'] );
|
@@ -1706,7 +1747,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1706 |
$exactdn_args['w'] = $image_args['width'];
|
1707 |
}
|
1708 |
} else {
|
1709 |
-
if ( ! isset( $image_meta['sizes'] ) ) {
|
1710 |
$size_meta = $image_meta;
|
1711 |
// Because we don't have the "real" meta, just the height/width for the specific size.
|
1712 |
$this->debug_message( 'getting attachment meta now' );
|
@@ -1744,6 +1785,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1744 |
$filename_width = $image_meta['width'] ? $image_meta['width'] : $filename_width;
|
1745 |
$filename_height = $image_meta['height'] ? $image_meta['height'] : $filename_height;
|
1746 |
if ( $filename_width && $filename_height && $image_args['width'] === $filename_width && $image_args['height'] === $filename_height ) {
|
|
|
1747 |
$image_url = $intermediate_url;
|
1748 |
} else {
|
1749 |
$resize_existing = true;
|
@@ -2201,61 +2243,22 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2201 |
return $args;
|
2202 |
}
|
2203 |
// TST is not active.
|
2204 |
-
if ( ! defined( 'TST_VERSION' ) ) {
|
2205 |
$this->debug_message( 'no TST plugin' );
|
2206 |
return $args;
|
2207 |
}
|
2208 |
-
if ( ! class_exists( 'TstPostOptions' ) || ! defined( 'TstPostOptions::META_POSITION' ) ) {
|
2209 |
-
$this->debug_message( 'no TstPostOptions class' );
|
2210 |
-
return $args;
|
2211 |
-
}
|
2212 |
if ( ! $meta || ! is_array( $meta ) || empty( $meta['sizes'] ) ) {
|
2213 |
-
// $focus_point = get_post_meta( $attachment_id, TstPostOptions::META_POSITION, true );
|
2214 |
$meta = wp_get_attachment_metadata( $attachment_id );
|
2215 |
-
if ( ! is_array( $meta ) || empty( $meta
|
2216 |
$this->debug_message( 'unusable meta retrieved' );
|
2217 |
return $args;
|
2218 |
}
|
2219 |
-
$focus_point = TstPostOptions::get_meta( $attachment_id, $meta['width'], $meta['height'] );
|
2220 |
-
} elseif ( ! empty( $meta['tst_thumbnail_version'] ) ) {
|
2221 |
-
if ( empty( $meta['width'] ) || empty( $meta['height'] ) ) {
|
2222 |
-
$this->debug_message( 'unusable meta passed' );
|
2223 |
-
return $args;
|
2224 |
-
}
|
2225 |
-
$focus_point = TstPostOptions::get_meta( $attachment_id, $meta['width'], $meta['height'] );
|
2226 |
-
} else {
|
2227 |
-
$this->debug_message( 'unusable meta' );
|
2228 |
-
return $args;
|
2229 |
}
|
2230 |
-
if (
|
2231 |
-
$
|
2232 |
return $args;
|
2233 |
}
|
2234 |
-
|
2235 |
-
$dimensions = explode( ',', $args['resize'] );
|
2236 |
-
|
2237 |
-
$new_w = $dimensions[0];
|
2238 |
-
$new_h = $dimensions[1];
|
2239 |
-
$this->debug_message( "full size dims: w{$meta['width']} h{$meta['height']}" );
|
2240 |
-
$this->debug_message( "smart crop dims: w$new_w h$new_h" );
|
2241 |
-
if ( ! empty( $args['zoom'] ) ) {
|
2242 |
-
$new_w = round( $args['zoom'] * $new_w );
|
2243 |
-
$new_h = round( $args['zoom'] * $new_h );
|
2244 |
-
$this->debug_message( "zooming: {$args['zoom']} w$new_w h$new_h" );
|
2245 |
-
}
|
2246 |
-
if ( ! $new_w || ! $new_h ) {
|
2247 |
-
$this->debug_message( 'empty dimension, not cropping' );
|
2248 |
-
return $args;
|
2249 |
-
}
|
2250 |
-
$size_ratio = max( $new_w / $meta['width'], $new_h / $meta['height'] );
|
2251 |
-
$crop_w = round( $new_w / $size_ratio );
|
2252 |
-
$crop_h = round( $new_h / $size_ratio );
|
2253 |
-
$s_x = floor( ( $meta['width'] - $crop_w ) * $focus_point[0] );
|
2254 |
-
$s_y = floor( ( $meta['height'] - $crop_h ) * $focus_point[1] );
|
2255 |
-
$this->debug_message( "doing the math with size_ratio of $size_ratio" );
|
2256 |
-
|
2257 |
-
$args['crop'] = $s_x . ',' . $s_y . ',' . $crop_w . ',' . $crop_h;
|
2258 |
-
$this->debug_message( $args['crop'] );
|
2259 |
return $args;
|
2260 |
}
|
2261 |
|
@@ -2653,38 +2656,6 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2653 |
return $skip;
|
2654 |
}
|
2655 |
|
2656 |
-
/**
|
2657 |
-
* Rewrites a script tag to be deferred.
|
2658 |
-
*
|
2659 |
-
* @param string $tag URL to the script.
|
2660 |
-
* @return string The deferred version of the resource, if it was allowed.
|
2661 |
-
*/
|
2662 |
-
function defer_scripts( $tag ) {
|
2663 |
-
if ( is_admin() ) {
|
2664 |
-
return $tag;
|
2665 |
-
}
|
2666 |
-
if ( false !== strpos( $tag, 'async' ) ) {
|
2667 |
-
return $tag;
|
2668 |
-
}
|
2669 |
-
if ( false !== strpos( $tag, 'defer' ) ) {
|
2670 |
-
return $tag;
|
2671 |
-
}
|
2672 |
-
if ( false !== strpos( $tag, 'jquery.js' ) && ! defined( 'EXACTDN_DEFER_JQUERY' ) ) {
|
2673 |
-
return $tag;
|
2674 |
-
}
|
2675 |
-
if ( false !== strpos( $tag, 'lazysizes' ) ) {
|
2676 |
-
if ( false !== strpos( $tag, 'ewww-image' ) || false !== strpos( $tag, 'easy-image' ) ) {
|
2677 |
-
return str_replace( '></script', ' async></script', $tag );
|
2678 |
-
}
|
2679 |
-
return $tag;
|
2680 |
-
}
|
2681 |
-
$deferred_tag = str_replace( '></script', ' defer></script', $tag );
|
2682 |
-
if ( $deferred_tag && $deferred_tag !== $tag ) {
|
2683 |
-
return $deferred_tag;
|
2684 |
-
}
|
2685 |
-
return $tag;
|
2686 |
-
}
|
2687 |
-
|
2688 |
/**
|
2689 |
* Converts a local script/css url to use ExactDN.
|
2690 |
*
|
@@ -2758,7 +2729,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2758 |
global $wp_version;
|
2759 |
// If a resource doesn't have a version string, we add one to help with cache-busting.
|
2760 |
if (
|
2761 |
-
false !== strpos( $url, '
|
2762 |
( empty( $parsed_url['query'] ) || 'ver=' . $wp_version === $parsed_url['query'] )
|
2763 |
) {
|
2764 |
$modified = $this->function_exists( 'filemtime' ) ? filemtime( get_template_directory() ) : '';
|
@@ -2772,7 +2743,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2772 |
*/
|
2773 |
$parsed_url['query'] = apply_filters( 'exactdn_version_string', "m=$modified" );
|
2774 |
} elseif (
|
2775 |
-
false !== strpos( $url, '
|
2776 |
( empty( $parsed_url['query'] ) || 'ver=' . $wp_version === $parsed_url['query'] )
|
2777 |
) {
|
2778 |
$parsed_url['query'] = '';
|
@@ -2809,6 +2780,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2809 |
function generate_url( $image_url, $args = array(), $scheme = null ) {
|
2810 |
$this->debug_message( '<b>' . __METHOD__ . '()</b>' );
|
2811 |
$image_url = trim( $image_url );
|
|
|
2812 |
|
2813 |
if ( is_null( $scheme ) ) {
|
2814 |
$scheme = $this->scheme;
|
@@ -2825,6 +2797,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2825 |
* @param bool false default
|
2826 |
*/
|
2827 |
if ( true === apply_filters( 'exactdn_development_mode', false ) ) {
|
|
|
2828 |
return $image_url;
|
2829 |
}
|
2830 |
|
@@ -2837,6 +2810,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2837 |
* @param string|null $scheme URL scheme. Default to null.
|
2838 |
*/
|
2839 |
if ( true === apply_filters( 'exactdn_skip_for_url', false, $image_url, $args, $scheme ) ) {
|
|
|
2840 |
return $image_url;
|
2841 |
}
|
2842 |
|
@@ -2876,6 +2850,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2876 |
* @param string|null $scheme Image scheme. Default to null.
|
2877 |
*/
|
2878 |
$image_url = apply_filters( 'exactdn_pre_image_url', $image_url, $args, $scheme );
|
|
|
2879 |
|
2880 |
if ( empty( $image_url ) ) {
|
2881 |
return $image_url;
|
@@ -2920,6 +2895,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2920 |
}
|
2921 |
|
2922 |
$this->debug_message( $image_url_parts['host'] );
|
|
|
2923 |
|
2924 |
// Figure out which CDN (sub)domain to use.
|
2925 |
if ( empty( $this->exactdn_domain ) ) {
|
@@ -2946,6 +2922,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2946 |
|
2947 |
if ( $this->remove_path && 0 === strpos( $image_url_parts['path'], $this->remove_path ) ) {
|
2948 |
$image_url_parts['path'] = substr( $image_url_parts['path'], strlen( $this->remove_path ) );
|
|
|
2949 |
}
|
2950 |
$domain = 'http://' . $this->exactdn_domain . '/';
|
2951 |
$exactdn_url = $domain . ltrim( $image_url_parts['path'], '/' );
|
@@ -2962,8 +2939,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2962 |
if ( isset( $image_url_parts['query'] ) && apply_filters( 'exactdn_add_query_string_to_domain', false, $image_url_parts['host'] ) ) {
|
2963 |
$exactdn_url .= '?q=' . rawurlencode( $image_url_parts['query'] );
|
2964 |
}
|
2965 |
-
|
2966 |
-
|
|
|
2967 |
$args = wp_parse_args( $image_url_parts['query'], $args );
|
2968 |
}
|
2969 |
|
192 |
add_filter( 'wp_calculate_image_srcset', array( $this, 'filter_srcset_array' ), 1001, 5 );
|
193 |
add_filter( 'wp_calculate_image_sizes', array( $this, 'filter_sizes' ), 1, 2 ); // Early so themes can still filter.
|
194 |
|
195 |
+
/* add_filter( 'fl_builder_render_assets_inline', '__return_true' ); */
|
196 |
+
|
197 |
// Filter for NextGEN image URLs within JS.
|
198 |
add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ) );
|
199 |
add_filter( 'ngg_get_image_url', array( $this, 'plugin_get_image_url' ) );
|
212 |
if ( $this->get_option( 'exactdn_all_the_things' ) && $this->plan_id > 1 ) {
|
213 |
add_filter( 'style_loader_src', array( $this, 'parse_enqueue' ), 9999 );
|
214 |
add_filter( 'script_loader_src', array( $this, 'parse_enqueue' ), 9999 );
|
|
|
|
|
|
|
215 |
}
|
216 |
$this->set_option( 'exactdn_prevent_db_queries', true );
|
217 |
|
273 |
$this->allowed_domains[] = $this->exactdn_domain;
|
274 |
$this->allowed_domains = apply_filters( 'exactdn_allowed_domains', $this->allowed_domains );
|
275 |
$this->debug_message( 'allowed domains: ' . implode( ',', $this->allowed_domains ) );
|
276 |
+
$this->get_allowed_paths();
|
277 |
$this->validate_user_exclusions();
|
278 |
}
|
279 |
|
559 |
$this->set_exactdn_option( 'verify_method', 1, false );
|
560 |
return;
|
561 |
}
|
562 |
+
} else {
|
563 |
+
$this->debug_message( 'exactdn (simulated) verification request failed, error unknown' );
|
564 |
}
|
|
|
565 |
$this->set_exactdn_option( 'verify_method', -1, false );
|
566 |
}
|
567 |
}
|
707 |
return false;
|
708 |
}
|
709 |
|
710 |
+
/**
|
711 |
+
* Get the paths for wp-content, wp-includes, and the uploads directory.
|
712 |
+
* These are used to help determine which URLs are allowed to be rewritten for Easy IO.
|
713 |
+
*/
|
714 |
+
function get_allowed_paths() {
|
715 |
+
$wp_content_path = trim( $this->parse_url( content_url(), PHP_URL_PATH ), '/' );
|
716 |
+
$wp_include_path = trim( $this->parse_url( includes_url(), PHP_URL_PATH ), '/' );
|
717 |
+
$this->debug_message( "wp-content path: $wp_content_path" );
|
718 |
+
$this->debug_message( "wp-includes path: $wp_include_path" );
|
719 |
+
|
720 |
+
$this->content_path = basename( $wp_content_path );
|
721 |
+
$this->include_path = basename( $wp_include_path );
|
722 |
+
$this->uploads_path = basename( $wp_content_path );
|
723 |
+
|
724 |
+
// NOTE: This bit is not currently in use, so we'll see if anyone needs it.
|
725 |
+
$uploads_info = wp_upload_dir();
|
726 |
+
if ( ! empty( $uploads_info['baseurl'] ) && false === strpos( $uploads_info['baseurl'], $wp_content_path ) ) {
|
727 |
+
$uploads_path = trim( $this->parse_url( $uploads_info['baseurl'], PHP_URL_PATH ), '/' );
|
728 |
+
$this->debug_message( "wp uploads path: $uploads_path" );
|
729 |
+
$this->uploads_path = basename( $uploads_path );
|
730 |
+
}
|
731 |
+
}
|
732 |
+
|
733 |
/**
|
734 |
* Validate the user-defined exclusions for "all the things" rewriting.
|
735 |
*/
|
744 |
if ( ! is_string( $exclusion ) ) {
|
745 |
continue;
|
746 |
}
|
747 |
+
if ( false !== strpos( $exclusion, $this->content_path ) ) {
|
748 |
+
$exclusion = preg_replace( '#([^"\'?>]+?)?' . $this->content_path . '/#i', '', $exclusion );
|
749 |
}
|
750 |
$this->user_exclusions[] = ltrim( $exclusion, '/' );
|
751 |
}
|
767 |
if ( function_exists( 'twentynineteen_setup' ) && 640 === (int) $content_width ) {
|
768 |
$content_width = 932;
|
769 |
}
|
770 |
+
if ( defined( 'EXACTDN_CONTENT_WIDTH' ) && EXACTDN_CONTENT_WIDTH ) {
|
771 |
+
$content_width = EXACTDN_CONTENT_WIDTH;
|
772 |
+
}
|
773 |
/**
|
774 |
* Filter the Content Width value.
|
775 |
*
|
984 |
$this->debug_message( 'url validated' );
|
985 |
|
986 |
// Find the width and height attributes.
|
987 |
+
$width = $this->get_attribute( $images['img_tag'][ $index ], 'width' );
|
988 |
+
$height = $this->get_attribute( $images['img_tag'][ $index ], 'height' );
|
989 |
|
990 |
// Can't pass both a relative width and height, so unset the dimensions in favor of not breaking the horizontal layout.
|
991 |
+
if ( false !== strpos( $width, '%' ) ) {
|
992 |
+
$width = false;
|
993 |
+
}
|
994 |
+
if ( false !== strpos( $height, '%' ) ) {
|
995 |
$height = false;
|
996 |
}
|
997 |
|
999 |
$width = $width && is_numeric( $width ) ? $width : false;
|
1000 |
$height = $height && is_numeric( $height ) ? $height : false;
|
1001 |
|
1002 |
+
// See if there is a width/height set in the style attribute.
|
1003 |
+
$style_width = $this->get_img_style_width( $images['img_tag'][ $index ] );
|
1004 |
+
$style_height = $this->get_img_style_height( $images['img_tag'][ $index ] );
|
1005 |
+
if ( $style_width && $style_height ) {
|
1006 |
+
$width = min( $style_width, $width );
|
1007 |
+
$height = min( $style_height, $height );
|
1008 |
+
} elseif ( $style_width && $style_width < $width ) {
|
1009 |
+
$width = $style_width;
|
1010 |
+
$transform = 'fit';
|
1011 |
+
} elseif ( $style_height && $style_height < $height ) {
|
1012 |
+
$height = $style_height;
|
1013 |
+
$transform = 'fit';
|
1014 |
+
}
|
1015 |
+
|
1016 |
// Detect WP registered image size from HTML class.
|
1017 |
if ( preg_match( '#class=["|\']?[^"\']*size-([^"\'\s]+)[^"\']*["|\']?#i', $images['img_tag'][ $index ], $size ) ) {
|
1018 |
$size = array_pop( $size );
|
1243 |
} elseif ( ! $lazy && $this->validate_image_url( $src, true ) ) {
|
1244 |
$this->debug_message( "found a potential exactdn src url to insert into srcset: $src" );
|
1245 |
// Find the width attribute.
|
1246 |
+
$width = $this->get_attribute( $images['img_tag'][ $index ], 'width' );
|
1247 |
if ( $width ) {
|
1248 |
$this->debug_message( 'found the width' );
|
1249 |
// Insert new image src into the srcset as well, if we have a width.
|
1299 |
}
|
1300 |
}
|
1301 |
if ( empty( $width ) || ! is_numeric( $width ) ) {
|
1302 |
+
$width = $this->get_attribute( $images['img_tag'][ $index ], 'width' );
|
1303 |
}
|
1304 |
list( $filename_width, $discard_height ) = $this->get_dimensions_from_filename( $src );
|
1305 |
if ( empty( $width ) || ! is_numeric( $width ) ) {
|
1328 |
}
|
1329 |
} // End foreach().
|
1330 |
} // End if();
|
1331 |
+
$element_types = apply_filters( 'eio_allowed_background_image_elements', array( 'div', 'li', 'span', 'section', 'a' ) );
|
1332 |
+
foreach ( $element_types as $element_type ) {
|
1333 |
+
// Process background images on HTML elements.
|
1334 |
+
$content = $this->filter_bg_images( $content, $element_type );
|
1335 |
+
}
|
1336 |
if ( $this->filtering_the_page ) {
|
1337 |
$content = $this->filter_prz_thumb( $content );
|
1338 |
}
|
1507 |
$escaped_upload_domain = str_replace( '.', '\.', $upload_domain );
|
1508 |
$this->debug_message( $escaped_upload_domain );
|
1509 |
if ( ! empty( $this->user_exclusions ) ) {
|
1510 |
+
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)?/' . $this->content_path . '/([^"\'?>]+?)?(' . implode( '|', $this->user_exclusions ) . ')#i', '$1//' . $this->upload_domain . '$2/?wpcontent-bypass?/$3$4', $content );
|
1511 |
}
|
1512 |
if ( strpos( $content, '<use ' ) ) {
|
1513 |
// Pre-empt rewriting of files within <use> tags, particularly to prevent security errors for SVGs.
|
1514 |
+
$content = preg_replace( '#(<use.+?href=["\'])(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)/' . $this->content_path . '/#is', '$1$2//' . $this->upload_domain . '$3/?wpcontent-bypass?/', $content );
|
1515 |
}
|
1516 |
// Pre-empt rewriting of wp-includes and wp-content if the extension is not allowed by using a temporary placeholder.
|
1517 |
+
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '([^"\'?>]+?)?/' . $this->content_path . '/([^"\'?>]+?)\.(htm|html|php|ashx|m4v|mov|wvm|qt|webm|ogv|mp4|m4p|mpg|mpeg|mpv)#i', '$1//' . $this->upload_domain . '$2/?wpcontent-bypass?/$3.$4', $content );
|
1518 |
// Pre-empt partial paths that are used by JS to build other URLs.
|
1519 |
+
$content = str_replace( $this->content_path . '/themes/jupiter"', '?wpcontent-bypass?/themes/jupiter"', $content );
|
1520 |
+
$content = str_replace( $this->content_path . '/plugins/onesignal-free-web-push-notifications/sdk_files/"', '?wpcontent-bypass?/plugins/onesignal-free-web-push-notifications/sdk_files/"', $content );
|
1521 |
+
$content = str_replace( $this->content_path . '/plugins/u-shortcodes/shortcodes/monthview/"', '?wpcontent-bypass?/plugins/u-shortcodes/shortcodes/monthview/"', $content );
|
1522 |
if (
|
1523 |
false !== strpos( $this->upload_domain, 'amazonaws.com' ) ||
|
1524 |
false !== strpos( $this->upload_domain, 'digitaloceanspaces.com' ) ||
|
1527 |
$this->debug_message( 'searching for #(https?:)?//(?:www\.)?' . $escaped_upload_domain . $this->remove_path . '/#i and replacing with $1//' . $this->exactdn_domain . '/' );
|
1528 |
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . $this->remove_path . '/#i', '$1//' . $this->exactdn_domain . '/', $content );
|
1529 |
} else {
|
1530 |
+
$this->debug_message( 'searching for #(https?:)?//(?:www\.)?' . $escaped_upload_domain . '/([^"\'?&>]+?)?(nextgen-image|' . $this->include_path . '|' . $this->content_path . ')/#i and replacing with $1//' . $this->exactdn_domain . '/$2$3/' );
|
1531 |
+
$content = preg_replace( '#(https?:)?//(?:www\.)?' . $escaped_upload_domain . '/([^"\'?>]+?)?(nextgen-image|' . $this->include_path . '|' . $this->content_path . ')/#i', '$1//' . $this->exactdn_domain . '/$2$3/', $content );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1532 |
}
|
1533 |
+
$content = str_replace( '?wpcontent-bypass?', $this->content_path, $content );
|
1534 |
}
|
1535 |
return $content;
|
1536 |
}
|
1546 |
if ( ! wp_doing_ajax() ) {
|
1547 |
return $allow;
|
1548 |
}
|
1549 |
+
if ( ! empty( $_REQUEST['action'] ) && 'alm_get_posts' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1550 |
+
return true;
|
1551 |
+
}
|
1552 |
if ( ! empty( $_POST['action'] ) && 'eddvbugm_viewport_downloads' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1553 |
return true;
|
1554 |
}
|
1555 |
+
if ( ! empty( $_POST['action'] ) && 'Essential_Grid_Front_request_ajax' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1556 |
return true;
|
1557 |
}
|
1558 |
if ( ! empty( $_POST['action'] ) && 'filter_listing' === $_POST['action'] && ! empty( $_POST['layout'] ) && ! empty( $_POST['paged'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1559 |
return true;
|
1560 |
}
|
1561 |
+
if ( ! empty( $_POST['action'] ) && 'mabel-rpn-getnew-purchased-products' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1562 |
return true;
|
1563 |
}
|
1564 |
+
if ( ! empty( $_POST['action'] ) && 'um_activity_load_wall' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1565 |
return true;
|
1566 |
}
|
1567 |
+
if ( ! empty( $_POST['action'] ) && 'vc_get_vc_grid_data' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1568 |
return true;
|
1569 |
}
|
1570 |
return $allow;
|
1684 |
}
|
1685 |
// Set this to true later when we know we have size meta.
|
1686 |
$has_size_meta = false;
|
1687 |
+
// To indicate whether or not we've already tried to get meta from the db.
|
1688 |
+
$got_meta = false;
|
1689 |
|
1690 |
if ( $image_url ) {
|
1691 |
// Check if image URL should be used with ExactDN.
|
1710 |
if ( 'full' === $size ) {
|
1711 |
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
1712 |
$intermediate = false;
|
1713 |
+
$got_meta = true;
|
1714 |
} elseif ( ! $image_meta ) {
|
1715 |
$this->debug_message( 'still do not have meta, getting it now' );
|
1716 |
// If we still don't have any image meta at this point, it's probably from a custom thumbnail size
|
1717 |
// for an image that was uploaded before the custom image was added to the theme. Try to determine the size manually.
|
1718 |
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
1719 |
+
$got_meta = true;
|
1720 |
|
1721 |
if ( isset( $image_meta['width'], $image_meta['height'] ) ) {
|
1722 |
$image_resized = image_resize_dimensions( $image_meta['width'], $image_meta['height'], $image_args['width'], $image_args['height'], $image_args['crop'] );
|
1747 |
$exactdn_args['w'] = $image_args['width'];
|
1748 |
}
|
1749 |
} else {
|
1750 |
+
if ( ! isset( $image_meta['sizes'] ) && empty( $got_meta ) ) {
|
1751 |
$size_meta = $image_meta;
|
1752 |
// Because we don't have the "real" meta, just the height/width for the specific size.
|
1753 |
$this->debug_message( 'getting attachment meta now' );
|
1785 |
$filename_width = $image_meta['width'] ? $image_meta['width'] : $filename_width;
|
1786 |
$filename_height = $image_meta['height'] ? $image_meta['height'] : $filename_height;
|
1787 |
if ( $filename_width && $filename_height && $image_args['width'] === $filename_width && $image_args['height'] === $filename_height ) {
|
1788 |
+
$this->debug_message( "changing $image_url to $intermediate_url" );
|
1789 |
$image_url = $intermediate_url;
|
1790 |
} else {
|
1791 |
$resize_existing = true;
|
2243 |
return $args;
|
2244 |
}
|
2245 |
// TST is not active.
|
2246 |
+
if ( ! defined( 'TST_VERSION' ) && ! defined( 'THEIA_SMART_THUMBNAILS_VERSION' ) ) {
|
2247 |
$this->debug_message( 'no TST plugin' );
|
2248 |
return $args;
|
2249 |
}
|
|
|
|
|
|
|
|
|
2250 |
if ( ! $meta || ! is_array( $meta ) || empty( $meta['sizes'] ) ) {
|
|
|
2251 |
$meta = wp_get_attachment_metadata( $attachment_id );
|
2252 |
+
if ( ! is_array( $meta ) || empty( $meta ) ) {
|
2253 |
$this->debug_message( 'unusable meta retrieved' );
|
2254 |
return $args;
|
2255 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2256 |
}
|
2257 |
+
if ( ! empty( $meta['tst_thumbnail_version'] ) ) {
|
2258 |
+
$args['theia_smart_thumbnails_file_version'] = (int) $meta['tst_thumbnail_version'];
|
2259 |
return $args;
|
2260 |
}
|
2261 |
+
$this->debug_message( 'no tst version in meta' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2262 |
return $args;
|
2263 |
}
|
2264 |
|
2656 |
return $skip;
|
2657 |
}
|
2658 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2659 |
/**
|
2660 |
* Converts a local script/css url to use ExactDN.
|
2661 |
*
|
2729 |
global $wp_version;
|
2730 |
// If a resource doesn't have a version string, we add one to help with cache-busting.
|
2731 |
if (
|
2732 |
+
false !== strpos( $url, $this->content_path . '/themes/' ) &&
|
2733 |
( empty( $parsed_url['query'] ) || 'ver=' . $wp_version === $parsed_url['query'] )
|
2734 |
) {
|
2735 |
$modified = $this->function_exists( 'filemtime' ) ? filemtime( get_template_directory() ) : '';
|
2743 |
*/
|
2744 |
$parsed_url['query'] = apply_filters( 'exactdn_version_string', "m=$modified" );
|
2745 |
} elseif (
|
2746 |
+
false !== strpos( $url, $this->content_path . '/plugins/' ) &&
|
2747 |
( empty( $parsed_url['query'] ) || 'ver=' . $wp_version === $parsed_url['query'] )
|
2748 |
) {
|
2749 |
$parsed_url['query'] = '';
|
2780 |
function generate_url( $image_url, $args = array(), $scheme = null ) {
|
2781 |
$this->debug_message( '<b>' . __METHOD__ . '()</b>' );
|
2782 |
$image_url = trim( $image_url );
|
2783 |
+
$this->debug_message( "starting with $image_url" );
|
2784 |
|
2785 |
if ( is_null( $scheme ) ) {
|
2786 |
$scheme = $this->scheme;
|
2797 |
* @param bool false default
|
2798 |
*/
|
2799 |
if ( true === apply_filters( 'exactdn_development_mode', false ) ) {
|
2800 |
+
$this->debug_message( 'skipping in dev mode' );
|
2801 |
return $image_url;
|
2802 |
}
|
2803 |
|
2810 |
* @param string|null $scheme URL scheme. Default to null.
|
2811 |
*/
|
2812 |
if ( true === apply_filters( 'exactdn_skip_for_url', false, $image_url, $args, $scheme ) ) {
|
2813 |
+
$this->debug_message( 'skipping via filter' );
|
2814 |
return $image_url;
|
2815 |
}
|
2816 |
|
2850 |
* @param string|null $scheme Image scheme. Default to null.
|
2851 |
*/
|
2852 |
$image_url = apply_filters( 'exactdn_pre_image_url', $image_url, $args, $scheme );
|
2853 |
+
$this->debug_message( "after exactdn_pre_image_url: $image_url" );
|
2854 |
|
2855 |
if ( empty( $image_url ) ) {
|
2856 |
return $image_url;
|
2895 |
}
|
2896 |
|
2897 |
$this->debug_message( $image_url_parts['host'] );
|
2898 |
+
$this->debug_message( $image_url_parts['path'] );
|
2899 |
|
2900 |
// Figure out which CDN (sub)domain to use.
|
2901 |
if ( empty( $this->exactdn_domain ) ) {
|
2922 |
|
2923 |
if ( $this->remove_path && 0 === strpos( $image_url_parts['path'], $this->remove_path ) ) {
|
2924 |
$image_url_parts['path'] = substr( $image_url_parts['path'], strlen( $this->remove_path ) );
|
2925 |
+
$this->debug_message( "trimming $this->remove_path from " . $image_url_parts['path'] );
|
2926 |
}
|
2927 |
$domain = 'http://' . $this->exactdn_domain . '/';
|
2928 |
$exactdn_url = $domain . ltrim( $image_url_parts['path'], '/' );
|
2939 |
if ( isset( $image_url_parts['query'] ) && apply_filters( 'exactdn_add_query_string_to_domain', false, $image_url_parts['host'] ) ) {
|
2940 |
$exactdn_url .= '?q=' . rawurlencode( $image_url_parts['query'] );
|
2941 |
}
|
2942 |
+
|
2943 |
+
// This makes sure we populate args with the existing TST image version.
|
2944 |
+
if ( ! empty( $image_url_parts['query'] ) && false !== strpos( $image_url_parts['query'], 'theia_smart' ) ) {
|
2945 |
$args = wp_parse_args( $image_url_parts['query'], $args );
|
2946 |
}
|
2947 |
|
common.php
CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
-
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
@@ -101,7 +101,7 @@ add_filter( 'myarcade_filter_thumbnail', 'ewww_image_optimizer_myarcade_thumbnai
|
|
101 |
// This filter turns off ewwwio_image_editor during save from the actual image editor and ensures that we parse the resizes list during the image editor save function.
|
102 |
add_filter( 'load_image_to_edit_path', 'ewww_image_optimizer_editor_save_pre' );
|
103 |
// Allows the user to override the default JPG quality used by WordPress.
|
104 |
-
add_filter( 'jpeg_quality', 'ewww_image_optimizer_set_jpg_quality' );
|
105 |
// Allows the user to override the default WebP quality used by EWWW IO.
|
106 |
add_filter( 'webp_quality', 'ewww_image_optimizer_set_webp_quality' );
|
107 |
// Prevent WP from over-riding EWWW IO's resize settings.
|
@@ -154,6 +154,10 @@ add_action( 'ewww_image_optimizer_auto', 'ewww_image_optimizer_auto' );
|
|
154 |
add_action( 'mfrh_path_renamed', 'ewww_image_optimizer_path_renamed', 10, 3 );
|
155 |
// Correct any records in the table created during retina generation.
|
156 |
add_action( 'wr2x_retina_file_added', 'ewww_image_optimizer_retina', 20, 2 );
|
|
|
|
|
|
|
|
|
157 |
// AJAX action hook for inserting WebP rewrite rules into .htaccess.
|
158 |
add_action( 'wp_ajax_ewww_webp_rewrite', 'ewww_image_optimizer_webp_rewrite' );
|
159 |
// AJAX action hook for removing WebP rewrite rules from .htaccess.
|
@@ -180,6 +184,8 @@ add_action( 'wp_head', 'ewww_image_optimizer_resize_detection_script' );
|
|
180 |
add_action( 'admin_bar_init', 'ewww_image_optimizer_admin_bar_init' );
|
181 |
// Non-AJAX handler to delete the API key, and reroute back to the settings page.
|
182 |
add_action( 'admin_action_ewww_image_optimizer_remove_cloud_key', 'ewww_image_optimizer_remove_cloud_key' );
|
|
|
|
|
183 |
// Non-AJAX handler to enable Force WebP for GIF files.
|
184 |
add_action( 'admin_action_ewww_image_optimizer_enable_force_gif2webp', 'ewww_image_optimizer_enable_force_gif2webp' );
|
185 |
// Non-AJAX handler to retest async/background mode.
|
@@ -190,8 +196,6 @@ add_action( 'admin_action_ewww_image_optimizer_view_debug_log', 'ewww_image_opti
|
|
190 |
add_action( 'admin_action_ewww_image_optimizer_delete_debug_log', 'ewww_image_optimizer_delete_debug_log' );
|
191 |
// Check if WebP option was turned off and is now enabled.
|
192 |
add_filter( 'pre_update_option_ewww_image_optimizer_webp', 'ewww_image_optimizer_webp_maybe_enabled', 10, 2 );
|
193 |
-
// Check if JS WebP option has just been enabled and see if Force WebP is needed for WP Offload Media.
|
194 |
-
add_filter( 'pre_update_option_ewww_image_optimizer_webp_for_cdn', 'ewww_image_optimizer_webp_cdn_check_force', 10, 2 );
|
195 |
// Check Scheduled Opt option has just been disabled and clear the queues/stop the process.
|
196 |
add_filter( 'pre_update_option_ewww_image_optimizer_auto', 'ewww_image_optimizer_scheduled_optimizaton_changed', 10, 2 );
|
197 |
// Makes sure to flush out any scheduled jobs on deactivation.
|
@@ -261,7 +265,8 @@ function ewww_image_optimizer_parser_init() {
|
|
261 |
* Alt WebP class for parsing image urls and rewriting them for WebP support.
|
262 |
*/
|
263 |
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-eio-alt-webp.php' );
|
264 |
-
}
|
|
|
265 |
$buffer_start = true;
|
266 |
/**
|
267 |
* Page Parsing class for working with HTML content.
|
@@ -326,6 +331,64 @@ function ewww_image_optimizer_get_plugin_version( $plugin_file ) {
|
|
326 |
return $plugin_data;
|
327 |
}
|
328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
/**
|
330 |
* Checks to see if the WebP option from the Cache Enabler plugin is enabled.
|
331 |
*
|
@@ -495,6 +558,163 @@ function ewww_image_optimizer_function_exists( $function, $debug = false ) {
|
|
495 |
return function_exists( $function );
|
496 |
}
|
497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
/**
|
499 |
* Runs on 'plugins_loaded' to make make sure the language files are loaded early.
|
500 |
*/
|
@@ -521,14 +741,16 @@ function ewww_image_optimizer_init() {
|
|
521 |
if ( ! empty( $_GET['enable-local'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
522 |
update_option( 'ewww_image_optimizer_local_mode', true );
|
523 |
update_site_option( 'ewww_image_optimizer_local_mode', true );
|
524 |
-
} elseif ( isset( $_GET['enable-local'] ) && ! (bool) $_GET['enable-local'] && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' )
|
525 |
delete_option( 'ewww_image_optimizer_local_mode', true );
|
526 |
delete_site_option( 'ewww_image_optimizer_local_mode', true );
|
527 |
-
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
528 |
-
ewww_image_optimizer_remove_cloud_key();
|
529 |
-
}
|
530 |
}
|
531 |
-
|
|
|
|
|
|
|
|
|
|
|
532 |
// Resizes and auto-rotates images.
|
533 |
add_filter( 'wp_handle_upload', 'ewww_image_optimizer_handle_upload' );
|
534 |
if ( class_exists( 'S3_Uploads' ) ) {
|
@@ -654,6 +876,10 @@ function ewww_image_optimizer_upgrade() {
|
|
654 |
add_option( 'ewww_image_optimizer_review_time', $review_time, '', false );
|
655 |
add_site_option( 'ewww_image_optimizer_review_time', $review_time );
|
656 |
}
|
|
|
|
|
|
|
|
|
657 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
658 |
if ( 'external' === get_option( 'elementor_css_print_method' ) ) {
|
659 |
update_option( 'elementor_css_print_method', 'internal' );
|
@@ -736,206 +962,71 @@ function ewww_image_optimizer_admin_init() {
|
|
736 |
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'mwebp.php' );
|
737 |
ewww_image_optimizer_cloud_init();
|
738 |
ewww_image_optimizer_upgrade();
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
$ewww_image_optimizer_enable_cloudinary = ( empty( $_POST['ewww_image_optimizer_enable_cloudinary'] ) ? false : true );
|
799 |
-
update_site_option( 'ewww_image_optimizer_enable_cloudinary', $ewww_image_optimizer_enable_cloudinary );
|
800 |
-
$ewww_image_optimizer_exactdn = ( empty( $_POST['ewww_image_optimizer_exactdn'] ) ? false : true );
|
801 |
-
update_site_option( 'ewww_image_optimizer_exactdn', $ewww_image_optimizer_exactdn );
|
802 |
-
$exactdn_all_the_things = ( empty( $_POST['exactdn_all_the_things'] ) ? false : true );
|
803 |
-
update_site_option( 'exactdn_all_the_things', $exactdn_all_the_things );
|
804 |
-
$exactdn_lossy = ( empty( $_POST['exactdn_lossy'] ) ? false : true );
|
805 |
-
update_site_option( 'exactdn_lossy', $exactdn_lossy );
|
806 |
-
$exactdn_exclude = empty( $_POST['exactdn_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['exactdn_exclude'] ) );
|
807 |
-
update_site_option( 'exactdn_exclude', ewww_image_optimizer_exclude_paths_sanitize( $exactdn_exclude ) );
|
808 |
-
$ewww_image_optimizer_lazy_load = ( empty( $_POST['ewww_image_optimizer_lazy_load'] ) ? false : true );
|
809 |
-
update_site_option( 'ewww_image_optimizer_lazy_load', $ewww_image_optimizer_lazy_load );
|
810 |
-
$ewww_image_optimizer_use_lqip = ( empty( $_POST['ewww_image_optimizer_use_lqip'] ) ? false : true );
|
811 |
-
update_site_option( 'ewww_image_optimizer_use_lqip', $ewww_image_optimizer_use_lqip );
|
812 |
-
$ewww_image_optimizer_ll_exclude = empty( $_POST['ewww_image_optimizer_ll_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_ll_exclude'] ) );
|
813 |
-
update_site_option( 'ewww_image_optimizer_ll_exclude', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_ll_exclude ) );
|
814 |
-
$ewww_image_optimizer_maxmediawidth = empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ? 0 : (int) $_POST['ewww_image_optimizer_maxmediawidth'];
|
815 |
-
update_site_option( 'ewww_image_optimizer_maxmediawidth', $ewww_image_optimizer_maxmediawidth );
|
816 |
-
$ewww_image_optimizer_maxmediaheight = empty( $_POST['ewww_image_optimizer_maxmediaheight'] ) ? 0 : (int) $_POST['ewww_image_optimizer_maxmediaheight'];
|
817 |
-
update_site_option( 'ewww_image_optimizer_maxmediaheight', $ewww_image_optimizer_maxmediaheight );
|
818 |
-
$ewww_image_optimizer_resize_detection = ( empty( $_POST['ewww_image_optimizer_resize_detection'] ) ? false : true );
|
819 |
-
update_site_option( 'ewww_image_optimizer_resize_detection', $ewww_image_optimizer_resize_detection );
|
820 |
-
$ewww_image_optimizer_resize_existing = ( empty( $_POST['ewww_image_optimizer_resize_existing'] ) ? false : true );
|
821 |
-
update_site_option( 'ewww_image_optimizer_resize_existing', $ewww_image_optimizer_resize_existing );
|
822 |
-
$ewww_image_optimizer_resize_other_existing = ( empty( $_POST['ewww_image_optimizer_resize_other_existing'] ) ? false : true );
|
823 |
-
update_site_option( 'ewww_image_optimizer_resize_other_existing', $ewww_image_optimizer_resize_other_existing );
|
824 |
-
$ewww_image_optimizer_parallel_optimization = ( empty( $_POST['ewww_image_optimizer_parallel_optimization'] ) ? false : true );
|
825 |
-
update_site_option( 'ewww_image_optimizer_parallel_optimization', $ewww_image_optimizer_parallel_optimization );
|
826 |
-
$ewww_image_optimizer_include_media_paths = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
|
827 |
-
update_site_option( 'ewww_image_optimizer_include_media_paths', $ewww_image_optimizer_include_media_paths );
|
828 |
-
$ewww_image_optimizer_include_originals = ( empty( $_POST['ewww_image_optimizer_include_originals'] ) ? false : true );
|
829 |
-
update_site_option( 'ewww_image_optimizer_include_originals', $ewww_image_optimizer_include_originals );
|
830 |
-
$ewww_image_optimizer_webp_for_cdn = ( empty( $_POST['ewww_image_optimizer_webp_for_cdn'] ) ? false : true );
|
831 |
-
update_site_option( 'ewww_image_optimizer_webp_for_cdn', $ewww_image_optimizer_webp_for_cdn );
|
832 |
-
$ewww_image_optimizer_picture_webp = ( empty( $_POST['ewww_image_optimizer_picture_webp'] ) ? false : true );
|
833 |
-
update_site_option( 'ewww_image_optimizer_picture_webp', $ewww_image_optimizer_picture_webp );
|
834 |
-
$ewww_image_optimizer_webp_rewrite_exclude = empty( $_POST['ewww_image_optimizer_webp_rewrite_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_webp_rewrite_exclude'] ) );
|
835 |
-
update_site_option( 'ewww_image_optimizer_webp_rewrite_exclude', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_webp_rewrite_exclude ) );
|
836 |
-
$ewww_image_optimizer_webp_force = ( empty( $_POST['ewww_image_optimizer_webp_force'] ) ? false : true );
|
837 |
-
update_site_option( 'ewww_image_optimizer_webp_force', $ewww_image_optimizer_webp_force );
|
838 |
-
$ewww_image_optimizer_webp_paths = ( empty( $_POST['ewww_image_optimizer_webp_paths'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_webp_paths'] ) ) );
|
839 |
-
update_site_option( 'ewww_image_optimizer_webp_paths', ewww_image_optimizer_webp_paths_sanitize( $ewww_image_optimizer_webp_paths ) );
|
840 |
-
$ewww_image_optimizer_allow_multisite_override = empty( $_POST['ewww_image_optimizer_allow_multisite_override'] ) ? false : true;
|
841 |
-
update_site_option( 'ewww_image_optimizer_allow_multisite_override', $ewww_image_optimizer_allow_multisite_override );
|
842 |
-
$ewww_image_optimizer_enable_help = empty( $_POST['ewww_image_optimizer_enable_help'] ) ? false : true;
|
843 |
-
update_site_option( 'ewww_image_optimizer_enable_help', $ewww_image_optimizer_enable_help );
|
844 |
-
global $ewwwio_tracking;
|
845 |
-
$ewww_image_optimizer_allow_tracking = empty( $_POST['ewww_image_optimizer_allow_tracking'] ) ? false : $ewwwio_tracking->check_for_settings_optin( (bool) $_POST['ewww_image_optimizer_allow_tracking'] );
|
846 |
-
update_site_option( 'ewww_image_optimizer_allow_tracking', $ewww_image_optimizer_allow_tracking );
|
847 |
-
add_action( 'network_admin_notices', 'ewww_image_optimizer_network_settings_saved' );
|
848 |
-
} elseif (
|
849 |
-
isset( $_POST['ewww_image_optimizer_allow_multisite_override_active'] ) &&
|
850 |
-
current_user_can( 'manage_network_options' ) &&
|
851 |
-
isset( $_REQUEST['_wpnonce'] ) &&
|
852 |
-
wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' )
|
853 |
-
) {
|
854 |
-
ewwwio_debug_message( 'network-wide settings, single-site overriding' );
|
855 |
-
$ewww_image_optimizer_allow_multisite_override = empty( $_POST['ewww_image_optimizer_allow_multisite_override'] ) ? false : true;
|
856 |
-
update_site_option( 'ewww_image_optimizer_allow_multisite_override', $ewww_image_optimizer_allow_multisite_override );
|
857 |
-
global $ewwwio_tracking;
|
858 |
-
$ewww_image_optimizer_allow_tracking = empty( $_POST['ewww_image_optimizer_allow_tracking'] ) ? false : $ewwwio_tracking->check_for_settings_optin( (bool) $_POST['ewww_image_optimizer_allow_tracking'] );
|
859 |
-
update_site_option( 'ewww_image_optimizer_allow_tracking', $ewww_image_optimizer_allow_tracking );
|
860 |
-
add_action( 'network_admin_notices', 'ewww_image_optimizer_network_settings_saved' );
|
861 |
-
} // End if().
|
862 |
-
} // End if().
|
863 |
-
if ( is_multisite() && get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) &&
|
864 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) &&
|
865 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) &&
|
866 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) &&
|
867 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) &&
|
868 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' )
|
869 |
-
) {
|
870 |
-
ewww_image_optimizer_set_defaults();
|
871 |
-
update_option( 'ewww_image_optimizer_disable_pngout', true );
|
872 |
-
update_option( 'ewww_image_optimizer_disable_svgcleaner', true );
|
873 |
-
update_option( 'ewww_image_optimizer_optipng_level', 2 );
|
874 |
-
update_option( 'ewww_image_optimizer_pngout_level', 2 );
|
875 |
-
update_option( 'ewww_image_optimizer_metadata_remove', true );
|
876 |
-
update_option( 'ewww_image_optimizer_jpg_level', '10' );
|
877 |
-
update_option( 'ewww_image_optimizer_png_level', '10' );
|
878 |
-
update_option( 'ewww_image_optimizer_gif_level', '10' );
|
879 |
-
update_option( 'ewww_image_optimizer_svg_level', 0 );
|
880 |
-
}
|
881 |
-
// Register all the common EWWW IO settings.
|
882 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_cloud_key', 'ewww_image_optimizer_cloud_key_sanitize' );
|
883 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
|
884 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_metadata_remove', 'boolval' );
|
885 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
|
886 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_level', 'intval' );
|
887 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_level', 'intval' );
|
888 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pdf_level', 'intval' );
|
889 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_svg_level', 'intval' );
|
890 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_backup_files', 'boolval' );
|
891 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_cloudinary', 'boolval' );
|
892 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_quality', 'ewww_image_optimizer_jpg_quality' );
|
893 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_quality', 'ewww_image_optimizer_webp_quality' );
|
894 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
|
895 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
|
896 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
|
897 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_originals', 'boolval' );
|
898 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_aux_paths', 'ewww_image_optimizer_aux_paths_sanitize' );
|
899 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exclude_paths', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
900 |
-
global $ewwwio_tracking;
|
901 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_allow_tracking', array( $ewwwio_tracking, 'check_for_settings_optin' ) );
|
902 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_help', 'boolval' );
|
903 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exactdn', 'boolval' );
|
904 |
-
register_setting( 'ewww_image_optimizer_options', 'exactdn_all_the_things', 'boolval' );
|
905 |
-
register_setting( 'ewww_image_optimizer_options', 'exactdn_lossy', 'boolval' );
|
906 |
-
register_setting( 'ewww_image_optimizer_options', 'exactdn_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
907 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_lazy_load', 'boolval' );
|
908 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_use_lqip', 'boolval' );
|
909 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
910 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_detection', 'boolval' );
|
911 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediawidth', 'intval' );
|
912 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediaheight', 'intval' );
|
913 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_existing', 'boolval' );
|
914 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_other_existing', 'boolval' );
|
915 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
916 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes_opt', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
917 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_convert_links', 'boolval' );
|
918 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_delete_originals', 'boolval' );
|
919 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_to_png', 'boolval' );
|
920 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_to_jpg', 'boolval' );
|
921 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_to_png', 'boolval' );
|
922 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_background', 'ewww_image_optimizer_jpg_background' );
|
923 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp', 'boolval' );
|
924 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_force', 'boolval' );
|
925 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_paths', 'ewww_image_optimizer_webp_paths_sanitize' );
|
926 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_for_cdn', 'boolval' );
|
927 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_picture_webp', 'boolval' );
|
928 |
-
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_rewrite_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
929 |
-
ewww_image_optimizer_exec_init();
|
930 |
-
ewww_image_optimizer_cron_setup( 'ewww_image_optimizer_auto' );
|
931 |
-
// Queue the function that contains custom styling for our progressbars.
|
932 |
-
add_action( 'admin_enqueue_scripts', 'ewww_image_optimizer_progressbar_style' );
|
933 |
-
if ( defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD_KEY' ) && get_option( 'ewww_image_optimizer_cloud_key_invalid' ) ) {
|
934 |
-
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_invalid_key' );
|
935 |
-
add_action( 'admin_notices', 'ewww_image_optimizer_notice_invalid_key' );
|
936 |
}
|
937 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_enabled' ) ) {
|
938 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_webp_bulk' );
|
|
|
|
|
|
|
939 |
}
|
940 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_auto' ) && ! ewww_image_optimizer_background_mode_enabled() ) {
|
941 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_schedule_noasync' );
|
@@ -946,12 +1037,12 @@ function ewww_image_optimizer_admin_init() {
|
|
946 |
}
|
947 |
// Prevent ShortPixel AIO messiness.
|
948 |
remove_action( 'admin_notices', 'autoptimizeMain::notice_plug_imgopt' );
|
949 |
-
if ( class_exists( 'autoptimizeExtra' ) ) {
|
950 |
-
$ao_extra = get_option( '
|
951 |
-
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! empty( $ao_extra['
|
952 |
ewwwio_debug_message( 'detected ExactDN + SP conflict' );
|
953 |
-
$ao_extra['
|
954 |
-
update_option( '
|
955 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_exactdn_sp_conflict' );
|
956 |
}
|
957 |
}
|
@@ -966,6 +1057,10 @@ function ewww_image_optimizer_admin_init() {
|
|
966 |
} else {
|
967 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_media_listmode' );
|
968 |
}
|
|
|
|
|
|
|
|
|
969 |
|
970 |
// Alert user if multiple re-optimizations detected.
|
971 |
if ( ! defined( 'EWWWIO_DISABLE_REOPT_NOTICE' ) ) {
|
@@ -981,22 +1076,22 @@ function ewww_image_optimizer_admin_init() {
|
|
981 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_review' );
|
982 |
add_action( 'admin_footer', 'ewww_image_optimizer_notice_review_script' );
|
983 |
}
|
984 |
-
if ( ! empty( $_GET['page'] ) ) {
|
985 |
-
if ( 'regenerate-thumbnails' === $_GET['page']
|
986 |
-
|| 'force-regenerate-thumbnails' === $_GET['page']
|
987 |
-
|| 'ajax-thumbnail-rebuild' === $_GET['page']
|
988 |
-
|| 'regenerate_thumbnails_advanced' === $_GET['page']
|
989 |
-
|| 'rta_generate_thumbnails' === $_GET['page']
|
990 |
) {
|
991 |
// Add a notice for thumb regeneration.
|
992 |
add_action( 'admin_notices', 'ewww_image_optimizer_thumbnail_regen_notice' );
|
993 |
}
|
994 |
}
|
995 |
-
if ( ! empty( $_GET['ewww_pngout'] ) ) {
|
996 |
add_action( 'admin_notices', 'ewww_image_optimizer_pngout_installed' );
|
997 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_pngout_installed' );
|
998 |
}
|
999 |
-
if ( ! empty( $_GET['ewww_svgcleaner'] ) ) {
|
1000 |
add_action( 'admin_notices', 'ewww_image_optimizer_svgcleaner_installed' );
|
1001 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_svgcleaner_installed' );
|
1002 |
}
|
@@ -1440,11 +1535,21 @@ function ewww_image_optimizer_install_table() {
|
|
1440 |
// See if the path column exists, and what collation it uses to determine the column index size.
|
1441 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ewwwio_images'" ) === $wpdb->ewwwio_images ) {
|
1442 |
ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
|
1443 |
-
|
1444 |
-
|
|
|
1445 |
}
|
1446 |
-
|
1447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1448 |
}
|
1449 |
// Check if the old path_image_size index exists, and drop it.
|
1450 |
if ( $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'path_image_size'", ARRAY_A ) ) {
|
@@ -1707,22 +1812,30 @@ function ewww_image_optimizer_webp_maybe_enabled( $new_value, $old_value ) {
|
|
1707 |
}
|
1708 |
|
1709 |
/**
|
1710 |
-
* Checks
|
1711 |
*
|
1712 |
-
* @
|
1713 |
-
* @param mixed $old_value The old value, also a boolean generally.
|
1714 |
-
* @return mixed The new value, unaltered.
|
1715 |
*/
|
1716 |
-
function
|
1717 |
-
if (
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1722 |
}
|
1723 |
}
|
1724 |
}
|
1725 |
-
return
|
1726 |
}
|
1727 |
|
1728 |
/**
|
@@ -1807,6 +1920,7 @@ function ewww_image_optimizer_svgcleaner_installed() {
|
|
1807 |
* Display a notice that we could not activate an ExactDN domain.
|
1808 |
*/
|
1809 |
function ewww_image_optimizer_notice_exactdn_activation_error() {
|
|
|
1810 |
global $exactdn_activate_error;
|
1811 |
if ( empty( $exactdn_activate_error ) ) {
|
1812 |
$exactdn_activate_error = 'error unknown';
|
@@ -1825,11 +1939,12 @@ function ewww_image_optimizer_notice_exactdn_activation_error() {
|
|
1825 |
* Let the user know ExactDN setup was successful.
|
1826 |
*/
|
1827 |
function ewww_image_optimizer_notice_exactdn_activation_success() {
|
|
|
1828 |
?>
|
1829 |
<div id="ewww-image-optimizer-notice-exactdn-success" class="notice notice-success"><p>
|
1830 |
<strong><?php esc_html_e( 'Easy IO setup and verification is complete.', 'ewww-image-optimizer' ); ?></strong>
|
1831 |
<?php esc_html_e( 'If you have problems, try disabling Lazy Load and Include All Resources. Finally, disable Easy IO if problems remain.', 'ewww-image-optimizer' ); ?><br>
|
1832 |
-
<a class='ewww-
|
1833 |
<?php esc_html_e( 'Then, let us know so we can find a fix for the problem.', 'ewww-image-optimizer' ); ?>
|
1834 |
</a>
|
1835 |
</p></div>
|
@@ -1860,7 +1975,7 @@ function ewww_image_optimizer_notice_exactdn_domain_mismatch() {
|
|
1860 |
printf(
|
1861 |
/* translators: %s: settings page */
|
1862 |
esc_html__( 'Please visit the %s to refresh the Easy IO settings and verify activation status.', 'ewww-image-optimizer' ),
|
1863 |
-
'<a href="' . esc_url(
|
1864 |
);
|
1865 |
?>
|
1866 |
</p>
|
@@ -2550,6 +2665,24 @@ function ewww_image_optimizer_auto() {
|
|
2550 |
return;
|
2551 |
}
|
2552 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2553 |
/**
|
2554 |
* Clears scheduled jobs for multisite when the plugin is deactivated.
|
2555 |
*
|
@@ -2604,24 +2737,6 @@ function ewww_image_optimizer_network_admin_menu() {
|
|
2604 |
}
|
2605 |
}
|
2606 |
|
2607 |
-
/**
|
2608 |
-
* Simulates regenerating a resize for an attachment.
|
2609 |
-
*/
|
2610 |
-
function ewww_image_optimizer_resize_dup_check() {
|
2611 |
-
$meta = wp_get_attachment_metadata( 34 );
|
2612 |
-
|
2613 |
-
list( $file, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, 34 );
|
2614 |
-
|
2615 |
-
$editor = wp_get_image_editor( $file );
|
2616 |
-
$resized_image = $editor->resize( 150, 150, true );
|
2617 |
-
$new_file = $editor->generate_filename();
|
2618 |
-
echo esc_html( $new_file );
|
2619 |
-
if ( ewwwio_is_file( $new_file ) ) {
|
2620 |
-
echo '<br>file already exists<br>';
|
2621 |
-
}
|
2622 |
-
$saved = $editor->save( $new_file );
|
2623 |
-
}
|
2624 |
-
|
2625 |
/**
|
2626 |
* Adds various items to the admin menu.
|
2627 |
*/
|
@@ -2746,13 +2861,12 @@ function ewww_image_optimizer_media_scripts( $hook ) {
|
|
2746 |
if ( 'upload.php' === $hook || 'ims_gallery_page_ewww-ims-optimize' === $hook ) {
|
2747 |
add_thickbox();
|
2748 |
wp_enqueue_script( 'jquery-ui-tooltip' );
|
2749 |
-
wp_enqueue_script( '
|
2750 |
wp_enqueue_style( 'jquery-ui-tooltip-custom', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ), array(), EWWW_IMAGE_OPTIMIZER_VERSION );
|
2751 |
// Submit a couple variables to the javascript to work with.
|
2752 |
-
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
2753 |
$loading_image = plugins_url( '/images/spinner.gif', __FILE__ );
|
2754 |
wp_localize_script(
|
2755 |
-
'
|
2756 |
'ewww_vars',
|
2757 |
array(
|
2758 |
'optimizing' => '<p>' . esc_html__( 'Optimizing', 'ewww-image-optimizer' ) . " <img src='$loading_image' /></p>",
|
@@ -2763,25 +2877,34 @@ function ewww_image_optimizer_media_scripts( $hook ) {
|
|
2763 |
}
|
2764 |
|
2765 |
/**
|
2766 |
-
*
|
2767 |
*
|
2768 |
-
* @
|
2769 |
-
* @return array The new list of links to be displayed.
|
2770 |
*/
|
2771 |
-
function
|
2772 |
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
2773 |
// Need to include the plugin library for the is_plugin_active function.
|
2774 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
2775 |
}
|
2776 |
-
if ( ! is_array( $links ) ) {
|
2777 |
-
$links = array();
|
2778 |
-
}
|
2779 |
// Load the html for the settings link.
|
2780 |
-
if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
2781 |
-
|
2782 |
} else {
|
2783 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2784 |
}
|
|
|
2785 |
// Load the settings link into the plugin links array.
|
2786 |
array_unshift( $links, $settings_link );
|
2787 |
// Send back the plugin links array.
|
@@ -4025,21 +4148,59 @@ function ewww_image_optimizer_media_replace( $image ) {
|
|
4025 |
}
|
4026 |
|
4027 |
/**
|
4028 |
-
*
|
4029 |
-
*
|
4030 |
-
* @param string $key An API key entered by the user.
|
4031 |
-
* @return string A sanitized and validated API key.
|
4032 |
*/
|
4033 |
-
function
|
4034 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4035 |
-
$
|
4036 |
-
|
4037 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4038 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4039 |
if ( empty( $key ) ) {
|
4040 |
return '';
|
4041 |
}
|
4042 |
-
if ( ewww_image_optimizer_cloud_verify(
|
4043 |
add_settings_error( 'ewww_image_optimizer_cloud_key', 'ewwwio-cloud-key', esc_html__( 'Successfully validated API key, happy optimizing!', 'ewww-image-optimizer' ), 'updated' );
|
4044 |
ewwwio_debug_message( 'sanitize (verification) successful' );
|
4045 |
ewwwio_memory( __FUNCTION__ );
|
@@ -4054,6 +4215,66 @@ function ewww_image_optimizer_cloud_key_sanitize( $key ) {
|
|
4054 |
}
|
4055 |
}
|
4056 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4057 |
/**
|
4058 |
* Checks to see if all images should be processed via the API.
|
4059 |
*
|
@@ -4099,19 +4320,13 @@ function ewww_image_optimizer_cloud_useragent( $useragent ) {
|
|
4099 |
*
|
4100 |
* @global object $ewwwio_async_key_verification
|
4101 |
*
|
|
|
4102 |
* @param bool $cache Optional. True to return cached verification results. Default true.
|
4103 |
-
* @param string $api_key Optional. The API key to verify. Default empty string.
|
4104 |
* @return string|bool False if verification fails, status message otherwise: great/exceeded.
|
4105 |
*/
|
4106 |
-
function ewww_image_optimizer_cloud_verify( $
|
4107 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4108 |
$sanitize = false;
|
4109 |
-
if ( ! empty( $api_key ) ) {
|
4110 |
-
$sanitize = true;
|
4111 |
-
}
|
4112 |
-
if ( empty( $api_key ) ) {
|
4113 |
-
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
4114 |
-
}
|
4115 |
if ( empty( $api_key ) ) {
|
4116 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 ) {
|
4117 |
update_site_option( 'ewww_image_optimizer_jpg_level', 10 );
|
@@ -4134,7 +4349,6 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
4134 |
ewwwio_debug_message( 'license exceeded notice has not expired' );
|
4135 |
return 'exceeded';
|
4136 |
}
|
4137 |
-
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
4138 |
$ewww_cloud_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
4139 |
if ( ! ewww_image_optimizer_detect_wpsf_location_lock() && $cache && preg_match( '/great/', $ewww_cloud_status ) ) {
|
4140 |
ewwwio_debug_message( 'using cached verification' );
|
@@ -4168,14 +4382,14 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
4168 |
if ( preg_match( '/exceeded/', $verified ) ) {
|
4169 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', time() + 300 );
|
4170 |
}
|
4171 |
-
if (
|
4172 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', '' );
|
4173 |
}
|
4174 |
ewwwio_debug_message( "verification success via: $url" );
|
4175 |
delete_option( 'ewww_image_optimizer_cloud_key_invalid' );
|
4176 |
} else {
|
4177 |
update_option( 'ewww_image_optimizer_cloud_key_invalid', true, false );
|
4178 |
-
if ( !
|
4179 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', '' );
|
4180 |
}
|
4181 |
ewwwio_debug_message( "verification failed via: $url" );
|
@@ -4205,6 +4419,7 @@ function ewww_image_optimizer_cloud_verify( $cache = true, $api_key = '' ) {
|
|
4205 |
* @return array The results of the http POST request.
|
4206 |
*/
|
4207 |
function ewww_image_optimizer_cloud_post_key( $url, $key ) {
|
|
|
4208 |
$result = wp_remote_post(
|
4209 |
$url,
|
4210 |
array(
|
@@ -4222,7 +4437,7 @@ function ewww_image_optimizer_cloud_post_key( $url, $key ) {
|
|
4222 |
* Let the user know their key is invalid.
|
4223 |
*/
|
4224 |
function ewww_image_optimizer_notice_invalid_key() {
|
4225 |
-
echo "<div id='ewww-image-optimizer-invalid-key' class='notice error'><p><strong>" . esc_html__( 'Could not validate EWWW Image Optimizer API key, please check your key to ensure it is correct.', 'ewww-image-optimizer' ) . '</strong></p></div>';
|
4226 |
}
|
4227 |
|
4228 |
/**
|
@@ -4266,7 +4481,13 @@ function ewww_image_optimizer_cloud_quota( $raw = false ) {
|
|
4266 |
if ( $raw ) {
|
4267 |
return $quota;
|
4268 |
}
|
4269 |
-
if ( ! $quota['
|
|
|
|
|
|
|
|
|
|
|
|
|
4270 |
return sprintf(
|
4271 |
/* translators: 1: Number of images 2: Number of days until renewal */
|
4272 |
_n( 'optimized %1$d images, renewal is in %2$d day.', 'optimized %1$d images, renewal is in %2$d days.', $quota['days'], 'ewww-image-optimizer' ),
|
@@ -4339,9 +4560,10 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
4339 |
ewww_image_optimizer_debug_log();
|
4340 |
}
|
4341 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
|
|
4342 |
if ( preg_match( '/exceeded/', $ewww_status ) ) {
|
4343 |
$started = microtime( true );
|
4344 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
4345 |
return array( $file, false, 'key verification failed', 0, '' );
|
4346 |
}
|
4347 |
// Calculate how much time has elapsed since we started.
|
@@ -4450,8 +4672,15 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
4450 |
ewwwio_debug_message( "jpg fill: $jpg_fill" );
|
4451 |
ewwwio_debug_message( "jpg quality: $jpg_quality" );
|
4452 |
$free_exec = EWWW_IMAGE_OPTIMIZER_NOEXEC && 'image/jpeg' === $type;
|
4453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
4454 |
if ( empty( $api_key ) && ! $free_exec ) {
|
|
|
4455 |
return array( $file, false, 'key verification failed', 0, '' );
|
4456 |
}
|
4457 |
$url = 'http://optimize.exactlywww.com/v2/';
|
@@ -4580,10 +4809,14 @@ function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
|
|
4580 |
}
|
4581 |
ewww_image_optimizer_debug_log();
|
4582 |
}
|
|
|
|
|
|
|
|
|
4583 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
4584 |
$started = microtime( true );
|
4585 |
if ( preg_match( '/exceeded/', $ewww_status ) ) {
|
4586 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
4587 |
ewwwio_debug_message( 'cloud verify failed, image not rotated' );
|
4588 |
return false;
|
4589 |
}
|
@@ -4600,10 +4833,6 @@ function ewww_image_optimizer_cloud_autorotate( $file, $type ) {
|
|
4600 |
ewwwio_get_filesystem();
|
4601 |
ewwwio_debug_message( "file: $file " );
|
4602 |
ewwwio_debug_message( "type: $type" );
|
4603 |
-
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
4604 |
-
if ( empty( $api_key ) ) {
|
4605 |
-
return false;
|
4606 |
-
}
|
4607 |
$url = 'http://optimize.exactlywww.com/rotate/';
|
4608 |
$ssl = wp_http_supports( array( 'ssl' ) );
|
4609 |
if ( $ssl ) {
|
@@ -4709,7 +4938,7 @@ function ewww_image_optimizer_cloud_backup( $file ) {
|
|
4709 |
}
|
4710 |
ewww_image_optimizer_debug_log();
|
4711 |
}
|
4712 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
4713 |
ewwwio_debug_message( 'cloud verify failed, image not backed up' );
|
4714 |
return false;
|
4715 |
}
|
@@ -4823,10 +5052,14 @@ function ewww_image_optimizer_cloud_resize( $file, $type, $dst_x, $dst_y, $src_x
|
|
4823 |
}
|
4824 |
ewww_image_optimizer_debug_log();
|
4825 |
}
|
|
|
|
|
|
|
|
|
4826 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
4827 |
$started = microtime( true );
|
4828 |
if ( false !== strpos( $ewww_status, 'exceeded' ) ) {
|
4829 |
-
if ( ! ewww_image_optimizer_cloud_verify() ) {
|
4830 |
ewwwio_debug_message( 'cloud verify failed, image not resized' );
|
4831 |
return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
|
4832 |
}
|
@@ -4844,10 +5077,6 @@ function ewww_image_optimizer_cloud_resize( $file, $type, $dst_x, $dst_y, $src_x
|
|
4844 |
ewwwio_debug_message( "file: $file " );
|
4845 |
ewwwio_debug_message( "width: $dst_w" );
|
4846 |
ewwwio_debug_message( "height: $dst_h" );
|
4847 |
-
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
4848 |
-
if ( empty( $api_key ) ) {
|
4849 |
-
return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
|
4850 |
-
}
|
4851 |
$url = 'http://optimize.exactlywww.com/resize/';
|
4852 |
$ssl = wp_http_supports( array( 'ssl' ) );
|
4853 |
if ( $ssl ) {
|
@@ -5490,7 +5719,7 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
|
|
5490 |
if ( $cli ) {
|
5491 |
WP_CLI::error( __( 'License Exceeded', 'ewww-image-optimizer' ) );
|
5492 |
}
|
5493 |
-
|
5494 |
}
|
5495 |
if ( ! $auto ) {
|
5496 |
// Output the path.
|
@@ -5516,9 +5745,7 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
|
|
5516 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
5517 |
$output['next_file'] = '<p>' . esc_html__( 'Optimizing', 'ewww-image-optimizer' ) . ' <b>' . esc_html( $next_file ) . "</b> <img src='$loading_image' alt='loading' /></p>";
|
5518 |
}
|
5519 |
-
|
5520 |
-
ewwwio_memory( __FUNCTION__ );
|
5521 |
-
wp_die();
|
5522 |
}
|
5523 |
if ( $cli ) {
|
5524 |
return $results[1];
|
@@ -6264,19 +6491,23 @@ function ewww_image_optimizer_autoconvert( $file ) {
|
|
6264 |
wp_raise_memory_limit( 'image' );
|
6265 |
}
|
6266 |
$type = ewww_image_optimizer_mimetype( $file, 'i' );
|
6267 |
-
if ( 'image/png' !== $type ) {
|
6268 |
ewwwio_debug_message( 'not a PNG, no conversion needed' );
|
6269 |
return;
|
6270 |
}
|
6271 |
$orig_size = ewww_image_optimizer_filesize( $file );
|
6272 |
-
if ( $orig_size < apply_filters( 'ewww_image_optimizer_autoconvert_threshold',
|
6273 |
-
ewwwio_debug_message( 'not a large PNG, skipping' );
|
6274 |
return;
|
6275 |
}
|
6276 |
-
if ( ewww_image_optimizer_png_alpha( $file ) && ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) || ! ewww_image_optimizer_jpg_background() ) ) {
|
6277 |
ewwwio_debug_message( 'alpha detected, skipping' );
|
6278 |
return;
|
6279 |
}
|
|
|
|
|
|
|
|
|
6280 |
$ewww_image = new EWWW_Image( 0, '', $file );
|
6281 |
// Pass the filename, false for db search/replace, and true for filesize comparison.
|
6282 |
return $ewww_image->convert( $file, false, true );
|
@@ -6946,6 +7177,83 @@ function ewww_image_optimizer_rebuild_meta( $attachment_id ) {
|
|
6946 |
}
|
6947 |
}
|
6948 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6949 |
/**
|
6950 |
* Find image paths from an attachment's meta data and process each image.
|
6951 |
*
|
@@ -8122,14 +8430,14 @@ function ewww_image_optimizer_resize_count( $sizes ) {
|
|
8122 |
/**
|
8123 |
* Add column header for optimizer results in the media library listing.
|
8124 |
*
|
8125 |
-
* @param array $
|
8126 |
* @return array The new list of columns.
|
8127 |
*/
|
8128 |
-
function ewww_image_optimizer_columns( $
|
8129 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
8130 |
-
$
|
8131 |
ewwwio_memory( __FUNCTION__ );
|
8132 |
-
return $
|
8133 |
}
|
8134 |
|
8135 |
/**
|
@@ -8231,7 +8539,7 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null ) {
|
|
8231 |
switch ( $type ) {
|
8232 |
case 'image/jpeg':
|
8233 |
// If jpegtran is missing and should not be skipped.
|
8234 |
-
if ( ! $skip['jpegtran'] && defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
8235 |
$msg = '<div>' . sprintf(
|
8236 |
/* translators: %s: name of a tool like jpegtran */
|
8237 |
__( '%s is missing', 'ewww-image-optimizer' ),
|
@@ -9006,7 +9314,7 @@ function ewww_image_optimizer_dismiss_wc_regen() {
|
|
9006 |
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
9007 |
}
|
9008 |
delete_option( 'ewww_image_optimizer_wc_regen' );
|
9009 |
-
|
9010 |
}
|
9011 |
|
9012 |
/**
|
@@ -9020,7 +9328,7 @@ function ewww_image_optimizer_dismiss_lr_sync() {
|
|
9020 |
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
9021 |
}
|
9022 |
delete_option( 'ewww_image_optimizer_lr_sync' );
|
9023 |
-
|
9024 |
}
|
9025 |
|
9026 |
/**
|
@@ -9035,7 +9343,7 @@ function ewww_image_optimizer_dismiss_media_notice() {
|
|
9035 |
}
|
9036 |
update_option( 'ewww_image_optimizer_dismiss_media_notice', true, false );
|
9037 |
update_site_option( 'ewww_image_optimizer_dismiss_media_notice', true );
|
9038 |
-
|
9039 |
}
|
9040 |
|
9041 |
/**
|
@@ -9050,7 +9358,7 @@ function ewww_image_optimizer_dismiss_review_notice() {
|
|
9050 |
}
|
9051 |
update_option( 'ewww_image_optimizer_dismiss_review_notice', true, false );
|
9052 |
update_site_option( 'ewww_image_optimizer_dismiss_review_notice', true );
|
9053 |
-
|
9054 |
}
|
9055 |
|
9056 |
/**
|
@@ -9260,6 +9568,16 @@ function ewww_image_optimizer_settings_script( $hook ) {
|
|
9260 |
if ( 'settings_page_ewww-image-optimizer-options' !== $hook ) {
|
9261 |
return;
|
9262 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9263 |
delete_option( 'ewww_image_optimizer_exactdn_checkin' );
|
9264 |
global $exactdn;
|
9265 |
if ( has_action( 'admin_notices', 'ewww_image_optimizer_notice_exactdn_domain_mismatch' ) ) {
|
@@ -9272,12 +9590,27 @@ function ewww_image_optimizer_settings_script( $hook ) {
|
|
9272 |
$exactdn->setup();
|
9273 |
}
|
9274 |
add_thickbox();
|
9275 |
-
wp_enqueue_script( '
|
9276 |
-
wp_enqueue_script( '
|
9277 |
wp_enqueue_style( 'jquery-ui-tooltip-custom', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ), array(), EWWW_IMAGE_OPTIMIZER_VERSION );
|
9278 |
wp_enqueue_script( 'postbox' );
|
9279 |
wp_enqueue_script( 'dashboard' );
|
9280 |
-
wp_localize_script(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9281 |
ewwwio_memory( __FUNCTION__ );
|
9282 |
}
|
9283 |
|
@@ -9377,31 +9710,73 @@ function ewww_image_optimizer_savings( $network_admin = false ) {
|
|
9377 |
*
|
9378 |
* Requests the test.png and checks to see if it is actually of type image/webp.
|
9379 |
*
|
9380 |
-
* @return
|
9381 |
*/
|
9382 |
-
function
|
9383 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9384 |
-
$
|
|
|
|
|
9385 |
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
|
|
|
|
9386 |
$test_result = wp_remote_get( $test_url, array( 'headers' => 'Accept: image/webp' ) );
|
9387 |
if ( is_wp_error( $test_result ) ) {
|
9388 |
$error_message = $test_result->get_error_message();
|
9389 |
ewwwio_debug_message( "webp verification request failed: $error_message" );
|
9390 |
-
return
|
9391 |
-
} elseif (
|
9392 |
-
|
9393 |
-
|
9394 |
-
|
9395 |
-
)
|
9396 |
-
|
9397 |
-
|
9398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9399 |
ewwwio_debug_message( 'webp mime check failed: ' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
|
|
|
9400 |
}
|
9401 |
-
|
9402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9403 |
}
|
9404 |
-
|
|
|
|
|
|
|
|
|
9405 |
}
|
9406 |
|
9407 |
/**
|
@@ -9434,20 +9809,29 @@ function ewww_image_optimizer_webp_rewrite() {
|
|
9434 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9435 |
// Verify that the user is properly authorized.
|
9436 |
if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['ewww_wpnonce'] ), 'ewww-image-optimizer-settings' ) ) {
|
9437 |
-
|
9438 |
}
|
9439 |
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
|
9440 |
-
|
9441 |
}
|
9442 |
$ewww_rules = ewww_image_optimizer_webp_rewrite_verify();
|
9443 |
if ( $ewww_rules ) {
|
9444 |
if ( insert_with_markers( ewww_image_optimizer_htaccess_path(), 'EWWWIO', $ewww_rules ) && ! ewww_image_optimizer_webp_rewrite_verify() ) {
|
9445 |
-
|
9446 |
-
|
9447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9448 |
}
|
|
|
9449 |
}
|
9450 |
-
|
9451 |
}
|
9452 |
|
9453 |
/**
|
@@ -9468,7 +9852,7 @@ function ewww_image_optimizer_webp_unwrite() {
|
|
9468 |
} else {
|
9469 |
esc_html_e( 'Removal failed', 'ewww-image-optimizer' );
|
9470 |
}
|
9471 |
-
|
9472 |
}
|
9473 |
|
9474 |
/**
|
@@ -9478,7 +9862,7 @@ function ewww_image_optimizer_webp_unwrite() {
|
|
9478 |
*/
|
9479 |
function ewww_image_optimizer_webp_rewrite_verify() {
|
9480 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9481 |
-
if (
|
9482 |
if ( ewwwio_extract_from_markers( ewww_image_optimizer_htaccess_path(), 'EWWWIO' ) ) {
|
9483 |
ewwwio_debug_message( 'removing htaccess webp to prevent ExactDN problems' );
|
9484 |
insert_with_markers( ewww_image_optimizer_htaccess_path(), 'EWWWIO', '' );
|
@@ -9495,10 +9879,12 @@ function ewww_image_optimizer_webp_rewrite_verify() {
|
|
9495 |
'RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png|gif)$',
|
9496 |
'RewriteCond %{REQUEST_FILENAME}.webp -f',
|
9497 |
'RewriteCond %{QUERY_STRING} !type=original',
|
9498 |
-
'RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_URI}.webp [T=image/webp,
|
9499 |
'</IfModule>',
|
9500 |
'<IfModule mod_headers.c>',
|
9501 |
-
'
|
|
|
|
|
9502 |
'</IfModule>',
|
9503 |
'AddType image/webp .webp',
|
9504 |
);
|
@@ -9509,6 +9895,7 @@ function ewww_image_optimizer_webp_rewrite_verify() {
|
|
9509 |
! ewww_image_optimizer_array_search( '{HTTP_ACCEPT} image/webp', $current_rules ) ||
|
9510 |
! ewww_image_optimizer_array_search( '{REQUEST_FILENAME}.webp', $current_rules ) ||
|
9511 |
! ewww_image_optimizer_array_search( 'Header append Vary Accept', $current_rules ) ||
|
|
|
9512 |
! ewww_image_optimizer_array_search( 'AddType image/webp', $current_rules )
|
9513 |
) {
|
9514 |
ewwwio_debug_message( 'missing or invalid rules' );
|
@@ -9608,6 +9995,7 @@ function ewww_image_optimizer_get_image_sizes() {
|
|
9608 |
if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
|
9609 |
$sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
|
9610 |
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
|
|
|
9611 |
if ( 'medium_large' === $_size && 0 === intval( $sizes[ $_size ]['width'] ) ) {
|
9612 |
$sizes[ $_size ]['width'] = '768';
|
9613 |
}
|
@@ -9618,6 +10006,7 @@ function ewww_image_optimizer_get_image_sizes() {
|
|
9618 |
$sizes[ $_size ] = array(
|
9619 |
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
|
9620 |
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
|
|
|
9621 |
);
|
9622 |
}
|
9623 |
}
|
@@ -9625,6 +10014,7 @@ function ewww_image_optimizer_get_image_sizes() {
|
|
9625 |
$sizes['pdf-full'] = array(
|
9626 |
'width' => 99999,
|
9627 |
'height' => 99999,
|
|
|
9628 |
);
|
9629 |
|
9630 |
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
@@ -9751,6 +10141,7 @@ function ewwwio_debug_info() {
|
|
9751 |
$eio_exclude_paths = ewww_image_optimizer_get_option( 'exactdn_exclude' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'exactdn_exclude' ) ) ) : '';
|
9752 |
ewwwio_debug_message( $eio_exclude_paths );
|
9753 |
ewwwio_debug_message( 'lazy load: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ? 'on' : 'off' ) );
|
|
|
9754 |
ewwwio_debug_message( 'LQIP: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_use_lqip' ) ? 'on' : 'off' ) );
|
9755 |
ewwwio_debug_message( 'LL exclusions:' );
|
9756 |
$ll_exclude_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ) ) : '';
|
@@ -9761,7 +10152,8 @@ function ewwwio_debug_info() {
|
|
9761 |
ewwwio_debug_message( 'pngout level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ) );
|
9762 |
ewwwio_debug_message( 'svgcleaner disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_svgcleaner' ) ? 'yes' : 'no' ) );
|
9763 |
}
|
9764 |
-
ewwwio_debug_message( '
|
|
|
9765 |
ewwwio_debug_message( 'effective WebP quality: ' . ewww_image_optimizer_set_webp_quality( 75 ) );
|
9766 |
ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) ? 'on' : 'off' ) );
|
9767 |
ewwwio_debug_message( 'background optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ? 'on' : 'off' ) );
|
@@ -9877,7 +10269,7 @@ function ewwwio_debug_info() {
|
|
9877 |
if ( ! apache_mod_loaded( 'mod_headers' ) ) {
|
9878 |
ewwwio_debug_message( 'possibly missing mod_headers' );
|
9879 |
}
|
9880 |
-
if (
|
9881 |
ewwwio_debug_message( 'webp .htaccess rewriting enabled' );
|
9882 |
} else {
|
9883 |
ewwwio_debug_message( 'webp .htaccess rules not detected' );
|
@@ -9889,92 +10281,604 @@ function ewwwio_debug_info() {
|
|
9889 |
ewwwio_check_memory_available();
|
9890 |
}
|
9891 |
|
9892 |
-
|
9893 |
-
/**
|
9894 |
-
* Wrapper that displays the EWWW IO options in the multisite network admin.
|
9895 |
-
*/
|
9896 |
-
function ewww_image_optimizer_network_options() {
|
9897 |
-
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9898 |
-
/* add_filter( 'ewww_image_optimizer_settings', 'ewww_image_optimizer_filter_network_settings_page', 9 ); */
|
9899 |
-
ewww_image_optimizer_options( 'network-multisite' );
|
9900 |
-
}
|
9901 |
-
|
9902 |
-
/**
|
9903 |
-
* Wrapper that displays the EWWW IO options for multisite mode on a single site.
|
9904 |
-
*
|
9905 |
-
* By default, the only options displayed are the per-site resizes list, but a network admin can
|
9906 |
-
* permit site admins to configure their own blog settings.
|
9907 |
-
*/
|
9908 |
-
function ewww_image_optimizer_network_singlesite_options() {
|
9909 |
-
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9910 |
-
/* add_filter( 'ewww_image_optimizer_settings', 'ewww_image_optimizer_filter_network_singlesite_settings_page', 9 ); */
|
9911 |
-
ewww_image_optimizer_options( 'network-singlesite' );
|
9912 |
-
}
|
9913 |
-
|
9914 |
/**
|
9915 |
-
* Displays the EWWW IO
|
9916 |
-
*
|
9917 |
-
* @global string $eio_debug In memory debug log.
|
9918 |
-
* @global int $wp_version
|
9919 |
-
*
|
9920 |
-
* @param string $network Indicates which options should be shown in multisite installations.
|
9921 |
*/
|
9922 |
-
function
|
9923 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9924 |
-
global $ewwwio_temp_debug;
|
9925 |
-
global $ewwwio_upgrading;
|
9926 |
-
global $eio_debug;
|
9927 |
-
global $eio_hs_beacon;
|
9928 |
global $exactdn;
|
9929 |
-
|
9930 |
-
$
|
9931 |
-
|
9932 |
-
|
9933 |
-
|
9934 |
-
|
9935 |
-
|
9936 |
-
|
9937 |
-
|
9938 |
-
|
9939 |
-
|
9940 |
-
$
|
9941 |
-
|
9942 |
-
|
9943 |
-
if (
|
9944 |
-
|
9945 |
-
|
9946 |
-
|
9947 |
-
|
9948 |
-
|
9949 |
-
|
9950 |
}
|
9951 |
-
$eio_hs_beacon->admin_notice( $network );
|
9952 |
-
?>
|
9953 |
-
|
9954 |
-
<script type='text/javascript'>
|
9955 |
-
jQuery(document).ready(function($) {$(".fade").fadeTo(5000,1).fadeOut(3000);});
|
9956 |
-
</script>
|
9957 |
-
<div id='ewww-settings-wrap' class='wrap'>
|
9958 |
-
<h1>EWWW Image Optimizer</h1>
|
9959 |
-
<?php
|
9960 |
-
$speed_score = 0;
|
9961 |
-
|
9962 |
-
$speed_recommendations = array();
|
9963 |
-
|
9964 |
-
$free_exec = false;
|
9965 |
if (
|
9966 |
-
|
9967 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
9968 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
9969 |
! ewww_image_optimizer_easy_active()
|
9970 |
) {
|
9971 |
-
$
|
9972 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9973 |
}
|
9974 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9975 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
9976 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', 0 );
|
9977 |
-
$verify_cloud = ewww_image_optimizer_cloud_verify( false );
|
9978 |
if ( false !== strpos( $verify_cloud, 'great' ) && ! ewww_image_optimizer_easy_active() ) {
|
9979 |
$speed_score += 35;
|
9980 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 20 ) {
|
@@ -10012,7 +10916,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10012 |
$speed_score += 20;
|
10013 |
}
|
10014 |
} elseif (
|
10015 |
-
( ! class_exists( '
|
10016 |
class_exists( 'ExactDN' ) &&
|
10017 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' )
|
10018 |
) {
|
@@ -10049,8 +10953,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10049 |
}
|
10050 |
$easymode = false;
|
10051 |
if (
|
10052 |
-
$exactdn_enabled &&
|
10053 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
10054 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_local_mode' )
|
10055 |
) {
|
10056 |
$easymode = true;
|
@@ -10236,24 +11138,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10236 |
'src' => array(),
|
10237 |
),
|
10238 |
);
|
10239 |
-
if ( ! $easymode ) {
|
10240 |
-
echo '<p>' . sprintf(
|
10241 |
-
/* translators: %s: Bulk Optimize (link) */
|
10242 |
-
esc_html__( 'New images uploaded to the Media Library will be optimized automatically. If you have existing images you would like to optimize, you can use the %s tool.', 'ewww-image-optimizer' ),
|
10243 |
-
( 'network-multisite' === esc_attr( $network ) ?
|
10244 |
-
esc_html__( 'Media Library', 'ewww-image-optimizer' ) . ' -> ' . esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ) :
|
10245 |
-
'<a href="' . esc_url( admin_url( 'upload.php?page=ewww-image-optimizer-bulk' ) ) . '">' . esc_html__( 'Bulk Optimize', 'ewww-image-optimizer' ) . '</a>'
|
10246 |
-
)
|
10247 |
-
);
|
10248 |
-
ewwwio_help_link( 'https://docs.ewww.io/article/4-getting-started', '5853713bc697912ffd6c0b98' );
|
10249 |
-
echo ' ' . ( ! class_exists( 'Amazon_S3_And_CloudFront' ) ?
|
10250 |
-
sprintf(
|
10251 |
-
/* translators: %s: S3 Image Optimizer (link) */
|
10252 |
-
esc_html__( 'Images stored in an Amazon S3 bucket can be optimized using our %s.' ),
|
10253 |
-
'<a href="https://ewww.io/downloads/s3-image-optimizer/">' . esc_html__( 'S3 Image Optimizer', 'ewww-image-optimizer' ) . '</a>'
|
10254 |
-
) : '' ) .
|
10255 |
-
"</p>\n";
|
10256 |
-
}
|
10257 |
|
10258 |
if ( 'network-multisite-over' === $network ) {
|
10259 |
ob_start();
|
@@ -10266,131 +11150,104 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10266 |
} elseif ( $speed_score < 90 ) {
|
10267 |
$stroke_class = 'ewww-orange';
|
10268 |
}
|
10269 |
-
$guage_stroke_dasharray = 2 * pi() * 54;
|
10270 |
-
$speed_stroke_dashoffset = $guage_stroke_dasharray * ( 1 - $speed_score / 100 );
|
10271 |
?>
|
10272 |
<div id='ewww-widgets' class='metabox-holder'>
|
10273 |
<div class='meta-box-sortables'>
|
10274 |
<div id='ewww-status' class='postbox'>
|
10275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10276 |
<div class='inside'>
|
10277 |
-
<div class=
|
10278 |
-
<div id=
|
10279 |
-
<div id=
|
10280 |
-
<
|
10281 |
-
|
10282 |
-
|
10283 |
-
|
10284 |
-
<
|
10285 |
-
|
10286 |
-
|
10287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10288 |
<?php if ( $speed_score < 100 ) : ?>
|
10289 |
<ul class="ewww-tooltip">
|
10290 |
-
<?php foreach ( $speed_recommendations as $recommendation )
|
10291 |
<li><?php echo wp_kses( $recommendation, $allow_help_html ); ?></li>
|
10292 |
-
<?php
|
10293 |
</ul>
|
10294 |
<?php endif; ?>
|
10295 |
</div><!-- end .ewww-recommend -->
|
10296 |
-
|
10297 |
-
|
10298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10299 |
<?php endif; ?>
|
10300 |
-
|
10301 |
-
|
10302 |
-
|
10303 |
-
|
10304 |
-
|
10305 |
-
|
10306 |
-
|
10307 |
-
|
10308 |
-
|
10309 |
-
|
10310 |
-
|
10311 |
-
|
10312 |
-
|
10313 |
-
|
10314 |
-
<p style="text-align:center"><strong><?php esc_html_e( 'Local Compression Savings', 'ewww-image-optimizer' ); ?></strong></p>
|
10315 |
-
<p><a href="<?php echo esc_url( admin_url( 'tools.php?page=ewww-image-optimizer-tools' ) ); ?>"><?php esc_html_e( 'View optimized images.', 'ewww-image-optimizer' ); ?></a></p>
|
10316 |
-
</div><!-- end .ewww-status-detail -->
|
10317 |
-
<?php } ?>
|
10318 |
-
<?php
|
10319 |
-
if ( $exactdn_enabled && ! empty( $exactdn_savings ) && ! empty( $exactdn_savings['original'] ) && ! empty( $exactdn_savings['savings'] ) ) {
|
10320 |
-
$savings_stroke_dashoffset = $guage_stroke_dasharray * ( 1 - $exactdn_savings['savings'] / $exactdn_savings['original'] );
|
10321 |
-
?>
|
10322 |
-
<div id="easyio-savings" class="ewww-status-detail">
|
10323 |
-
<div id="easyio-savings-guage" class="ewww-guage" data-score="<?php echo esc_attr( $exactdn_savings['savings'] / $exactdn_savings['original'] ); ?>">
|
10324 |
-
<svg width="120" height="120">
|
10325 |
-
<title><?php echo esc_html( round( $exactdn_savings['savings'] / $exactdn_savings['original'], 3 ) * 100 ); ?>%</title>
|
10326 |
-
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
10327 |
-
<circle class="ewww-active" r="54" cy="60" cx="60" stroke-width="12" style="stroke-dasharray: <?php echo esc_attr( $guage_stroke_dasharray ); ?>px; stroke-dashoffset: <?php echo esc_attr( $savings_stroke_dashoffset ); ?>px;" />
|
10328 |
-
</svg>
|
10329 |
-
<div class="ewww-score"><?php echo esc_html( ewww_image_optimizer_size_format( $exactdn_savings['savings'], 2 ) ); ?></div>
|
10330 |
-
</div><!-- end .ewww-guage -->
|
10331 |
-
<p style="text-align:center">
|
10332 |
-
<strong><?php esc_html_e( 'Easy IO Savings', 'ewww-image-optimizer' ); ?></strong>
|
10333 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/96-easy-io-is-it-working', '5f871dd2c9e77c0016217c4e' ); ?>
|
10334 |
-
</p>
|
10335 |
-
</div><!-- end .ewww-status-detail -->
|
10336 |
-
<?php } ?>
|
10337 |
<!-- begin notices section -->
|
10338 |
<div id="ewww-notices" class="ewww-status-detail">
|
10339 |
-
|
10340 |
-
|
10341 |
-
|
10342 |
-
|
10343 |
-
|
10344 |
-
|
10345 |
-
|
10346 |
-
|
10347 |
-
|
10348 |
-
|
10349 |
-
|
10350 |
-
|
10351 |
-
|
10352 |
-
|
10353 |
-
|
10354 |
-
|
10355 |
-
|
10356 |
-
|
10357 |
-
|
10358 |
-
|
10359 |
-
<p>
|
10360 |
-
<span style="font-weight:bold;color:#3eadc9;">Compress API:</span>
|
10361 |
-
<a href="https://optimize.exactlywww.com/api_key/free-trial.php?TB_iframe=true&width=600&height=375" class="thickbox" target="_blank">
|
10362 |
-
<?php if ( $exactdn_enabled || get_option( 'easyio_exactdn' ) ) : ?>
|
10363 |
-
<?php esc_html_e( 'Need to save storage space?', 'ewww-image-optimizer' ); ?>
|
10364 |
-
<?php else : ?>
|
10365 |
-
<?php esc_html_e( 'Unlock premium compression, save storage space, and reduce server load.', 'ewww-image-optimizer' ); ?>
|
10366 |
-
<?php endif; ?>
|
10367 |
-
</a>
|
10368 |
-
</p>
|
10369 |
-
<?php endif; ?>
|
10370 |
-
<?php if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
10371 |
-
<p><b>Easy IO:</b> <span style="color: red"><?php esc_html_e( 'Inactive, please disable the Image Performance option on the Jetpack Dashboard.', 'ewww-image-optimizer' ); ?></span></p>
|
10372 |
-
<?php elseif ( ! get_option( 'easyio_exactdn' ) && class_exists( 'ExactDN' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
10373 |
-
<p><b>Easy IO:</b>
|
10374 |
-
<?php if ( $exactdn->get_exactdn_domain() && $exactdn->verify_domain( $exactdn->get_exactdn_domain() ) ) : ?>
|
10375 |
-
<span style="color: #3eadc9; font-weight: bolder"><?php esc_html_e( 'Verified', 'ewww-image-optimizer' ); ?></span>
|
10376 |
-
<br><?php echo esc_html( $exactdn->get_exactdn_domain() ); ?>
|
10377 |
-
<?php elseif ( $exactdn->get_exactdn_domain() && $exactdn->get_exactdn_option( 'verified' ) ) : ?>
|
10378 |
-
<span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Temporarily disabled.', 'ewww-image-optimizer' ); ?></span>
|
10379 |
-
<?php elseif ( $exactdn->get_exactdn_domain() && $exactdn->get_exactdn_option( 'suspended' ) ) : ?>
|
10380 |
-
<span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Active, not yet verified.', 'ewww-image-optimizer' ); ?></span>';
|
10381 |
-
<?php else : ?>
|
10382 |
-
<span style="color: red; font-weight: bolder"><a href="https://ewww.io/manage-sites/" target="_blank"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></a></span>
|
10383 |
-
<?php endif; ?>
|
10384 |
-
<?php if ( function_exists( 'remove_query_strings_link' ) || function_exists( 'rmqrst_loader_src' ) || function_exists( 'qsr_remove_query_strings_1' ) ) : ?>
|
10385 |
-
<br><i><?php esc_html_e( 'Plugins that remove query strings are unnecessary with Easy IO. You may remove them at your convenience.', 'ewww-image-optimizer' ); ?></i><?php ewwwio_help_link( 'https://docs.ewww.io/article/50-exactdn-and-query-strings', '5a3d278a2c7d3a1943677b52' ); ?>
|
10386 |
-
<?php endif; ?>
|
10387 |
-
</p>
|
10388 |
-
<?php elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! get_option( 'easyio_exactdn' ) ) : ?>
|
10389 |
-
<p><span style="font-weight:bold;color:#3eadc9;">Easy IO:</span> <a href="https://ewww.io/easy/" target="_blank"><?php esc_html_e( 'Comprehensive image optimization with auto-compress, auto-sizing, auto-WebP, and lazy load.', 'ewww-image-optimizer' ); ?></a></p>
|
10390 |
-
<?php endif; ?>
|
10391 |
-
<?php if ( ! function_exists( 'swis' ) ) : ?>
|
10392 |
-
<p><span style="font-weight:bold;color:#3eadc9;">SWIS Performance:</span> <a href="https://ewww.io/swis/" target="_blank"><?php esc_html_e( 'Go beyond image optimization with the tools I use for improving site speed.', 'ewww-image-optimizer' ); ?></a></p>
|
10393 |
-
<?php endif; ?>
|
10394 |
<p>
|
10395 |
<strong><?php esc_html_e( 'Background optimization (faster uploads):', 'ewww-image-optimizer' ); ?></strong><br>
|
10396 |
<?php if ( defined( 'EWWW_DISABLE_ASYNC' ) && EWWW_DISABLE_ASYNC ) : ?>
|
@@ -10439,18 +11296,94 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10439 |
var exactdn_enabled = false;
|
10440 |
</script>
|
10441 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10442 |
|
10443 |
<!-- 'network-multisite-over' and 'network-singlesite' get simpler settings, 'network-singlesite-over' masquerades as 'singlesite' -->
|
10444 |
<?php if ( ! $easymode && ( 'singlesite' === $network || 'network-multisite' === $network ) ) : ?>
|
10445 |
<ul class='ewww-tab-nav'>
|
10446 |
<li class='ewww-tab ewww-general-nav'><span><?php esc_html_e( 'Basic', 'ewww-image-optimizer' ); ?></span></li>
|
10447 |
-
|
10448 |
-
<li class='ewww-tab ewww-
|
10449 |
-
<?php endif; ?>
|
10450 |
-
<li class='ewww-tab ewww-optimization-nav'><span><?php esc_html_e( 'Advanced', 'ewww-image-optimizer' ); ?></span></li>
|
10451 |
<li class='ewww-tab ewww-resize-nav'><span><?php esc_html_e( 'Resize', 'ewww-image-optimizer' ); ?></span></li>
|
10452 |
<li class='ewww-tab ewww-conversion-nav'><span><?php esc_html_e( 'Convert', 'ewww-image-optimizer' ); ?></span></li>
|
10453 |
-
<li class='ewww-tab ewww-webp-nav'><span><?php esc_html_e( 'WebP', 'ewww-image-optimizer' ); ?></span></li>
|
10454 |
<li class='ewww-tab ewww-overrides-nav'><span><a href='https://docs.ewww.io/article/40-override-options' target='_blank'><span class='ewww-tab-hidden'><?php esc_html_e( 'Overrides', 'ewww-image-optimizer' ); ?></a></span></li>
|
10455 |
<li class='ewww-tab ewww-support-nav'><span><?php esc_html_e( 'Support', 'ewww-image-optimizer' ); ?></span></li>
|
10456 |
<li class='ewww-tab ewww-contribute-nav'><span><?php esc_html_e( 'Contribute', 'ewww-image-optimizer' ); ?></span></li>
|
@@ -10458,8 +11391,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10458 |
<?php elseif ( $easymode ) : ?>
|
10459 |
<ul class='ewww-tab-nav'>
|
10460 |
<li class='ewww-tab ewww-general-nav'><span><?php esc_html_e( 'Basic', 'ewww-image-optimizer' ); ?></span></li>
|
10461 |
-
<li class='ewww-tab ewww-exactdn-nav'><span><?php esc_html_e( 'Easy Mode', 'ewww-image-optimizer' ); ?></span></li>
|
10462 |
-
<li class='ewww-tab ewww-resize-nav'><span><?php esc_html_e( 'Resize', 'ewww-image-optimizer' ); ?></span></li>
|
10463 |
<li class='ewww-tab ewww-support-nav'><span><?php esc_html_e( 'Support', 'ewww-image-optimizer' ); ?></span></li>
|
10464 |
<li class='ewww-tab ewww-contribute-nav'><span><?php esc_html_e( 'Contribute', 'ewww-image-optimizer' ); ?></span></li>
|
10465 |
</ul>
|
@@ -10473,33 +11404,25 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10473 |
<input type='hidden' name='action' value='update' />
|
10474 |
<?php wp_nonce_field( 'ewww_image_optimizer_options-options' ); ?>
|
10475 |
<?php if ( 'network-singlesite' === $network ) : ?>
|
10476 |
-
<i class="network-singlesite"><strong
|
|
|
|
|
|
|
10477 |
<?php ob_start(); ?>
|
10478 |
<?php endif; ?>
|
10479 |
<div id='ewww-general-settings'>
|
10480 |
<noscript><h2><?php esc_html_e( 'Basic', 'ewww-image-optimizer' ); ?></h2></noscript>
|
10481 |
-
<?php if (
|
10482 |
-
<p
|
10483 |
-
|
10484 |
-
|
10485 |
-
|
10486 |
-
|
10487 |
-
|
10488 |
-
<
|
10489 |
-
|
10490 |
-
|
10491 |
-
|
10492 |
-
<p><strong><?php esc_html_e( 'Easy IO is optimizing your site, no more configuration needed!', 'ewww-image-optimizer' ); ?></strong><br>
|
10493 |
-
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
10494 |
-
<?php /* translators: %s: Easy Mode */ ?>
|
10495 |
-
<?php printf( esc_html__( 'Remove API key and switch to %s.', 'ewww-image-optimizer' ), '<a href="' . esc_url( wp_nonce_url( admin_url( 'options-general.php?page=ewww-image-optimizer-options&enable-local=0' ), 'ewww_image_optimizer_options-options' ) ) . '">' . esc_html__( 'Easy Mode', 'ewww-image-optimizer' ) . '</a>' ); ?></p>
|
10496 |
-
<?php else : ?>
|
10497 |
-
<?php /* translators: %s: Easy Mode */ ?>
|
10498 |
-
<?php printf( esc_html__( 'Switch to %s.', 'ewww-image-optimizer' ), '<a href="' . esc_url( wp_nonce_url( admin_url( 'options-general.php?page=ewww-image-optimizer-options&enable-local=0' ), 'ewww_image_optimizer_options-options' ) ) . '">' . esc_html__( 'Easy Mode', 'ewww-image-optimizer' ) . '</a>' ); ?></p>
|
10499 |
-
<?php endif; ?>
|
10500 |
-
<?php elseif ( 'singlesite' === $network && get_option( 'easyio_exactdn' ) ) : ?>
|
10501 |
-
<p><strong><?php esc_html_e( 'Easy IO is optimizing your site, no more configuration needed!', 'ewww-image-optimizer' ); ?></strong><br>
|
10502 |
-
<?php esc_html_e( 'Unless you need to save storage space, you can now disable the EWWW Image Optimizer.', 'ewww-image-optimizer' ); ?></p>
|
10503 |
<?php endif; ?>
|
10504 |
<?php ob_start(); ?>
|
10505 |
<table class='form-table'>
|
@@ -10520,7 +11443,19 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10520 |
</th>
|
10521 |
<td>
|
10522 |
<input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' <?php checked( get_site_option( 'ewww_image_optimizer_allow_tracking' ) ); ?> />
|
10523 |
-
<?php esc_html_e( '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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10524 |
</td>
|
10525 |
</tr>
|
10526 |
</table>
|
@@ -10535,32 +11470,170 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10535 |
<?php
|
10536 |
return;
|
10537 |
endif;
|
|
|
|
|
|
|
|
|
10538 |
?>
|
10539 |
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
10540 |
-
<tr>
|
10541 |
<th scope='row'>
|
10542 |
<label for='ewww_image_optimizer_cloud_notkey'><?php esc_html_e( 'Compress API Key', 'ewww-image-optimizer' ); ?></label>
|
10543 |
</th>
|
10544 |
<td>
|
10545 |
<input type='text' id='ewww_image_optimizer_cloud_notkey' name='ewww_image_optimizer_cloud_notkey' readonly='readonly' value='****************************<?php echo esc_attr( substr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ), 28 ) ); ?>' size='32' />
|
10546 |
-
<a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_remove_cloud_key' ) ); ?>'>
|
10547 |
<?php esc_html_e( 'Remove API key', 'ewww-image-optimizer' ); ?>
|
10548 |
</a>
|
10549 |
<input type='hidden' id='ewww_image_optimizer_cloud_key' name='ewww_image_optimizer_cloud_key' value='<?php echo esc_attr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ); ?>' />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10550 |
</td>
|
10551 |
</tr>
|
10552 |
<?php else : ?>
|
|
|
10553 |
<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10554 |
<th scope='row'>
|
10555 |
<label for='ewww_image_optimizer_cloud_key'><?php esc_html_e( 'Compress API Key', 'ewww-image-optimizer' ); ?></label>
|
10556 |
<?php ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2,5ad0c8e7042863075092650b,5a9efec62c7d3a7549516550' ); ?>
|
10557 |
</th>
|
10558 |
<td>
|
|
|
10559 |
<input type='text' id='ewww_image_optimizer_cloud_key' name='ewww_image_optimizer_cloud_key' value='' size='32' />
|
10560 |
-
|
10561 |
-
<
|
10562 |
-
|
10563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10564 |
</td>
|
10565 |
</tr>
|
10566 |
<?php endif; ?>
|
@@ -10575,6 +11648,376 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10575 |
<p class ='description'><?php esc_html_e( 'Color profiles are preserved when using the API or Easy IO.', 'ewww-image-optimizer' ); ?></p>
|
10576 |
</td>
|
10577 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10578 |
<?php $maybe_api_level = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ? '*' : ''; ?>
|
10579 |
<tr>
|
10580 |
<th scope='row'>
|
@@ -10693,184 +12136,28 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10693 |
<td>
|
10694 |
<?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
10695 |
<p>
|
10696 |
-
* <strong><a href='https://ewww.io/
|
10697 |
-
<?php esc_html_e( '
|
10698 |
-
</a></strong
|
10699 |
-
<a href='https://optimize.exactlywww.com/api_key/free-trial.php?TB_iframe=true&width=600&height=375' class='thickbox' target='_blank'>
|
10700 |
-
<?php esc_html_e( 'Or get a free trial key and take it for a test drive.', 'ewww-image-optimizer' ); ?>
|
10701 |
-
</a>
|
10702 |
</p>
|
10703 |
<?php else : ?>
|
10704 |
<p>
|
10705 |
-
* <?php esc_html_e( 'These levels use the compression API.', 'ewww-image-optimizer' ); ?>
|
10706 |
-
</p>
|
10707 |
-
<?php endif; ?>
|
10708 |
-
<p class='description'>
|
10709 |
-
<?php esc_html_e( 'All methods used by the EWWW Image Optimizer are intended to produce visually identical images.', 'ewww-image-optimizer' ); ?>
|
10710 |
-
</p>
|
10711 |
-
</td>
|
10712 |
-
</tr>
|
10713 |
-
<tr>
|
10714 |
-
<th scope='row'>
|
10715 |
-
<label for='ewww_image_optimizer_backup_files'><?php esc_html_e( 'Backup Originals', 'ewww-image-optimizer' ); ?></label>
|
10716 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2' ); ?>
|
10717 |
-
</th>
|
10718 |
-
<td>
|
10719 |
-
<input type='checkbox' id='ewww_image_optimizer_backup_files' name='ewww_image_optimizer_backup_files' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' ) ); ?> <?php disabled( $disable_level ); ?>>
|
10720 |
-
<?php esc_html_e( 'Store a copy of your original images on our secure server for 30 days. *Requires an active API key.', 'ewww-image-optimizer' ); ?>
|
10721 |
-
</td>
|
10722 |
-
</tr>
|
10723 |
-
<?php if ( class_exists( 'Cloudinary' ) && Cloudinary::config_get( 'api_secret' ) ) : ?>
|
10724 |
-
<tr>
|
10725 |
-
<th scope='row'>
|
10726 |
-
<label for='ewww_image_optimizer_enable_cloudinary'><?php esc_html_e( 'Automatic Cloudinary Upload', 'ewww-image-optimizer' ); ?></label>
|
10727 |
-
</th>
|
10728 |
-
<td>
|
10729 |
-
<input type='checkbox' id='ewww_image_optimizer_enable_cloudinary' name='ewww_image_optimizer_enable_cloudinary' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_cloudinary' ) ); ?> />
|
10730 |
-
<?php esc_html_e( 'When enabled, uploads to the Media Library will be transferred to Cloudinary after optimization. Cloudinary generates resizes, so only the full-size image is uploaded.', 'ewww-image-optimizer' ); ?>
|
10731 |
-
</td>
|
10732 |
-
</tr>
|
10733 |
-
<?php endif; ?>
|
10734 |
-
</table>
|
10735 |
-
<?php
|
10736 |
-
if ( $easymode ) {
|
10737 |
-
ob_end_clean();
|
10738 |
-
} else {
|
10739 |
-
ob_end_flush();
|
10740 |
-
}
|
10741 |
-
?>
|
10742 |
-
</div>
|
10743 |
-
|
10744 |
-
<?php
|
10745 |
-
$eio_base = new EIO_Base();
|
10746 |
-
$easyio_site_url = $eio_base->content_url();
|
10747 |
-
$exactdn_att_che = ewww_image_optimizer_get_option( 'exactdn_all_the_things' ) && ( ! is_object( $exactdn ) || 1 < $exactdn->get_plan_id() );
|
10748 |
-
$exactdn_att_id = ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ? 'exactdn_all_the_things_disabled' : 'exactdn_all_the_things' );
|
10749 |
-
$exactdn_att_dis = ! $exactdn_enabled || 1 === $exactdn->get_plan_id();
|
10750 |
-
$exactdn_los_che = ewww_image_optimizer_get_option( 'exactdn_lossy' ) || ( is_object( $exactdn ) && 1 === $exactdn->get_plan_id() );
|
10751 |
-
$exactdn_los_id = ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ? 'exactdn_lossy_disabled' : 'exactdn_lossy' );
|
10752 |
-
$exactdn_los_dis = ! $exactdn_enabled || 1 === $exactdn->get_plan_id();
|
10753 |
-
$eio_exclude_paths = ewww_image_optimizer_get_option( 'exactdn_exclude' ) ? implode( "\n", ewww_image_optimizer_get_option( 'exactdn_exclude' ) ) : '';
|
10754 |
-
$lqip_che = is_object( $exactdn ) && 1 < $exactdn->get_plan_id() && ewww_image_optimizer_get_option( 'ewww_image_optimizer_use_lqip' );
|
10755 |
-
$lqip_id = ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ? 'ewww_image_optimizer_use_lqip_disabled' : 'ewww_image_optimizer_use_lqip' );
|
10756 |
-
$lqip_dis = ! $exactdn_enabled || 1 === $exactdn->get_plan_id();
|
10757 |
-
$ll_exclude_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ? implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ) : '';
|
10758 |
-
?>
|
10759 |
-
|
10760 |
-
<div id='ewww-exactdn-settings'>
|
10761 |
-
<noscript><h2><?php esc_html_e( 'Easy Mode', 'ewww-image-optimizer' ); ?></h2></noscript>
|
10762 |
-
<p>
|
10763 |
-
<?php esc_html_e( 'Having problems? Try disabling Lazy Load and Include All Resources. Finally, disable Easy IO if problems remain.', 'ewww-image-optimizer' ); ?><br>
|
10764 |
-
<a class='ewww-docs-root' href='https://ewww.io/contact-us/'>
|
10765 |
-
<?php esc_html_e( 'Then, let us know so we can find a fix for the problem.', 'ewww-image-optimizer' ); ?>
|
10766 |
-
</a>
|
10767 |
-
<?php if ( $exactdn_enabled && 1 === $exactdn->get_plan_id() ) : ?>
|
10768 |
-
<br><i>* <?php esc_html_e( 'Upgrade to a Pro or Developer subscription to unlock additional options below.', 'ewww-image-optimizer' ); ?></i>
|
10769 |
-
<?php endif; ?>
|
10770 |
-
</p>
|
10771 |
-
<table class='form-table'>
|
10772 |
-
<tr>
|
10773 |
-
<th scope='row'>
|
10774 |
-
<label for='ewww_image_optimizer_exactdn'><?php esc_html_e( 'Easy IO', 'ewww-image-optimizer' ); ?></label>
|
10775 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/44-introduction-to-exactdn', '59bc5ad6042863033a1ce370,5c0042892c7d3a31944e88a4' ); ?>
|
10776 |
-
</th>
|
10777 |
-
<td>
|
10778 |
-
<input type='checkbox' id='ewww_image_optimizer_exactdn' name='ewww_image_optimizer_exactdn' value='true' <?php checked( $exactdn_enabled ); ?> />
|
10779 |
-
<?php esc_html_e( 'Comprehensive and automatic image optimization:', 'ewww-image-optimizer' ); ?>
|
10780 |
-
<p class="description">
|
10781 |
-
<?php esc_html_e( 'Premium Compression', 'ewww-image-optimizer' ); ?><br>
|
10782 |
-
<?php esc_html_e( 'Properly scale images to fit any device', 'ewww-image-optimizer' ); ?><br>
|
10783 |
-
<?php esc_html_e( 'Automatic WebP Conversion', 'ewww-image-optimizer' ); ?><br>
|
10784 |
-
<?php esc_html_e( 'Smart Image Conversion', 'ewww-image-optimizer' ); ?><br>
|
10785 |
-
<?php esc_html_e( 'JS/CSS Minification and Compression', 'ewww-image-optimizer' ); ?><br>
|
10786 |
-
<?php esc_html_e( 'CDN Included', 'ewww-image-optimizer' ); ?><br>
|
10787 |
-
<?php if ( ! $exactdn_enabled ) : ?>
|
10788 |
-
<strong>
|
10789 |
-
<a href="https://ewww.io/easy/" target="_blank">
|
10790 |
-
<?php esc_html_e( 'Purchase a subscription for your site.', 'ewww-image-optimizer' ); ?>
|
10791 |
-
</a>
|
10792 |
-
</strong><br>
|
10793 |
-
<a href="https://ewww.io/manage-sites/" target="_blank"><?php esc_html_e( 'Then, add your Site URL to your account:', 'easy-image-optimizer' ); ?></a>
|
10794 |
-
<?php echo ' ' . esc_url( $easyio_site_url ); ?><br>
|
10795 |
-
<?php endif; ?>
|
10796 |
-
<a href="https://docs.ewww.io/article/44-introduction-to-exactdn" target="_blank" data-beacon-article="59bc5ad6042863033a1ce370">
|
10797 |
-
<?php esc_html_e( 'Learn more about Easy IO', 'ewww-image-optimizer' ); ?>
|
10798 |
-
</a>
|
10799 |
-
</p>
|
10800 |
-
</td>
|
10801 |
-
</tr>
|
10802 |
-
<tr>
|
10803 |
-
<td> </td>
|
10804 |
-
<td>
|
10805 |
-
<input type='checkbox' name='exactdn_all_the_things' value='true' id='<?php echo esc_attr( $exactdn_att_id ); ?>' <?php disabled( $exactdn_att_dis ); ?> <?php checked( $exactdn_att_che ); ?> />
|
10806 |
-
<label for='exactdn_all_the_things'><strong><?php esc_html_e( 'Include All Resources', 'ewww-image-optimizer' ); ?></strong></label>
|
10807 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/47-getting-more-from-exactdn', '59de6631042863379ddc953c' ); ?>
|
10808 |
-
<p class='description'>
|
10809 |
-
<?php esc_html_e( 'Use Easy IO for all resources in wp-includes/ and wp-content/, including JavaScript, CSS, fonts, etc.', 'ewww-image-optimizer' ); ?>
|
10810 |
-
</p>
|
10811 |
-
</td>
|
10812 |
-
</tr>
|
10813 |
-
<tr>
|
10814 |
-
<td> </td>
|
10815 |
-
<td>
|
10816 |
-
<input type='checkbox' name='exactdn_lossy' value='true' id='<?php echo esc_attr( $exactdn_los_id ); ?>' <?php disabled( $exactdn_los_dis ); ?> <?php checked( $exactdn_los_che ); ?> />
|
10817 |
-
<label for='exactdn_lossy'><strong><?php esc_html_e( 'Premium Compression', 'ewww-image-optimizer' ); ?></strong></label>
|
10818 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/47-getting-more-from-exactdn', '59de6631042863379ddc953c' ); ?>
|
10819 |
-
<p class='description'>
|
10820 |
-
<?php esc_html_e( 'Enable high quality premium compression for all images. Disable to use Pixel Perfect mode instead.', 'ewww-image-optimizer' ); ?>
|
10821 |
-
</p>
|
10822 |
-
</td>
|
10823 |
-
</tr>
|
10824 |
-
<?php if ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ) : ?>
|
10825 |
-
<input type='hidden' id='exactdn_all_the_things' name='exactdn_all_the_things' <?php echo ( ewww_image_optimizer_get_option( 'exactdn_all_the_things' ) ? "value='1'" : "value='0'" ); ?> />
|
10826 |
-
<input type='hidden' id='exactdn_lossy' name='exactdn_lossy' <?php echo ( ewww_image_optimizer_get_option( 'exactdn_lossy' ) ? "value='1'" : "value='0'" ); ?> />
|
10827 |
-
<input type='hidden' id='ewww_image_optimizer_use_lqip' name='ewww_image_optimizer_use_lqip' <?php echo ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_use_lqip' ) ? "value='1'" : "value='0'" ); ?> />
|
10828 |
-
<?php endif; ?>
|
10829 |
-
<tr>
|
10830 |
-
<td> </td>
|
10831 |
-
<td>
|
10832 |
-
<label for='exactdn_exclude'><strong><?php esc_html_e( 'Exclusions', 'ewww-image-optimizer' ); ?></strong></label>
|
10833 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/68-exactdn-exclude', '5c0042892c7d3a31944e88a4' ); ?><br>
|
10834 |
-
<textarea id='exactdn_exclude' name='exactdn_exclude' rows='3' cols='60'><?php echo esc_html( $eio_exclude_paths ); ?></textarea>
|
10835 |
-
<p class='description'>
|
10836 |
-
<?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Any pattern or path provided will not be routed through Easy IO.', 'ewww-image-optimizer' ); ?>
|
10837 |
-
</p>
|
10838 |
-
</td>
|
10839 |
-
</tr>
|
10840 |
-
<tr>
|
10841 |
-
<th scope='row'>
|
10842 |
-
<label for='ewww_image_optimizer_lazy_load'><?php esc_html_e( 'Lazy Load', 'ewww-image-optimizer' ); ?></label>
|
10843 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?>
|
10844 |
-
</th>
|
10845 |
-
<td>
|
10846 |
-
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ); ?> />
|
10847 |
-
<?php esc_html_e( 'Improves actual and perceived loading time as images will be loaded only as they enter (or are about to enter) the viewport.', 'ewww-image-optimizer' ); ?>
|
10848 |
-
<p class='description'>
|
10849 |
-
<?php esc_html_e( 'When used with Easy IO and/or JS WebP Rewriting, the plugin will load the best available image size and format for each device.', 'ewww-image-optimizer' ); ?></br>
|
10850 |
-
<?php esc_html_e( 'To disable auto-scaling for an image, add "skip-autoscale" to the HTML element via a class or attribute.', 'ewww-image-optimizer' ); ?>
|
10851 |
</p>
|
10852 |
-
|
10853 |
-
</tr>
|
10854 |
-
<tr>
|
10855 |
-
<td> </td>
|
10856 |
-
<td>
|
10857 |
-
<input type='checkbox' name='ewww_image_optimizer_use_lqip' value='true' id='<?php echo esc_attr( $lqip_id ); ?>' <?php disabled( $lqip_dis ); ?> <?php checked( $lqip_che ); ?> />
|
10858 |
-
<label for='ewww_image_optimizer_use_lqip'><strong>LQIP</strong></label>
|
10859 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/75-lazy-load-placeholders', '5c9a7a302c7d3a1544615e47' ); ?>
|
10860 |
<p class='description'>
|
10861 |
-
<?php esc_html_e( '
|
10862 |
</p>
|
10863 |
</td>
|
10864 |
</tr>
|
10865 |
<tr>
|
10866 |
-
<
|
|
|
|
|
|
|
10867 |
<td>
|
10868 |
-
<
|
10869 |
-
<?php
|
10870 |
-
<textarea id='ewww_image_optimizer_ll_exclude' name='ewww_image_optimizer_ll_exclude' rows='3' cols='60'><?php echo esc_html( $ll_exclude_paths ); ?></textarea>
|
10871 |
-
<p class='description'>
|
10872 |
-
<?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Use any string that matches the desired element(s) or exclude entire element types like "div", "span", etc. The class "skip-lazy" and attribute "data-skip-lazy" are excluded by default.', 'ewww-image-optimizer' ); ?>
|
10873 |
-
</p>
|
10874 |
</td>
|
10875 |
</tr>
|
10876 |
</table>
|
@@ -10887,22 +12174,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10887 |
$aux_paths_desc = sprintf( __( 'One path per line, must be within %s. Use full paths, not relative paths.', 'ewww-image-optimizer' ), ABSPATH );
|
10888 |
?>
|
10889 |
|
10890 |
-
<div id='ewww-
|
10891 |
<noscript><h2><?php esc_html_e( 'Advanced', 'ewww-image-optimizer' ); ?></h2></noscript>
|
10892 |
<table class='form-table'>
|
10893 |
-
<tr>
|
10894 |
-
<th scope='row'>
|
10895 |
-
<label for='ewww_image_optimizer_jpg_quality'><?php esc_html_e( 'JPG Quality Level', 'ewww-image-optimizer' ); ?></label>
|
10896 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,58543c69c697912ffd6c19a7' ); ?>
|
10897 |
-
</th>
|
10898 |
-
<td>
|
10899 |
-
<input type='text' id='ewww_image_optimizer_jpg_quality' name='ewww_image_optimizer_jpg_quality' class='small-text' value='<?php echo esc_attr( ewww_image_optimizer_jpg_quality() ); ?>' />
|
10900 |
-
<?php esc_html_e( 'Valid values are 1-100.', 'ewww-image-optimizer' ); ?>
|
10901 |
-
<p class='description'>
|
10902 |
-
<?php esc_html_e( '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' ); ?>
|
10903 |
-
</p>
|
10904 |
-
</td>
|
10905 |
-
</tr>
|
10906 |
<tr>
|
10907 |
<th scope='row'>
|
10908 |
<label for='ewww_image_optimizer_parallel_optimization'><?php esc_html_e( 'Parallel Optimization', 'ewww-image-optimizer' ); ?></label>
|
@@ -11011,23 +12285,6 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11011 |
</td>
|
11012 |
</tr>
|
11013 |
<?php endif; ?>
|
11014 |
-
<tr>
|
11015 |
-
<th scope='row'>
|
11016 |
-
<?php esc_html_e( 'Resize Images', 'ewww-image-optimizer' ); ?>
|
11017 |
-
<?php ewwwio_help_link( 'https://docs.ewww.io/article/41-resize-settings', '59849911042863033a1ba5f9' ); ?>
|
11018 |
-
</th>
|
11019 |
-
<td>
|
11020 |
-
<label for='ewww_image_optimizer_maxmediawidth'><?php esc_html_e( 'Max Width', 'ewww-image-optimizer' ); ?></label>
|
11021 |
-
<input type='number' step='1' min='0' class='small-text' id='ewww_image_optimizer_maxmediawidth' name='ewww_image_optimizer_maxmediawidth' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' ); ?>' <?php disabled( function_exists( 'imsanity_get_max_width_height' ) ); ?> />
|
11022 |
-
<label for='ewww_image_optimizer_maxmediaheight'><?php esc_html_e( 'Max Height', 'ewww-image-optimizer' ); ?></label>
|
11023 |
-
<input type='number' step='1' min='0' class='small-text' id='ewww_image_optimizer_maxmediaheight' name='ewww_image_optimizer_maxmediaheight' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' ); ?>' <?php disabled( function_exists( 'imsanity_get_max_width_height' ) ); ?> />
|
11024 |
-
<?php esc_html_e( 'in pixels', 'ewww-image-optimizer' ); ?>
|
11025 |
-
<p class='description'>
|
11026 |
-
<?php esc_html_e( 'Resize uploaded images to these dimensions.', 'ewww-image-optimizer' ); ?>
|
11027 |
-
</p>
|
11028 |
-
</td>
|
11029 |
-
</tr>
|
11030 |
-
<?php if ( ! $easymode ) : ?>
|
11031 |
<tr>
|
11032 |
<th scope='row'>
|
11033 |
<label for='ewww_image_optimizer_resize_existing'><?php esc_html_e( 'Resize Existing Images', 'ewww-image-optimizer' ); ?></label>
|
@@ -11048,10 +12305,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11048 |
<?php esc_html_e( 'Allow resizing of existing images outside the Media Library. Use this to resize images specified under the Folders to Optimize setting when running Bulk or Scheduled Optimization.', 'ewww-image-optimizer' ); ?>
|
11049 |
</td>
|
11050 |
</tr>
|
11051 |
-
<?php
|
11052 |
-
|
11053 |
-
<?php if ( $easymode ) : ?>
|
11054 |
-
<?php elseif ( 'network-multisite' === $network ) : ?>
|
11055 |
<tr>
|
11056 |
<th scope="row">
|
11057 |
<?php esc_html_e( 'Disable Resizes', 'ewww-image-optimizer' ); ?>
|
@@ -11106,7 +12360,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11106 |
<input type='checkbox' id='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>' name='ewww_image_optimizer_disable_resizes[<?php echo esc_attr( $size ); ?>]' value='true' disabled />
|
11107 |
</td>
|
11108 |
<td>
|
11109 |
-
<label for='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>'
|
|
|
|
|
11110 |
</td>
|
11111 |
</tr>
|
11112 |
<?php elseif ( 'pdf-full' === $size ) : ?>
|
@@ -11118,8 +12374,8 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11118 |
<input type='checkbox' id='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>' name='ewww_image_optimizer_disable_resizes[<?php echo esc_attr( $size ); ?>]' value='true' <?php checked( ! empty( $disabled_sizes[ $size ] ) ); ?> />
|
11119 |
</td>
|
11120 |
<td>
|
11121 |
-
<label for='ewww_image_optimizer_disable_resizes_$size'>
|
11122 |
-
<?php echo
|
11123 |
</label>
|
11124 |
</td>
|
11125 |
</tr>
|
@@ -11132,7 +12388,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11132 |
<input type='checkbox' id='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>' name='ewww_image_optimizer_disable_resizes[<?php echo esc_attr( $size ); ?>]' value='true' <?php checked( ! empty( $disabled_sizes[ $size ] ) ); ?> />
|
11133 |
</td>
|
11134 |
<td>
|
11135 |
-
<label for='ewww_image_optimizer_disable_resizes_
|
|
|
|
|
11136 |
</td>
|
11137 |
</tr>
|
11138 |
<?php endif; ?>
|
@@ -11237,145 +12495,9 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11237 |
</table>
|
11238 |
</div>
|
11239 |
|
11240 |
-
<?php
|
11241 |
-
$rewrite_notice = ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ? __( 'You can use the rewrite rules below to serve WebP images with Apache.', 'ewww-image-optimizer' ) : '' );
|
11242 |
-
$webp_exclude_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_rewrite_exclude' ) ? implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_rewrite_exclude' ) ) : '';
|
11243 |
-
$webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) : '';
|
11244 |
-
$webp_url_example = sprintf(
|
11245 |
-
/* translators: 1: An image URL on a CDN 2: An image URL 3: An example folder URL */
|
11246 |
-
esc_html__( 'For example, with a CDN URL of %1$s and a local URL of %2$s you would enter %3$s.', 'ewww-image-optimizer' ),
|
11247 |
-
'https://cdn.example.com/<strong>files/</strong>2038/01/image.jpg',
|
11248 |
-
'https://example.com/<strong>wp-content/uploads/</strong>2038/01/image.jpg',
|
11249 |
-
'https://cdn.example.com/<strong>files/</strong>'
|
11250 |
-
);
|
11251 |
-
?>
|
11252 |
-
|
11253 |
<div id='ewww-webp-settings'>
|
11254 |
<noscript><h2><?php esc_html_e( 'WebP', 'ewww-image-optimizer' ); ?></h2></noscript>
|
11255 |
-
<?php if ( ! $free_exec && ! ewww_image_optimizer_easy_active() ) : ?>
|
11256 |
-
<p>
|
11257 |
-
<?php esc_html_e( 'Once WebP conversion is enabled, WebP images will be generated for new uploads, but you will need to use the Bulk Optimizer for existing uploads.', 'ewww-image-optimizer' ); ?><br>
|
11258 |
-
<a href='https://ewww.io/easy/'><?php esc_html_e( 'Get Easy IO for automatic WebP conversion and delivery.', 'ewww-image-optimizer' ); ?></a>
|
11259 |
-
</p>
|
11260 |
-
<?php endif; ?>
|
11261 |
<table class='form-table'>
|
11262 |
-
<?php if ( $free_exec ) : ?>
|
11263 |
-
<tr>
|
11264 |
-
<th> </th>
|
11265 |
-
<td>
|
11266 |
-
<p class='description'><?php esc_html_e( 'WebP conversion requires an API key or Easy IO subscription.', 'ewww-image-optimizer' ); ?></p>
|
11267 |
-
</td>
|
11268 |
-
</tr>
|
11269 |
-
<?php elseif ( ! ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
|
11270 |
-
<tr>
|
11271 |
-
<th scope='row'>
|
11272 |
-
<label for='ewww_image_optimizer_webp'><?php esc_html_e( 'WebP Conversion', 'ewww-image-optimizer' ); ?></label>
|
11273 |
-
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
|
11274 |
-
</th>
|
11275 |
-
<td>
|
11276 |
-
<input type='checkbox' id='ewww_image_optimizer_webp' name='ewww_image_optimizer_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ); ?> />
|
11277 |
-
<span><?php esc_html_e( 'Convert your images to the next generation format for supported browsers, while retaining originals for other browsers.', 'ewww-image-optimizer' ); ?></span>
|
11278 |
-
<p class='description'>
|
11279 |
-
<?php echo ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ? '' : esc_html__( 'GIF to WebP conversion requires an active API key.', 'ewww-image-optimizer' ) ); ?>
|
11280 |
-
<a href='#ewww-webp-rewrite'><?php echo esc_html( $rewrite_notice ); ?></a>
|
11281 |
-
</p>
|
11282 |
-
</td>
|
11283 |
-
</tr>
|
11284 |
-
<tr>
|
11285 |
-
<th scope='row'>
|
11286 |
-
<label for='ewww_image_optimizer_webp_quality'><?php esc_html_e( 'WebP Quality Level', 'ewww-image-optimizer' ); ?></label>
|
11287 |
-
</th>
|
11288 |
-
<td>
|
11289 |
-
<input type='text' id='ewww_image_optimizer_webp_quality' name='ewww_image_optimizer_webp_quality' class='small-text' value='<?php echo esc_attr( ewww_image_optimizer_webp_quality() ); ?>' />
|
11290 |
-
<?php esc_html_e( 'Default is 75, allowed range is 50-100.', 'ewww-image-optimizer' ); ?>
|
11291 |
-
</td>
|
11292 |
-
</tr>
|
11293 |
-
<?php endif; ?>
|
11294 |
-
|
11295 |
-
<?php if ( ! $free_exec && ( ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) ) : ?>
|
11296 |
-
<tr>
|
11297 |
-
<th scope='row'>
|
11298 |
-
<label for='ewww_image_optimizer_webp_for_cdn'><?php esc_html_e( 'JS WebP Rewriting', 'ewww-image-optimizer' ); ?></label>
|
11299 |
-
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span>
|
11300 |
-
</th>
|
11301 |
-
<td>
|
11302 |
-
<input type='checkbox' id='ewww_image_optimizer_webp_for_cdn' name='ewww_image_optimizer_webp_for_cdn' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ); ?> />
|
11303 |
-
<span><?php esc_html_e( 'Use this if the Apache rewrite rules do not work, or if your images are served from a CDN.', 'ewww-image-optimizer' ); ?></span>
|
11304 |
-
<p class='description'><?php esc_html_e( 'Supports CSS background images with Lazy Load option on the Easy Mode tab.', 'ewww-image-optimizer' ); ?></p>
|
11305 |
-
</td>
|
11306 |
-
</tr>
|
11307 |
-
<tr>
|
11308 |
-
<th scope='row'>
|
11309 |
-
<label for='ewww_image_optimizer_picture_webp'><?php esc_html_e( '<picture> WebP Rewriting', 'ewww-image-optimizer' ); ?></label>
|
11310 |
-
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span>
|
11311 |
-
</th>
|
11312 |
-
<td>
|
11313 |
-
<input type='checkbox' id='ewww_image_optimizer_picture_webp' name='ewww_image_optimizer_picture_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ); ?> />
|
11314 |
-
<span><?php esc_html_e( 'A JavaScript-free rewriting method using picture tags.', 'ewww-image-optimizer' ); ?></span>
|
11315 |
-
<p class='description'><?php esc_html_e( 'Use this if Apache rewrite rules do not work for your site. Some themes may not display <picture> tags properly, and does not support CSS background images.', 'ewww-image-optimizer' ); ?></p>
|
11316 |
-
</td>
|
11317 |
-
</tr>
|
11318 |
-
<tr>
|
11319 |
-
<td> </td>
|
11320 |
-
<td>
|
11321 |
-
<label for='ewww_image_optimizer_webp_rewrite_exclude'><?php esc_html_e( 'JS WebP and <picture> Web Exclusions', 'ewww-image-optimizer' ); ?></label><br>
|
11322 |
-
<textarea id='ewww_image_optimizer_webp_rewrite_exclude' name='ewww_image_optimizer_webp_rewrite_exclude' rows='3' cols='60'><?php echo esc_html( $webp_exclude_paths ); ?></textarea>
|
11323 |
-
<p class='description'><?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Use any string that matches the desired element(s) or exclude entire element types like "div", "span", etc.', 'ewww-image-optimizer' ); ?></p>
|
11324 |
-
</td>
|
11325 |
-
</tr>
|
11326 |
-
<tr>
|
11327 |
-
<th scope='row'>
|
11328 |
-
<label for='ewww_image_optimizer_webp_paths'><?php esc_html_e( 'WebP URLs', 'ewww-image-optimizer' ); ?></label>
|
11329 |
-
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
|
11330 |
-
</th>
|
11331 |
-
<td>
|
11332 |
-
<span><?php esc_html_e( 'Enter additional URL patterns, like a CDN URL, that should be permitted for WebP Rewriting. One URL per line, must include the domain name (cdn.example.com).', 'ewww-image-optimizer' ); ?></span>
|
11333 |
-
<p><?php esc_html_e( 'Optionally include a folder with the URL if your CDN path is different from your local path.', 'ewww-image-optimizer' ); ?></p>
|
11334 |
-
<textarea id='ewww_image_optimizer_webp_paths' name='ewww_image_optimizer_webp_paths' rows='3' cols='60'><?php echo esc_html( $webp_paths ); ?></textarea>
|
11335 |
-
<p class='description'><?php echo wp_kses_post( $webp_url_example ); ?></p>
|
11336 |
-
</td>
|
11337 |
-
</tr>
|
11338 |
-
<?php elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
11339 |
-
<tr>
|
11340 |
-
<th> </th>
|
11341 |
-
<td>
|
11342 |
-
<p class='description'><?php esc_html_e( 'WebP images are served automatically by Easy IO.', 'ewww-image-optimizer' ); ?></p>
|
11343 |
-
</td>
|
11344 |
-
</tr>
|
11345 |
-
<?php elseif ( get_option( 'easyio_exactdn' ) ) : ?>
|
11346 |
-
<tr>
|
11347 |
-
<th> </th>
|
11348 |
-
<td>
|
11349 |
-
<p class='description'><?php esc_html_e( 'WebP images are served automatically by Easy Image Optimizer.', 'ewww-image-optimizer' ); ?></p>
|
11350 |
-
</td>
|
11351 |
-
</tr>
|
11352 |
-
<?php endif; ?>
|
11353 |
-
|
11354 |
-
<?php if ( ! $free_exec && ( ! ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ) ) : ?>
|
11355 |
-
<tr>
|
11356 |
-
<th scope='row'>
|
11357 |
-
<label for='ewww_image_optimizer_webp_force'><?php esc_html_e( 'Force WebP', 'ewww-image-optimizer' ); ?></label>
|
11358 |
-
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
|
11359 |
-
</th>
|
11360 |
-
<td>
|
11361 |
-
<input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
|
11362 |
-
<span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
|
11363 |
-
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
11364 |
-
<p>
|
11365 |
-
<a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
|
11366 |
-
<?php esc_html_e( 'Click to enable forced GIF rewriting once WebP version have been generated.', 'ewww-image-optimizer' ); ?>
|
11367 |
-
</a>
|
11368 |
-
</p>
|
11369 |
-
<?php elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
11370 |
-
<p>
|
11371 |
-
<a href="https://optimize.exactlywww.com/api_key/free-trial.php?TB_iframe=true&width=600&height=375" class="thickbox" target="_blank">
|
11372 |
-
<?php esc_html_e( 'GIF to WebP conversion requires an API key.', 'ewww-image-optimizer' ); ?>
|
11373 |
-
</a>
|
11374 |
-
</p>
|
11375 |
-
<?php endif; ?>
|
11376 |
-
</td>
|
11377 |
-
</tr>
|
11378 |
-
<?php endif; ?>
|
11379 |
</table>
|
11380 |
</div>
|
11381 |
|
@@ -11385,9 +12507,27 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11385 |
<a class='ewww-docs-root' href='https://docs.ewww.io/'><?php esc_html_e( 'Documentation', 'ewww-image-optimizer' ); ?></a> |
|
11386 |
<a class='ewww-docs-root' href='https://ewww.io/contact-us/'><?php esc_html_e( 'Plugin Support', 'ewww-image-optimizer' ); ?></a> |
|
11387 |
<a href='https://feedback.ewww.io/'><?php esc_html_e( 'Submit Feedback', 'ewww-image-optimizer' ); ?></a> |
|
11388 |
-
<a href='https://ewww.io/chat/'><?php esc_html_e( 'Community Chat', 'ewww-image-optimizer' ); ?></a> |
|
11389 |
<a href='https://ewww.io/status/'><?php esc_html_e( 'Server Status', 'ewww-image-optimizer' ); ?></a>
|
11390 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11391 |
<table class='form-table'>
|
11392 |
<tr>
|
11393 |
<th scope='row'>
|
@@ -11443,7 +12583,19 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11443 |
</th>
|
11444 |
<td>
|
11445 |
<input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) ); ?> />
|
11446 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11447 |
</td>
|
11448 |
</tr>
|
11449 |
</table>
|
@@ -11451,117 +12603,39 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11451 |
<p class='submit'><input type='submit' class='button-primary' value='<?php esc_attr_e( 'Save Changes', 'ewww-image-optimizer' ); ?>' /></p>
|
11452 |
</form>
|
11453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11454 |
<?php
|
11455 |
-
// Make sure .htaccess rules are terminated when ExactDN is enabled or if Cloudflare is detected.
|
11456 |
-
$cf_host = ewwwio_is_cf_host();
|
11457 |
-
if ( ewww_image_optimizer_easy_active() || $cf_host ) {
|
11458 |
-
ewww_image_optimizer_webp_rewrite_verify();
|
11459 |
-
}
|
11460 |
-
$test_webp_image = plugins_url( '/images/test.png.webp', __FILE__ );
|
11461 |
-
$test_png_image = plugins_url( '/images/test.png', __FILE__ );
|
11462 |
-
if (
|
11463 |
-
! $cf_host &&
|
11464 |
-
ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) &&
|
11465 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) &&
|
11466 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) &&
|
11467 |
-
! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active()
|
11468 |
-
) {
|
11469 |
-
if ( defined( 'PHP_SAPI' ) && false === strpos( PHP_SAPI, 'apache' ) && false === strpos( PHP_SAPI, 'litespeed' ) ) {
|
11470 |
-
$false_positive_headers = esc_html( 'This may be a false positive. If so, the warning should go away once you implement the rewrite rules.' );
|
11471 |
-
}
|
11472 |
-
$header_error = '';
|
11473 |
-
if ( ! apache_mod_loaded( 'mod_rewrite' ) ) {
|
11474 |
-
/* translators: %s: mod_rewrite or mod_headers */
|
11475 |
-
$header_error = '<p><strong>' . sprintf( esc_html__( 'Your site appears to be missing %s, please contact your webhost or system administrator to enable this Apache module.', 'ewww-image-optimizer' ), 'mod_rewrite' ) . "</strong><br>$false_positive_headers</p>\n";
|
11476 |
-
}
|
11477 |
-
if ( ! apache_mod_loaded( 'mod_headers' ) ) {
|
11478 |
-
/* translators: %s: mod_rewrite or mod_headers */
|
11479 |
-
$header_error = '<p><strong>' . sprintf( esc_html__( 'Your site appears to be missing %s, please contact your webhost or system administrator to enable this Apache module.', 'ewww-image-optimizer' ), 'mod_headers' ) . "</strong><br>$false_positive_headers</p>\n";
|
11480 |
-
}
|
11481 |
-
|
11482 |
-
$webp_verified = ewww_image_optimizer_test_webp_mime_verify();
|
11483 |
-
if ( ! $webp_verified ) {
|
11484 |
-
echo wp_kses_post( $header_error );
|
11485 |
-
}
|
11486 |
-
|
11487 |
-
if ( $webp_verified || ! ewww_image_optimizer_webp_rewrite_verify() ) {
|
11488 |
-
?>
|
11489 |
-
<form id='ewww-webp-rewrite'>
|
11490 |
-
<img id='webp-image' src='<?php echo esc_url( $test_png_image . '?m=' . time() ); ?>' style='float: right; padding: 0 1px 10px 10px;'>
|
11491 |
-
<p id='ewww-webp-rewrite-status'><strong><?php esc_html_e( 'Rules verified successfully', 'ewww-image-optimizer' ); ?></strong></p>
|
11492 |
-
<button type='button' id='ewww-webp-remove' class='button-secondary action'><?php esc_html_e( 'Remove Rewrite Rules', 'ewww-image-optimizer' ); ?></button>
|
11493 |
-
</form>
|
11494 |
-
<?php } else { ?>
|
11495 |
-
<p><?php esc_html_e( 'There are many ways to serve WebP images to visitors with supported browsers. You may choose any you wish, but it is recommended to serve them with an .htaccess file using mod_rewrite and mod_headers. The plugin can insert the rules for you if the file is writable, or you can edit .htaccess yourself.', 'ewww-image-optimizer' ); ?></p>
|
11496 |
-
<form id='ewww-webp-rewrite'>
|
11497 |
-
<pre id='webp-rewrite-rules' style='background: white; font-color: black; border: 1px solid black; clear: both; padding: 10px;'>
|
11498 |
-
<IfModule mod_rewrite.c>
|
11499 |
-
RewriteEngine On
|
11500 |
-
RewriteCond %{HTTP_ACCEPT} image/webp
|
11501 |
-
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png|gif)$
|
11502 |
-
RewriteCond %{REQUEST_FILENAME}\.webp -f
|
11503 |
-
RewriteCond %{QUERY_STRING} !type=original
|
11504 |
-
RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1,L]
|
11505 |
-
</IfModule>
|
11506 |
-
<IfModule mod_headers.c>
|
11507 |
-
Header append Vary Accept env=REDIRECT_accept
|
11508 |
-
</IfModule>
|
11509 |
-
AddType image/webp .webp</pre>
|
11510 |
-
<img id='webp-image' src='<?php echo esc_url( $test_png_image . '?m=' . time() ); ?>' style='float: right; padding-left: 10px;'>
|
11511 |
-
<p id='ewww-webp-rewrite-status'><?php esc_html_e( 'The image to the right will display a WebP image with WEBP in white text, if your site is serving WebP images and your browser supports WebP.', 'ewww-image-optimizer' ); ?></p>
|
11512 |
-
<button type='button' id='ewww-webp-insert' class='button-secondary action'><?php esc_html_e( 'Insert Rewrite Rules', 'ewww-image-optimizer' ); ?></button>
|
11513 |
-
<?php } ?>
|
11514 |
-
</form>
|
11515 |
-
<?php } elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() ) { ?>
|
11516 |
-
<noscript data-img='<?php echo esc_url( $test_png_image ); ?>' data-webp='<?php echo esc_url( $test_webp_image ); ?>' data-style='padding: 0 0 10px 0;' class='ewww_webp'>
|
11517 |
-
<img src='<?php echo esc_url( $test_png_image ); ?>' style='float: right; padding: 0 0 10px 10px;'>
|
11518 |
-
</noscript>
|
11519 |
-
<?php } elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) && ! ewww_image_optimizer_ce_webp_enabled() ) { ?>
|
11520 |
-
<picture>
|
11521 |
-
<source srcset='<?php echo esc_url( $test_webp_image ); ?>' type='image/webp'>
|
11522 |
-
<img src='<?php echo esc_url( $test_webp_image ); ?>' style='padding: 0 0 10px 0;'>
|
11523 |
-
</picture>
|
11524 |
-
<?php } elseif ( $cf_host && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) { ?>
|
11525 |
-
<p><?php esc_html_e( 'Your site is using Cloudflare, please use JS WebP or <picture> WebP rewriting.', 'ewww-image-optimizer' ); ?></p>
|
11526 |
-
<?php } ?>
|
11527 |
-
|
11528 |
-
<?php
|
11529 |
-
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) {
|
11530 |
-
if ( ! isset( $eio_alt_webp ) ) {
|
11531 |
-
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-eio-page-parser.php' );
|
11532 |
-
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-eio-alt-webp.php' );
|
11533 |
-
}
|
11534 |
-
$eio_alt_webp->inline_script();
|
11535 |
-
}
|
11536 |
-
|
11537 |
-
echo '<hr style="clear:both;"><div id="ewwwio-banner"><img src="' . esc_url( plugins_url( '/images/ewwwio-logo.png', __FILE__ ) ) . '">' .
|
11538 |
-
'<p>' . esc_html__( 'Get performance tips, exclusive discounts, and the latest news when you signup for our newsletter!', 'ewww-image-optimizer' ) . '</p>' .
|
11539 |
-
'<a href="https://eepurl.com/gKyU6L?TB_iframe=true&width=600&height=610" class="thickbox button-secondary">' . esc_html__( 'Subscribe now!', 'ewww-image-optimizer' ) . ' →</a></div>';
|
11540 |
-
|
11541 |
-
echo '<h2>' . esc_html__( "Shane's Recommendations", 'ewww-image-optimizer' ) . '</h2>';
|
11542 |
-
echo '<p>' . esc_html__( 'These are products I have personally used. An * indicates an affiliate link so you can support future development of EWWW IO.', 'ewww-image-optimizer' ) . '</p>';
|
11543 |
-
echo '<h3>' . esc_html__( 'Hosting', 'ewww-image-optimizer' ) . '</h3>' .
|
11544 |
-
'<p><a href="http://shareasale.com/r.cfm?b=917225&u=1481701&m=41388&urllink=&afftrack=">WP Engine</a>* - ' .
|
11545 |
-
esc_html__( 'ewww.io is powered by WP Engine, and their performance is worth every penny. This is "managed WordPress hosting" at it\'s finest. 20% discount off your first payment with our link.', 'ewww-image-optimizer' ) .
|
11546 |
-
'<br><a href="https://kinsta.com?kaid=OCKKBJARSDFR">Kinsta</a>* - ' .
|
11547 |
-
esc_html__( 'Their performance is the same blazing speed as WP Engine, and the support is top notch as well. In addition, they offer SSH access with WP-CLI. Very solid offering and highly recommended.', 'ewww-image-optimizer' ) .
|
11548 |
-
'<br><a href="https://vrlps.co/kXJu5yF/cp">Cloudways</a>* - ' .
|
11549 |
-
esc_html__( 'Simple, yet powerful, managed VPS hosting. I use their hosting for a few client sites and performance is crazy fast. Support has been great any time I\'ve needed their assistance.', 'ewww-image-optimizer' ) .
|
11550 |
-
'</p>' .
|
11551 |
-
'<h3>' . esc_html__( 'Plugins and Services', 'ewww-image-optimizer' ) . '</h3>' .
|
11552 |
-
'<p><a href="https://easydigitaldownloads.com/?ref=4735">Easy Digital Downloads</a>* - ' .
|
11553 |
-
esc_html__( 'Sell digital products with a huge number of extensions for amazing flexibility. Naturally, this is how we sell our services and plugins.', 'ewww-image-optimizer' ) .
|
11554 |
-
'<br><a href="https://www.helpscout.net/referral/?code=SVhaTmZDSSt2WG4xYS9FRmZrNllUa3RSR25VTStXcGhmaStQQ21QQjBDVmdZdz09OnoyVTFIUzBnbldtM21VMEM.">Helpscout</a>* - ' .
|
11555 |
-
esc_html__( 'Treat your customers like people, not numbers, and keep them satisfied. Personal favorite feature is Traffic Cop that keeps you from sending a message if you receive another message from the customer while you are typing.', 'ewww-image-optimizer' ) .
|
11556 |
-
'<br><a href="http://eepurl.com/cLPIeD">MailChimp</a>* - ' .
|
11557 |
-
esc_html__( 'Mailing lists that just work plus automation features that work even when you\'re not.', 'ewww-image-optimizer' ) .
|
11558 |
-
'<br><a href="https://malcare.com?src=C600E7">MalCare</a>* - ' .
|
11559 |
-
esc_html__( 'Secure your site with a firewall, advanced heuristic scanning, and brute force login protection. Securing your site is not an option, it\'s a necessity.', 'ewww-image-optimizer' ) .
|
11560 |
-
'<br><a href="https://nodeping.com?rid=201407082225W862K">NodePing</a>* - ' .
|
11561 |
-
esc_html__( 'Monitor all the things, and make sure they stay online. They have a fantastic array of monitors and notifications that you can setup, they are cheap, simple, and have great support.', 'ewww-image-optimizer' ) .
|
11562 |
-
'</p>';
|
11563 |
-
|
11564 |
-
echo "</div><!-- end container wrap -->\n";
|
11565 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
11566 |
$current_user = wp_get_current_user();
|
11567 |
$help_email = $current_user->user_email;
|
@@ -11584,65 +12658,6 @@ AddType image/webp .webp</pre>
|
|
11584 |
ewww_image_optimizer_temp_debug_clear();
|
11585 |
}
|
11586 |
|
11587 |
-
/**
|
11588 |
-
* Filters through the settings page to remove unneeded settings for the -cloud plugin.
|
11589 |
-
*
|
11590 |
-
* @param array $input The output of the settings page, broken up into an array.
|
11591 |
-
* @return string The filtered output for the settings page.
|
11592 |
-
*/
|
11593 |
-
function ewww_image_optimizer_filter_settings_page( $input ) {
|
11594 |
-
$output = '';
|
11595 |
-
foreach ( $input as $line ) {
|
11596 |
-
if ( ewww_image_optimizer_full_cloud() && preg_match( '/nocloud/', $line ) ) {
|
11597 |
-
continue;
|
11598 |
-
} else {
|
11599 |
-
$output .= $line;
|
11600 |
-
}
|
11601 |
-
}
|
11602 |
-
ewwwio_memory( __FUNCTION__ );
|
11603 |
-
return $output;
|
11604 |
-
}
|
11605 |
-
|
11606 |
-
/**
|
11607 |
-
* Filters through the multisite settings page to remove unneeded settings in multisite mode.
|
11608 |
-
*
|
11609 |
-
* @param array $input The output of the settings page, broken up into an array.
|
11610 |
-
* @return string The filtered output for the settings page.
|
11611 |
-
*/
|
11612 |
-
function ewww_image_optimizer_filter_network_settings_page( $input ) {
|
11613 |
-
$output = array();
|
11614 |
-
foreach ( $input as $line ) {
|
11615 |
-
if ( strpos( $line, 'network-singlesite' ) ) {
|
11616 |
-
continue;
|
11617 |
-
} else {
|
11618 |
-
$output[] = $line;
|
11619 |
-
}
|
11620 |
-
}
|
11621 |
-
ewwwio_memory( __FUNCTION__ );
|
11622 |
-
return $output;
|
11623 |
-
}
|
11624 |
-
|
11625 |
-
/**
|
11626 |
-
* Filters through the single-site settings page to remove unneeded settings in multisite mode.
|
11627 |
-
*
|
11628 |
-
* @param array $input The output of the settings page, broken up into an array.
|
11629 |
-
* @return string The filtered output for the settings page.
|
11630 |
-
*/
|
11631 |
-
function ewww_image_optimizer_filter_network_singlesite_settings_page( $input ) {
|
11632 |
-
$output = array();
|
11633 |
-
foreach ( $input as $line ) {
|
11634 |
-
if ( ! get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) && strpos( $line, 'network-multisite' ) ) {
|
11635 |
-
continue;
|
11636 |
-
} elseif ( strpos( $line, 'network-only' ) ) {
|
11637 |
-
continue;
|
11638 |
-
} else {
|
11639 |
-
$output[] = $line;
|
11640 |
-
}
|
11641 |
-
}
|
11642 |
-
ewwwio_memory( __FUNCTION__ );
|
11643 |
-
return $output;
|
11644 |
-
}
|
11645 |
-
|
11646 |
/**
|
11647 |
* Gets the HTML for a help icon linked to the docs.
|
11648 |
*
|
@@ -11734,6 +12749,34 @@ function ewww_image_optimizer_remove_cloud_key( $redirect = true ) {
|
|
11734 |
}
|
11735 |
}
|
11736 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11737 |
/**
|
11738 |
* Enables Forced WebP for GIF images once the site is ready.
|
11739 |
*/
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '600' );
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
101 |
// This filter turns off ewwwio_image_editor during save from the actual image editor and ensures that we parse the resizes list during the image editor save function.
|
102 |
add_filter( 'load_image_to_edit_path', 'ewww_image_optimizer_editor_save_pre' );
|
103 |
// Allows the user to override the default JPG quality used by WordPress.
|
104 |
+
add_filter( 'jpeg_quality', 'ewww_image_optimizer_set_jpg_quality', PHP_INT_MAX - 1 );
|
105 |
// Allows the user to override the default WebP quality used by EWWW IO.
|
106 |
add_filter( 'webp_quality', 'ewww_image_optimizer_set_webp_quality' );
|
107 |
// Prevent WP from over-riding EWWW IO's resize settings.
|
154 |
add_action( 'mfrh_path_renamed', 'ewww_image_optimizer_path_renamed', 10, 3 );
|
155 |
// Correct any records in the table created during retina generation.
|
156 |
add_action( 'wr2x_retina_file_added', 'ewww_image_optimizer_retina', 20, 2 );
|
157 |
+
// AJAX action hook to verify an API key.
|
158 |
+
add_action( 'wp_ajax_ewww_cloud_key_verify', 'ewww_image_optimizer_cloud_key_verify_ajax' );
|
159 |
+
// AJAX action hook to activate Easy IO.
|
160 |
+
add_action( 'wp_ajax_ewww_exactdn_activate', 'ewww_image_optimizer_exactdn_activate_ajax' );
|
161 |
// AJAX action hook for inserting WebP rewrite rules into .htaccess.
|
162 |
add_action( 'wp_ajax_ewww_webp_rewrite', 'ewww_image_optimizer_webp_rewrite' );
|
163 |
// AJAX action hook for removing WebP rewrite rules from .htaccess.
|
184 |
add_action( 'admin_bar_init', 'ewww_image_optimizer_admin_bar_init' );
|
185 |
// Non-AJAX handler to delete the API key, and reroute back to the settings page.
|
186 |
add_action( 'admin_action_ewww_image_optimizer_remove_cloud_key', 'ewww_image_optimizer_remove_cloud_key' );
|
187 |
+
// Non-AJAX handler to disable Easy IO and reroute back to the settings page.
|
188 |
+
add_action( 'admin_action_ewww_image_optimizer_remove_easyio', 'ewww_image_optimizer_remove_easyio' );
|
189 |
// Non-AJAX handler to enable Force WebP for GIF files.
|
190 |
add_action( 'admin_action_ewww_image_optimizer_enable_force_gif2webp', 'ewww_image_optimizer_enable_force_gif2webp' );
|
191 |
// Non-AJAX handler to retest async/background mode.
|
196 |
add_action( 'admin_action_ewww_image_optimizer_delete_debug_log', 'ewww_image_optimizer_delete_debug_log' );
|
197 |
// Check if WebP option was turned off and is now enabled.
|
198 |
add_filter( 'pre_update_option_ewww_image_optimizer_webp', 'ewww_image_optimizer_webp_maybe_enabled', 10, 2 );
|
|
|
|
|
199 |
// Check Scheduled Opt option has just been disabled and clear the queues/stop the process.
|
200 |
add_filter( 'pre_update_option_ewww_image_optimizer_auto', 'ewww_image_optimizer_scheduled_optimizaton_changed', 10, 2 );
|
201 |
// Makes sure to flush out any scheduled jobs on deactivation.
|
265 |
* Alt WebP class for parsing image urls and rewriting them for WebP support.
|
266 |
*/
|
267 |
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-eio-alt-webp.php' );
|
268 |
+
}
|
269 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
270 |
$buffer_start = true;
|
271 |
/**
|
272 |
* Page Parsing class for working with HTML content.
|
331 |
return $plugin_data;
|
332 |
}
|
333 |
|
334 |
+
/**
|
335 |
+
* Checks to see if some other lazy loader is active.
|
336 |
+
*
|
337 |
+
* @return bool True if third-party lazy load detected, false otherwise.
|
338 |
+
*/
|
339 |
+
function ewwwio_other_lazy_detected() {
|
340 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
341 |
+
if ( class_exists( 'RocketLazyLoadPlugin\Plugin' ) || defined( 'ROCKET_LL_VERSION' ) ) {
|
342 |
+
$rocketll_settings = get_option( 'rocket_lazyload_options' );
|
343 |
+
if ( is_array( $rocketll_settings ) && ! empty( $rocketll_settings['images'] ) ) {
|
344 |
+
ewwwio_debug_message( 'rocket lazy detected (standalone free plugin)' );
|
345 |
+
return true;
|
346 |
+
}
|
347 |
+
}
|
348 |
+
if ( class_exists( 'WP_Rocket\Plugin' ) || defined( 'WP_ROCKET_VERSION' ) ) {
|
349 |
+
$rocket_settings = get_option( 'wp_rocket_settings' );
|
350 |
+
if ( is_array( $rocket_settings ) && ! empty( $rocket_settings['lazyload'] ) ) {
|
351 |
+
ewwwio_debug_message( 'WP Rocket with lazy detected' );
|
352 |
+
return true;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
if ( class_exists( 'autoptimizeExtra' ) || defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) ) {
|
356 |
+
$ao_extra = get_option( 'autoptimize_imgopt_settings' );
|
357 |
+
if ( ! empty( $ao_extra['autoptimize_imgopt_checkbox_field_3'] ) ) {
|
358 |
+
ewwwio_debug_message( 'Autoptimize lazy detected' );
|
359 |
+
return true;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
if ( class_exists( 'SiteGround_Optimizer\Helper\Helper' ) && get_option( 'siteground_optimizer_lazyload_images' ) ) {
|
363 |
+
ewwwio_debug_message( 'SG Optimizer lazy detected' );
|
364 |
+
return true;
|
365 |
+
}
|
366 |
+
if ( class_exists( '\A3Rev\LazyLoad' ) || defined( 'A3_LAZY_VERSION' ) ) {
|
367 |
+
ewwwio_debug_message( 'A3 lazy detected' );
|
368 |
+
return true;
|
369 |
+
}
|
370 |
+
if ( class_exists( 'WpFastestCache' ) || defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
|
371 |
+
if ( ! empty( $GLOBALS['wp_fastest_cache_options']->wpFastestCacheLazyLoad ) ) {
|
372 |
+
ewwwio_debug_message( 'WPFC lazy detected' );
|
373 |
+
return true;
|
374 |
+
}
|
375 |
+
}
|
376 |
+
if ( class_exists( '\W3TC\Dispatcher' ) || defined( 'W3TC_VERSION' ) ) {
|
377 |
+
if ( method_exists( '\W3TC\Dispatcher', 'config' ) ) {
|
378 |
+
$w3tc_config = \W3TC\Dispatcher::config();
|
379 |
+
if ( method_exists( $w3tc_config, 'get_boolean' ) && $w3tc_config->get_boolean( 'lazyload.enabled' ) ) {
|
380 |
+
ewwwio_debug_message( 'W3TC lazy detected' );
|
381 |
+
return true;
|
382 |
+
}
|
383 |
+
}
|
384 |
+
}
|
385 |
+
if ( class_exists( '\Automattic\Jetpack\Jetpack_Lazy_Images' ) && class_exists( '\Jetpack' ) && Jetpack::is_module_active( 'lazy-images' ) ) {
|
386 |
+
ewwwio_debug_message( 'Jetpack lazy detected' );
|
387 |
+
return true;
|
388 |
+
}
|
389 |
+
return false;
|
390 |
+
}
|
391 |
+
|
392 |
/**
|
393 |
* Checks to see if the WebP option from the Cache Enabler plugin is enabled.
|
394 |
*
|
558 |
return function_exists( $function );
|
559 |
}
|
560 |
|
561 |
+
/**
|
562 |
+
* Save the multi-site settings, if this is the WP admin, and they've been POSTed.
|
563 |
+
*/
|
564 |
+
function ewww_image_optimizer_save_network_settings() {
|
565 |
+
if ( ! is_admin() ) {
|
566 |
+
return;
|
567 |
+
}
|
568 |
+
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
569 |
+
// Need to include the plugin library for the is_plugin_active function.
|
570 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
571 |
+
}
|
572 |
+
if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) ) {
|
573 |
+
ewwwio_debug_message( 'saving network settings' );
|
574 |
+
// Set the common network settings if they have been POSTed.
|
575 |
+
if (
|
576 |
+
! empty( $_REQUEST['_wpnonce'] ) &&
|
577 |
+
wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) &&
|
578 |
+
isset( $_POST['option_page'] ) &&
|
579 |
+
false !== strpos( sanitize_text_field( wp_unslash( $_POST['option_page'] ) ), 'ewww_image_optimizer_options' ) &&
|
580 |
+
current_user_can( 'manage_network_options' ) &&
|
581 |
+
! get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) &&
|
582 |
+
false === strpos( wp_get_referer(), 'options-general' )
|
583 |
+
) {
|
584 |
+
ewwwio_debug_message( 'network-wide settings, no override' );
|
585 |
+
$ewww_image_optimizer_debug = ( empty( $_POST['ewww_image_optimizer_debug'] ) ? false : true );
|
586 |
+
update_site_option( 'ewww_image_optimizer_debug', $ewww_image_optimizer_debug );
|
587 |
+
$ewww_image_optimizer_metadata_remove = ( empty( $_POST['ewww_image_optimizer_metadata_remove'] ) ? false : true );
|
588 |
+
update_site_option( 'ewww_image_optimizer_metadata_remove', $ewww_image_optimizer_metadata_remove );
|
589 |
+
$ewww_image_optimizer_jpg_level = empty( $_POST['ewww_image_optimizer_jpg_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_jpg_level'];
|
590 |
+
update_site_option( 'ewww_image_optimizer_jpg_level', $ewww_image_optimizer_jpg_level );
|
591 |
+
$ewww_image_optimizer_png_level = empty( $_POST['ewww_image_optimizer_png_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_png_level'];
|
592 |
+
update_site_option( 'ewww_image_optimizer_png_level', $ewww_image_optimizer_png_level );
|
593 |
+
$ewww_image_optimizer_gif_level = empty( $_POST['ewww_image_optimizer_gif_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_gif_level'];
|
594 |
+
update_site_option( 'ewww_image_optimizer_gif_level', $ewww_image_optimizer_gif_level );
|
595 |
+
$ewww_image_optimizer_pdf_level = empty( $_POST['ewww_image_optimizer_pdf_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_pdf_level'];
|
596 |
+
update_site_option( 'ewww_image_optimizer_pdf_level', $ewww_image_optimizer_pdf_level );
|
597 |
+
$ewww_image_optimizer_svg_level = empty( $_POST['ewww_image_optimizer_svg_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_svg_level'];
|
598 |
+
update_site_option( 'ewww_image_optimizer_svg_level', $ewww_image_optimizer_svg_level );
|
599 |
+
$ewww_image_optimizer_delete_originals = ( empty( $_POST['ewww_image_optimizer_delete_originals'] ) ? false : true );
|
600 |
+
update_site_option( 'ewww_image_optimizer_delete_originals', $ewww_image_optimizer_delete_originals );
|
601 |
+
$ewww_image_optimizer_jpg_to_png = ( empty( $_POST['ewww_image_optimizer_jpg_to_png'] ) ? false : true );
|
602 |
+
update_site_option( 'ewww_image_optimizer_jpg_to_png', $ewww_image_optimizer_jpg_to_png );
|
603 |
+
$ewww_image_optimizer_png_to_jpg = ( empty( $_POST['ewww_image_optimizer_png_to_jpg'] ) ? false : true );
|
604 |
+
update_site_option( 'ewww_image_optimizer_png_to_jpg', $ewww_image_optimizer_png_to_jpg );
|
605 |
+
$ewww_image_optimizer_gif_to_png = ( empty( $_POST['ewww_image_optimizer_gif_to_png'] ) ? false : true );
|
606 |
+
update_site_option( 'ewww_image_optimizer_gif_to_png', $ewww_image_optimizer_gif_to_png );
|
607 |
+
$ewww_image_optimizer_webp = ( empty( $_POST['ewww_image_optimizer_webp'] ) ? false : true );
|
608 |
+
update_site_option( 'ewww_image_optimizer_webp', $ewww_image_optimizer_webp );
|
609 |
+
$ewww_image_optimizer_jpg_background = empty( $_POST['ewww_image_optimizer_jpg_background'] ) ? '' : sanitize_text_field( wp_unslash( $_POST['ewww_image_optimizer_jpg_background'] ) );
|
610 |
+
update_site_option( 'ewww_image_optimizer_jpg_background', ewww_image_optimizer_jpg_background( $ewww_image_optimizer_jpg_background ) );
|
611 |
+
$ewww_image_optimizer_jpg_quality = empty( $_POST['ewww_image_optimizer_jpg_quality'] ) ? '' : (int) $_POST['ewww_image_optimizer_jpg_quality'];
|
612 |
+
update_site_option( 'ewww_image_optimizer_jpg_quality', ewww_image_optimizer_jpg_quality( $ewww_image_optimizer_jpg_quality ) );
|
613 |
+
$ewww_image_optimizer_webp_quality = empty( $_POST['ewww_image_optimizer_webp_quality'] ) ? '' : (int) $_POST['ewww_image_optimizer_webp_quality'];
|
614 |
+
update_site_option( 'ewww_image_optimizer_webp_quality', ewww_image_optimizer_webp_quality( $ewww_image_optimizer_webp_quality ) );
|
615 |
+
$ewww_image_optimizer_disable_convert_links = ( empty( $_POST['ewww_image_optimizer_disable_convert_links'] ) ? false : true );
|
616 |
+
update_site_option( 'ewww_image_optimizer_disable_convert_links', $ewww_image_optimizer_disable_convert_links );
|
617 |
+
$ewww_image_optimizer_backup_files = ( empty( $_POST['ewww_image_optimizer_backup_files'] ) ? false : true );
|
618 |
+
update_site_option( 'ewww_image_optimizer_backup_files', $ewww_image_optimizer_backup_files );
|
619 |
+
$ewww_image_optimizer_auto = ( empty( $_POST['ewww_image_optimizer_auto'] ) ? false : true );
|
620 |
+
update_site_option( 'ewww_image_optimizer_auto', $ewww_image_optimizer_auto );
|
621 |
+
$ewww_image_optimizer_aux_paths = empty( $_POST['ewww_image_optimizer_aux_paths'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_aux_paths'] ) );
|
622 |
+
update_site_option( 'ewww_image_optimizer_aux_paths', ewww_image_optimizer_aux_paths_sanitize( $ewww_image_optimizer_aux_paths ) );
|
623 |
+
$ewww_image_optimizer_exclude_paths = empty( $_POST['ewww_image_optimizer_exclude_paths'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_exclude_paths'] ) );
|
624 |
+
update_site_option( 'ewww_image_optimizer_exclude_paths', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_exclude_paths ) );
|
625 |
+
$ewww_image_optimizer_enable_cloudinary = ( empty( $_POST['ewww_image_optimizer_enable_cloudinary'] ) ? false : true );
|
626 |
+
update_site_option( 'ewww_image_optimizer_enable_cloudinary', $ewww_image_optimizer_enable_cloudinary );
|
627 |
+
$exactdn_all_the_things = ( empty( $_POST['exactdn_all_the_things'] ) ? false : true );
|
628 |
+
update_site_option( 'exactdn_all_the_things', $exactdn_all_the_things );
|
629 |
+
$exactdn_lossy = ( empty( $_POST['exactdn_lossy'] ) ? false : true );
|
630 |
+
update_site_option( 'exactdn_lossy', $exactdn_lossy );
|
631 |
+
$exactdn_exclude = empty( $_POST['exactdn_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['exactdn_exclude'] ) );
|
632 |
+
update_site_option( 'exactdn_exclude', ewww_image_optimizer_exclude_paths_sanitize( $exactdn_exclude ) );
|
633 |
+
$ewww_image_optimizer_lazy_load = ( empty( $_POST['ewww_image_optimizer_lazy_load'] ) ? false : true );
|
634 |
+
update_site_option( 'ewww_image_optimizer_lazy_load', $ewww_image_optimizer_lazy_load );
|
635 |
+
$ewww_image_optimizer_use_lqip = ( empty( $_POST['ewww_image_optimizer_use_lqip'] ) ? false : true );
|
636 |
+
update_site_option( 'ewww_image_optimizer_use_lqip', $ewww_image_optimizer_use_lqip );
|
637 |
+
$ewww_image_optimizer_ll_exclude = empty( $_POST['ewww_image_optimizer_ll_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_ll_exclude'] ) );
|
638 |
+
update_site_option( 'ewww_image_optimizer_ll_exclude', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_ll_exclude ) );
|
639 |
+
$ewww_image_optimizer_maxmediawidth = empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ? 0 : (int) $_POST['ewww_image_optimizer_maxmediawidth'];
|
640 |
+
update_site_option( 'ewww_image_optimizer_maxmediawidth', $ewww_image_optimizer_maxmediawidth );
|
641 |
+
$ewww_image_optimizer_maxmediaheight = empty( $_POST['ewww_image_optimizer_maxmediaheight'] ) ? 0 : (int) $_POST['ewww_image_optimizer_maxmediaheight'];
|
642 |
+
update_site_option( 'ewww_image_optimizer_maxmediaheight', $ewww_image_optimizer_maxmediaheight );
|
643 |
+
$ewww_image_optimizer_resize_detection = ( empty( $_POST['ewww_image_optimizer_resize_detection'] ) ? false : true );
|
644 |
+
update_site_option( 'ewww_image_optimizer_resize_detection', $ewww_image_optimizer_resize_detection );
|
645 |
+
$ewww_image_optimizer_resize_existing = ( empty( $_POST['ewww_image_optimizer_resize_existing'] ) ? false : true );
|
646 |
+
update_site_option( 'ewww_image_optimizer_resize_existing', $ewww_image_optimizer_resize_existing );
|
647 |
+
$ewww_image_optimizer_resize_other_existing = ( empty( $_POST['ewww_image_optimizer_resize_other_existing'] ) ? false : true );
|
648 |
+
update_site_option( 'ewww_image_optimizer_resize_other_existing', $ewww_image_optimizer_resize_other_existing );
|
649 |
+
$ewww_image_optimizer_parallel_optimization = ( empty( $_POST['ewww_image_optimizer_parallel_optimization'] ) ? false : true );
|
650 |
+
update_site_option( 'ewww_image_optimizer_parallel_optimization', $ewww_image_optimizer_parallel_optimization );
|
651 |
+
$ewww_image_optimizer_include_media_paths = ( empty( $_POST['ewww_image_optimizer_include_media_paths'] ) ? false : true );
|
652 |
+
update_site_option( 'ewww_image_optimizer_include_media_paths', $ewww_image_optimizer_include_media_paths );
|
653 |
+
$ewww_image_optimizer_include_originals = ( empty( $_POST['ewww_image_optimizer_include_originals'] ) ? false : true );
|
654 |
+
update_site_option( 'ewww_image_optimizer_include_originals', $ewww_image_optimizer_include_originals );
|
655 |
+
$ewww_image_optimizer_webp_for_cdn = ( empty( $_POST['ewww_image_optimizer_webp_for_cdn'] ) ? false : true );
|
656 |
+
update_site_option( 'ewww_image_optimizer_webp_for_cdn', $ewww_image_optimizer_webp_for_cdn );
|
657 |
+
$ewww_image_optimizer_picture_webp = ( empty( $_POST['ewww_image_optimizer_picture_webp'] ) ? false : true );
|
658 |
+
update_site_option( 'ewww_image_optimizer_picture_webp', $ewww_image_optimizer_picture_webp );
|
659 |
+
$ewww_image_optimizer_webp_rewrite_exclude = empty( $_POST['ewww_image_optimizer_webp_rewrite_exclude'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_webp_rewrite_exclude'] ) );
|
660 |
+
update_site_option( 'ewww_image_optimizer_webp_rewrite_exclude', ewww_image_optimizer_exclude_paths_sanitize( $ewww_image_optimizer_webp_rewrite_exclude ) );
|
661 |
+
$ewww_image_optimizer_webp_force = ( empty( $_POST['ewww_image_optimizer_webp_force'] ) ? false : true );
|
662 |
+
update_site_option( 'ewww_image_optimizer_webp_force', $ewww_image_optimizer_webp_force );
|
663 |
+
$ewww_image_optimizer_webp_paths = ( empty( $_POST['ewww_image_optimizer_webp_paths'] ) ? '' : sanitize_textarea_field( wp_unslash( $_POST['ewww_image_optimizer_webp_paths'] ) ) );
|
664 |
+
update_site_option( 'ewww_image_optimizer_webp_paths', ewww_image_optimizer_webp_paths_sanitize( $ewww_image_optimizer_webp_paths ) );
|
665 |
+
$ewww_image_optimizer_allow_multisite_override = empty( $_POST['ewww_image_optimizer_allow_multisite_override'] ) ? false : true;
|
666 |
+
update_site_option( 'ewww_image_optimizer_allow_multisite_override', $ewww_image_optimizer_allow_multisite_override );
|
667 |
+
$ewww_image_optimizer_enable_help = empty( $_POST['ewww_image_optimizer_enable_help'] ) ? false : true;
|
668 |
+
update_site_option( 'ewww_image_optimizer_enable_help', $ewww_image_optimizer_enable_help );
|
669 |
+
global $ewwwio_tracking;
|
670 |
+
$ewww_image_optimizer_allow_tracking = empty( $_POST['ewww_image_optimizer_allow_tracking'] ) ? false : $ewwwio_tracking->check_for_settings_optin( (bool) $_POST['ewww_image_optimizer_allow_tracking'] );
|
671 |
+
update_site_option( 'ewww_image_optimizer_allow_tracking', $ewww_image_optimizer_allow_tracking );
|
672 |
+
add_action( 'network_admin_notices', 'ewww_image_optimizer_network_settings_saved' );
|
673 |
+
if ( ! empty( $_POST['ewww_image_optimizer_exactdn'] ) && ! class_exists( 'ExactDN' ) ) {
|
674 |
+
/**
|
675 |
+
* Page Parsing class for working with HTML content.
|
676 |
+
*/
|
677 |
+
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-eio-page-parser.php' );
|
678 |
+
/**
|
679 |
+
* ExactDN class for parsing image urls and rewriting them.
|
680 |
+
*/
|
681 |
+
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-exactdn.php' );
|
682 |
+
}
|
683 |
+
} elseif (
|
684 |
+
isset( $_POST['ewww_image_optimizer_allow_multisite_override_active'] ) &&
|
685 |
+
current_user_can( 'manage_network_options' ) &&
|
686 |
+
isset( $_REQUEST['_wpnonce'] ) &&
|
687 |
+
wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' )
|
688 |
+
) {
|
689 |
+
ewwwio_debug_message( 'network-wide settings, single-site overriding' );
|
690 |
+
$ewww_image_optimizer_allow_multisite_override = empty( $_POST['ewww_image_optimizer_allow_multisite_override'] ) ? false : true;
|
691 |
+
update_site_option( 'ewww_image_optimizer_allow_multisite_override', $ewww_image_optimizer_allow_multisite_override );
|
692 |
+
global $ewwwio_tracking;
|
693 |
+
$ewww_image_optimizer_allow_tracking = empty( $_POST['ewww_image_optimizer_allow_tracking'] ) ? false : $ewwwio_tracking->check_for_settings_optin( (bool) $_POST['ewww_image_optimizer_allow_tracking'] );
|
694 |
+
update_site_option( 'ewww_image_optimizer_allow_tracking', $ewww_image_optimizer_allow_tracking );
|
695 |
+
add_action( 'network_admin_notices', 'ewww_image_optimizer_network_settings_saved' );
|
696 |
+
} // End if().
|
697 |
+
} // End if().
|
698 |
+
if ( is_multisite() && get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) &&
|
699 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) &&
|
700 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) &&
|
701 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) &&
|
702 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) &&
|
703 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' )
|
704 |
+
) {
|
705 |
+
ewww_image_optimizer_set_defaults();
|
706 |
+
update_option( 'ewww_image_optimizer_disable_pngout', true );
|
707 |
+
update_option( 'ewww_image_optimizer_disable_svgcleaner', true );
|
708 |
+
update_option( 'ewww_image_optimizer_optipng_level', 2 );
|
709 |
+
update_option( 'ewww_image_optimizer_pngout_level', 2 );
|
710 |
+
update_option( 'ewww_image_optimizer_metadata_remove', true );
|
711 |
+
update_option( 'ewww_image_optimizer_jpg_level', '10' );
|
712 |
+
update_option( 'ewww_image_optimizer_png_level', '10' );
|
713 |
+
update_option( 'ewww_image_optimizer_gif_level', '10' );
|
714 |
+
update_option( 'ewww_image_optimizer_svg_level', 0 );
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
/**
|
719 |
* Runs on 'plugins_loaded' to make make sure the language files are loaded early.
|
720 |
*/
|
741 |
if ( ! empty( $_GET['enable-local'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
742 |
update_option( 'ewww_image_optimizer_local_mode', true );
|
743 |
update_site_option( 'ewww_image_optimizer_local_mode', true );
|
744 |
+
} elseif ( isset( $_GET['enable-local'] ) && ! (bool) $_GET['enable-local'] && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
745 |
delete_option( 'ewww_image_optimizer_local_mode', true );
|
746 |
delete_site_option( 'ewww_image_optimizer_local_mode', true );
|
|
|
|
|
|
|
747 |
}
|
748 |
+
if ( ! empty( $_GET['complete_wizard'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
749 |
+
update_option( 'ewww_image_optimizer_wizard_complete', true, false );
|
750 |
+
}
|
751 |
+
if ( ! empty( $_GET['uncomplete_wizard'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
752 |
+
update_option( 'ewww_image_optimizer_wizard_complete', false, false );
|
753 |
+
}
|
754 |
// Resizes and auto-rotates images.
|
755 |
add_filter( 'wp_handle_upload', 'ewww_image_optimizer_handle_upload' );
|
756 |
if ( class_exists( 'S3_Uploads' ) ) {
|
876 |
add_option( 'ewww_image_optimizer_review_time', $review_time, '', false );
|
877 |
add_site_option( 'ewww_image_optimizer_review_time', $review_time );
|
878 |
}
|
879 |
+
if ( get_option( 'ewww_image_optimizer_version' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_wizard_complete' ) ) {
|
880 |
+
add_option( 'ewww_image_optimizer_wizard_complete', true, '', false );
|
881 |
+
add_site_option( 'ewww_image_optimizer_wizard_complete', true );
|
882 |
+
}
|
883 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
884 |
if ( 'external' === get_option( 'elementor_css_print_method' ) ) {
|
885 |
update_option( 'elementor_css_print_method', 'internal' );
|
962 |
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'mwebp.php' );
|
963 |
ewww_image_optimizer_cloud_init();
|
964 |
ewww_image_optimizer_upgrade();
|
965 |
+
|
966 |
+
// Do settings validation for multi-site.
|
967 |
+
ewww_image_optimizer_save_network_settings();
|
968 |
+
|
969 |
+
// Register all the common EWWW IO settings.
|
970 |
+
/* register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_cloud_key', 'ewww_image_optimizer_cloud_key_sanitize' ); */
|
971 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
|
972 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_metadata_remove', 'boolval' );
|
973 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
|
974 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_level', 'intval' );
|
975 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_level', 'intval' );
|
976 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pdf_level', 'intval' );
|
977 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_svg_level', 'intval' );
|
978 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_backup_files', 'boolval' );
|
979 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_cloudinary', 'boolval' );
|
980 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_quality', 'ewww_image_optimizer_jpg_quality' );
|
981 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_quality', 'ewww_image_optimizer_webp_quality' );
|
982 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
|
983 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
|
984 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
|
985 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_originals', 'boolval' );
|
986 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_aux_paths', 'ewww_image_optimizer_aux_paths_sanitize' );
|
987 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exclude_paths', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
988 |
+
global $ewwwio_tracking;
|
989 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_allow_tracking', array( $ewwwio_tracking, 'check_for_settings_optin' ) );
|
990 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_help', 'boolval' );
|
991 |
+
/* register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_exactdn', 'boolval' ); */
|
992 |
+
register_setting( 'ewww_image_optimizer_options', 'exactdn_all_the_things', 'boolval' );
|
993 |
+
register_setting( 'ewww_image_optimizer_options', 'exactdn_lossy', 'boolval' );
|
994 |
+
register_setting( 'ewww_image_optimizer_options', 'exactdn_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
995 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_lazy_load', 'boolval' );
|
996 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_use_lqip', 'boolval' );
|
997 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_ll_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
998 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_detection', 'boolval' );
|
999 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediawidth', 'intval' );
|
1000 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_maxmediaheight', 'intval' );
|
1001 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_existing', 'boolval' );
|
1002 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_resize_other_existing', 'boolval' );
|
1003 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
1004 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_resizes_opt', 'ewww_image_optimizer_disable_resizes_sanitize' );
|
1005 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_disable_convert_links', 'boolval' );
|
1006 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_delete_originals', 'boolval' );
|
1007 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_to_png', 'boolval' );
|
1008 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_to_jpg', 'boolval' );
|
1009 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_to_png', 'boolval' );
|
1010 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_background', 'ewww_image_optimizer_jpg_background' );
|
1011 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp', 'boolval' );
|
1012 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_force', 'boolval' );
|
1013 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_paths', 'ewww_image_optimizer_webp_paths_sanitize' );
|
1014 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_for_cdn', 'boolval' );
|
1015 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_picture_webp', 'boolval' );
|
1016 |
+
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_webp_rewrite_exclude', 'ewww_image_optimizer_exclude_paths_sanitize' );
|
1017 |
+
ewww_image_optimizer_exec_init();
|
1018 |
+
ewww_image_optimizer_cron_setup( 'ewww_image_optimizer_auto' );
|
1019 |
+
// Queue the function that contains custom styling for our progressbars.
|
1020 |
+
add_action( 'admin_enqueue_scripts', 'ewww_image_optimizer_progressbar_style' );
|
1021 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD_KEY' ) && get_option( 'ewww_image_optimizer_cloud_key_invalid' ) ) {
|
1022 |
+
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_invalid_key' );
|
1023 |
+
add_action( 'admin_notices', 'ewww_image_optimizer_notice_invalid_key' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1024 |
}
|
1025 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_enabled' ) ) {
|
1026 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_webp_bulk' );
|
1027 |
+
if ( ewww_image_optimizer_cloud_based_media() ) {
|
1028 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_webp_force', true );
|
1029 |
+
}
|
1030 |
}
|
1031 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_auto' ) && ! ewww_image_optimizer_background_mode_enabled() ) {
|
1032 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_schedule_noasync' );
|
1037 |
}
|
1038 |
// Prevent ShortPixel AIO messiness.
|
1039 |
remove_action( 'admin_notices', 'autoptimizeMain::notice_plug_imgopt' );
|
1040 |
+
if ( class_exists( 'autoptimizeExtra' ) || defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) ) {
|
1041 |
+
$ao_extra = get_option( 'autoptimize_imgopt_settings' );
|
1042 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! empty( $ao_extra['autoptimize_imgopt_checkbox_field_1'] ) ) {
|
1043 |
ewwwio_debug_message( 'detected ExactDN + SP conflict' );
|
1044 |
+
$ao_extra['autoptimize_imgopt_checkbox_field_1'] = 0;
|
1045 |
+
update_option( 'autoptimize_imgopt_settings', $ao_extra );
|
1046 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_exactdn_sp_conflict' );
|
1047 |
}
|
1048 |
}
|
1057 |
} else {
|
1058 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_media_listmode' );
|
1059 |
}
|
1060 |
+
if ( ewww_image_optimizer_easy_active() ) {
|
1061 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_webp', false );
|
1062 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_webp_force', false );
|
1063 |
+
}
|
1064 |
|
1065 |
// Alert user if multiple re-optimizations detected.
|
1066 |
if ( ! defined( 'EWWWIO_DISABLE_REOPT_NOTICE' ) ) {
|
1076 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_review' );
|
1077 |
add_action( 'admin_footer', 'ewww_image_optimizer_notice_review_script' );
|
1078 |
}
|
1079 |
+
if ( ! empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1080 |
+
if ( 'regenerate-thumbnails' === $_GET['page'] // phpcs:ignore WordPress.Security.NonceVerification
|
1081 |
+
|| 'force-regenerate-thumbnails' === $_GET['page'] // phpcs:ignore WordPress.Security.NonceVerification
|
1082 |
+
|| 'ajax-thumbnail-rebuild' === $_GET['page'] // phpcs:ignore WordPress.Security.NonceVerification
|
1083 |
+
|| 'regenerate_thumbnails_advanced' === $_GET['page'] // phpcs:ignore WordPress.Security.NonceVerification
|
1084 |
+
|| 'rta_generate_thumbnails' === $_GET['page'] // phpcs:ignore WordPress.Security.NonceVerification
|
1085 |
) {
|
1086 |
// Add a notice for thumb regeneration.
|
1087 |
add_action( 'admin_notices', 'ewww_image_optimizer_thumbnail_regen_notice' );
|
1088 |
}
|
1089 |
}
|
1090 |
+
if ( ! empty( $_GET['ewww_pngout'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1091 |
add_action( 'admin_notices', 'ewww_image_optimizer_pngout_installed' );
|
1092 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_pngout_installed' );
|
1093 |
}
|
1094 |
+
if ( ! empty( $_GET['ewww_svgcleaner'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1095 |
add_action( 'admin_notices', 'ewww_image_optimizer_svgcleaner_installed' );
|
1096 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_svgcleaner_installed' );
|
1097 |
}
|
1535 |
// See if the path column exists, and what collation it uses to determine the column index size.
|
1536 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ewwwio_images'" ) === $wpdb->ewwwio_images ) {
|
1537 |
ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
|
1538 |
+
$mysql_version = 'unknown';
|
1539 |
+
if ( method_exists( $wpdb, 'db_server_info' ) ) {
|
1540 |
+
$mysql_version = strtolower( $wpdb->db_server_info() );
|
1541 |
}
|
1542 |
+
ewwwio_debug_message( $mysql_version );
|
1543 |
+
if ( false === strpos( $mysql_version, 'maria' ) || false === strpos( $mysql_version, '10.4.' ) ) {
|
1544 |
+
ewwwio_debug_message( 'checking primary/unique index' );
|
1545 |
+
if ( ! $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'PRIMARY'", ARRAY_A ) ) {
|
1546 |
+
ewwwio_debug_message( 'adding primary index' );
|
1547 |
+
$wpdb->query( "ALTER TABLE $wpdb->ewwwio_images ADD PRIMARY KEY(id)" );
|
1548 |
+
}
|
1549 |
+
if ( $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'id'", ARRAY_A ) ) {
|
1550 |
+
ewwwio_debug_message( 'dropping unique index' );
|
1551 |
+
$wpdb->query( "ALTER TABLE $wpdb->ewwwio_images DROP INDEX id" );
|
1552 |
+
}
|
1553 |
}
|
1554 |
// Check if the old path_image_size index exists, and drop it.
|
1555 |
if ( $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'path_image_size'", ARRAY_A ) ) {
|
1812 |
}
|
1813 |
|
1814 |
/**
|
1815 |
+
* Checks if a plugin is offloading media to cloud storage and removing local copies.
|
1816 |
*
|
1817 |
+
* @return bool True if a plugin is removing local files, false otherwise..
|
|
|
|
|
1818 |
*/
|
1819 |
+
function ewww_image_optimizer_cloud_based_media() {
|
1820 |
+
if ( class_exists( 'Amazon_S3_And_CloudFront' ) ) {
|
1821 |
+
global $as3cf;
|
1822 |
+
if ( is_object( $as3cf ) && $as3cf->get_setting( 'serve-from-s3' ) && $as3cf->get_setting( 'remove-local-file' ) ) {
|
1823 |
+
return true;
|
1824 |
+
}
|
1825 |
+
}
|
1826 |
+
if ( class_exists( 'S3_Uploads' ) && function_exists( 's3_uploads_enabled' ) && s3_uploads_enabled() ) {
|
1827 |
+
return true;
|
1828 |
+
}
|
1829 |
+
if ( class_exists( 'wpCloud\StatelessMedia\EWWW' ) && function_exists( 'ud_get_stateless_media' ) ) {
|
1830 |
+
$sm = ud_get_stateless_media();
|
1831 |
+
if ( method_exists( $sm, 'get' ) ) {
|
1832 |
+
$sm_mode = $sm->get( 'sm.mode' );
|
1833 |
+
if ( 'disabled' !== $sm_mode ) {
|
1834 |
+
return true;
|
1835 |
}
|
1836 |
}
|
1837 |
}
|
1838 |
+
return false;
|
1839 |
}
|
1840 |
|
1841 |
/**
|
1920 |
* Display a notice that we could not activate an ExactDN domain.
|
1921 |
*/
|
1922 |
function ewww_image_optimizer_notice_exactdn_activation_error() {
|
1923 |
+
return;
|
1924 |
global $exactdn_activate_error;
|
1925 |
if ( empty( $exactdn_activate_error ) ) {
|
1926 |
$exactdn_activate_error = 'error unknown';
|
1939 |
* Let the user know ExactDN setup was successful.
|
1940 |
*/
|
1941 |
function ewww_image_optimizer_notice_exactdn_activation_success() {
|
1942 |
+
return;
|
1943 |
?>
|
1944 |
<div id="ewww-image-optimizer-notice-exactdn-success" class="notice notice-success"><p>
|
1945 |
<strong><?php esc_html_e( 'Easy IO setup and verification is complete.', 'ewww-image-optimizer' ); ?></strong>
|
1946 |
<?php esc_html_e( 'If you have problems, try disabling Lazy Load and Include All Resources. Finally, disable Easy IO if problems remain.', 'ewww-image-optimizer' ); ?><br>
|
1947 |
+
<a class='ewww-contact-root' href='https://ewww.io/contact-us/'>
|
1948 |
<?php esc_html_e( 'Then, let us know so we can find a fix for the problem.', 'ewww-image-optimizer' ); ?>
|
1949 |
</a>
|
1950 |
</p></div>
|
1975 |
printf(
|
1976 |
/* translators: %s: settings page */
|
1977 |
esc_html__( 'Please visit the %s to refresh the Easy IO settings and verify activation status.', 'ewww-image-optimizer' ),
|
1978 |
+
'<a href="' . esc_url( ewww_image_optimizer_get_settings_link() ) . '">' . esc_html__( 'settings page', 'ewww-image-optimizer' ) . '</a>'
|
1979 |
);
|
1980 |
?>
|
1981 |
</p>
|
2665 |
return;
|
2666 |
}
|
2667 |
|
2668 |
+
/**
|
2669 |
+
* Simulates regenerating a resize for an attachment.
|
2670 |
+
*/
|
2671 |
+
function ewww_image_optimizer_resize_dup_check() {
|
2672 |
+
$meta = wp_get_attachment_metadata( 34 );
|
2673 |
+
|
2674 |
+
list( $file, $upload_path ) = ewww_image_optimizer_attachment_path( $meta, 34 );
|
2675 |
+
|
2676 |
+
$editor = wp_get_image_editor( $file );
|
2677 |
+
$resized_image = $editor->resize( 150, 150, true );
|
2678 |
+
$new_file = $editor->generate_filename();
|
2679 |
+
echo esc_html( $new_file );
|
2680 |
+
if ( ewwwio_is_file( $new_file ) ) {
|
2681 |
+
echo '<br>file already exists<br>';
|
2682 |
+
}
|
2683 |
+
$saved = $editor->save( $new_file );
|
2684 |
+
}
|
2685 |
+
|
2686 |
/**
|
2687 |
* Clears scheduled jobs for multisite when the plugin is deactivated.
|
2688 |
*
|
2737 |
}
|
2738 |
}
|
2739 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2740 |
/**
|
2741 |
* Adds various items to the admin menu.
|
2742 |
*/
|
2861 |
if ( 'upload.php' === $hook || 'ims_gallery_page_ewww-ims-optimize' === $hook ) {
|
2862 |
add_thickbox();
|
2863 |
wp_enqueue_script( 'jquery-ui-tooltip' );
|
2864 |
+
wp_enqueue_script( 'ewww-media-script', plugins_url( '/includes/media.js', __FILE__ ), array( 'jquery' ), EWWW_IMAGE_OPTIMIZER_VERSION );
|
2865 |
wp_enqueue_style( 'jquery-ui-tooltip-custom', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ), array(), EWWW_IMAGE_OPTIMIZER_VERSION );
|
2866 |
// Submit a couple variables to the javascript to work with.
|
|
|
2867 |
$loading_image = plugins_url( '/images/spinner.gif', __FILE__ );
|
2868 |
wp_localize_script(
|
2869 |
+
'ewww-media-script',
|
2870 |
'ewww_vars',
|
2871 |
array(
|
2872 |
'optimizing' => '<p>' . esc_html__( 'Optimizing', 'ewww-image-optimizer' ) . " <img src='$loading_image' /></p>",
|
2877 |
}
|
2878 |
|
2879 |
/**
|
2880 |
+
* Gets the link to the main EWWW IO settings.
|
2881 |
*
|
2882 |
+
* @return string The link to the main settings (network vs. single-site).
|
|
|
2883 |
*/
|
2884 |
+
function ewww_image_optimizer_get_settings_link() {
|
2885 |
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
2886 |
// Need to include the plugin library for the is_plugin_active function.
|
2887 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
2888 |
}
|
|
|
|
|
|
|
2889 |
// Load the html for the settings link.
|
2890 |
+
if ( is_multisite() && is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) && ! get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) ) {
|
2891 |
+
return network_admin_url( 'settings.php?page=ewww-image-optimizer-options' );
|
2892 |
} else {
|
2893 |
+
return admin_url( 'options-general.php?page=ewww-image-optimizer-options' );
|
2894 |
+
}
|
2895 |
+
}
|
2896 |
+
|
2897 |
+
/**
|
2898 |
+
* Adds a link on the Plugins page for the EWWW IO settings.
|
2899 |
+
*
|
2900 |
+
* @param array $links A list of links to display next to the plugin listing.
|
2901 |
+
* @return array The new list of links to be displayed.
|
2902 |
+
*/
|
2903 |
+
function ewww_image_optimizer_settings_link( $links ) {
|
2904 |
+
if ( ! is_array( $links ) ) {
|
2905 |
+
$links = array();
|
2906 |
}
|
2907 |
+
$settings_link = '<a href="' . ewww_image_optimizer_get_settings_link() . '">' . esc_html__( 'Settings', 'ewww-image-optimizer' ) . '</a>';
|
2908 |
// Load the settings link into the plugin links array.
|
2909 |
array_unshift( $links, $settings_link );
|
2910 |
// Send back the plugin links array.
|
4148 |
}
|
4149 |
|
4150 |
/**
|
4151 |
+
* Activates Easy IO via AJAX.
|
|
|
|
|
|
|
4152 |
*/
|
4153 |
+
function ewww_image_optimizer_exactdn_activate_ajax() {
|
4154 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4155 |
+
if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['ewww_wpnonce'] ), 'ewww-image-optimizer-settings' ) ) {
|
4156 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) ) ) );
|
4157 |
+
}
|
4158 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_exactdn', true );
|
4159 |
+
if ( ! class_exists( 'ExactDN' ) ) {
|
4160 |
+
/**
|
4161 |
+
* Page Parsing class for working with HTML content.
|
4162 |
+
*/
|
4163 |
+
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-eio-page-parser.php' );
|
4164 |
+
/**
|
4165 |
+
* ExactDN class for parsing image urls and rewriting them.
|
4166 |
+
*/
|
4167 |
+
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-exactdn.php' );
|
4168 |
+
global $exactdn;
|
4169 |
+
if ( $exactdn->get_exactdn_domain() ) {
|
4170 |
+
die( wp_json_encode( array( 'success' => esc_html__( 'Easy IO setup and verification is complete.', 'ewww-image-optimizer' ) ) ) );
|
4171 |
+
}
|
4172 |
+
}
|
4173 |
+
global $exactdn_activate_error;
|
4174 |
+
if ( empty( $exactdn_activate_error ) ) {
|
4175 |
+
$exactdn_activate_error = 'error unknown';
|
4176 |
}
|
4177 |
+
die(
|
4178 |
+
wp_json_encode(
|
4179 |
+
array(
|
4180 |
+
'error' => sprintf(
|
4181 |
+
/* translators: 1: A link to the documentation 2: the error message/details */
|
4182 |
+
esc_html__( 'Could not activate Easy IO, please try again in a few minutes. If this error continues, please see %1$s for troubleshooting steps: %2$s', 'ewww-image-optimizer' ),
|
4183 |
+
'https://docs.ewww.io/article/66-exactdn-not-verified',
|
4184 |
+
'<code>' . esc_html( $exactdn_activate_error ) . '</code>'
|
4185 |
+
),
|
4186 |
+
)
|
4187 |
+
)
|
4188 |
+
);
|
4189 |
+
}
|
4190 |
+
|
4191 |
+
/**
|
4192 |
+
* Sanitizes and verifies an API key for the cloud service.
|
4193 |
+
*
|
4194 |
+
* @param string $key An API key entered by the user.
|
4195 |
+
* @return string A sanitized and validated API key.
|
4196 |
+
*/
|
4197 |
+
function ewww_image_optimizer_cloud_key_sanitize( $key ) {
|
4198 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4199 |
+
$key = trim( $key );
|
4200 |
if ( empty( $key ) ) {
|
4201 |
return '';
|
4202 |
}
|
4203 |
+
if ( ewww_image_optimizer_cloud_verify( $key, false ) ) {
|
4204 |
add_settings_error( 'ewww_image_optimizer_cloud_key', 'ewwwio-cloud-key', esc_html__( 'Successfully validated API key, happy optimizing!', 'ewww-image-optimizer' ), 'updated' );
|
4205 |
ewwwio_debug_message( 'sanitize (verification) successful' );
|
4206 |
ewwwio_memory( __FUNCTION__ );
|
4215 |
}
|
4216 |
}
|
4217 |
|
4218 |
+
/**
|
4219 |
+
* Verifies an API key via AJAX.
|
4220 |
+
*/
|
4221 |
+
function ewww_image_optimizer_cloud_key_verify_ajax() {
|
4222 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4223 |
+
if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['ewww_wpnonce'] ), 'ewww-image-optimizer-settings' ) ) {
|
4224 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'Access token has expired, please reload the page.', 'ewww-image-optimizer' ) ) ) );
|
4225 |
+
}
|
4226 |
+
if ( empty( $_POST['compress_api_key'] ) ) {
|
4227 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'Please enter your API key and try again.', 'ewww-image-optimizer' ) ) ) );
|
4228 |
+
}
|
4229 |
+
$api_key = trim( sanitize_key( $_POST['compress_api_key'] ) );
|
4230 |
+
$url = 'http://optimize.exactlywww.com/verify/';
|
4231 |
+
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
4232 |
+
$url = set_url_scheme( $url, 'https' );
|
4233 |
+
}
|
4234 |
+
$result = ewww_image_optimizer_cloud_post_key( $url, $api_key );
|
4235 |
+
if ( is_wp_error( $result ) ) {
|
4236 |
+
$url = set_url_scheme( $url, 'http' );
|
4237 |
+
$error_message = $result->get_error_message();
|
4238 |
+
ewwwio_debug_message( "verification failed: $error_message" );
|
4239 |
+
$result = ewww_image_optimizer_cloud_post_key( $url, $api_key );
|
4240 |
+
}
|
4241 |
+
if ( is_wp_error( $result ) ) {
|
4242 |
+
$error_message = $result->get_error_message();
|
4243 |
+
ewwwio_debug_message( "verification failed via $url: $error_message" );
|
4244 |
+
die(
|
4245 |
+
wp_json_encode(
|
4246 |
+
array(
|
4247 |
+
'error' => sprintf(
|
4248 |
+
/* translators: %s: an error message from the WebP self-test */
|
4249 |
+
esc_html__( 'Could not validate API key, HTTP error: %s', 'ewww-image-optimizer' ),
|
4250 |
+
$error_message
|
4251 |
+
),
|
4252 |
+
)
|
4253 |
+
)
|
4254 |
+
);
|
4255 |
+
} elseif ( ! empty( $result['body'] ) && preg_match( '/(great|exceeded)/', $result['body'] ) ) {
|
4256 |
+
$verified = $result['body'];
|
4257 |
+
if ( preg_match( '/exceeded/', $verified ) ) {
|
4258 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'No credits remaining for API key.', 'ewww-image-optimizer' ) ) ) );
|
4259 |
+
}
|
4260 |
+
ewwwio_debug_message( "verification success via: $url" );
|
4261 |
+
delete_option( 'ewww_image_optimizer_cloud_key_invalid' );
|
4262 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', $api_key );
|
4263 |
+
set_transient( 'ewww_image_optimizer_cloud_status', $verified, HOUR_IN_SECONDS );
|
4264 |
+
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' ) ) {
|
4265 |
+
ewww_image_optimizer_cloud_enable();
|
4266 |
+
}
|
4267 |
+
ewwwio_debug_message( "verification body contents: {$result['body']}" );
|
4268 |
+
die( wp_json_encode( array( 'success' => esc_html__( 'Successfully validated API key, happy optimizing!', 'ewww-image-optimizer' ) ) ) );
|
4269 |
+
} else {
|
4270 |
+
ewwwio_debug_message( "verification failed via: $url" );
|
4271 |
+
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
4272 |
+
ewwwio_debug_message( print_r( $result, true ) );
|
4273 |
+
}
|
4274 |
+
die( wp_json_encode( array( 'error' => esc_html__( 'Could not validate API key, please copy and paste your key to ensure it is correct.', 'ewww-image-optimizer' ) ) ) );
|
4275 |
+
}
|
4276 |
+
}
|
4277 |
+
|
4278 |
/**
|
4279 |
* Checks to see if all images should be processed via the API.
|
4280 |
*
|
4320 |
*
|
4321 |
* @global object $ewwwio_async_key_verification
|
4322 |
*
|
4323 |
+
* @param string $api_key The API key to verify. Default empty string.
|
4324 |
* @param bool $cache Optional. True to return cached verification results. Default true.
|
|
|
4325 |
* @return string|bool False if verification fails, status message otherwise: great/exceeded.
|
4326 |
*/
|
4327 |
+
function ewww_image_optimizer_cloud_verify( $api_key, $cache = true ) {
|
4328 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4329 |
$sanitize = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
4330 |
if ( empty( $api_key ) ) {
|
4331 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 ) {
|
4332 |
update_site_option( 'ewww_image_optimizer_jpg_level', 10 );
|
4349 |
ewwwio_debug_message( 'license exceeded notice has not expired' );
|
4350 |
return 'exceeded';
|
4351 |
}
|
|
|
4352 |
$ewww_cloud_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
4353 |
if ( ! ewww_image_optimizer_detect_wpsf_location_lock() && $cache && preg_match( '/great/', $ewww_cloud_status ) ) {
|
4354 |
ewwwio_debug_message( 'using cached verification' );
|
4382 |
if ( preg_match( '/exceeded/', $verified ) ) {
|
4383 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', time() + 300 );
|
4384 |
}
|
4385 |
+
if ( false !== strpos( $result['body'], 'expired' ) ) {
|
4386 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', '' );
|
4387 |
}
|
4388 |
ewwwio_debug_message( "verification success via: $url" );
|
4389 |
delete_option( 'ewww_image_optimizer_cloud_key_invalid' );
|
4390 |
} else {
|
4391 |
update_option( 'ewww_image_optimizer_cloud_key_invalid', true, false );
|
4392 |
+
if ( ! empty( $result['body'] ) && false !== strpos( $result['body'], 'invalid' ) ) {
|
4393 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_key', '' );
|
4394 |
}
|
4395 |
ewwwio_debug_message( "verification failed via: $url" );
|
4419 |
* @return array The results of the http POST request.
|
4420 |
*/
|
4421 |
function ewww_image_optimizer_cloud_post_key( $url, $key ) {
|
4422 |
+
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
4423 |
$result = wp_remote_post(
|
4424 |
$url,
|
4425 |
array(
|
4437 |
* Let the user know their key is invalid.
|
4438 |
*/
|
4439 |
function ewww_image_optimizer_notice_invalid_key() {
|
4440 |
+
echo "<div id='ewww-image-optimizer-invalid-key' class='notice notice-error'><p><strong>" . esc_html__( 'Could not validate EWWW Image Optimizer API key, please check your key to ensure it is correct.', 'ewww-image-optimizer' ) . '</strong></p></div>';
|
4441 |
}
|
4442 |
|
4443 |
/**
|
4481 |
if ( $raw ) {
|
4482 |
return $quota;
|
4483 |
}
|
4484 |
+
if ( ! empty( $quota['unlimited'] ) && $quota['consumed'] >= 0 ) {
|
4485 |
+
return sprintf(
|
4486 |
+
/* translators: %d: Number of images */
|
4487 |
+
__( 'optimized %d images.', 'ewww-image-optimizer' ),
|
4488 |
+
$quota['consumed']
|
4489 |
+
);
|
4490 |
+
} elseif ( ! $quota['licensed'] && $quota['consumed'] > 0 ) {
|
4491 |
return sprintf(
|
4492 |
/* translators: 1: Number of images 2: Number of days until renewal */
|
4493 |
_n( 'optimized %1$d images, renewal is in %2$d day.', 'optimized %1$d images, renewal is in %2$d days.', $quota['days'], 'ewww-image-optimizer' ),
|
4560 |
ewww_image_optimizer_debug_log();
|
4561 |
}
|
4562 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
4563 |
+
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
4564 |
if ( preg_match( '/exceeded/', $ewww_status ) ) {
|
4565 |
$started = microtime( true );
|
4566 |
+
if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
|
4567 |
return array( $file, false, 'key verification failed', 0, '' );
|
4568 |
}
|
4569 |
// Calculate how much time has elapsed since we started.
|
4672 |
ewwwio_debug_message( "jpg fill: $jpg_fill" );
|
4673 |
ewwwio_debug_message( "jpg quality: $jpg_quality" );
|
4674 |
$free_exec = EWWW_IMAGE_OPTIMIZER_NOEXEC && 'image/jpeg' === $type;
|
4675 |
+
if (
|
4676 |
+
! $free_exec &&
|
4677 |
+
defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN &&
|
4678 |
+
'image/jpeg' === $type
|
4679 |
+
) {
|
4680 |
+
$free_exec = true;
|
4681 |
+
}
|
4682 |
if ( empty( $api_key ) && ! $free_exec ) {
|
4683 |
+
ewwwio_debug_message( 'no API key and free_exec mode inactive' );
|
4684 |
return array( $file, false, 'key verification failed', 0, '' );
|
4685 |
}
|
4686 |
$url = 'http://optimize.exactlywww.com/v2/';
|
4809 |
}
|
4810 |
ewww_image_optimizer_debug_log();
|
4811 |
}
|
4812 |
+
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
4813 |
+
if ( empty( $api_key ) ) {
|
4814 |
+
return false;
|
4815 |
+
}
|
4816 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
4817 |
$started = microtime( true );
|
4818 |
if ( preg_match( '/exceeded/', $ewww_status ) ) {
|
4819 |
+
if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
|
4820 |
ewwwio_debug_message( 'cloud verify failed, image not rotated' );
|
4821 |
return false;
|
4822 |
}
|
4833 |
ewwwio_get_filesystem();
|
4834 |
ewwwio_debug_message( "file: $file " );
|
4835 |
ewwwio_debug_message( "type: $type" );
|
|
|
|
|
|
|
|
|
4836 |
$url = 'http://optimize.exactlywww.com/rotate/';
|
4837 |
$ssl = wp_http_supports( array( 'ssl' ) );
|
4838 |
if ( $ssl ) {
|
4938 |
}
|
4939 |
ewww_image_optimizer_debug_log();
|
4940 |
}
|
4941 |
+
if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
|
4942 |
ewwwio_debug_message( 'cloud verify failed, image not backed up' );
|
4943 |
return false;
|
4944 |
}
|
5052 |
}
|
5053 |
ewww_image_optimizer_debug_log();
|
5054 |
}
|
5055 |
+
$api_key = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' );
|
5056 |
+
if ( empty( $api_key ) ) {
|
5057 |
+
return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
|
5058 |
+
}
|
5059 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
5060 |
$started = microtime( true );
|
5061 |
if ( false !== strpos( $ewww_status, 'exceeded' ) ) {
|
5062 |
+
if ( ! ewww_image_optimizer_cloud_verify( $api_key ) ) {
|
5063 |
ewwwio_debug_message( 'cloud verify failed, image not resized' );
|
5064 |
return new WP_Error( 'invalid_key', __( 'Could not verify API key', 'ewww-image-optimizer' ) );
|
5065 |
}
|
5077 |
ewwwio_debug_message( "file: $file " );
|
5078 |
ewwwio_debug_message( "width: $dst_w" );
|
5079 |
ewwwio_debug_message( "height: $dst_h" );
|
|
|
|
|
|
|
|
|
5080 |
$url = 'http://optimize.exactlywww.com/resize/';
|
5081 |
$ssl = wp_http_supports( array( 'ssl' ) );
|
5082 |
if ( $ssl ) {
|
5719 |
if ( $cli ) {
|
5720 |
WP_CLI::error( __( 'License Exceeded', 'ewww-image-optimizer' ) );
|
5721 |
}
|
5722 |
+
die();
|
5723 |
}
|
5724 |
if ( ! $auto ) {
|
5725 |
// Output the path.
|
5745 |
$loading_image = plugins_url( '/images/wpspin.gif', __FILE__ );
|
5746 |
$output['next_file'] = '<p>' . esc_html__( 'Optimizing', 'ewww-image-optimizer' ) . ' <b>' . esc_html( $next_file ) . "</b> <img src='$loading_image' alt='loading' /></p>";
|
5747 |
}
|
5748 |
+
die( wp_json_encode( $output ) );
|
|
|
|
|
5749 |
}
|
5750 |
if ( $cli ) {
|
5751 |
return $results[1];
|
6491 |
wp_raise_memory_limit( 'image' );
|
6492 |
}
|
6493 |
$type = ewww_image_optimizer_mimetype( $file, 'i' );
|
6494 |
+
if ( 'image/png' !== $type && 'image/gif' !== $type ) {
|
6495 |
ewwwio_debug_message( 'not a PNG, no conversion needed' );
|
6496 |
return;
|
6497 |
}
|
6498 |
$orig_size = ewww_image_optimizer_filesize( $file );
|
6499 |
+
if ( 'image/png' === $type && $orig_size < apply_filters( 'ewww_image_optimizer_autoconvert_threshold', 250000 ) ) {
|
6500 |
+
ewwwio_debug_message( 'not a large PNG (size or dimensions), skipping' );
|
6501 |
return;
|
6502 |
}
|
6503 |
+
if ( 'image/png' === $type && ewww_image_optimizer_png_alpha( $file ) && ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_to_jpg' ) || ! ewww_image_optimizer_jpg_background() ) ) {
|
6504 |
ewwwio_debug_message( 'alpha detected, skipping' );
|
6505 |
return;
|
6506 |
}
|
6507 |
+
if ( 'image/gif' === $type && ewww_image_optimizer_is_animated( $file ) ) {
|
6508 |
+
ewwwio_debug_message( 'animation detected, skipping' );
|
6509 |
+
return;
|
6510 |
+
}
|
6511 |
$ewww_image = new EWWW_Image( 0, '', $file );
|
6512 |
// Pass the filename, false for db search/replace, and true for filesize comparison.
|
6513 |
return $ewww_image->convert( $file, false, true );
|
7177 |
}
|
7178 |
}
|
7179 |
|
7180 |
+
/**
|
7181 |
+
* Find the path to a backed-up original (not the full-size version like the core WP function).
|
7182 |
+
*
|
7183 |
+
* @param int $id The attachment ID number.
|
7184 |
+
* @param string $image_file The path to a scaled image file.
|
7185 |
+
* @param array $meta The attachment metadata. Optional, default to null.
|
7186 |
+
* @return bool True on success, false on failure.
|
7187 |
+
*/
|
7188 |
+
function ewwwio_get_original_image_path( $id, $image_file = '', $meta = null ) {
|
7189 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
7190 |
+
$id = (int) $id;
|
7191 |
+
if ( empty( $id ) ) {
|
7192 |
+
return false;
|
7193 |
+
}
|
7194 |
+
if ( ! wp_attachment_is_image( $id ) ) {
|
7195 |
+
return false;
|
7196 |
+
}
|
7197 |
+
if ( is_null( $meta ) ) {
|
7198 |
+
$meta = wp_get_attachment_metadata( $id );
|
7199 |
+
}
|
7200 |
+
if ( empty( $image_file ) ) {
|
7201 |
+
$image_file = get_attached_file( $id, true );
|
7202 |
+
}
|
7203 |
+
if ( ! $image_file || ! ewww_image_optimizer_iterable( $meta ) || empty( $meta['original_image'] ) ) {
|
7204 |
+
if ( $image_file && apply_filters( 'ewwwio_find_original_image_no_meta', false, $image_file ) && strpos( $image_file, '-scaled.' ) ) {
|
7205 |
+
ewwwio_debug_message( "constructing path with $image_file alone" );
|
7206 |
+
$original_image = trailingslashit( dirname( $image_file ) ) . wp_basename( str_replace( '-scaled.', '.', $original_image ) );
|
7207 |
+
if ( $original_image !== $image_file ) {
|
7208 |
+
ewwwio_debug_message( "found $original_image" );
|
7209 |
+
return $original_image;
|
7210 |
+
}
|
7211 |
+
}
|
7212 |
+
return false;
|
7213 |
+
}
|
7214 |
+
ewwwio_debug_message( "constructing path with $image_file and " . $meta['original_image'] );
|
7215 |
+
|
7216 |
+
return trailingslashit( dirname( $image_file ) ) . wp_basename( $meta['original_image'] );
|
7217 |
+
}
|
7218 |
+
|
7219 |
+
/**
|
7220 |
+
* Remove the backed-up original_image stored by WP 5.3+.
|
7221 |
+
*
|
7222 |
+
* @param int $id The attachment ID number.
|
7223 |
+
* @param array $meta The attachment metadata. Optional, default to null.
|
7224 |
+
* @return bool|array Returns meta if modified, false otherwise (even if an "unlinked" original is removed).
|
7225 |
+
*/
|
7226 |
+
function ewwwio_remove_original_image( $id, $meta = null ) {
|
7227 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
7228 |
+
$id = (int) $id;
|
7229 |
+
if ( empty( $id ) ) {
|
7230 |
+
return false;
|
7231 |
+
}
|
7232 |
+
if ( is_null( $meta ) ) {
|
7233 |
+
ewwwio_debug_message( "getting meta for $id" );
|
7234 |
+
$meta = wp_get_attachment_metadata( $id );
|
7235 |
+
}
|
7236 |
+
|
7237 |
+
if (
|
7238 |
+
$meta && is_array( $meta ) &&
|
7239 |
+
imsanity_get_option( 'imsanity_delete_originals', false ) &&
|
7240 |
+
! empty( $meta['original_image'] ) && function_exists( 'wp_get_original_image_path' )
|
7241 |
+
) {
|
7242 |
+
$original_image = ewwwio_get_original_image_path( $id, '', $meta );
|
7243 |
+
if ( $original_image && is_file( $original_image ) && is_writable( $original_image ) ) {
|
7244 |
+
ewwwio_debug_message( "removing $original_image" );
|
7245 |
+
unlink( $original_image );
|
7246 |
+
}
|
7247 |
+
clearstatcache();
|
7248 |
+
if ( empty( $original_image ) || ! is_file( $original_image ) ) {
|
7249 |
+
ewwwio_debug_message( 'cleaning meta' );
|
7250 |
+
unset( $meta['original_image'] );
|
7251 |
+
return $meta;
|
7252 |
+
}
|
7253 |
+
}
|
7254 |
+
return false;
|
7255 |
+
}
|
7256 |
+
|
7257 |
/**
|
7258 |
* Find image paths from an attachment's meta data and process each image.
|
7259 |
*
|
8430 |
/**
|
8431 |
* Add column header for optimizer results in the media library listing.
|
8432 |
*
|
8433 |
+
* @param array $columns A list of columns in the media library.
|
8434 |
* @return array The new list of columns.
|
8435 |
*/
|
8436 |
+
function ewww_image_optimizer_columns( $columns ) {
|
8437 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
8438 |
+
$columns['ewww-image-optimizer'] = esc_html__( 'Image Optimizer', 'ewww-image-optimizer' );
|
8439 |
ewwwio_memory( __FUNCTION__ );
|
8440 |
+
return $columns;
|
8441 |
}
|
8442 |
|
8443 |
/**
|
8539 |
switch ( $type ) {
|
8540 |
case 'image/jpeg':
|
8541 |
// If jpegtran is missing and should not be skipped.
|
8542 |
+
if ( ! $skip['jpegtran'] && defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_dismiss_exec_notice' ) ) {
|
8543 |
$msg = '<div>' . sprintf(
|
8544 |
/* translators: %s: name of a tool like jpegtran */
|
8545 |
__( '%s is missing', 'ewww-image-optimizer' ),
|
9314 |
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
9315 |
}
|
9316 |
delete_option( 'ewww_image_optimizer_wc_regen' );
|
9317 |
+
die();
|
9318 |
}
|
9319 |
|
9320 |
/**
|
9328 |
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
9329 |
}
|
9330 |
delete_option( 'ewww_image_optimizer_lr_sync' );
|
9331 |
+
die();
|
9332 |
}
|
9333 |
|
9334 |
/**
|
9343 |
}
|
9344 |
update_option( 'ewww_image_optimizer_dismiss_media_notice', true, false );
|
9345 |
update_site_option( 'ewww_image_optimizer_dismiss_media_notice', true );
|
9346 |
+
die();
|
9347 |
}
|
9348 |
|
9349 |
/**
|
9358 |
}
|
9359 |
update_option( 'ewww_image_optimizer_dismiss_review_notice', true, false );
|
9360 |
update_site_option( 'ewww_image_optimizer_dismiss_review_notice', true );
|
9361 |
+
die();
|
9362 |
}
|
9363 |
|
9364 |
/**
|
9568 |
if ( 'settings_page_ewww-image-optimizer-options' !== $hook ) {
|
9569 |
return;
|
9570 |
}
|
9571 |
+
if (
|
9572 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_wizard_complete' ) &&
|
9573 |
+
! is_network_admin() &&
|
9574 |
+
( ! is_multisite() || get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) || ! is_plugin_active_for_network( EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL ) )
|
9575 |
+
) {
|
9576 |
+
remove_all_actions( 'admin_notices' );
|
9577 |
+
}
|
9578 |
+
if ( ! empty( $_GET['rescue_mode'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
9579 |
+
remove_all_actions( 'admin_notices' );
|
9580 |
+
}
|
9581 |
delete_option( 'ewww_image_optimizer_exactdn_checkin' );
|
9582 |
global $exactdn;
|
9583 |
if ( has_action( 'admin_notices', 'ewww_image_optimizer_notice_exactdn_domain_mismatch' ) ) {
|
9590 |
$exactdn->setup();
|
9591 |
}
|
9592 |
add_thickbox();
|
9593 |
+
wp_enqueue_script( 'ewww-beacon-script', plugins_url( '/includes/eio-beacon.js', __FILE__ ), array( 'jquery' ), EWWW_IMAGE_OPTIMIZER_VERSION );
|
9594 |
+
wp_enqueue_script( 'ewww-settings-script', plugins_url( '/includes/eio-settings.js', __FILE__ ), array( 'jquery' ), EWWW_IMAGE_OPTIMIZER_VERSION, true );
|
9595 |
wp_enqueue_style( 'jquery-ui-tooltip-custom', plugins_url( '/includes/jquery-ui-1.10.1.custom.css', __FILE__ ), array(), EWWW_IMAGE_OPTIMIZER_VERSION );
|
9596 |
wp_enqueue_script( 'postbox' );
|
9597 |
wp_enqueue_script( 'dashboard' );
|
9598 |
+
wp_localize_script(
|
9599 |
+
'ewww-settings-script',
|
9600 |
+
'ewww_vars',
|
9601 |
+
array(
|
9602 |
+
'_wpnonce' => wp_create_nonce( 'ewww-image-optimizer-settings' ),
|
9603 |
+
'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' ),
|
9604 |
+
'loading_image_url' => plugins_url( '/images/spinner.gif', __FILE__ ),
|
9605 |
+
'webp_cloud_warning' => esc_html__( 'If you have not run the Bulk Optimizer on existing images, you will likely encounter broken image URLs. Are you ready to continue?', 'ewww-image-optimizer' ),
|
9606 |
+
)
|
9607 |
+
);
|
9608 |
+
wp_add_inline_script(
|
9609 |
+
'ewww-settings-script',
|
9610 |
+
'ewww_vars.cloud_media = ' . ( ewww_image_optimizer_cloud_based_media() ? 1 : 0 ) . ";\n" .
|
9611 |
+
'ewww_vars.save_space = ' . ( get_option( 'ewww_image_optimizer_goal_save_space' ) ? 1 : 0 ) . ";\n" .
|
9612 |
+
'ewww_vars.site_speed = ' . ( get_option( 'ewww_image_optimizer_goal_site_speed' ) ? 1 : 0 ) . ";\n"
|
9613 |
+
);
|
9614 |
ewwwio_memory( __FUNCTION__ );
|
9615 |
}
|
9616 |
|
9710 |
*
|
9711 |
* Requests the test.png and checks to see if it is actually of type image/webp.
|
9712 |
*
|
9713 |
+
* @return string Empty if the test image is WebP, error message otherwise.
|
9714 |
*/
|
9715 |
+
function ewww_image_optimizer_test_webp_mime_error() {
|
9716 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9717 |
+
$positive_test = false;
|
9718 |
+
$negative_test = false;
|
9719 |
+
$test_url = plugins_url( '/images/test.png', __FILE__ ) . '?m=' . time();
|
9720 |
add_filter( 'http_headers_useragent', 'ewww_image_optimizer_cloud_useragent', PHP_INT_MAX );
|
9721 |
+
|
9722 |
+
// Run the "positive" test, which should receive a WebP in a .png wrapper.
|
9723 |
$test_result = wp_remote_get( $test_url, array( 'headers' => 'Accept: image/webp' ) );
|
9724 |
if ( is_wp_error( $test_result ) ) {
|
9725 |
$error_message = $test_result->get_error_message();
|
9726 |
ewwwio_debug_message( "webp verification request failed: $error_message" );
|
9727 |
+
return $error_message;
|
9728 |
+
} elseif ( empty( $test_result['body'] ) ) {
|
9729 |
+
ewwwio_debug_message( 'webp verification response empty' );
|
9730 |
+
return __( 'WebP response was empty', 'ewww-image-optimizer' );
|
9731 |
+
} elseif ( strlen( $test_result['body'] ) < 300 ) {
|
9732 |
+
ewwwio_debug_message( 'webp verification response too small: ' . strlen( $test_result['body'] ) );
|
9733 |
+
return __( 'WebP response was too small', 'ewww-image-optimizer' );
|
9734 |
+
} elseif ( empty( $test_result['response']['code'] ) ) {
|
9735 |
+
ewwwio_debug_message( 'webp test received unknown response code' );
|
9736 |
+
return __( 'WebP response status code missing', 'ewww-image-optimizer' );
|
9737 |
+
} elseif ( 200 !== (int) $test_result['response']['code'] ) {
|
9738 |
+
ewwwio_debug_message( 'webp test received response code: ' . $test_result['response']['code'] );
|
9739 |
+
/* translators: %d: the HTTP status code */
|
9740 |
+
return sprintf( __( 'WebP response received status %d', 'ewww-image-optimizer' ), $test_result['response']['code'] );
|
9741 |
+
} elseif ( '52494646' === bin2hex( substr( $test_result['body'], 0, 4 ) ) ) {
|
9742 |
+
ewwwio_debug_message( 'webp (real-world) verification succeeded' );
|
9743 |
+
$positive_test = true;
|
9744 |
+
} else {
|
9745 |
ewwwio_debug_message( 'webp mime check failed: ' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
|
9746 |
+
return __( 'WebP response failed mime-type test', 'ewww-image-optimizer' );
|
9747 |
}
|
9748 |
+
|
9749 |
+
// Run the "negative" test, which should receive the original PNG image.
|
9750 |
+
$test_result = wp_remote_get( $test_url );
|
9751 |
+
if ( is_wp_error( $test_result ) ) {
|
9752 |
+
$error_message = $test_result->get_error_message();
|
9753 |
+
ewwwio_debug_message( "png verification request failed: $error_message" );
|
9754 |
+
return $error_message;
|
9755 |
+
} elseif ( empty( $test_result['body'] ) ) {
|
9756 |
+
ewwwio_debug_message( 'png verification response empty' );
|
9757 |
+
return __( 'PNG response was empty', 'ewww-image-optimizer' );
|
9758 |
+
} elseif ( strlen( $test_result['body'] ) < 300 ) {
|
9759 |
+
ewwwio_debug_message( 'png verification response too small: ' . strlen( $test_result['body'] ) );
|
9760 |
+
return __( 'PNG response was too small', 'ewww-image-optimizer' );
|
9761 |
+
} elseif ( empty( $test_result['response']['code'] ) ) {
|
9762 |
+
ewwwio_debug_message( 'png test received unknown response code' );
|
9763 |
+
return __( 'PNG response status code missing', 'ewww-image-optimizer' );
|
9764 |
+
} elseif ( 200 !== (int) $test_result['response']['code'] ) {
|
9765 |
+
ewwwio_debug_message( 'png test received response code: ' . $test_result['response']['code'] );
|
9766 |
+
/* translators: %d: the HTTP status code */
|
9767 |
+
return sprintf( __( 'PNG response received status %d', 'ewww-image-optimizer' ), $test_result['response']['code'] );
|
9768 |
+
} elseif ( '89504e470d0a1a0a' === bin2hex( substr( $test_result['body'], 0, 8 ) ) ) {
|
9769 |
+
ewwwio_debug_message( 'png (real-world) verification succeeded' );
|
9770 |
+
$negative_test = true;
|
9771 |
+
} else {
|
9772 |
+
ewwwio_debug_message( 'png mime check failed: ' . bin2hex( substr( $test_result['body'], 0, 3 ) ) );
|
9773 |
+
return __( 'PNG response failed mime-type test', 'ewww-image-optimizer' );
|
9774 |
}
|
9775 |
+
if ( ! $positive_test || ! $negative_test ) {
|
9776 |
+
ewwwio_debug_message( 'no idea what happened' );
|
9777 |
+
return __( 'WebP validation failed for an unknown reason', 'ewww-image-optimizer' );
|
9778 |
+
}
|
9779 |
+
return '';
|
9780 |
}
|
9781 |
|
9782 |
/**
|
9809 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9810 |
// Verify that the user is properly authorized.
|
9811 |
if ( empty( $_REQUEST['ewww_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['ewww_wpnonce'] ), 'ewww-image-optimizer-settings' ) ) {
|
9812 |
+
die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
9813 |
}
|
9814 |
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
|
9815 |
+
die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
9816 |
}
|
9817 |
$ewww_rules = ewww_image_optimizer_webp_rewrite_verify();
|
9818 |
if ( $ewww_rules ) {
|
9819 |
if ( insert_with_markers( ewww_image_optimizer_htaccess_path(), 'EWWWIO', $ewww_rules ) && ! ewww_image_optimizer_webp_rewrite_verify() ) {
|
9820 |
+
$webp_mime_error = ewww_image_optimizer_test_webp_mime_error();
|
9821 |
+
if ( empty( $webp_mime_error ) ) {
|
9822 |
+
die( esc_html__( 'Insertion successful', 'ewww-image-optimizer' ) );
|
9823 |
+
}
|
9824 |
+
die(
|
9825 |
+
sprintf(
|
9826 |
+
/* translators: %s: an error message from the WebP self-test */
|
9827 |
+
esc_html__( 'Insertion successful, but self-test failed: %s', 'ewww-image-optimizer' ),
|
9828 |
+
esc_html( $webp_mime_error )
|
9829 |
+
)
|
9830 |
+
);
|
9831 |
}
|
9832 |
+
die( esc_html__( 'Insertion failed', 'ewww-image-optimizer' ) );
|
9833 |
}
|
9834 |
+
die( esc_html__( 'Insertion aborted', 'ewww-image-optimizer' ) );
|
9835 |
}
|
9836 |
|
9837 |
/**
|
9852 |
} else {
|
9853 |
esc_html_e( 'Removal failed', 'ewww-image-optimizer' );
|
9854 |
}
|
9855 |
+
die();
|
9856 |
}
|
9857 |
|
9858 |
/**
|
9862 |
*/
|
9863 |
function ewww_image_optimizer_webp_rewrite_verify() {
|
9864 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
9865 |
+
if ( ewww_image_optimizer_easy_active() ) {
|
9866 |
if ( ewwwio_extract_from_markers( ewww_image_optimizer_htaccess_path(), 'EWWWIO' ) ) {
|
9867 |
ewwwio_debug_message( 'removing htaccess webp to prevent ExactDN problems' );
|
9868 |
insert_with_markers( ewww_image_optimizer_htaccess_path(), 'EWWWIO', '' );
|
9879 |
'RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png|gif)$',
|
9880 |
'RewriteCond %{REQUEST_FILENAME}.webp -f',
|
9881 |
'RewriteCond %{QUERY_STRING} !type=original',
|
9882 |
+
'RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_URI}.webp [T=image/webp,L]',
|
9883 |
'</IfModule>',
|
9884 |
'<IfModule mod_headers.c>',
|
9885 |
+
'<FilesMatch "\.(jpe?g|png|gif)$">',
|
9886 |
+
'Header append Vary Accept',
|
9887 |
+
'</FilesMatch>',
|
9888 |
'</IfModule>',
|
9889 |
'AddType image/webp .webp',
|
9890 |
);
|
9895 |
! ewww_image_optimizer_array_search( '{HTTP_ACCEPT} image/webp', $current_rules ) ||
|
9896 |
! ewww_image_optimizer_array_search( '{REQUEST_FILENAME}.webp', $current_rules ) ||
|
9897 |
! ewww_image_optimizer_array_search( 'Header append Vary Accept', $current_rules ) ||
|
9898 |
+
ewww_image_optimizer_array_search( 'Header append Vary Accept env=REDIRECT', $current_rules ) ||
|
9899 |
! ewww_image_optimizer_array_search( 'AddType image/webp', $current_rules )
|
9900 |
) {
|
9901 |
ewwwio_debug_message( 'missing or invalid rules' );
|
9995 |
if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ), true ) ) {
|
9996 |
$sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
|
9997 |
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
|
9998 |
+
$sizes[ $_size ]['crop'] = get_option( $_size . '_crop' );
|
9999 |
if ( 'medium_large' === $_size && 0 === intval( $sizes[ $_size ]['width'] ) ) {
|
10000 |
$sizes[ $_size ]['width'] = '768';
|
10001 |
}
|
10006 |
$sizes[ $_size ] = array(
|
10007 |
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
|
10008 |
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
|
10009 |
+
'crop' => $_wp_additional_image_sizes[ $_size ]['crop'],
|
10010 |
);
|
10011 |
}
|
10012 |
}
|
10014 |
$sizes['pdf-full'] = array(
|
10015 |
'width' => 99999,
|
10016 |
'height' => 99999,
|
10017 |
+
'crop' => false,
|
10018 |
);
|
10019 |
|
10020 |
if ( ewww_image_optimizer_function_exists( 'print_r' ) ) {
|
10141 |
$eio_exclude_paths = ewww_image_optimizer_get_option( 'exactdn_exclude' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'exactdn_exclude' ) ) ) : '';
|
10142 |
ewwwio_debug_message( $eio_exclude_paths );
|
10143 |
ewwwio_debug_message( 'lazy load: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ? 'on' : 'off' ) );
|
10144 |
+
ewwwio_other_lazy_detected();
|
10145 |
ewwwio_debug_message( 'LQIP: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_use_lqip' ) ? 'on' : 'off' ) );
|
10146 |
ewwwio_debug_message( 'LL exclusions:' );
|
10147 |
$ll_exclude_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ? esc_html( implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ) ) : '';
|
10152 |
ewwwio_debug_message( 'pngout level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ) );
|
10153 |
ewwwio_debug_message( 'svgcleaner disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_svgcleaner' ) ? 'yes' : 'no' ) );
|
10154 |
}
|
10155 |
+
ewwwio_debug_message( 'configured quality: ' . ewww_image_optimizer_set_jpg_quality( 82 ) );
|
10156 |
+
ewwwio_debug_message( 'effective quality: ' . apply_filters( 'jpeg_quality', 82, 'image_resize' ) );
|
10157 |
ewwwio_debug_message( 'effective WebP quality: ' . ewww_image_optimizer_set_webp_quality( 75 ) );
|
10158 |
ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) ? 'on' : 'off' ) );
|
10159 |
ewwwio_debug_message( 'background optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ? 'on' : 'off' ) );
|
10269 |
if ( ! apache_mod_loaded( 'mod_headers' ) ) {
|
10270 |
ewwwio_debug_message( 'possibly missing mod_headers' );
|
10271 |
}
|
10272 |
+
if ( ! ewww_image_optimizer_test_webp_mime_error() || ! ewww_image_optimizer_webp_rewrite_verify() ) {
|
10273 |
ewwwio_debug_message( 'webp .htaccess rewriting enabled' );
|
10274 |
} else {
|
10275 |
ewwwio_debug_message( 'webp .htaccess rules not detected' );
|
10281 |
ewwwio_check_memory_available();
|
10282 |
}
|
10283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10284 |
/**
|
10285 |
+
* Displays the EWWW IO wizard/intro to assist the user in setting up the plugin initially.
|
|
|
|
|
|
|
|
|
|
|
10286 |
*/
|
10287 |
+
function ewww_image_optimizer_intro_wizard() {
|
10288 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
|
|
|
|
|
|
|
|
10289 |
global $exactdn;
|
10290 |
+
$display_exec_notice = false;
|
10291 |
+
$tools_missing_notice = false;
|
10292 |
+
$current_jpeg_quality = apply_filters( 'jpeg_quality', 82, 'image_resize' );
|
10293 |
+
$wizard_complete_url = wp_nonce_url( add_query_arg( 'complete_wizard', 1, ewww_image_optimizer_get_settings_link() ), 'ewww_image_optimizer_options-options' );
|
10294 |
+
$settings_page_url = ewww_image_optimizer_get_settings_link();
|
10295 |
+
$loading_image_url = plugins_url( '/images/spinner.gif', __FILE__ );
|
10296 |
+
$wizard_step = 1;
|
10297 |
+
$show_premium = false;
|
10298 |
+
$eio_base = new EIO_Base();
|
10299 |
+
$easyio_site_url = $eio_base->content_url();
|
10300 |
+
$no_tracking = false;
|
10301 |
+
$webp_available = true;
|
10302 |
+
$bulk_available = false;
|
10303 |
+
$tools_available = true;
|
10304 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) ) {
|
10305 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_CLOUD' ) && EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
10306 |
+
ewww_image_optimizer_disable_tools();
|
10307 |
+
} else {
|
10308 |
+
ewww_image_optimizer_tool_init();
|
10309 |
+
ewww_image_optimizer_notice_utils( 'quiet' );
|
10310 |
+
}
|
10311 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10312 |
if (
|
10313 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ||
|
10314 |
+
ewww_image_optimizer_easy_active() ||
|
10315 |
+
! empty( $_GET['show-premium'] )
|
10316 |
+
) {
|
10317 |
+
$show_premium = true;
|
10318 |
+
} elseif (
|
10319 |
+
ewww_image_optimizer_exec_check() &&
|
10320 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_dismiss_exec_notice' ) &&
|
10321 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
10322 |
! ewww_image_optimizer_easy_active()
|
10323 |
) {
|
10324 |
+
$display_exec_notice = true;
|
10325 |
+
} elseif (
|
10326 |
+
( defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) ||
|
10327 |
+
( defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG' ) && ! EWWW_IMAGE_OPTIMIZER_OPTIPNG ) ||
|
10328 |
+
( defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) && ! EWWW_IMAGE_OPTIMIZER_GIFSICLE )
|
10329 |
+
) {
|
10330 |
+
$tools_missing = array();
|
10331 |
+
$tools_available = false;
|
10332 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
10333 |
+
$tools_missing[] = 'jpegtran';
|
10334 |
+
} elseif ( defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) ) {
|
10335 |
+
$tools_available = true;
|
10336 |
+
}
|
10337 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG' ) && ! EWWW_IMAGE_OPTIMIZER_OPTIPNG ) {
|
10338 |
+
$tools_missing[] = 'optipng';
|
10339 |
+
} elseif ( defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG' ) ) {
|
10340 |
+
$tools_available = true;
|
10341 |
+
}
|
10342 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) && ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) {
|
10343 |
+
$tools_missing[] = 'gifsicle';
|
10344 |
+
} elseif ( defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) ) {
|
10345 |
+
$tools_available = true;
|
10346 |
+
}
|
10347 |
+
$tools_missing_notice = true;
|
10348 |
+
// Expand the missing utilities list for use in the error message.
|
10349 |
+
$tools_missing_message = implode( ', ', $tools_missing );
|
10350 |
}
|
10351 |
+
if (
|
10352 |
+
defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) && EWWW_IMAGE_OPTIMIZER_NOEXEC &&
|
10353 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' )
|
10354 |
+
) {
|
10355 |
+
$webp_available = false;
|
10356 |
+
}
|
10357 |
+
if (
|
10358 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ||
|
10359 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ||
|
10360 |
+
! ewww_image_optimizer_exec_check()
|
10361 |
+
) {
|
10362 |
+
$bulk_available = true;
|
10363 |
+
}
|
10364 |
+
if (
|
10365 |
+
stristr( network_site_url( '/' ), '.local' ) !== false ||
|
10366 |
+
stristr( network_site_url( '/' ), 'dev' ) !== false ||
|
10367 |
+
stristr( network_site_url( '/' ), 'localhost' ) !== false ||
|
10368 |
+
stristr( network_site_url( '/' ), ':8888' ) !== false // This is common with MAMP on OS X.
|
10369 |
+
) {
|
10370 |
+
$no_tracking = true;
|
10371 |
+
}
|
10372 |
+
if ( ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_wizard' ) ) {
|
10373 |
+
if ( ! empty( $_POST['ewwwio_wizard_step'] ) ) {
|
10374 |
+
$wizard_step = (int) $_POST['ewwwio_wizard_step'];
|
10375 |
+
}
|
10376 |
+
if ( ! empty( $_POST['ewww_image_optimizer_goal_save_space'] ) ) {
|
10377 |
+
update_option( 'ewww_image_optimizer_goal_save_space', true, false );
|
10378 |
+
} else {
|
10379 |
+
update_option( 'ewww_image_optimizer_goal_save_space', false, false );
|
10380 |
+
}
|
10381 |
+
if ( ! empty( $_POST['ewww_image_optimizer_goal_site_speed'] ) ) {
|
10382 |
+
update_option( 'ewww_image_optimizer_goal_site_speed', true, false );
|
10383 |
+
} else {
|
10384 |
+
update_option( 'ewww_image_optimizer_goal_site_speed', false, false );
|
10385 |
+
}
|
10386 |
+
if ( ! empty( $_POST['ewww_image_optimizer_budget'] ) && 'free' === $_POST['ewww_image_optimizer_budget'] ) {
|
10387 |
+
if ( $display_exec_notice ) {
|
10388 |
+
ewww_image_optimizer_enable_free_exec();
|
10389 |
+
}
|
10390 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_OPTIPNG' ) && ! EWWW_IMAGE_OPTIMIZER_OPTIPNG ) {
|
10391 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_png_level', 0 );
|
10392 |
+
}
|
10393 |
+
if ( defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) && ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) {
|
10394 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_gif_level', 0 );
|
10395 |
+
}
|
10396 |
+
if ( $tools_missing_notice && ! $tools_available ) {
|
10397 |
+
ewww_image_optimizer_enable_free_exec();
|
10398 |
+
$webp_available = false;
|
10399 |
+
}
|
10400 |
+
}
|
10401 |
+
if ( 3 === $wizard_step ) {
|
10402 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_metadata_remove', ! empty( $_POST['ewww_image_optimizer_metadata_remove'] ) );
|
10403 |
+
if ( ! empty( $_POST['ewww_image_optimizer_jpg_quality'] ) ) {
|
10404 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_jpg_quality', (int) $_POST['ewww_image_optimizer_jpg_quality'] );
|
10405 |
+
}
|
10406 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_lazy_load', ! empty( $_POST['ewww_image_optimizer_lazy_load'] ) );
|
10407 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_webp', ! empty( $_POST['ewww_image_optimizer_webp'] ) );
|
10408 |
+
if ( ! empty( $_POST['ewww_image_optimizer_maxmediawidth'] ) ) {
|
10409 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxmediawidth', (int) $_POST['ewww_image_optimizer_maxmediawidth'] );
|
10410 |
+
}
|
10411 |
+
if ( ! empty( $_POST['ewww_image_optimizer_maxmediaheight'] ) ) {
|
10412 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_maxmediaheight', (int) $_POST['ewww_image_optimizer_maxmediaheight'] );
|
10413 |
+
}
|
10414 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_enable_help', ! empty( $_POST['ewww_image_optimizer_enable_help'] ) );
|
10415 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_allow_tracking', ! empty( $_POST['ewww_image_optimizer_allow_tracking'] ) );
|
10416 |
+
update_option( 'ewww_image_optimizer_wizard_complete', true, false );
|
10417 |
+
global $eio_debug;
|
10418 |
+
$debug_info = '';
|
10419 |
+
if ( ! empty( $eio_debug ) ) {
|
10420 |
+
$debug_info = $eio_debug;
|
10421 |
+
}
|
10422 |
+
}
|
10423 |
+
wp_add_inline_script(
|
10424 |
+
'ewww-settings-script',
|
10425 |
+
'ewww_vars.save_space = ' . ( ! empty( $_POST['ewww_image_optimizer_goal_save_space'] ) ? 1 : 0 ) . ";\n" .
|
10426 |
+
'ewww_vars.site_speed = ' . ( ! empty( $_POST['ewww_image_optimizer_goal_site_speed'] ) ? 1 : 0 ) . ";\n"
|
10427 |
+
);
|
10428 |
+
}
|
10429 |
+
?>
|
10430 |
+
<div id='ewww-settings-wrap' class='wrap'>
|
10431 |
+
<div id='ewwwio-wizard'>
|
10432 |
+
<div id="ewwwio-wizard-header">
|
10433 |
+
<img height="95" width="167" src="<?php echo esc_url( plugins_url( '/images/ewwwio-logo.png', __FILE__ ) ); ?>">
|
10434 |
+
</div>
|
10435 |
+
<div id='ewwwio-wizard-body'>
|
10436 |
+
<?php if ( 1 === $wizard_step ) : ?>
|
10437 |
+
<?php if ( $display_exec_notice ) : ?>
|
10438 |
+
<div id='ewww-image-optimizer-warning-exec' class='ewwwio-notice notice-warning'>
|
10439 |
+
<?php esc_html_e( 'Sites where the exec() function is disabled require cloud-based optimization, because free server-based optimization will not work.', 'ewww-image-optimizer' ); ?>
|
10440 |
+
<br>
|
10441 |
+
<strong>
|
10442 |
+
<?php esc_html_e( 'You may ask your system administrator to enable exec() for free server-based optimization. Otherwise, choose between free cloud-based JPG-only compression and premium optimization below.', 'ewww-image-optimizer' ); ?>
|
10443 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/29-what-is-exec-and-why-do-i-need-it', '592dd12d0428634b4a338c39' ); ?>
|
10444 |
+
</strong>
|
10445 |
+
</div>
|
10446 |
+
<?php elseif ( $tools_missing_notice && $tools_available ) : ?>
|
10447 |
+
<div id='ewww-image-optimizer-warning-opt-missing' class='ewwwio-notice notice-warning'>
|
10448 |
+
<?php
|
10449 |
+
printf(
|
10450 |
+
/* translators: %s: comma-separated list of missing tools */
|
10451 |
+
esc_html__( 'EWWW Image Optimizer uses open-source tools to enable free mode, but your server is missing these: %s.', 'ewww-image-optimizer' ),
|
10452 |
+
esc_html( $tools_missing_message )
|
10453 |
+
);
|
10454 |
+
echo '<br><br>';
|
10455 |
+
printf(
|
10456 |
+
/* translators: %s: Installation Instructions (link) */
|
10457 |
+
esc_html__( 'You may install missing tools via the %s or continue with reduced functionality.', 'ewww-image-optimizer' ),
|
10458 |
+
"<a href='https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something' data-beacon-article='585371e3c697912ffd6c0ba1' target='_blank'>" . esc_html__( 'Installation Instructions', 'ewww-image-optimizer' ) . '</a>'
|
10459 |
+
);
|
10460 |
+
?>
|
10461 |
+
</div>
|
10462 |
+
<?php elseif ( $tools_missing_notice ) : ?>
|
10463 |
+
<div id='ewww-image-optimizer-warning-opt-missing' class='ewwwio-notice notice-warning'>
|
10464 |
+
<?php
|
10465 |
+
printf(
|
10466 |
+
/* translators: %s: comma-separated list of missing tools */
|
10467 |
+
esc_html__( 'EWWW Image Optimizer uses open-source tools to enable free mode, but your server is missing these: %s.', 'ewww-image-optimizer' ),
|
10468 |
+
esc_html( $tools_missing_message )
|
10469 |
+
);
|
10470 |
+
echo '<br><br>';
|
10471 |
+
printf(
|
10472 |
+
/* translators: %s: Installation Instructions (link) */
|
10473 |
+
esc_html__( 'You may install missing tools via the %s. Otherwise, choose between free cloud-based JPG-only compression and premium optimization below.', 'ewww-image-optimizer' ),
|
10474 |
+
"<a href='https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something' data-beacon-article='585371e3c697912ffd6c0ba1' target='_blank'>" . esc_html__( 'Installation Instructions', 'ewww-image-optimizer' ) . '</a>'
|
10475 |
+
);
|
10476 |
+
?>
|
10477 |
+
</div>
|
10478 |
+
<?php endif; ?>
|
10479 |
+
<form id='ewwwio-wizard-step-1' class='ewwwio-wizard-form' method='post' action=''>
|
10480 |
+
<input type='hidden' name='ewwwio_wizard_step' value='2' />
|
10481 |
+
<?php wp_nonce_field( 'ewww_image_optimizer_wizard' ); ?>
|
10482 |
+
<div class='ewwwio-intro-text'><?php esc_html_e( 'In order to recommend the best settings for your site, please select which goal(s) are most important:', 'ewww-image-optimizer' ); ?></div>
|
10483 |
+
<div class='ewwwio-wizard-form-group'>
|
10484 |
+
<input type='checkbox' id='ewww_image_optimizer_goal_site_speed' name='ewww_image_optimizer_goal_site_speed' value='true' required />
|
10485 |
+
<label for='ewww_image_optimizer_goal_site_speed'><?php esc_html_e( 'Speed up your site', 'ewww-image-optimizer' ); ?></label><br>
|
10486 |
+
<input type='checkbox' id='ewww_image_optimizer_goal_save_space' name='ewww_image_optimizer_goal_save_space' value='true' required />
|
10487 |
+
<label for='ewww_image_optimizer_goal_save_space'><?php esc_html_e( 'Save storage space', 'ewww-image-optimizer' ); ?></label>
|
10488 |
+
</div>
|
10489 |
+
<div class='ewwwio-wizard-form-group'>
|
10490 |
+
<input type='radio' id='ewww_image_optimizer_budget_pay' name='ewww_image_optimizer_budget' value='pay' required <?php checked( $show_premium ); ?>/>
|
10491 |
+
<label for='ewww_image_optimizer_budget_pay'><?php esc_html_e( 'Get 5x more optimization and priority support', 'ewww-image-optimizer' ); ?></label><br>
|
10492 |
+
<div class="ewwwio-wizard-form-group ewwwio-premium-setup" <?php echo ( $show_premium ? "style='display:block'" : '' ); ?>>
|
10493 |
+
<p><strong><a href='https://ewww.io/plans/' target='_blank'>>><?php esc_html_e( 'Start your free trial', 'ewww-image-optimizer' ); ?></a></strong></p>
|
10494 |
+
<div id='ewwwio-api-activation-result'></div>
|
10495 |
+
<p id='ewww_image_optimizer_cloud_key_container'>
|
10496 |
+
<label for='ewww_image_optimizer_cloud_key'><?php esc_html_e( 'Compress API Key', 'ewww-image-optimizer' ); ?></label><br>
|
10497 |
+
<input type='text' id='ewww_image_optimizer_cloud_key' name='ewww_image_optimizer_cloud_key' value='<?php echo esc_attr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ); ?>' />
|
10498 |
+
<?php if ( empty( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) ) : ?>
|
10499 |
+
<span id='ewwwio-api-activate'><a href='#' class='button-secondary'><?php esc_html_e( 'Activate', 'ewww-image-optimizer' ); ?></a></span>
|
10500 |
+
<span id='ewwwio-api-activation-processing'><img src='<?php echo esc_url( $loading_image_url ); ?>' alt='loading'/></span>
|
10501 |
+
<?php else : ?>
|
10502 |
+
<span class="dashicons dashicons-yes"></span>
|
10503 |
+
<?php endif; ?>
|
10504 |
+
<br>
|
10505 |
+
<span class="description"><?php esc_html_e( 'Premium compression for your local images.', 'ewww-image-optimizer' ); ?></span>
|
10506 |
+
</p>
|
10507 |
+
<div id='ewwwio-easy-activation-result'></div>
|
10508 |
+
<p>
|
10509 |
+
<label><?php esc_html_e( 'Easy IO', 'ewww-image-optimizer' ); ?></label><br>
|
10510 |
+
<span class="description">
|
10511 |
+
<?php
|
10512 |
+
printf(
|
10513 |
+
/* translators: %s: the string 'and more' with a link to the docs */
|
10514 |
+
esc_html__( 'An image-optimizing CDN that does not modify your local images. Includes automatic compression, scaling, WebP %s.', 'ewww-image-optimizer' ),
|
10515 |
+
'<a href="https://docs.ewww.io/article/44-introduction-to-exactdn" target="_blank" data-beacon-article="59bc5ad6042863033a1ce370">' . esc_html__( 'and more', 'ewww-image-optimizer' ) . '</a>'
|
10516 |
+
);
|
10517 |
+
?>
|
10518 |
+
</span>
|
10519 |
+
<?php if ( empty( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) ) : ?>
|
10520 |
+
<br>
|
10521 |
+
<a href="<?php echo esc_url( add_query_arg( 'site_url', trim( $easyio_site_url ), 'https://ewww.io/manage-sites/' ) ); ?>" target="_blank">
|
10522 |
+
<?php esc_html_e( 'Add your Site URL to your account:', 'easy-image-optimizer' ); ?>
|
10523 |
+
</a>
|
10524 |
+
<input type='text' id='exactdn_site_url' name='exactdn_site_url' value='<?php echo esc_url( trim( $easyio_site_url ) ); ?>' readonly />
|
10525 |
+
<span id='exactdn-site-url-copy'><?php esc_html_e( 'Click to Copy', 'ewww-image-optimizer' ); ?></span>
|
10526 |
+
<span id='exactdn-site-url-copied'><?php esc_html_e( 'Copied', 'ewww-image-optimizer' ); ?></span><br>
|
10527 |
+
<a id='ewwwio-easy-activate' href='#' class='button-secondary'><?php esc_html_e( 'Activate', 'ewww-image-optimizer' ); ?></a>
|
10528 |
+
<span id='ewwwio-easy-activation-processing'><img src='<?php echo esc_url( $loading_image_url ); ?>' alt='loading'/></span>
|
10529 |
+
<?php elseif ( class_exists( 'ExactDN' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && $exactdn->get_exactdn_domain() && $exactdn->verify_domain( $exactdn->get_exactdn_domain() ) ) : ?>
|
10530 |
+
<span style="color: #3eadc9; font-weight: bolder"><?php esc_html_e( 'Verified', 'ewww-image-optimizer' ); ?></span>
|
10531 |
+
<span class="dashicons dashicons-yes"></span>
|
10532 |
+
<?php endif; ?>
|
10533 |
+
</p>
|
10534 |
+
</div>
|
10535 |
+
<input type='radio' id='ewww_image_optimizer_budget_free' name='ewww_image_optimizer_budget' value='free' required />
|
10536 |
+
<label for='ewww_image_optimizer_budget_free'><?php esc_html_e( 'Stick with free mode for now', 'ewww-image-optimizer' ); ?></label>
|
10537 |
+
</div>
|
10538 |
+
<div class='ewwwio-flex-space-between'>
|
10539 |
+
<p><input type='submit' class='button-primary' value='<?php esc_attr_e( 'Next', 'ewww-image-optimizer' ); ?>' /></p>
|
10540 |
+
<p><a href='<?php echo esc_url( $wizard_complete_url ); ?>'><?php esc_html_e( "I know what I'm doing, leave me alone!", 'ewww-image-optimizer' ); ?></a></p>
|
10541 |
+
</div>
|
10542 |
+
</form>
|
10543 |
+
<?php elseif ( 2 === $wizard_step ) : ?>
|
10544 |
+
<form id='ewwwio-wizard-step-2' class='ewwwio-wizard-form' method='post' action=''>
|
10545 |
+
<input type='hidden' name='ewwwio_wizard_step' value='3' />
|
10546 |
+
<?php wp_nonce_field( 'ewww_image_optimizer_wizard' ); ?>
|
10547 |
+
<div class='ewwwio-intro-text'><?php esc_html_e( 'Here are the recommended settings for your site. Please review and then save the settings.', 'ewww-image-optimizer' ); ?></div>
|
10548 |
+
<p>
|
10549 |
+
<input type='checkbox' id='ewww_image_optimizer_metadata_remove' name='ewww_image_optimizer_metadata_remove' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_remove' ) ); ?> />
|
10550 |
+
<label for='ewww_image_optimizer_metadata_remove'><?php esc_html_e( 'Remove Metadata', 'ewww-image-optimizer' ); ?></label>
|
10551 |
+
</p>
|
10552 |
+
<?php if ( $current_jpeg_quality > 90 || $current_jpeg_quality < 50 || ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_quality' ) ) : ?>
|
10553 |
+
<p>
|
10554 |
+
<input type='text' id='ewww_image_optimizer_jpg_quality' name='ewww_image_optimizer_jpg_quality' class='small-text' value='82' />
|
10555 |
+
<label for='ewww_image_optimizer_jpg_quality'><?php esc_html_e( 'JPG Quality Level', 'ewww-image-optimizer' ); ?></label>
|
10556 |
+
</p>
|
10557 |
+
<?php endif; ?>
|
10558 |
+
<?php if ( ! ewwwio_other_lazy_detected() ) : ?>
|
10559 |
+
<p>
|
10560 |
+
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' checked />
|
10561 |
+
<label for='ewww_image_optimizer_lazy_load'><?php esc_html_e( 'Lazy Load', 'ewww-image-optimizer' ); ?></label>
|
10562 |
+
</p>
|
10563 |
+
<?php else : ?>
|
10564 |
+
<p><strong><?php esc_html_e( 'Though you have a lazy loader already, our lazy loader includes CSS background images and auto-scaling.', 'ewww-image-optimizer' ); ?></strong></p>
|
10565 |
+
<p>
|
10566 |
+
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' />
|
10567 |
+
<label for='ewww_image_optimizer_lazy_load'><?php esc_html_e( 'Lazy Load', 'ewww-image-optimizer' ); ?></label>
|
10568 |
+
</p>
|
10569 |
+
<?php endif; ?>
|
10570 |
+
<?php if ( ! $webp_available ) : ?>
|
10571 |
+
<p>
|
10572 |
+
<input type='checkbox' id='ewww_image_optimizer_easy_webp' name='ewww_image_optimizer_easy_webp' value='true' disabled />
|
10573 |
+
<label for='ewww_image_optimizer_easy_webp'><?php esc_html_e( 'WebP Conversion', 'ewww-image-optimizer' ); ?></label><br>
|
10574 |
+
</p>
|
10575 |
+
<p>*<?php esc_html_e( 'WebP conversion requires an API key or Easy IO subscription.', 'ewww-image-optimizer' ); ?></p>
|
10576 |
+
<?php elseif ( ewww_image_optimizer_easy_active() ) : ?>
|
10577 |
+
<p>
|
10578 |
+
<input type='checkbox' id='ewww_image_optimizer_easy_webp' name='ewww_image_optimizer_easy_webp' value='true' checked disabled />
|
10579 |
+
<label for='ewww_image_optimizer_easy_webp'><?php esc_html_e( 'WebP Conversion (included with Easy IO)', 'ewww-image-optimizer' ); ?></label><br>
|
10580 |
+
</p>
|
10581 |
+
<?php else : ?>
|
10582 |
+
<p>
|
10583 |
+
<input type='checkbox' id='ewww_image_optimizer_webp' name='ewww_image_optimizer_webp' value='true' <?php checked( ! get_option( 'ewww_image_optimizer_goal_save_space' ) ); ?>/>
|
10584 |
+
<label for='ewww_image_optimizer_webp'><?php esc_html_e( 'WebP Conversion', 'ewww-image-optimizer' ); ?></label>
|
10585 |
+
</p>
|
10586 |
+
<p id='ewwwio-webp-storage-warning'>
|
10587 |
+
<i><?php esc_html_e( 'Enabling WebP Conversion without Easy IO will increase your storage requirements. Do you want to continue?', 'ewww-image-optimizer' ); ?></i><br>
|
10588 |
+
<a id='ewwwio-cancel-webp' href='#'><?php esc_html_e( 'Nevermind', 'ewww-image-optimizer' ); ?></a><br>
|
10589 |
+
<a id='ewwwio-easyio-webp-info' href='<?php echo esc_url( $settings_page_url ) . '&show-premium=1'; ?>'><?php esc_html_e( 'Tell me more about Easy IO', 'ewww-image-optimizer' ); ?></a><br>
|
10590 |
+
<span id='ewwwio-confirm-webp' class='button-primary'><?php esc_html_e( 'Continue', 'ewww-image-optimizer' ); ?></span>
|
10591 |
+
</p>
|
10592 |
+
<?php endif; ?>
|
10593 |
+
<?php if ( ! function_exists( 'imsanity_get_max_width_height' ) ) : ?>
|
10594 |
+
<p>
|
10595 |
+
<input type='number' step='10' min='0' class='small-text' id='ewww_image_optimizer_maxmediawidth' name='ewww_image_optimizer_maxmediawidth' value='<?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' ) ? (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' ) : 1920; ?>' <?php disabled( function_exists( 'imsanity_get_max_width_height' ) ); ?> />
|
10596 |
+
<label for='ewww_image_optimizer_maxmediawidth'><?php esc_html_e( 'Max Width', 'ewww-image-optimizer' ); ?></label>
|
10597 |
+
<input type='number' step='10' min='0' class='small-text' id='ewww_image_optimizer_maxmediaheight' name='ewww_image_optimizer_maxmediaheight' value='<?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' ) ? (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' ) : 1920; ?>' <?php disabled( function_exists( 'imsanity_get_max_width_height' ) ); ?> />
|
10598 |
+
<label for='ewww_image_optimizer_maxmediaheight'><?php esc_html_e( 'Max Height', 'ewww-image-optimizer' ); ?></label><br>
|
10599 |
+
<span class='description'><?php esc_html_e( 'Resize uploaded images to these dimensions (in pixels).', 'ewww-image-optimizer' ); ?></span>
|
10600 |
+
</p>
|
10601 |
+
<?php endif; ?>
|
10602 |
+
<p>
|
10603 |
+
<input type='checkbox' id='ewww_image_optimizer_enable_help' name='ewww_image_optimizer_enable_help' value='true' checked />
|
10604 |
+
<label for='ewww_image_optimizer_enable_help'><?php esc_html_e( 'Embedded Help', 'ewww-image-optimizer' ); ?></label><br>
|
10605 |
+
<span class='description'><?php esc_html_e( 'Access documentation and support from your WordPress dashboard. Uses resources from external servers.', 'ewww-image-optimizer' ); ?></span>
|
10606 |
+
</p>
|
10607 |
+
<?php if ( ! $no_tracking ) : ?>
|
10608 |
+
<p>
|
10609 |
+
<input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' checked />
|
10610 |
+
<label for='ewww_image_optimizer_allow_tracking'><?php esc_html_e( 'Anonymous Reporting', 'ewww-image-optimizer' ); ?></label>
|
10611 |
+
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/23-usage-tracking', '591f3a8e2c7d3a057f893d91' ); ?></span><br>
|
10612 |
+
<span class='description'><?php esc_html_e( 'Send anonymized usage data to help make the plugin better. Opt-in and get a 10% discount code.', 'ewww-image-optimizer' ); ?></span>
|
10613 |
+
</p>
|
10614 |
+
<?php endif; ?>
|
10615 |
+
<div class='ewwwio-flex-space-between'>
|
10616 |
+
<p><input type='submit' class='button-primary' value='<?php esc_attr_e( 'Save Settings', 'ewww-image-optimizer' ); ?>' /></p>
|
10617 |
+
<p class='ewwwio-wizard-back'><a href='<?php echo esc_url( $settings_page_url ); ?>' class='button-secondary'><?php esc_html_e( 'Go Back', 'ewww-image-optimizer' ); ?></a></p>
|
10618 |
+
</div>
|
10619 |
+
</form>
|
10620 |
+
<?php elseif ( 3 === $wizard_step ) : ?>
|
10621 |
+
<p>
|
10622 |
+
<?php
|
10623 |
+
printf(
|
10624 |
+
/* translators: %s: Bulk Optimize (link) */
|
10625 |
+
esc_html__( 'New uploads will be optimized automatically. Optimize existing images with the %s.', 'ewww-image-optimizer' ),
|
10626 |
+
'<a href="' . esc_url( admin_url( 'upload.php?page=ewww-image-optimizer-bulk' ) ) . '">' . esc_html__( 'Bulk Optimizer', 'ewww-image-optimizer' ) . '</a>'
|
10627 |
+
);
|
10628 |
+
ewwwio_help_link( 'https://docs.ewww.io/article/4-getting-started', '5853713bc697912ffd6c0b98' );
|
10629 |
+
?>
|
10630 |
+
</p>
|
10631 |
+
<p>
|
10632 |
+
<?php
|
10633 |
+
printf(
|
10634 |
+
/* translators: 1: List View in the Media Library 2: the WP-CLI command */
|
10635 |
+
esc_html__( 'You may also use %1$s to selectively optimize images or WP-CLI to optimize your images in bulk: %2$s', 'ewww-image-optimizer' ),
|
10636 |
+
'<a href="' . esc_url( admin_url( 'upload.php?mode=list' ) ) . '">' . esc_html__( 'List View in the Media Library', 'ewww-image-optimizer' ) . '</a>',
|
10637 |
+
'<br><code>wp help ewwwio optimize</code>'
|
10638 |
+
);
|
10639 |
+
ewwwio_help_link( 'https://docs.ewww.io/article/25-optimizing-with-wp-cli', '592da1482c7d3a074e8aeb6b' );
|
10640 |
+
?>
|
10641 |
+
</p>
|
10642 |
+
<p>
|
10643 |
+
<?php
|
10644 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) ) {
|
10645 |
+
printf(
|
10646 |
+
/* translators: 1: link to https://ewww.io/plans/ 2: discount code (yes, you may use it) */
|
10647 |
+
esc_html__( 'Use this code at %1$s: %2$s', 'ewww-image-optimizer' ),
|
10648 |
+
'<a href="https://ewww.io/plans/" target="_blank">https://ewww.io/</a>',
|
10649 |
+
'<code>SPEEDER1012</code>'
|
10650 |
+
);
|
10651 |
+
}
|
10652 |
+
?>
|
10653 |
+
</p>
|
10654 |
+
<p><a type='submit' class='button-primary' href='<?php echo esc_url( $settings_page_url ); ?>'><?php esc_attr_e( 'Done', 'ewww-image-optimizer' ); ?></a></p>
|
10655 |
+
<?php
|
10656 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
10657 |
+
$current_user = wp_get_current_user();
|
10658 |
+
$help_email = $current_user->user_email;
|
10659 |
+
$hs_debug = '';
|
10660 |
+
if ( ! empty( $debug_info ) ) {
|
10661 |
+
$hs_debug = str_replace( array( "'", '<br>', '<b>', '</b>', '=>' ), array( "\'", '\n', '**', '**', '=' ), $debug_info );
|
10662 |
+
}
|
10663 |
+
?>
|
10664 |
+
<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout.net",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
|
10665 |
+
<script type="text/javascript">
|
10666 |
+
window.Beacon('init', 'aa9c3d3b-d4bc-4e9b-b6cb-f11c9f69da87');
|
10667 |
+
Beacon( 'prefill', {
|
10668 |
+
email: '<?php echo esc_js( utf8_encode( $help_email ) ); ?>',
|
10669 |
+
text: '\n\n----------------------------------------\n<?php echo wp_kses_post( $hs_debug ); ?>',
|
10670 |
+
});
|
10671 |
+
</script>
|
10672 |
+
<?php
|
10673 |
+
}
|
10674 |
+
?>
|
10675 |
+
<?php endif; ?>
|
10676 |
+
</div>
|
10677 |
+
</div>
|
10678 |
+
</div>
|
10679 |
+
<?php
|
10680 |
+
}
|
10681 |
+
|
10682 |
+
/**
|
10683 |
+
* De-activates front-end parsing functions and displays troubleshooting instructions.
|
10684 |
+
*/
|
10685 |
+
function ewww_image_optimizer_rescue_mode() {
|
10686 |
+
$settings_page_url = ewww_image_optimizer_get_settings_link();
|
10687 |
+
$frontend_functions = array();
|
10688 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
10689 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_exactdn', '' );
|
10690 |
+
$frontend_functions[] = 'easyio';
|
10691 |
+
}
|
10692 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
10693 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_lazy_load', false );
|
10694 |
+
$frontend_functions[] = 'lazyload';
|
10695 |
+
}
|
10696 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ) {
|
10697 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_webp_for_cdn', false );
|
10698 |
+
$frontend_functions[] = 'jswebp';
|
10699 |
+
}
|
10700 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ) {
|
10701 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_picture_webp', false );
|
10702 |
+
$frontend_functions[] = 'picturewebp';
|
10703 |
+
}
|
10704 |
+
global $eio_debug;
|
10705 |
+
$debug_info = '';
|
10706 |
+
if ( ! empty( $eio_debug ) ) {
|
10707 |
+
$debug_info = $eio_debug;
|
10708 |
+
}
|
10709 |
+
?>
|
10710 |
+
<div id='ewww-settings-wrap' class='wrap'>
|
10711 |
+
<div id='ewwwio-rescue'>
|
10712 |
+
<div id="ewwwio-rescue-header">
|
10713 |
+
<img height="95" width="167" src="<?php echo esc_url( plugins_url( '/images/ewwwio-logo.png', __FILE__ ) ); ?>">
|
10714 |
+
</div>
|
10715 |
+
<div id='ewwwio-rescue-body'>
|
10716 |
+
<div id='ewww-image-optimizer-warning-exec' class='ewwwio-notice notice-warning'>
|
10717 |
+
<?php esc_html_e( 'All front-end functions have been disabled. Please clear all caches, and check your site to ensure it is functioning normally.', 'ewww-image-optimizer' ); ?>
|
10718 |
+
<br>
|
10719 |
+
<a class='ewww-contact-root' href='https://ewww.io/contact-us/'>
|
10720 |
+
<?php esc_html_e( 'If you continue to have problems, let us know right away!', 'ewww-image-optimizer' ); ?>
|
10721 |
+
</a>
|
10722 |
+
</div>
|
10723 |
+
<div class='ewwwio-intro-text'>
|
10724 |
+
<?php esc_html_e( 'We don\'t want you to settle for reduced functionality, so here are some troubleshooting tips:', 'ewww-image-optimizer' ); ?>
|
10725 |
+
</div>
|
10726 |
+
<ul>
|
10727 |
+
<?php if ( in_array( 'easyio', $frontend_functions, true ) ) : ?>
|
10728 |
+
<li>
|
10729 |
+
<?php esc_html_e( 'Without Easy IO, several key optimizations are no longer working. First, re-enable Easy IO, and if your site is encounters problems again, try disabling the option to Include All Resources.', 'ewww-image-optimizer' ); ?>
|
10730 |
+
</li>
|
10731 |
+
<?php endif; ?>
|
10732 |
+
<?php if ( in_array( 'lazyload', $frontend_functions, true ) || in_array( 'easyio', $frontend_functions, true ) ) : ?>
|
10733 |
+
<li>
|
10734 |
+
<?php esc_html_e( 'Third-party lazy loaders prevent Easy IO from auto-scaling some images, and may cause conflicts. We recommend disabling them and using the EWWW IO lazy loader.', 'ewww-image-optimizer' ); ?>
|
10735 |
+
</li>
|
10736 |
+
<?php endif; ?>
|
10737 |
+
<?php if ( in_array( 'lazyload', $frontend_functions, true ) ) : ?>
|
10738 |
+
<li>
|
10739 |
+
<?php /* translators: %s: Documentation (link) */ ?>
|
10740 |
+
<?php printf( esc_html__( 'The lazy loader has browser-native and auto-scaling components that may not be compatible with some themes/plugins. Instructions for disabling these can be found in the %s.', 'ewww-image-optimizer' ), "<a class='ewww-help-beacon-single' href='https://docs.ewww.io/article/74-lazy-load' data-beacon-article='5c6c36ed042863543ccd2d9b'>" . esc_html__( 'Documentation', 'ewww-image-optimizer' ) . '</a>' ); ?>
|
10741 |
+
</li>
|
10742 |
+
<?php endif; ?>
|
10743 |
+
<?php if ( in_array( 'jswebp', $frontend_functions, true ) ) : ?>
|
10744 |
+
<li>
|
10745 |
+
<?php esc_html_e( 'Enabling Lazy Load alongside JS WebP enables better compatibility with some themes/plugins. Alternatively, you may try <picture> WebP Rewriting for a JavaScript-free delivery method.', 'ewww-image-optimizer' ); ?>
|
10746 |
+
</li>
|
10747 |
+
<?php endif; ?>
|
10748 |
+
<?php if ( in_array( 'picturewebp', $frontend_functions, true ) ) : ?>
|
10749 |
+
<li>
|
10750 |
+
<?php esc_html_e( 'Some themes may not display <picture> elements properly, so try JS WebP Rewriting for WebP delivery.', 'ewww-image-optimizer' ); ?>
|
10751 |
+
</li>
|
10752 |
+
<?php endif; ?>
|
10753 |
+
</ul>
|
10754 |
+
<p>
|
10755 |
+
<a class='ewww-contact-root' href='https://ewww.io/contact-us/'>
|
10756 |
+
<?php esc_html_e( 'If you have not found a solution that works for your site, let us know! We would love to help you find a solution.', 'ewww-image-optimizer' ); ?>
|
10757 |
+
</a>
|
10758 |
+
</p>
|
10759 |
+
<p><a href='<?php echo esc_url( $settings_page_url ); ?>' class='button-secondary'><?php esc_html_e( 'Return to Settings', 'ewww-image-optimizer' ); ?></a></p>
|
10760 |
+
</div>
|
10761 |
+
</div>
|
10762 |
+
</div>
|
10763 |
+
<?php
|
10764 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
10765 |
+
$current_user = wp_get_current_user();
|
10766 |
+
$help_email = $current_user->user_email;
|
10767 |
+
$hs_debug = '';
|
10768 |
+
if ( ! empty( $debug_info ) ) {
|
10769 |
+
$hs_debug = str_replace( array( "'", '<br>', '<b>', '</b>', '=>' ), array( "\'", '\n', '**', '**', '=' ), $debug_info );
|
10770 |
+
}
|
10771 |
+
?>
|
10772 |
+
<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout.net",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
|
10773 |
+
<script type="text/javascript">
|
10774 |
+
window.Beacon('init', 'aa9c3d3b-d4bc-4e9b-b6cb-f11c9f69da87');
|
10775 |
+
Beacon( 'prefill', {
|
10776 |
+
email: '<?php echo esc_js( utf8_encode( $help_email ) ); ?>',
|
10777 |
+
text: '\n\n----------------------------------------\n<?php echo wp_kses_post( $hs_debug ); ?>',
|
10778 |
+
});
|
10779 |
+
</script>
|
10780 |
+
<?php
|
10781 |
+
}
|
10782 |
+
}
|
10783 |
+
|
10784 |
+
/**
|
10785 |
+
* Wrapper that displays the EWWW IO options in the multisite network admin.
|
10786 |
+
*/
|
10787 |
+
function ewww_image_optimizer_network_options() {
|
10788 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
10789 |
+
ewww_image_optimizer_options( 'network-multisite' );
|
10790 |
+
}
|
10791 |
+
|
10792 |
+
/**
|
10793 |
+
* Wrapper that displays the EWWW IO options for multisite mode on a single site.
|
10794 |
+
*
|
10795 |
+
* By default, the only options displayed are the per-site resizes list, but a network admin can
|
10796 |
+
* permit site admins to configure their own blog settings.
|
10797 |
+
*/
|
10798 |
+
function ewww_image_optimizer_network_singlesite_options() {
|
10799 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
10800 |
+
ewww_image_optimizer_options( 'network-singlesite' );
|
10801 |
+
}
|
10802 |
+
|
10803 |
+
/**
|
10804 |
+
* Displays the EWWW IO options along with status information, and debugging information.
|
10805 |
+
*
|
10806 |
+
* @global string $eio_debug In memory debug log.
|
10807 |
+
* @global int $wp_version
|
10808 |
+
*
|
10809 |
+
* @param string $network Indicates which options should be shown in multisite installations.
|
10810 |
+
*/
|
10811 |
+
function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
10812 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
10813 |
+
global $ewwwio_temp_debug;
|
10814 |
+
global $ewwwio_upgrading;
|
10815 |
+
global $eio_debug;
|
10816 |
+
global $eio_hs_beacon;
|
10817 |
+
global $exactdn;
|
10818 |
+
global $eio_alt_webp;
|
10819 |
+
$total_savings = 0;
|
10820 |
+
if ( 'network-multisite' === $network ) {
|
10821 |
+
$total_sizes = ewww_image_optimizer_savings( true );
|
10822 |
+
$total_savings = $total_sizes[1] - $total_sizes[0];
|
10823 |
+
} else {
|
10824 |
+
$total_sizes = ewww_image_optimizer_savings();
|
10825 |
+
$total_savings = $total_sizes[1] - $total_sizes[0];
|
10826 |
+
}
|
10827 |
+
|
10828 |
+
ewwwio_debug_info();
|
10829 |
+
$debug_info = $eio_debug;
|
10830 |
+
ewww_image_optimizer_temp_debug_clear();
|
10831 |
+
|
10832 |
+
if ( empty( $network ) ) {
|
10833 |
+
$network = 'singlesite';
|
10834 |
+
}
|
10835 |
+
if ( 'network-multisite' === $network && get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) ) {
|
10836 |
+
$network = 'network-multisite-over';
|
10837 |
+
} elseif ( 'network-singlesite' === $network && get_site_option( 'ewww_image_optimizer_allow_multisite_override' ) ) {
|
10838 |
+
$network = 'singlesite';
|
10839 |
+
}
|
10840 |
+
if ( 'singlesite' === $network && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_wizard_complete' ) ) {
|
10841 |
+
ewww_image_optimizer_intro_wizard();
|
10842 |
+
return;
|
10843 |
+
}
|
10844 |
+
if ( ! empty( $_GET['rescue_mode'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'ewww_image_optimizer_options-options' ) ) {
|
10845 |
+
ewww_image_optimizer_rescue_mode();
|
10846 |
+
return;
|
10847 |
+
}
|
10848 |
+
$eio_hs_beacon->admin_notice( $network );
|
10849 |
+
?>
|
10850 |
+
|
10851 |
+
<div id='ewww-settings-wrap' class='wrap'>
|
10852 |
+
<h1 style="display:none;">EWWW Image Optimizer</h1>
|
10853 |
+
<?php
|
10854 |
+
$speed_score = 0;
|
10855 |
+
|
10856 |
+
$speed_recommendations = array();
|
10857 |
+
|
10858 |
+
$free_exec = false;
|
10859 |
+
if (
|
10860 |
+
defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) && EWWW_IMAGE_OPTIMIZER_NOEXEC &&
|
10861 |
+
10 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) &&
|
10862 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
10863 |
+
! ewww_image_optimizer_easy_active()
|
10864 |
+
) {
|
10865 |
+
$free_exec = true;
|
10866 |
+
$speed_score += 5;
|
10867 |
+
}
|
10868 |
+
if (
|
10869 |
+
! $free_exec &&
|
10870 |
+
defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN &&
|
10871 |
+
10 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) &&
|
10872 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
10873 |
+
! ewww_image_optimizer_easy_active()
|
10874 |
+
) {
|
10875 |
+
$free_exec = true;
|
10876 |
+
$speed_score += 5;
|
10877 |
+
}
|
10878 |
+
$verify_cloud = '';
|
10879 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
10880 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', 0 );
|
10881 |
+
$verify_cloud = ewww_image_optimizer_cloud_verify( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ), false );
|
10882 |
if ( false !== strpos( $verify_cloud, 'great' ) && ! ewww_image_optimizer_easy_active() ) {
|
10883 |
$speed_score += 35;
|
10884 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 20 ) {
|
10916 |
$speed_score += 20;
|
10917 |
}
|
10918 |
} elseif (
|
10919 |
+
( ! class_exists( 'Jetpack' ) || ! Jetpack::is_module_active( 'photon' ) ) &&
|
10920 |
class_exists( 'ExactDN' ) &&
|
10921 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' )
|
10922 |
) {
|
10953 |
}
|
10954 |
$easymode = false;
|
10955 |
if (
|
|
|
|
|
10956 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_local_mode' )
|
10957 |
) {
|
10958 |
$easymode = true;
|
11138 |
'src' => array(),
|
11139 |
),
|
11140 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11141 |
|
11142 |
if ( 'network-multisite-over' === $network ) {
|
11143 |
ob_start();
|
11150 |
} elseif ( $speed_score < 90 ) {
|
11151 |
$stroke_class = 'ewww-orange';
|
11152 |
}
|
|
|
|
|
11153 |
?>
|
11154 |
<div id='ewww-widgets' class='metabox-holder'>
|
11155 |
<div class='meta-box-sortables'>
|
11156 |
<div id='ewww-status' class='postbox'>
|
11157 |
+
<!--<h2 class='ewww-hndle'><?php esc_html_e( 'Optimization Status', 'ewww-image-optimizer' ); ?></h2>-->
|
11158 |
+
<div class='ewww-hndle' id="ewwwio-banner">
|
11159 |
+
<img height="95" width="167" src="<?php echo esc_url( plugins_url( '/images/ewwwio-logo.png', __FILE__ ) ); ?>">
|
11160 |
+
<div>
|
11161 |
+
<div class='ewwwio-flex-space-between'>
|
11162 |
+
<p>
|
11163 |
+
<?php esc_html_e( 'Get performance tips, exclusive discounts, and the latest news when you signup for our newsletter!', 'ewww-image-optimizer' ); ?>
|
11164 |
+
</p>
|
11165 |
+
<p id='ewww-review'>
|
11166 |
+
<a target="_blank" href="https://wordpress.org/support/plugin/ewww-image-optimizer/reviews/#new-post"><?php esc_html_e( 'Write a Review', 'ewww-image-optimizer' ); ?></a>
|
11167 |
+
<a target="_blank" href="https://wordpress.org/support/plugin/ewww-image-optimizer/reviews/#new-post">
|
11168 |
+
<span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span>
|
11169 |
+
</a>
|
11170 |
+
</p>
|
11171 |
+
</div>
|
11172 |
+
<p id='ewww-news-button'>
|
11173 |
+
<a href="https://eepurl.com/gKyU6L?TB_iframe=true&width=600&height=610" class="thickbox button-secondary"><?php esc_html_e( 'Subscribe now!', 'ewww-image-optimizer' ); ?></a>
|
11174 |
+
</p>
|
11175 |
+
</div>
|
11176 |
+
</div>
|
11177 |
<div class='inside'>
|
11178 |
+
<div class='ewww-row ewww-blocks'>
|
11179 |
+
<div id='ewww-score-bars' class='ewww-status-detail'>
|
11180 |
+
<div id='ewww-speed-container' class='ewww-bar-container'>
|
11181 |
+
<div id='ewww-speed-fill' data-score='<?php echo (int) $speed_score; ?>' class='<?php echo esc_attr( $stroke_class ); ?> ewww-bar-fill'></div>
|
11182 |
+
</div>
|
11183 |
+
<div id='ewww-speed-flex' class='ewww-bar-caption'>
|
11184 |
+
<p><strong><?php esc_html_e( 'Optimization Score', 'ewww-image-optimizer' ); ?></strong></p>
|
11185 |
+
<p class='ewww-bar-score'><?php echo (int) $speed_score; ?>%</p>
|
11186 |
+
<p id='ewww-show-recommendations'>
|
11187 |
+
<?php if ( $speed_score < 100 ) : ?>
|
11188 |
+
<a href='#'><?php esc_html_e( 'View recommendations', 'ewww-image-optimizer' ); ?></a>
|
11189 |
+
<a style='display:none' href='#'><?php esc_html_e( 'Hide recommendations', 'ewww-image-optimizer' ); ?></a>
|
11190 |
+
<?php endif; ?>
|
11191 |
+
</p>
|
11192 |
+
</div>
|
11193 |
+
<div class="ewww-recommend">
|
11194 |
+
<p><strong><?php echo ( (int) $speed_score < 100 ? esc_html__( 'How do I get to 100%?', 'ewww-image-optimizer' ) : esc_html__( 'You got the perfect score!', 'ewww-image-optimizer' ) ); ?></strong></p>
|
11195 |
<?php if ( $speed_score < 100 ) : ?>
|
11196 |
<ul class="ewww-tooltip">
|
11197 |
+
<?php foreach ( $speed_recommendations as $recommendation ) : ?>
|
11198 |
<li><?php echo wp_kses( $recommendation, $allow_help_html ); ?></li>
|
11199 |
+
<?php endforeach; ?>
|
11200 |
</ul>
|
11201 |
<?php endif; ?>
|
11202 |
</div><!-- end .ewww-recommend -->
|
11203 |
+
<?php if ( $total_savings > 0 ) : ?>
|
11204 |
+
<div id='ewww-savings-container' class='ewww-bar-container'>
|
11205 |
+
<div id='ewww-savings-fill' data-score='<?php echo intval( $total_savings / $total_sizes[1] * 100 ); ?>' class='ewww-bar-fill'></div>
|
11206 |
+
</div>
|
11207 |
+
<div id='ewww-savings-flex' class='ewww-bar-caption'>
|
11208 |
+
<p><strong><?php esc_html_e( 'Local Compression Savings', 'ewww-image-optimizer' ); ?></strong></p>
|
11209 |
+
<p class='ewww-bar-score'><?php echo esc_html( ewww_image_optimizer_size_format( $total_savings, 2 ) ); ?></p>
|
11210 |
+
<p>
|
11211 |
+
<a href="<?php echo esc_url( admin_url( 'tools.php?page=ewww-image-optimizer-tools' ) ); ?>"><?php esc_html_e( 'View optimized images', 'ewww-image-optimizer' ); ?></a>
|
11212 |
+
</p>
|
11213 |
+
</div>
|
11214 |
<?php endif; ?>
|
11215 |
+
<?php if ( $exactdn_enabled && ! empty( $exactdn_savings ) && ! empty( $exactdn_savings['original'] ) && ! empty( $exactdn_savings['savings'] ) ) : ?>
|
11216 |
+
<div id='easyio-savings-container' class='ewww-bar-container'>
|
11217 |
+
<div id='easyio-savings-fill' data-score='<?php echo intval( $exactdn_savings['savings'] / $exactdn_savings['original'] * 100 ); ?>' class='ewww-bar-fill'></div>
|
11218 |
+
</div>
|
11219 |
+
<div id='easyio-savings-flex' class='ewww-bar-caption'>
|
11220 |
+
<p>
|
11221 |
+
<strong><?php esc_html_e( 'Easy IO Savings', 'ewww-image-optimizer' ); ?></strong>
|
11222 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/96-easy-io-is-it-working', '5f871dd2c9e77c0016217c4e' ); ?>
|
11223 |
+
</p>
|
11224 |
+
<p class='ewww-bar-score'><?php echo esc_html( ewww_image_optimizer_size_format( $exactdn_savings['savings'], 2 ) ); ?></p>
|
11225 |
+
<p> </p>
|
11226 |
+
</div>
|
11227 |
+
<?php endif; ?>
|
11228 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11229 |
<!-- begin notices section -->
|
11230 |
<div id="ewww-notices" class="ewww-status-detail">
|
11231 |
+
<p>
|
11232 |
+
<?php
|
11233 |
+
printf(
|
11234 |
+
/* translators: %s: Bulk Optimize (link) */
|
11235 |
+
esc_html__( 'New uploads will be optimized automatically. Optimize existing images with the %s.', 'ewww-image-optimizer' ),
|
11236 |
+
( 'network-multisite' === esc_attr( $network ) ?
|
11237 |
+
esc_html__( 'Media Library', 'ewww-image-optimizer' ) . ' -> ' . esc_html__( 'Bulk Optimizer', 'ewww-image-optimizer' ) :
|
11238 |
+
'<a href="' . esc_url( admin_url( 'upload.php?page=ewww-image-optimizer-bulk' ) ) . '">' . esc_html__( 'Bulk Optimizer', 'ewww-image-optimizer' ) . '</a>'
|
11239 |
+
)
|
11240 |
+
);
|
11241 |
+
ewwwio_help_link( 'https://docs.ewww.io/article/4-getting-started', '5853713bc697912ffd6c0b98' );
|
11242 |
+
echo ' ' . ( ! class_exists( 'Amazon_S3_And_CloudFront' ) ?
|
11243 |
+
'<br>' .
|
11244 |
+
sprintf(
|
11245 |
+
/* translators: %s: S3 Image Optimizer (link) */
|
11246 |
+
esc_html__( 'Optimize unlimited Amazon S3 buckets with our %s.' ),
|
11247 |
+
'<a href="https://ewww.io/downloads/s3-image-optimizer/">' . esc_html__( 'S3 Image Optimizer', 'ewww-image-optimizer' ) . '</a>'
|
11248 |
+
) : '' );
|
11249 |
+
?>
|
11250 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11251 |
<p>
|
11252 |
<strong><?php esc_html_e( 'Background optimization (faster uploads):', 'ewww-image-optimizer' ); ?></strong><br>
|
11253 |
<?php if ( defined( 'EWWW_DISABLE_ASYNC' ) && EWWW_DISABLE_ASYNC ) : ?>
|
11296 |
var exactdn_enabled = false;
|
11297 |
</script>
|
11298 |
<?php endif; ?>
|
11299 |
+
<?php
|
11300 |
+
$frontend_functions = array();
|
11301 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
11302 |
+
$frontend_functions[] = __( 'Lazy Load', 'ewww-image-optimizer' );
|
11303 |
+
}
|
11304 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ) {
|
11305 |
+
$frontend_functions[] = __( 'JS WebP Rewriting', 'ewww-image-optimizer' );
|
11306 |
+
}
|
11307 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ) {
|
11308 |
+
$frontend_functions[] = __( '<picture> WebP Rewriting', 'ewww-image-optimizer' );
|
11309 |
+
}
|
11310 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
11311 |
+
$frontend_functions[] = __( 'Easy IO', 'ewww-image-optimizer' );
|
11312 |
+
}
|
11313 |
+
$loading_image_url = plugins_url( '/images/spinner.gif', __FILE__ );
|
11314 |
+
$eio_base = new EIO_Base();
|
11315 |
+
$easyio_site_url = $eio_base->content_url();
|
11316 |
+
$exactdn_att_che = ewww_image_optimizer_get_option( 'exactdn_all_the_things' ) && ( ! is_object( $exactdn ) || 1 < $exactdn->get_plan_id() );
|
11317 |
+
$exactdn_att_id = ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ? 'exactdn_all_the_things_disabled' : 'exactdn_all_the_things' );
|
11318 |
+
$exactdn_att_dis = ! $exactdn_enabled || 1 === $exactdn->get_plan_id();
|
11319 |
+
$exactdn_los_che = ewww_image_optimizer_get_option( 'exactdn_lossy' ) || ( is_object( $exactdn ) && 1 === $exactdn->get_plan_id() );
|
11320 |
+
$exactdn_los_id = ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ? 'exactdn_lossy_disabled' : 'exactdn_lossy' );
|
11321 |
+
$exactdn_los_dis = ! $exactdn_enabled || 1 === $exactdn->get_plan_id();
|
11322 |
+
$eio_exclude_paths = ewww_image_optimizer_get_option( 'exactdn_exclude' ) ? implode( "\n", ewww_image_optimizer_get_option( 'exactdn_exclude' ) ) : '';
|
11323 |
+
$lqip_che = is_object( $exactdn ) && 1 < $exactdn->get_plan_id() && ewww_image_optimizer_get_option( 'ewww_image_optimizer_use_lqip' );
|
11324 |
+
$lqip_id = ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ? 'ewww_image_optimizer_use_lqip_disabled' : 'ewww_image_optimizer_use_lqip' );
|
11325 |
+
$lqip_dis = ! $exactdn_enabled || 1 === $exactdn->get_plan_id();
|
11326 |
+
$ll_exclude_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ? implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_ll_exclude' ) ) : '';
|
11327 |
+
$current_jpeg_quality = apply_filters( 'jpeg_quality', 82, 'image_resize' );
|
11328 |
+
$webp_php_rewriting = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' );
|
11329 |
+
$webp_exclude_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_rewrite_exclude' ) ? implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_rewrite_exclude' ) ) : '';
|
11330 |
+
$webp_paths = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ? implode( "\n", ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_paths' ) ) : '';
|
11331 |
+
$webp_url_example = sprintf(
|
11332 |
+
/* translators: 1: An image URL on a CDN 2: An image URL 3: An example folder URL */
|
11333 |
+
esc_html__( 'For example, with a CDN URL of %1$s and a local URL of %2$s you would enter %3$s.', 'ewww-image-optimizer' ),
|
11334 |
+
'https://cdn.example.com/<strong>files/</strong>2038/01/image.jpg',
|
11335 |
+
'https://example.com/<strong>wp-content/uploads/</strong>2038/01/image.jpg',
|
11336 |
+
'https://cdn.example.com/<strong>files/</strong>'
|
11337 |
+
);
|
11338 |
+
// Setup URLs for Ludicrous/Easy Mode.
|
11339 |
+
$enable_local_url = wp_nonce_url(
|
11340 |
+
add_query_arg(
|
11341 |
+
array(
|
11342 |
+
'page' => 'ewww-image-optimizer-options',
|
11343 |
+
'enable-local' => 1,
|
11344 |
+
),
|
11345 |
+
null
|
11346 |
+
),
|
11347 |
+
'ewww_image_optimizer_options-options'
|
11348 |
+
);
|
11349 |
+
$enable_easy_url = wp_nonce_url(
|
11350 |
+
add_query_arg(
|
11351 |
+
array(
|
11352 |
+
'page' => 'ewww-image-optimizer-options',
|
11353 |
+
'enable-local' => 0,
|
11354 |
+
),
|
11355 |
+
null
|
11356 |
+
),
|
11357 |
+
'ewww_image_optimizer_options-options'
|
11358 |
+
);
|
11359 |
+
$rescue_mode_url = wp_nonce_url(
|
11360 |
+
add_query_arg(
|
11361 |
+
array(
|
11362 |
+
'page' => 'ewww-image-optimizer-options',
|
11363 |
+
'rescue_mode' => 1,
|
11364 |
+
),
|
11365 |
+
null
|
11366 |
+
),
|
11367 |
+
'ewww_image_optimizer_options-options'
|
11368 |
+
);
|
11369 |
+
// Make sure .htaccess rules are terminated when ExactDN is enabled or if Cloudflare is detected.
|
11370 |
+
$cf_host = ewwwio_is_cf_host();
|
11371 |
+
if ( ewww_image_optimizer_easy_active() || $cf_host ) {
|
11372 |
+
ewww_image_optimizer_webp_rewrite_verify();
|
11373 |
+
}
|
11374 |
+
$test_webp_image = plugins_url( '/images/test.png.webp', __FILE__ );
|
11375 |
+
$test_png_image = plugins_url( '/images/test.png', __FILE__ );
|
11376 |
+
?>
|
11377 |
+
|
11378 |
|
11379 |
<!-- 'network-multisite-over' and 'network-singlesite' get simpler settings, 'network-singlesite-over' masquerades as 'singlesite' -->
|
11380 |
<?php if ( ! $easymode && ( 'singlesite' === $network || 'network-multisite' === $network ) ) : ?>
|
11381 |
<ul class='ewww-tab-nav'>
|
11382 |
<li class='ewww-tab ewww-general-nav'><span><?php esc_html_e( 'Basic', 'ewww-image-optimizer' ); ?></span></li>
|
11383 |
+
<li class='ewww-tab ewww-local-nav'><span><?php esc_html_e( 'Local', 'ewww-image-optimizer' ); ?></span></li>
|
11384 |
+
<li class='ewww-tab ewww-advanced-nav'><span><?php esc_html_e( 'Advanced', 'ewww-image-optimizer' ); ?></span></li>
|
|
|
|
|
11385 |
<li class='ewww-tab ewww-resize-nav'><span><?php esc_html_e( 'Resize', 'ewww-image-optimizer' ); ?></span></li>
|
11386 |
<li class='ewww-tab ewww-conversion-nav'><span><?php esc_html_e( 'Convert', 'ewww-image-optimizer' ); ?></span></li>
|
|
|
11387 |
<li class='ewww-tab ewww-overrides-nav'><span><a href='https://docs.ewww.io/article/40-override-options' target='_blank'><span class='ewww-tab-hidden'><?php esc_html_e( 'Overrides', 'ewww-image-optimizer' ); ?></a></span></li>
|
11388 |
<li class='ewww-tab ewww-support-nav'><span><?php esc_html_e( 'Support', 'ewww-image-optimizer' ); ?></span></li>
|
11389 |
<li class='ewww-tab ewww-contribute-nav'><span><?php esc_html_e( 'Contribute', 'ewww-image-optimizer' ); ?></span></li>
|
11391 |
<?php elseif ( $easymode ) : ?>
|
11392 |
<ul class='ewww-tab-nav'>
|
11393 |
<li class='ewww-tab ewww-general-nav'><span><?php esc_html_e( 'Basic', 'ewww-image-optimizer' ); ?></span></li>
|
|
|
|
|
11394 |
<li class='ewww-tab ewww-support-nav'><span><?php esc_html_e( 'Support', 'ewww-image-optimizer' ); ?></span></li>
|
11395 |
<li class='ewww-tab ewww-contribute-nav'><span><?php esc_html_e( 'Contribute', 'ewww-image-optimizer' ); ?></span></li>
|
11396 |
</ul>
|
11404 |
<input type='hidden' name='action' value='update' />
|
11405 |
<?php wp_nonce_field( 'ewww_image_optimizer_options-options' ); ?>
|
11406 |
<?php if ( 'network-singlesite' === $network ) : ?>
|
11407 |
+
<p><i class="network-singlesite"><strong>
|
11408 |
+
<?php /* translators: %s: Network Admin */ ?>
|
11409 |
+
<?php printf( esc_html__( 'Configure network-wide settings in the %s.', 'ewww-image-optimizer' ), '<a href="' . esc_url( ewww_image_optimizer_get_settings_link() ) . '">' . esc_html__( 'Network Admin', 'ewww-image-optimizer' ) . '</a>' ); ?>
|
11410 |
+
</strong></i></p>
|
11411 |
<?php ob_start(); ?>
|
11412 |
<?php endif; ?>
|
11413 |
<div id='ewww-general-settings'>
|
11414 |
<noscript><h2><?php esc_html_e( 'Basic', 'ewww-image-optimizer' ); ?></h2></noscript>
|
11415 |
+
<?php if ( $easymode ) : ?>
|
11416 |
+
<p>
|
11417 |
+
<a href='<?php echo esc_url( $enable_local_url ); ?>'>
|
11418 |
+
<?php esc_html_e( 'Enable Ludicrous Mode', 'ewww-image-optimizer' ); ?>
|
11419 |
+
</a>
|
11420 |
+
</p>
|
11421 |
+
<?php else : ?>
|
11422 |
+
<p>
|
11423 |
+
<?php /* translators: %s: Easy Mode */ ?>
|
11424 |
+
<?php printf( esc_html__( 'Switch to %s.', 'ewww-image-optimizer' ), '<a href="' . esc_url( $enable_easy_url ) . '">' . esc_html__( 'Easy Mode', 'ewww-image-optimizer' ) . '</a>' ); ?>
|
11425 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11426 |
<?php endif; ?>
|
11427 |
<?php ob_start(); ?>
|
11428 |
<table class='form-table'>
|
11443 |
</th>
|
11444 |
<td>
|
11445 |
<input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' <?php checked( get_site_option( 'ewww_image_optimizer_allow_tracking' ) ); ?> />
|
11446 |
+
<?php esc_html_e( '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 a 10% discount on premium compression. No sensitive data is tracked.', 'ewww-image-optimizer' ); ?>
|
11447 |
+
<p>
|
11448 |
+
<?php
|
11449 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) ) {
|
11450 |
+
printf(
|
11451 |
+
/* translators: 1: link to https://ewww.io/plans/ 2: discount code (yes, you may use it) */
|
11452 |
+
esc_html__( 'Use this code at %1$s: %2$s', 'ewww-image-optimizer' ),
|
11453 |
+
'<a href="https://ewww.io/plans/" target="_blank">https://ewww.io/</a>',
|
11454 |
+
'<code>SPEEDER1012</code>'
|
11455 |
+
);
|
11456 |
+
}
|
11457 |
+
?>
|
11458 |
+
</p>
|
11459 |
</td>
|
11460 |
</tr>
|
11461 |
</table>
|
11470 |
<?php
|
11471 |
return;
|
11472 |
endif;
|
11473 |
+
$premium_hide = '';
|
11474 |
+
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
11475 |
+
$premium_hide = ' style="display:none"';
|
11476 |
+
}
|
11477 |
?>
|
11478 |
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
11479 |
+
<tr id='ewww_image_optimizer_cloud_key_container'>
|
11480 |
<th scope='row'>
|
11481 |
<label for='ewww_image_optimizer_cloud_notkey'><?php esc_html_e( 'Compress API Key', 'ewww-image-optimizer' ); ?></label>
|
11482 |
</th>
|
11483 |
<td>
|
11484 |
<input type='text' id='ewww_image_optimizer_cloud_notkey' name='ewww_image_optimizer_cloud_notkey' readonly='readonly' value='****************************<?php echo esc_attr( substr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ), 28 ) ); ?>' size='32' />
|
11485 |
+
<a class='button-secondary' href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_remove_cloud_key' ) ); ?>'>
|
11486 |
<?php esc_html_e( 'Remove API key', 'ewww-image-optimizer' ); ?>
|
11487 |
</a>
|
11488 |
<input type='hidden' id='ewww_image_optimizer_cloud_key' name='ewww_image_optimizer_cloud_key' value='<?php echo esc_attr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ); ?>' />
|
11489 |
+
<p>
|
11490 |
+
<?php if ( false !== strpos( $verify_cloud, 'great' ) ) : ?>
|
11491 |
+
<span style="color: #3eadc9; font-weight: bolder"><?php esc_html_e( 'Verified,', 'ewww-image-optimizer' ); ?> </span><?php echo esc_html( ewww_image_optimizer_cloud_quota() ); ?>
|
11492 |
+
<?php elseif ( false !== strpos( $verify_cloud, 'exceeded' ) ) : ?>
|
11493 |
+
<span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Out of credits', 'ewww-image-optimizer' ); ?></span> - <a href="https://ewww.io/buy-credits/" target="_blank"><?php esc_html_e( 'Purchase more', 'ewww-image-optimizer' ); ?></a>
|
11494 |
+
<?php else : ?>
|
11495 |
+
<span style="color: red; font-weight: bolder"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></span>
|
11496 |
+
<?php endif; ?>
|
11497 |
+
<?php if ( false !== strpos( $verify_cloud, 'great' ) ) : ?>
|
11498 |
+
<a target="_blank" href="https://history.exactlywww.com/show/?api_key=<?php echo esc_attr( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ); ?>"><?php esc_html_e( 'View Usage', 'ewww-image-optimizer' ); ?></a>
|
11499 |
+
<?php endif; ?>
|
11500 |
+
</p>
|
11501 |
</td>
|
11502 |
</tr>
|
11503 |
<?php else : ?>
|
11504 |
+
<?php if ( ! $exactdn_enabled ) : ?>
|
11505 |
<tr>
|
11506 |
+
<th scope='row'> </th>
|
11507 |
+
<td>
|
11508 |
+
<input type='radio' id='ewww_image_optimizer_budget_pay' name='ewww_image_optimizer_budget' value='pay' required />
|
11509 |
+
<label for='ewww_image_optimizer_budget_pay'><?php esc_html_e( 'Activate Easy IO and/or the Compress API to get 5x more optimization and priority support', 'ewww-image-optimizer' ); ?></label><br>
|
11510 |
+
<input type='radio' id='ewww_image_optimizer_budget_free' name='ewww_image_optimizer_budget' value='free' required <?php checked( (bool) $premium_hide ); ?> />
|
11511 |
+
<label for='ewww_image_optimizer_budget_free'><?php esc_html_e( 'Stick with free mode for now', 'ewww-image-optimizer' ); ?></label>
|
11512 |
+
<p class="ewwwio-premium-setup-disabled-for-now" <?php echo wp_kses_post( $premium_hide ); ?>><strong><a href='https://ewww.io/plans/' target='_blank'>>><?php esc_html_e( 'Start your free trial', 'ewww-image-optimizer' ); ?></a></strong></p>
|
11513 |
+
</td>
|
11514 |
+
</tr>
|
11515 |
+
<?php endif; ?>
|
11516 |
+
<tr id='ewww_image_optimizer_cloud_key_container' class='ewwwio-premium-setup' <?php echo wp_kses_post( $premium_hide ); ?>>
|
11517 |
<th scope='row'>
|
11518 |
<label for='ewww_image_optimizer_cloud_key'><?php esc_html_e( 'Compress API Key', 'ewww-image-optimizer' ); ?></label>
|
11519 |
<?php ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2,5ad0c8e7042863075092650b,5a9efec62c7d3a7549516550' ); ?>
|
11520 |
</th>
|
11521 |
<td>
|
11522 |
+
<div id='ewwwio-api-activation-result'></div>
|
11523 |
<input type='text' id='ewww_image_optimizer_cloud_key' name='ewww_image_optimizer_cloud_key' value='' size='32' />
|
11524 |
+
<span id='ewwwio-api-activate'><a href='#' class='button-secondary'><?php esc_html_e( 'Activate', 'ewww-image-optimizer' ); ?></a></span>
|
11525 |
+
<span id='ewwwio-api-activation-processing'><img src='<?php echo esc_url( $loading_image_url ); ?>' alt='loading'/></span>
|
11526 |
+
<p class='description'>
|
11527 |
+
<?php esc_html_e( 'Premium compression for your local images.', 'ewww-image-optimizer' ); ?>
|
11528 |
+
<a href='https://ewww.io/plans/' target='_blank'>
|
11529 |
+
<?php esc_html_e( 'Start your free trial today.', 'ewww-image-optimizer' ); ?>
|
11530 |
+
</a>
|
11531 |
+
</p>
|
11532 |
+
</td>
|
11533 |
+
</tr>
|
11534 |
+
<?php endif; ?>
|
11535 |
+
<?php if ( ! get_option( 'easyio_exactdn' ) ) : ?>
|
11536 |
+
<tr id="ewww_image_optimizer_exactdn_container" class="ewwwio-premium-setup" <?php echo wp_kses_post( $premium_hide ); ?>>
|
11537 |
+
<th scope='row'>
|
11538 |
+
<span id='ewwwio-exactdn-anchor'></span>
|
11539 |
+
<label for='ewww_image_optimizer_exactdn'><?php esc_html_e( 'Easy IO', 'ewww-image-optimizer' ); ?></label>
|
11540 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/44-introduction-to-exactdn', '59bc5ad6042863033a1ce370,5c0042892c7d3a31944e88a4' ); ?>
|
11541 |
+
</th>
|
11542 |
+
<td>
|
11543 |
+
<div id='ewwwio-easy-activation-result'></div>
|
11544 |
+
<?php
|
11545 |
+
printf(
|
11546 |
+
/* translators: %s: the string 'and more' with a link to the docs */
|
11547 |
+
esc_html__( 'An image-optimizing CDN with automatic compression, scaling, WebP conversion %s.', 'ewww-image-optimizer' ),
|
11548 |
+
'<a href="https://docs.ewww.io/article/44-introduction-to-exactdn" target="_blank" data-beacon-article="59bc5ad6042863033a1ce370">' . esc_html__( 'and more', 'ewww-image-optimizer' ) . '</a>'
|
11549 |
+
);
|
11550 |
+
?>
|
11551 |
+
<?php if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
11552 |
+
<p style='color: red'><?php esc_html_e( 'Inactive, please disable the Image Accelerator option on the Jetpack Dashboard.', 'ewww-image-optimizer' ); ?></p>
|
11553 |
+
<?php elseif ( ! $exactdn_enabled ) : ?>
|
11554 |
+
<p>
|
11555 |
+
<strong><a href="https://ewww.io/plans/" target="_blank">
|
11556 |
+
<?php esc_html_e( 'Purchase a subscription for your site.', 'ewww-image-optimizer' ); ?>
|
11557 |
+
</a></strong><br>
|
11558 |
+
<a href="https://ewww.io/manage-sites/" target="_blank"><?php esc_html_e( 'Then, add your Site URL to your account:', 'easy-image-optimizer' ); ?></a>
|
11559 |
+
<input type='text' id='exactdn_site_url' name='exactdn_site_url' value='<?php echo esc_url( trim( $easyio_site_url ) ); ?>' readonly />
|
11560 |
+
<span id='exactdn-site-url-copy'><?php esc_html_e( 'Click to Copy', 'ewww-image-optimizer' ); ?></span>
|
11561 |
+
<span id='exactdn-site-url-copied'><?php esc_html_e( 'Copied', 'ewww-image-optimizer' ); ?></span><br>
|
11562 |
+
<a id='ewwwio-easy-activate' href='#' class='button-secondary'><?php esc_html_e( 'Activate', 'ewww-image-optimizer' ); ?></a>
|
11563 |
+
<span id='ewwwio-easy-activation-processing'><img src='<?php echo esc_url( $loading_image_url ); ?>' alt='loading'/></span>
|
11564 |
+
</p>
|
11565 |
+
<?php elseif ( class_exists( 'ExactDN' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
11566 |
+
<p>
|
11567 |
+
<?php if ( $exactdn->get_exactdn_domain() && $exactdn->verify_domain( $exactdn->get_exactdn_domain() ) ) : ?>
|
11568 |
+
<span style="color: #3eadc9; font-weight: bolder"><?php esc_html_e( 'Verified', 'ewww-image-optimizer' ); ?></span>
|
11569 |
+
<br><?php echo esc_html( $exactdn->get_exactdn_domain() ); ?>
|
11570 |
+
<?php elseif ( $exactdn->get_exactdn_domain() && $exactdn->get_exactdn_option( 'verified' ) ) : ?>
|
11571 |
+
<span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Temporarily disabled.', 'ewww-image-optimizer' ); ?></span>
|
11572 |
+
<?php elseif ( $exactdn->get_exactdn_domain() && $exactdn->get_exactdn_option( 'suspended' ) ) : ?>
|
11573 |
+
<span style="color: orange; font-weight: bolder"><?php esc_html_e( 'Active, not yet verified.', 'ewww-image-optimizer' ); ?></span>';
|
11574 |
+
<?php else : ?>
|
11575 |
+
<span style="color: red; font-weight: bolder"><a href="https://ewww.io/manage-sites/" target="_blank"><?php esc_html_e( 'Not Verified', 'ewww-image-optimizer' ); ?></a></span>
|
11576 |
+
<?php endif; ?>
|
11577 |
+
<?php if ( function_exists( 'remove_query_strings_link' ) || function_exists( 'rmqrst_loader_src' ) || function_exists( 'qsr_remove_query_strings_1' ) ) : ?>
|
11578 |
+
<br><i><?php esc_html_e( 'Plugins that remove query strings are unnecessary with Easy IO. You may remove them at your convenience.', 'ewww-image-optimizer' ); ?></i><?php ewwwio_help_link( 'https://docs.ewww.io/article/50-exactdn-and-query-strings', '5a3d278a2c7d3a1943677b52' ); ?>
|
11579 |
+
<?php endif; ?>
|
11580 |
+
<br>
|
11581 |
+
<a id='ewwwio-easy-deactivate' class='button-secondary' href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_remove_easyio' ) ); ?>'>
|
11582 |
+
<?php esc_html_e( 'De-activate', 'ewww-image-optimizer' ); ?>
|
11583 |
+
</a>
|
11584 |
+
</p>
|
11585 |
+
<?php endif; ?>
|
11586 |
+
</td>
|
11587 |
+
</tr>
|
11588 |
+
<?php endif; ?>
|
11589 |
+
<tr class='ewwwio-exactdn-options' <?php echo $exactdn_enabled ? '' : 'style="display:none;"'; ?>>
|
11590 |
+
<td> </td>
|
11591 |
+
<td>
|
11592 |
+
<input type='checkbox' name='exactdn_all_the_things' value='true' id='<?php echo esc_attr( $exactdn_att_id ); ?>' <?php disabled( $exactdn_att_dis ); ?> <?php checked( $exactdn_att_che ); ?> />
|
11593 |
+
<label for='exactdn_all_the_things'><strong><?php esc_html_e( 'Include All Resources', 'ewww-image-optimizer' ); ?></strong></label>
|
11594 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/47-getting-more-from-exactdn', '59de6631042863379ddc953c' ); ?>
|
11595 |
+
<p class='description'>
|
11596 |
+
<?php esc_html_e( 'Use Easy IO for all resources in wp-includes/ and wp-content/, including JavaScript, CSS, fonts, etc.', 'ewww-image-optimizer' ); ?>
|
11597 |
+
</p>
|
11598 |
+
<?php if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon-cdn' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
11599 |
+
<p style="color: red"><?php esc_html_e( 'Inactive, please disable the Site Accelerator in the Jetpack Performance settings.', 'ewww-image-optimizer' ); ?></p>
|
11600 |
+
<?php endif; ?>
|
11601 |
+
</td>
|
11602 |
+
</tr>
|
11603 |
+
<tr class='ewwwio-exactdn-options' <?php echo $exactdn_enabled && ! $easymode ? '' : 'style="display:none;"'; ?>>
|
11604 |
+
<td> </td>
|
11605 |
+
<td>
|
11606 |
+
<input type='checkbox' name='exactdn_lossy' value='true' id='<?php echo esc_attr( $exactdn_los_id ); ?>' <?php disabled( $exactdn_los_dis ); ?> <?php checked( $exactdn_los_che ); ?> />
|
11607 |
+
<label for='exactdn_lossy'><strong><?php esc_html_e( 'Premium Compression', 'ewww-image-optimizer' ); ?></strong></label>
|
11608 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/47-getting-more-from-exactdn', '59de6631042863379ddc953c' ); ?>
|
11609 |
+
<p class='description'>
|
11610 |
+
<?php esc_html_e( 'Enable high quality premium compression for all images on Easy IO. Disable to use Pixel Perfect mode instead.', 'ewww-image-optimizer' ); ?>
|
11611 |
+
</p>
|
11612 |
+
</td>
|
11613 |
+
</tr>
|
11614 |
+
<?php if ( ! $exactdn_enabled || 1 === $exactdn->get_plan_id() ) : ?>
|
11615 |
+
<input type='hidden' id='exactdn_all_the_things' name='exactdn_all_the_things' <?php echo ( ewww_image_optimizer_get_option( 'exactdn_all_the_things' ) ? "value='1'" : "value='0'" ); ?> />
|
11616 |
+
<input type='hidden' id='exactdn_lossy' name='exactdn_lossy' <?php echo ( ewww_image_optimizer_get_option( 'exactdn_lossy' ) ? "value='1'" : "value='0'" ); ?> />
|
11617 |
+
<input type='hidden' id='ewww_image_optimizer_use_lqip' name='ewww_image_optimizer_use_lqip' <?php echo ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_use_lqip' ) ? "value='1'" : "value='0'" ); ?> />
|
11618 |
+
<?php endif; ?>
|
11619 |
+
<tr class="ewwwio-exactdn-options" <?php echo $exactdn_enabled ? '' : 'style="display:none;"'; ?>>
|
11620 |
+
<td> </td>
|
11621 |
+
<td>
|
11622 |
+
<label for='exactdn_exclude'><strong><?php esc_html_e( 'Exclusions', 'ewww-image-optimizer' ); ?></strong></label>
|
11623 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/68-exactdn-exclude', '5c0042892c7d3a31944e88a4' ); ?><br>
|
11624 |
+
<textarea id='exactdn_exclude' name='exactdn_exclude' rows='3' cols='60'><?php echo esc_html( $eio_exclude_paths ); ?></textarea>
|
11625 |
+
<p class='description'>
|
11626 |
+
<?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Any pattern or path provided will not be routed through Easy IO.', 'ewww-image-optimizer' ); ?>
|
11627 |
+
</p>
|
11628 |
+
</td>
|
11629 |
+
</tr>
|
11630 |
+
<?php if ( ! function_exists( 'swis' ) ) : ?>
|
11631 |
+
<tr id="swis_promo_container" class="ewwwio-premium-setup" <?php echo wp_kses_post( $premium_hide ); ?>>
|
11632 |
+
<th scope='row'>
|
11633 |
+
SWIS Performance
|
11634 |
+
</th>
|
11635 |
+
<td>
|
11636 |
+
<a href="https://ewww.io/swis/" target="_blank"><?php esc_html_e( 'Go beyond image optimization with the tools I use for improving site speed.', 'ewww-image-optimizer' ); ?></a>
|
11637 |
</td>
|
11638 |
</tr>
|
11639 |
<?php endif; ?>
|
11648 |
<p class ='description'><?php esc_html_e( 'Color profiles are preserved when using the API or Easy IO.', 'ewww-image-optimizer' ); ?></p>
|
11649 |
</td>
|
11650 |
</tr>
|
11651 |
+
<?php if ( $current_jpeg_quality > 90 || $current_jpeg_quality < 50 || ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_quality' ) ) : ?>
|
11652 |
+
<tr>
|
11653 |
+
<th scope='row'>
|
11654 |
+
<label for='ewww_image_optimizer_jpg_quality'><?php esc_html_e( 'JPG Quality Level', 'ewww-image-optimizer' ); ?></label>
|
11655 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/11-advanced-configuration', '58542afac697912ffd6c18c0,58543c69c697912ffd6c19a7' ); ?>
|
11656 |
+
</th>
|
11657 |
+
<td>
|
11658 |
+
<input type='text' id='ewww_image_optimizer_jpg_quality' name='ewww_image_optimizer_jpg_quality' class='small-text' value='<?php echo esc_attr( ewww_image_optimizer_jpg_quality() ); ?>' />
|
11659 |
+
<?php esc_html_e( 'Valid values are 1-100.', 'ewww-image-optimizer' ); ?>
|
11660 |
+
<p class='description'>
|
11661 |
+
<?php esc_html_e( 'Use this to override the default WordPress quality level of 82. Applies to image editing, resizing, and PNG to JPG conversion. Does not affect the original uploaded image unless maximum dimensions are set and resizing occurs.', 'ewww-image-optimizer' ); ?>
|
11662 |
+
</p>
|
11663 |
+
</td>
|
11664 |
+
</tr>
|
11665 |
+
<?php endif; ?>
|
11666 |
+
<tr>
|
11667 |
+
<th scope='row'>
|
11668 |
+
<?php esc_html_e( 'Resize Images', 'ewww-image-optimizer' ); ?>
|
11669 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/41-resize-settings', '59849911042863033a1ba5f9' ); ?>
|
11670 |
+
</th>
|
11671 |
+
<td>
|
11672 |
+
<label for='ewww_image_optimizer_maxmediawidth'><?php esc_html_e( 'Max Width', 'ewww-image-optimizer' ); ?></label>
|
11673 |
+
<input type='number' step='1' min='0' class='small-text' id='ewww_image_optimizer_maxmediawidth' name='ewww_image_optimizer_maxmediawidth' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediawidth' ); ?>' <?php disabled( function_exists( 'imsanity_get_max_width_height' ) ); ?> />
|
11674 |
+
<label for='ewww_image_optimizer_maxmediaheight'><?php esc_html_e( 'Max Height', 'ewww-image-optimizer' ); ?></label>
|
11675 |
+
<input type='number' step='1' min='0' class='small-text' id='ewww_image_optimizer_maxmediaheight' name='ewww_image_optimizer_maxmediaheight' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_maxmediaheight' ); ?>' <?php disabled( function_exists( 'imsanity_get_max_width_height' ) ); ?> />
|
11676 |
+
<?php esc_html_e( 'in pixels', 'ewww-image-optimizer' ); ?>
|
11677 |
+
<p class='description'>
|
11678 |
+
<?php esc_html_e( 'Resize uploaded images to these dimensions (in pixels).', 'ewww-image-optimizer' ); ?>
|
11679 |
+
</p>
|
11680 |
+
</td>
|
11681 |
+
</tr>
|
11682 |
+
<tr>
|
11683 |
+
<th scope='row'>
|
11684 |
+
<label for='ewww_image_optimizer_lazy_load'><?php esc_html_e( 'Lazy Load', 'ewww-image-optimizer' ); ?></label>
|
11685 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?>
|
11686 |
+
</th>
|
11687 |
+
<td>
|
11688 |
+
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ); ?> />
|
11689 |
+
<?php esc_html_e( 'Improves actual and perceived loading time as images will be loaded only as they enter (or are about to enter) the viewport.', 'ewww-image-optimizer' ); ?>
|
11690 |
+
<?php if ( ewwwio_other_lazy_detected() ) : ?>
|
11691 |
+
<p><strong><?php esc_html_e( 'Though you already have a lazy loader on your site, the EWWW IO lazy loader includes auto-scaling for improved responsive images.', 'ewww-image-optimizer' ); ?></strong></p>
|
11692 |
+
<?php endif; ?>
|
11693 |
+
<p class='description'>
|
11694 |
+
<?php esc_html_e( 'The lazy loader chooses the best available image size from existing responsive markup. When used with Easy IO, all images become responsive.', 'ewww-image-optimizer' ); ?></br>
|
11695 |
+
<?php esc_html_e( 'To disable auto-scaling for an image, add "skip-autoscale" to the HTML element via a class or attribute.', 'ewww-image-optimizer' ); ?>
|
11696 |
+
</p>
|
11697 |
+
</td>
|
11698 |
+
</tr>
|
11699 |
+
<tr id='ewww_image_optimizer_lqip_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ? '' : ' style="display:none"'; ?>>
|
11700 |
+
<td> </td>
|
11701 |
+
<td>
|
11702 |
+
<input type='checkbox' name='ewww_image_optimizer_use_lqip' value='true' id='<?php echo esc_attr( $lqip_id ); ?>' <?php disabled( $lqip_dis ); ?> <?php checked( $lqip_che ); ?> />
|
11703 |
+
<label for='ewww_image_optimizer_use_lqip'><strong>LQIP</strong></label>
|
11704 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/75-lazy-load-placeholders', '5c9a7a302c7d3a1544615e47' ); ?>
|
11705 |
+
<p class='description'>
|
11706 |
+
<?php esc_html_e( 'Use low-quality versions of your images as placeholders via Easy IO. Can improve user experience, but may be slower than blank placeholders.', 'ewww-image-optimizer' ); ?>
|
11707 |
+
</p>
|
11708 |
+
</td>
|
11709 |
+
</tr>
|
11710 |
+
<tr id='ewww_image_optimizer_ll_exclude_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ? '' : ' style="display:none"'; ?>>
|
11711 |
+
<td> </td>
|
11712 |
+
<td>
|
11713 |
+
<label for='ewww_image_optimizer_ll_exclude'><strong><?php esc_html_e( 'Exclusions', 'ewww-image-optimizer' ); ?></strong></label>
|
11714 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?><br>
|
11715 |
+
<textarea id='ewww_image_optimizer_ll_exclude' name='ewww_image_optimizer_ll_exclude' rows='3' cols='60'><?php echo esc_html( $ll_exclude_paths ); ?></textarea>
|
11716 |
+
<p class='description'>
|
11717 |
+
<?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Use any string that matches the desired element(s) or exclude entire element types like "div", "span", etc. The class "skip-lazy" and attribute "data-skip-lazy" are excluded by default.', 'ewww-image-optimizer' ); ?>
|
11718 |
+
</p>
|
11719 |
+
</td>
|
11720 |
+
</tr>
|
11721 |
+
<?php if ( $free_exec ) : ?>
|
11722 |
+
<tr>
|
11723 |
+
<th> </th>
|
11724 |
+
<td>
|
11725 |
+
<p class='description'><?php esc_html_e( 'WebP conversion requires an API key or Easy IO subscription.', 'ewww-image-optimizer' ); ?></p>
|
11726 |
+
</td>
|
11727 |
+
</tr>
|
11728 |
+
<?php elseif ( ! ewww_image_optimizer_easy_active() || ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
|
11729 |
+
<tr>
|
11730 |
+
<th scope='row'>
|
11731 |
+
<label for='ewww_image_optimizer_webp'><?php esc_html_e( 'WebP Conversion', 'ewww-image-optimizer' ); ?></label>
|
11732 |
+
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
|
11733 |
+
</th>
|
11734 |
+
<td>
|
11735 |
+
<input type='checkbox' id='ewww_image_optimizer_webp' name='ewww_image_optimizer_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ); ?> />
|
11736 |
+
<span><?php esc_html_e( 'Convert your images to the next generation format for supported browsers, while retaining originals for other browsers.', 'ewww-image-optimizer' ); ?></span>
|
11737 |
+
<?php if ( ! ewww_image_optimizer_easy_active() ) : ?>
|
11738 |
+
<p id='ewwwio-webp-storage-warning'>
|
11739 |
+
<i><?php esc_html_e( 'Enabling WebP Conversion without Easy IO will increase your storage requirements. Do you want to continue?', 'ewww-image-optimizer' ); ?></i><br>
|
11740 |
+
<a id='ewwwio-cancel-webp' href='#'><?php esc_html_e( 'Nevermind', 'ewww-image-optimizer' ); ?></a><br>
|
11741 |
+
<a id='ewwwio-easyio-webp-info' class='ewww-help-beacon-single' href='https://docs.ewww.io/article/44-introduction-to-exactdn' data-beacon-article='59bc5ad6042863033a1ce370'><?php esc_html_e( 'Tell me more about Easy IO', 'ewww-image-optimizer' ); ?></a><br>
|
11742 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/44-introduction-to-exactdn', '59bc5ad6042863033a1ce370,5c0042892c7d3a31944e88a4' ); ?>
|
11743 |
+
<span id='ewwwio-confirm-webp' class='button-primary'><?php esc_html_e( 'Continue', 'ewww-image-optimizer' ); ?></span>
|
11744 |
+
</p>
|
11745 |
+
<p class='description'>
|
11746 |
+
<?php esc_html_e( 'WebP images will be generated automatically for new uploads.', 'ewww-image-optimizer' ); ?>
|
11747 |
+
<?php
|
11748 |
+
printf(
|
11749 |
+
/* translators: 1: Bulk Optimizer 2: Easy IO */
|
11750 |
+
esc_html__( 'Use the %1$s for existing uploads or get %2$s for automatic WebP conversion and delivery.', 'ewww-image-optimizer' ),
|
11751 |
+
'<a href="' . esc_url( admin_url( 'upload.php?page=ewww-image-optimizer-bulk' ) ) . '">' . esc_html__( 'Bulk Optimizer', 'ewww-image-optimizer' ) . '</a>',
|
11752 |
+
'<a href="https://ewww.io/plans/">' . esc_html__( 'Easy IO', 'ewww-image-optimizer' ) . '</a>'
|
11753 |
+
);
|
11754 |
+
?>
|
11755 |
+
</p>
|
11756 |
+
<?php endif; ?>
|
11757 |
+
<?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
11758 |
+
<p class='description'>
|
11759 |
+
*<?php esc_html_e( 'GIF to WebP conversion requires an active API key.', 'ewww-image-optimizer' ); ?>
|
11760 |
+
</p>
|
11761 |
+
<?php endif; ?>
|
11762 |
+
</td>
|
11763 |
+
</tr>
|
11764 |
+
<tr>
|
11765 |
+
<?php endif; ?>
|
11766 |
+
<?php if ( ! $free_exec && ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) : ?>
|
11767 |
+
<tr class='ewww_image_optimizer_webp_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ? '' : ' style="display:none"'; ?>>
|
11768 |
+
<th scope='row'>
|
11769 |
+
<?php esc_html_e( 'WebP Delivery Method', 'ewww-image-optimizer' ); ?>
|
11770 |
+
</th>
|
11771 |
+
<td>
|
11772 |
+
<?php if ( ! $cf_host && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
|
11773 |
+
<?php
|
11774 |
+
printf(
|
11775 |
+
/* translators: %s: documentation */
|
11776 |
+
esc_html__( 'The recommended delivery method is to use Apache/LiteSpeed rewrite rules. Nginx users may reference the %s for configuration instructions.', 'ewww-image-optimizer' ),
|
11777 |
+
'<a class="ewww-help-beacon-single" href="https://docs.ewww.io/article/16-ewww-io-and-webp-images" target="_blank" data-beacon-article="5854745ac697912ffd6c1c89">' . esc_html__( 'documentation', 'ewww-image-optimizer' ) . '</a>'
|
11778 |
+
);
|
11779 |
+
?>
|
11780 |
+
<?php else : ?>
|
11781 |
+
<?php endif; ?>
|
11782 |
+
<?php
|
11783 |
+
if (
|
11784 |
+
! $cf_host &&
|
11785 |
+
ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) &&
|
11786 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) &&
|
11787 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' )
|
11788 |
+
) :
|
11789 |
+
if ( defined( 'PHP_SAPI' ) && false === strpos( PHP_SAPI, 'apache' ) && false === strpos( PHP_SAPI, 'litespeed' ) ) {
|
11790 |
+
$false_positive_headers = esc_html( 'This may be a false positive. If so, the warning should go away once you implement the rewrite rules.' );
|
11791 |
+
}
|
11792 |
+
$header_error = '';
|
11793 |
+
if ( ! apache_mod_loaded( 'mod_rewrite' ) ) {
|
11794 |
+
/* translators: %s: mod_rewrite or mod_headers */
|
11795 |
+
$header_error = '<p><strong>' . sprintf( esc_html__( 'Your site appears to be missing %s, please contact your webhost or system administrator to enable this Apache module.', 'ewww-image-optimizer' ), 'mod_rewrite' ) . "</strong><br>$false_positive_headers</p>\n";
|
11796 |
+
}
|
11797 |
+
if ( ! apache_mod_loaded( 'mod_headers' ) ) {
|
11798 |
+
/* translators: %s: mod_rewrite or mod_headers */
|
11799 |
+
$header_error = '<p><strong>' . sprintf( esc_html__( 'Your site appears to be missing %s, please contact your webhost or system administrator to enable this Apache module.', 'ewww-image-optimizer' ), 'mod_headers' ) . "</strong><br>$false_positive_headers</p>\n";
|
11800 |
+
}
|
11801 |
+
|
11802 |
+
$webp_mime_error = ewww_image_optimizer_test_webp_mime_error();
|
11803 |
+
if ( $webp_mime_error ) {
|
11804 |
+
echo wp_kses_post( $header_error );
|
11805 |
+
}
|
11806 |
+
|
11807 |
+
$webp_rewrite_verify = ! (bool) ewww_image_optimizer_webp_rewrite_verify();
|
11808 |
+
if ( $webp_mime_error && $webp_rewrite_verify ) :
|
11809 |
+
printf(
|
11810 |
+
/* translators: %s: an error message from the WebP self-test */
|
11811 |
+
'<p>' . esc_html__( 'WebP rules verified, but self-test failed: %s', 'ewww-image-optimizer' ) . '</p>',
|
11812 |
+
esc_html( $webp_mime_error )
|
11813 |
+
);
|
11814 |
+
elseif ( ! $webp_mime_error || $webp_rewrite_verify ) :
|
11815 |
+
?>
|
11816 |
+
<div id='ewww-webp-rewrite'>
|
11817 |
+
<img id='ewww-webp-image' src='<?php echo esc_url( $test_png_image . '?m=' . time() ); ?>'>
|
11818 |
+
<div id='ewww-webp-rewrite-status'>
|
11819 |
+
<p>
|
11820 |
+
<?php esc_html_e( 'WebP Rules verified successfully', 'ewww-image-optimizer' ); ?>
|
11821 |
+
</p>
|
11822 |
+
</div>
|
11823 |
+
<?php if ( $webp_rewrite_verify ) : ?>
|
11824 |
+
<div id='ewww-webp-rewrite-result'></div>
|
11825 |
+
<button type='button' id='ewww-webp-remove' class='button-secondary action'><?php esc_html_e( 'Remove Rewrite Rules', 'ewww-image-optimizer' ); ?></button>
|
11826 |
+
<?php endif; ?>
|
11827 |
+
</div>
|
11828 |
+
<?php else : ?>
|
11829 |
+
<p>
|
11830 |
+
<?php
|
11831 |
+
printf(
|
11832 |
+
/* translators: %s: documentation */
|
11833 |
+
esc_html__( 'The recommended delivery method is to use Apache/LiteSpeed rewrite rules. Nginx users may reference the %s for configuration instructions.', 'ewww-image-optimizer' ),
|
11834 |
+
'<a class="ewww-help-beacon-single" href="https://docs.ewww.io/article/16-ewww-io-and-webp-images" target="_blank" data-beacon-article="5854745ac697912ffd6c1c89">' . esc_html__( 'documentation', 'ewww-image-optimizer' ) . '</a>'
|
11835 |
+
);
|
11836 |
+
?>
|
11837 |
+
</p>
|
11838 |
+
<div id='ewww-webp-rewrite'>
|
11839 |
+
<pre id='webp-rewrite-rules'><IfModule mod_rewrite.c>
|
11840 |
+
RewriteEngine On
|
11841 |
+
RewriteCond %{HTTP_ACCEPT} image/webp
|
11842 |
+
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png|gif)$
|
11843 |
+
RewriteCond %{REQUEST_FILENAME}\.webp -f
|
11844 |
+
RewriteCond %{QUERY_STRING} !type=original
|
11845 |
+
RewriteRule (.+)\.(jpe?g|png|gif)$ %{REQUEST_FILENAME}.webp [T=image/webp,L]
|
11846 |
+
</IfModule>
|
11847 |
+
<IfModule mod_headers.c>
|
11848 |
+
<FilesMatch "\.(jpe?g|png|gif)$">
|
11849 |
+
Header append Vary Accept
|
11850 |
+
</FilesMatch>
|
11851 |
+
</IfModule>
|
11852 |
+
AddType image/webp .webp</pre>
|
11853 |
+
<img id='ewww-webp-image' src='<?php echo esc_url( $test_png_image . '?m=' . time() ); ?>'>
|
11854 |
+
<p id='ewww-webp-rewrite-status'>
|
11855 |
+
<?php esc_html_e( 'The image to the right will display a WebP image with WEBP in white text, if your site is serving WebP images and your browser supports WebP.', 'ewww-image-optimizer' ); ?>
|
11856 |
+
</p>
|
11857 |
+
<div id='ewww-webp-rewrite-result'></div>
|
11858 |
+
<button type='button' id='ewww-webp-insert' class='button-secondary action'><?php esc_html_e( 'Insert Rewrite Rules', 'ewww-image-optimizer' ); ?></button>
|
11859 |
+
</div>
|
11860 |
+
<?php endif; ?>
|
11861 |
+
<?php elseif ( $cf_host && ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) : ?>
|
11862 |
+
<p><?php esc_html_e( 'Your site is using Cloudflare, please use JS WebP or <picture> WebP rewriting.', 'ewww-image-optimizer' ); ?></p>
|
11863 |
+
<?php endif; ?>
|
11864 |
+
</td>
|
11865 |
+
</tr>
|
11866 |
+
<tr class='ewww_image_optimizer_webp_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ? '' : ' style="display:none"'; ?>>
|
11867 |
+
<th> </th>
|
11868 |
+
<td>
|
11869 |
+
<input type='checkbox' id='ewww_image_optimizer_webp_for_cdn' name='ewww_image_optimizer_webp_for_cdn' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ); ?> />
|
11870 |
+
<label for='ewww_image_optimizer_webp_for_cdn'><strong><?php esc_html_e( 'JS WebP Rewriting', 'ewww-image-optimizer' ); ?></strong></label>
|
11871 |
+
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span>
|
11872 |
+
<p class='description'>
|
11873 |
+
<?php esc_html_e( 'Uses JavaScript for CDN and cache friendly WebP delivery.', 'ewww-image-optimizer' ); ?>
|
11874 |
+
<?php esc_html_e( 'Supports CSS background images via the Lazy Load option.', 'ewww-image-optimizer' ); ?>
|
11875 |
+
</p>
|
11876 |
+
</td>
|
11877 |
+
</tr>
|
11878 |
+
<tr class='ewww_image_optimizer_webp_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ? '' : ' style="display:none"'; ?>>
|
11879 |
+
<th> </th>
|
11880 |
+
<td>
|
11881 |
+
<input type='checkbox' id='ewww_image_optimizer_picture_webp' name='ewww_image_optimizer_picture_webp' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ); ?> />
|
11882 |
+
<label for='ewww_image_optimizer_picture_webp'><strong><?php esc_html_e( '<picture> WebP Rewriting', 'ewww-image-optimizer' ); ?></strong></label>
|
11883 |
+
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89,59443d162c7d3a0747cdf9f0' ); ?></span><br>
|
11884 |
+
<p class='description'>
|
11885 |
+
<?php esc_html_e( 'A JavaScript-free rewriting method using picture tags.', 'ewww-image-optimizer' ); ?>
|
11886 |
+
<?php esc_html_e( 'Some themes may not display <picture> tags properly, and does not support CSS background images.', 'ewww-image-optimizer' ); ?>
|
11887 |
+
</p>
|
11888 |
+
</td>
|
11889 |
+
</tr>
|
11890 |
+
<tr class='ewww_image_optimizer_webp_rewrite_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && $webp_php_rewriting ? '' : ' style="display:none"'; ?>>
|
11891 |
+
<td> </td>
|
11892 |
+
<td>
|
11893 |
+
<label for='ewww_image_optimizer_webp_rewrite_exclude'><strong><?php esc_html_e( 'JS WebP and <picture> Web Exclusions', 'ewww-image-optimizer' ); ?></strong></label><br>
|
11894 |
+
<textarea id='ewww_image_optimizer_webp_rewrite_exclude' name='ewww_image_optimizer_webp_rewrite_exclude' rows='3' cols='60'><?php echo esc_html( $webp_exclude_paths ); ?></textarea>
|
11895 |
+
<p class='description'><?php esc_html_e( 'One exclusion per line, no wildcards (*) needed. Use any string that matches the desired element(s) or exclude entire element types like "div", "span", etc.', 'ewww-image-optimizer' ); ?></p>
|
11896 |
+
</td>
|
11897 |
+
</tr>
|
11898 |
+
<?php if ( ! $easymode ) : ?>
|
11899 |
+
<tr class='ewww_image_optimizer_webp_rewrite_setting_container' <?php echo $webp_php_rewriting ? '' : ' style="display:none"'; ?>>
|
11900 |
+
<th> </th>
|
11901 |
+
<td>
|
11902 |
+
<label for='ewww_image_optimizer_webp_paths'><strong><?php esc_html_e( 'WebP URLs', 'ewww-image-optimizer' ); ?></strong></label>
|
11903 |
+
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span><br>
|
11904 |
+
<span><?php esc_html_e( 'Enter additional URL patterns, like a CDN URL, that should be permitted for WebP Rewriting. One URL per line, must include the domain name (cdn.example.com).', 'ewww-image-optimizer' ); ?></span>
|
11905 |
+
<p><?php esc_html_e( 'Optionally include a folder with the URL if your CDN path is different from your local path.', 'ewww-image-optimizer' ); ?></p>
|
11906 |
+
<textarea id='ewww_image_optimizer_webp_paths' name='ewww_image_optimizer_webp_paths' rows='3' cols='60'><?php echo esc_html( $webp_paths ); ?></textarea>
|
11907 |
+
<?php
|
11908 |
+
if ( ewww_image_optimizer_cloud_based_media() ) {
|
11909 |
+
$webp_domains = false;
|
11910 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ) {
|
11911 |
+
global $eio_alt_webp;
|
11912 |
+
if ( isset( $eio_alt_webp ) && is_object( $eio_alt_webp ) ) {
|
11913 |
+
$webp_domains = $eio_alt_webp->get_webp_domains();
|
11914 |
+
}
|
11915 |
+
} elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_picture_webp' ) ) {
|
11916 |
+
global $eio_picture_webp;
|
11917 |
+
if ( isset( $eio_picture_webp ) && is_object( $eio_picture_webp ) ) {
|
11918 |
+
$webp_domains = $eio_picture_webp->get_webp_domains();
|
11919 |
+
}
|
11920 |
+
}
|
11921 |
+
if ( ! empty( $webp_domains ) ) {
|
11922 |
+
echo "<p class='description'>";
|
11923 |
+
printf(
|
11924 |
+
/* translators: %s: a comma-separated list of domain names */
|
11925 |
+
'*' . esc_html__( 'These domains have been auto-detected: %s', 'ewww-image-optimizer' ),
|
11926 |
+
esc_html( implode( ',', $webp_domains ) )
|
11927 |
+
);
|
11928 |
+
echo '</p>';
|
11929 |
+
}
|
11930 |
+
}
|
11931 |
+
?>
|
11932 |
+
<p class='description'><?php echo wp_kses_post( $webp_url_example ); ?></p>
|
11933 |
+
</td>
|
11934 |
+
</tr>
|
11935 |
+
<tr class='ewww_image_optimizer_webp_rewrite_setting_container' <?php echo $webp_php_rewriting ? '' : ' style="display:none"'; ?>>
|
11936 |
+
<th scope='row'>
|
11937 |
+
<label for='ewww_image_optimizer_webp_force'><?php esc_html_e( 'Force WebP', 'ewww-image-optimizer' ); ?></label>
|
11938 |
+
<span><?php ewwwio_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' ); ?></span>
|
11939 |
+
</th>
|
11940 |
+
<td>
|
11941 |
+
<input type='checkbox' id='ewww_image_optimizer_webp_force' name='ewww_image_optimizer_webp_force' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) ); ?> />
|
11942 |
+
<span><?php esc_html_e( 'WebP images will be generated and saved for all images regardless of their size. The JS WebP Rewriting will not check if a file exists, only that the domain matches the home url, or one of the provided WebP URLs.', 'ewww-image-optimizer' ); ?></span>
|
11943 |
+
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
11944 |
+
<p>
|
11945 |
+
<a href='<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_enable_force_gif2webp' ) ); ?>'>
|
11946 |
+
<?php esc_html_e( 'Click to enable forced GIF rewriting once WebP version have been generated.', 'ewww-image-optimizer' ); ?>
|
11947 |
+
</a>
|
11948 |
+
</p>
|
11949 |
+
<?php elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_force' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
11950 |
+
<p>
|
11951 |
+
<a href="https://ewww.io/plans/" target="_blank">
|
11952 |
+
<?php esc_html_e( 'GIF to WebP conversion requires an API key.', 'ewww-image-optimizer' ); ?>
|
11953 |
+
</a>
|
11954 |
+
</p>
|
11955 |
+
<?php endif; ?>
|
11956 |
+
</td>
|
11957 |
+
</tr>
|
11958 |
+
<tr class='ewww_image_optimizer_webp_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ? '' : ' style="display:none"'; ?>>
|
11959 |
+
<th scope='row'>
|
11960 |
+
<label for='ewww_image_optimizer_webp_quality'><?php esc_html_e( 'WebP Quality Level', 'ewww-image-optimizer' ); ?></label>
|
11961 |
+
</th>
|
11962 |
+
<td>
|
11963 |
+
<input type='text' id='ewww_image_optimizer_webp_quality' name='ewww_image_optimizer_webp_quality' class='small-text' value='<?php echo esc_attr( ewww_image_optimizer_webp_quality() ); ?>' />
|
11964 |
+
<?php esc_html_e( 'Default is 75, allowed range is 50-100.', 'ewww-image-optimizer' ); ?>
|
11965 |
+
</td>
|
11966 |
+
</tr>
|
11967 |
+
<?php elseif ( ewww_image_optimizer_cloud_based_media() ) : ?>
|
11968 |
+
<tr class='ewww_image_optimizer_webp_setting_container' <?php echo ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ? '' : ' style="display:none"'; ?>>
|
11969 |
+
<th> </th>
|
11970 |
+
<td>
|
11971 |
+
<p class='description'>
|
11972 |
+
<?php
|
11973 |
+
printf(
|
11974 |
+
/* translators: %s: Enable Ludicrous Mode */
|
11975 |
+
'*' . esc_html__( 'It seems your images are being offloaded to cloud-based storage without retaining the local copies. Force WebP mode has been configured automatically. %s to view/change these settings.', 'ewww-image-optimizer' ),
|
11976 |
+
"<a href='" . esc_url( $enable_local_url ) . "'>" . esc_html__( 'Enable Ludicrous Mode', 'ewww-image-optimizer' ) . '</a>'
|
11977 |
+
);
|
11978 |
+
?>
|
11979 |
+
</p>
|
11980 |
+
</td>
|
11981 |
+
<?php endif; ?>
|
11982 |
+
<?php elseif ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
11983 |
+
<tr>
|
11984 |
+
<th> </th>
|
11985 |
+
<td>
|
11986 |
+
<p class='description'><?php esc_html_e( 'WebP images are served automatically by Easy IO.', 'ewww-image-optimizer' ); ?></p>
|
11987 |
+
</td>
|
11988 |
+
</tr>
|
11989 |
+
<?php elseif ( get_option( 'easyio_exactdn' ) ) : ?>
|
11990 |
+
<tr>
|
11991 |
+
<th> </th>
|
11992 |
+
<td>
|
11993 |
+
<p class='description'><?php esc_html_e( 'WebP images are served automatically by Easy Image Optimizer.', 'ewww-image-optimizer' ); ?></p>
|
11994 |
+
</td>
|
11995 |
+
</tr>
|
11996 |
+
<?php endif; ?>
|
11997 |
+
|
11998 |
+
<?php if ( class_exists( 'Cloudinary' ) && Cloudinary::config_get( 'api_secret' ) ) : ?>
|
11999 |
+
<tr>
|
12000 |
+
<th scope='row'>
|
12001 |
+
<label for='ewww_image_optimizer_enable_cloudinary'><?php esc_html_e( 'Automatic Cloudinary Upload', 'ewww-image-optimizer' ); ?></label>
|
12002 |
+
</th>
|
12003 |
+
<td>
|
12004 |
+
<input type='checkbox' id='ewww_image_optimizer_enable_cloudinary' name='ewww_image_optimizer_enable_cloudinary' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_cloudinary' ) ); ?> />
|
12005 |
+
<?php esc_html_e( 'When enabled, uploads to the Media Library will be transferred to Cloudinary after optimization. Cloudinary generates resizes, so only the full-size image is uploaded.', 'ewww-image-optimizer' ); ?>
|
12006 |
+
</td>
|
12007 |
+
</tr>
|
12008 |
+
<?php endif; ?>
|
12009 |
+
</table>
|
12010 |
+
<?php ob_end_flush(); ?>
|
12011 |
+
</div>
|
12012 |
+
|
12013 |
+
<div id='ewww-local-settings'>
|
12014 |
+
<noscript><h2><?php esc_html_e( 'Local', 'ewww-image-optimizer' ); ?></h2></noscript>
|
12015 |
+
<p>
|
12016 |
+
<?php if ( $exactdn_enabled && 1 === $exactdn->get_plan_id() ) : ?>
|
12017 |
+
<br><i>* <?php esc_html_e( 'Upgrade to a Pro or Developer subscription to unlock additional options below.', 'ewww-image-optimizer' ); ?></i>
|
12018 |
+
<?php endif; ?>
|
12019 |
+
</p>
|
12020 |
+
<table class='form-table'>
|
12021 |
<?php $maybe_api_level = ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ? '*' : ''; ?>
|
12022 |
<tr>
|
12023 |
<th scope='row'>
|
12136 |
<td>
|
12137 |
<?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
12138 |
<p>
|
12139 |
+
* <strong><a href='https://ewww.io/plans/' target='_blank'>
|
12140 |
+
<?php esc_html_e( 'Get an API key to unlock these optimization levels and receive priority support. Achieve up to 80% compression to speed up your site, save storage space, and reduce server load.', 'ewww-image-optimizer' ); ?>
|
12141 |
+
</a></strong>
|
|
|
|
|
|
|
12142 |
</p>
|
12143 |
<?php else : ?>
|
12144 |
<p>
|
12145 |
+
* <?php esc_html_e( 'These levels use the compression API.', 'ewww-image-optimizer' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12146 |
</p>
|
12147 |
+
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12148 |
<p class='description'>
|
12149 |
+
<?php esc_html_e( 'All methods used by the EWWW Image Optimizer are intended to produce visually identical images.', 'ewww-image-optimizer' ); ?>
|
12150 |
</p>
|
12151 |
</td>
|
12152 |
</tr>
|
12153 |
<tr>
|
12154 |
+
<th scope='row'>
|
12155 |
+
<label for='ewww_image_optimizer_backup_files'><?php esc_html_e( 'Backup Originals', 'ewww-image-optimizer' ); ?></label>
|
12156 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2' ); ?>
|
12157 |
+
</th>
|
12158 |
<td>
|
12159 |
+
<input type='checkbox' id='ewww_image_optimizer_backup_files' name='ewww_image_optimizer_backup_files' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' ) ); ?> <?php disabled( $disable_level ); ?>>
|
12160 |
+
<?php esc_html_e( 'Store a copy of your original images on our secure server for 30 days. *Requires an active API key.', 'ewww-image-optimizer' ); ?>
|
|
|
|
|
|
|
|
|
12161 |
</td>
|
12162 |
</tr>
|
12163 |
</table>
|
12174 |
$aux_paths_desc = sprintf( __( 'One path per line, must be within %s. Use full paths, not relative paths.', 'ewww-image-optimizer' ), ABSPATH );
|
12175 |
?>
|
12176 |
|
12177 |
+
<div id='ewww-advanced-settings'>
|
12178 |
<noscript><h2><?php esc_html_e( 'Advanced', 'ewww-image-optimizer' ); ?></h2></noscript>
|
12179 |
<table class='form-table'>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12180 |
<tr>
|
12181 |
<th scope='row'>
|
12182 |
<label for='ewww_image_optimizer_parallel_optimization'><?php esc_html_e( 'Parallel Optimization', 'ewww-image-optimizer' ); ?></label>
|
12285 |
</td>
|
12286 |
</tr>
|
12287 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12288 |
<tr>
|
12289 |
<th scope='row'>
|
12290 |
<label for='ewww_image_optimizer_resize_existing'><?php esc_html_e( 'Resize Existing Images', 'ewww-image-optimizer' ); ?></label>
|
12305 |
<?php esc_html_e( 'Allow resizing of existing images outside the Media Library. Use this to resize images specified under the Folders to Optimize setting when running Bulk or Scheduled Optimization.', 'ewww-image-optimizer' ); ?>
|
12306 |
</td>
|
12307 |
</tr>
|
12308 |
+
<?php if ( 'network-multisite' === $network ) : ?>
|
|
|
|
|
|
|
12309 |
<tr>
|
12310 |
<th scope="row">
|
12311 |
<?php esc_html_e( 'Disable Resizes', 'ewww-image-optimizer' ); ?>
|
12360 |
<input type='checkbox' id='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>' name='ewww_image_optimizer_disable_resizes[<?php echo esc_attr( $size ); ?>]' value='true' disabled />
|
12361 |
</td>
|
12362 |
<td>
|
12363 |
+
<label for='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>'>
|
12364 |
+
<?php echo esc_html( $size ) . ' - ' . (int) $dimensions['width'] . ' x ' . (int) $dimensions['height'] . ( empty( $dimensions['crop'] ) ? '' : ' (' . esc_html__( 'cropped', 'ewww-image-optimizer' ) . ')' ); ?>
|
12365 |
+
</label>
|
12366 |
</td>
|
12367 |
</tr>
|
12368 |
<?php elseif ( 'pdf-full' === $size ) : ?>
|
12374 |
<input type='checkbox' id='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>' name='ewww_image_optimizer_disable_resizes[<?php echo esc_attr( $size ); ?>]' value='true' <?php checked( ! empty( $disabled_sizes[ $size ] ) ); ?> />
|
12375 |
</td>
|
12376 |
<td>
|
12377 |
+
<label for='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>'>
|
12378 |
+
<?php echo esc_html( $size ); ?> - <span class='description'><?php esc_html_e( 'Disabling creation of the full-size preview for PDF files will disable all PDF preview sizes', 'ewww-image-optimizer' ); ?></span>
|
12379 |
</label>
|
12380 |
</td>
|
12381 |
</tr>
|
12388 |
<input type='checkbox' id='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>' name='ewww_image_optimizer_disable_resizes[<?php echo esc_attr( $size ); ?>]' value='true' <?php checked( ! empty( $disabled_sizes[ $size ] ) ); ?> />
|
12389 |
</td>
|
12390 |
<td>
|
12391 |
+
<label for='ewww_image_optimizer_disable_resizes_<?php echo esc_attr( $size ); ?>'>
|
12392 |
+
<?php echo esc_html( $size ) . ' - ' . (int) $dimensions['width'] . ' x ' . (int) $dimensions['height'] . ( empty( $dimensions['crop'] ) ? '' : ' (' . esc_html__( 'cropped', 'ewww-image-optimizer' ) . ')' ); ?>
|
12393 |
+
</label>
|
12394 |
</td>
|
12395 |
</tr>
|
12396 |
<?php endif; ?>
|
12495 |
</table>
|
12496 |
</div>
|
12497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12498 |
<div id='ewww-webp-settings'>
|
12499 |
<noscript><h2><?php esc_html_e( 'WebP', 'ewww-image-optimizer' ); ?></h2></noscript>
|
|
|
|
|
|
|
|
|
|
|
|
|
12500 |
<table class='form-table'>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12501 |
</table>
|
12502 |
</div>
|
12503 |
|
12507 |
<a class='ewww-docs-root' href='https://docs.ewww.io/'><?php esc_html_e( 'Documentation', 'ewww-image-optimizer' ); ?></a> |
|
12508 |
<a class='ewww-docs-root' href='https://ewww.io/contact-us/'><?php esc_html_e( 'Plugin Support', 'ewww-image-optimizer' ); ?></a> |
|
12509 |
<a href='https://feedback.ewww.io/'><?php esc_html_e( 'Submit Feedback', 'ewww-image-optimizer' ); ?></a> |
|
|
|
12510 |
<a href='https://ewww.io/status/'><?php esc_html_e( 'Server Status', 'ewww-image-optimizer' ); ?></a>
|
12511 |
</p>
|
12512 |
+
<p style='float:right;'>
|
12513 |
+
<a href='<?php echo esc_url( wp_nonce_url( admin_url( 'options-general.php?page=ewww-image-optimizer-options&uncomplete_wizard=1' ), 'ewww_image_optimizer_options-options' ) ); ?>'>
|
12514 |
+
<?php echo '.'; ?>
|
12515 |
+
</a>
|
12516 |
+
</p>
|
12517 |
+
<?php if ( ! empty( $frontend_functions ) ) : ?>
|
12518 |
+
<p>
|
12519 |
+
<strong><?php esc_html_e( 'Having problems with a broken site or wrong-sized images?', 'ewww-image-optimizer' ); ?></strong><br>
|
12520 |
+
<?php esc_html_e( 'Try disabling each of these options to identify the problem, or use the Panic Button to disable them all at once:', 'ewww-image-optimizer' ); ?><br>
|
12521 |
+
<?php
|
12522 |
+
foreach ( $frontend_functions as $frontend_function ) {
|
12523 |
+
echo '<i>' . esc_html( $frontend_function ) . '</i><br>';
|
12524 |
+
}
|
12525 |
+
?>
|
12526 |
+
<a id='ewww-rescue-mode' class='button-secondary' href='<?php echo esc_url( $rescue_mode_url ); ?>'>
|
12527 |
+
<?php esc_html_e( 'Panic Button', 'ewww-image-optimizer' ); ?>
|
12528 |
+
</a>
|
12529 |
+
</p>
|
12530 |
+
<?php endif; ?>
|
12531 |
<table class='form-table'>
|
12532 |
<tr>
|
12533 |
<th scope='row'>
|
12583 |
</th>
|
12584 |
<td>
|
12585 |
<input type='checkbox' id='ewww_image_optimizer_allow_tracking' name='ewww_image_optimizer_allow_tracking' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) ); ?> />
|
12586 |
+
<?php esc_html_e( '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 a 10% discount on premium compression. No sensitive data is tracked.', 'ewww-image-optimizer' ); ?>
|
12587 |
+
<p>
|
12588 |
+
<?php
|
12589 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_allow_tracking' ) ) {
|
12590 |
+
printf(
|
12591 |
+
/* translators: 1: link to https://ewww.io/plans/ 2: discount code (yes, you may use it) */
|
12592 |
+
esc_html__( 'Use this code at %1$s: %2$s', 'ewww-image-optimizer' ),
|
12593 |
+
'<a href="https://ewww.io/plans/" target="_blank">https://ewww.io/</a>',
|
12594 |
+
'<code>SPEEDER1012</code>'
|
12595 |
+
);
|
12596 |
+
}
|
12597 |
+
?>
|
12598 |
+
</p>
|
12599 |
</td>
|
12600 |
</tr>
|
12601 |
</table>
|
12603 |
<p class='submit'><input type='submit' class='button-primary' value='<?php esc_attr_e( 'Save Changes', 'ewww-image-optimizer' ); ?>' /></p>
|
12604 |
</form>
|
12605 |
|
12606 |
+
<hr style='clear:both;'>
|
12607 |
+
<h2><?php esc_html_e( "Shane's Recommendations", 'ewww-image-optimizer' ); ?></h2>
|
12608 |
+
<p><?php esc_html_e( 'These are products I have personally used. An * indicates an affiliate link so you can support future development of EWWW IO.', 'ewww-image-optimizer' ); ?></p>
|
12609 |
+
<h3><?php esc_html_e( 'Hosting', 'ewww-image-optimizer' ); ?></h3>
|
12610 |
+
<p>
|
12611 |
+
<a href='http://shareasale.com/r.cfm?b=917225&u=1481701&m=41388&urllink=&afftrack='>WP Engine</a>* -
|
12612 |
+
<?php esc_html_e( 'ewww.io is powered by WP Engine, and their performance is worth every penny. This is "managed WordPress hosting" at it\'s finest. 20% discount off your first payment with our link.', 'ewww-image-optimizer' ); ?>
|
12613 |
+
<br>
|
12614 |
+
<a href="https://kinsta.com?kaid=OCKKBJARSDFR">Kinsta</a>* -
|
12615 |
+
<?php esc_html_e( 'Their performance is the same blazing speed as WP Engine, and the support is top notch as well. Very solid offering and highly recommended.', 'ewww-image-optimizer' ); ?>
|
12616 |
+
<br>
|
12617 |
+
<a href="https://www.cloudways.com/en/?id=48939">Cloudways</a>* -
|
12618 |
+
<?php esc_html_e( 'Simple, yet powerful, managed VPS hosting. I use their hosting for a few client sites and performance is crazy fast. Support has been great any time I\'ve needed their assistance.', 'ewww-image-optimizer' ); ?>
|
12619 |
+
</p>
|
12620 |
+
<h3><?php esc_html_e( 'Plugins and Services', 'ewww-image-optimizer' ); ?></h3>
|
12621 |
+
<p>
|
12622 |
+
<a href="https://easydigitaldownloads.com/?ref=4735">Easy Digital Downloads</a>* -
|
12623 |
+
<?php esc_html_e( 'Sell digital products with a huge number of extensions for amazing flexibility. Naturally, this is how we sell our services and plugins.', 'ewww-image-optimizer' ); ?>
|
12624 |
+
<br>
|
12625 |
+
<a href="https://www.helpscout.net/referral/?code=SVhaTmZDSSt2WG4xYS9FRmZrNllUa3RSR25VTStXcGhmaStQQ21QQjBDVmdZdz09OnoyVTFIUzBnbldtM21VMEM.">Helpscout</a>* -
|
12626 |
+
<?php esc_html_e( 'Treat your customers like people, not numbers, and keep them satisfied. Personal favorite feature is Traffic Cop that keeps you from sending a message if you receive another message from the customer while you are typing.', 'ewww-image-optimizer' ); ?>
|
12627 |
+
<br>
|
12628 |
+
<a href="http://eepurl.com/cLPIeD">MailChimp</a>* -
|
12629 |
+
<?php esc_html_e( 'Mailing lists that just work plus automation features that work even when you\'re not.', 'ewww-image-optimizer' ); ?>
|
12630 |
+
<br>
|
12631 |
+
<a href="https://malcare.com?src=C600E7">MalCare</a>* -
|
12632 |
+
<?php esc_html_e( 'Secure your site with a firewall, advanced heuristic scanning, and brute force login protection. Securing your site is not an option, it\'s a necessity.', 'ewww-image-optimizer' ); ?>
|
12633 |
+
<br>
|
12634 |
+
<a href="https://nodeping.com?rid=201407082225W862K">NodePing</a>* -
|
12635 |
+
<?php esc_html_e( 'Monitor all the things, and make sure they stay online. They have a fantastic array of monitors and notifications that you can setup, they are cheap, simple, and have great support.', 'ewww-image-optimizer' ); ?>
|
12636 |
+
</p>
|
12637 |
+
</div><!-- end container wrap -->
|
12638 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12639 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_help' ) ) {
|
12640 |
$current_user = wp_get_current_user();
|
12641 |
$help_email = $current_user->user_email;
|
12658 |
ewww_image_optimizer_temp_debug_clear();
|
12659 |
}
|
12660 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12661 |
/**
|
12662 |
* Gets the HTML for a help icon linked to the docs.
|
12663 |
*
|
12749 |
}
|
12750 |
}
|
12751 |
|
12752 |
+
/**
|
12753 |
+
* De-activates Easy IO.
|
12754 |
+
*/
|
12755 |
+
function ewww_image_optimizer_remove_easyio() {
|
12756 |
+
$permissions = apply_filters( 'ewww_image_optimizer_admin_permissions', '' );
|
12757 |
+
if ( false === current_user_can( $permissions ) ) {
|
12758 |
+
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
12759 |
+
}
|
12760 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_exactdn', '' );
|
12761 |
+
delete_option( 'ewww_image_optimizer_exactdn_domain' );
|
12762 |
+
delete_option( 'ewww_image_optimizer_exactdn_plan_id' );
|
12763 |
+
delete_option( 'ewww_image_optimizer_exactdn_failures' );
|
12764 |
+
delete_option( 'ewww_image_optimizer_exactdn_checkin' );
|
12765 |
+
delete_option( 'ewww_image_optimizer_exactdn_verified' );
|
12766 |
+
delete_option( 'ewww_image_optimizer_exactdn_validation' );
|
12767 |
+
delete_option( 'ewww_image_optimizer_exactdn_suspended' );
|
12768 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_domain' );
|
12769 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_plan_id' );
|
12770 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_failures' );
|
12771 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_checkin' );
|
12772 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_verified' );
|
12773 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_validation' );
|
12774 |
+
delete_site_option( 'ewww_image_optimizer_exactdn_suspended' );
|
12775 |
+
$sendback = wp_get_referer();
|
12776 |
+
wp_safe_redirect( $sendback );
|
12777 |
+
exit;
|
12778 |
+
}
|
12779 |
+
|
12780 |
/**
|
12781 |
* Enables Forced WebP for GIF images once the site is ready.
|
12782 |
*/
|
ewww-image-optimizer.php
CHANGED
@@ -13,7 +13,7 @@ Plugin Name: EWWW Image Optimizer
|
|
13 |
Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
|
14 |
Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
|
15 |
Author: Exactly WWW
|
16 |
-
Version:
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
@@ -127,27 +127,3 @@ if ( ! function_exists( 'ewww_image_optimizer_unsupported_php' ) ) {
|
|
127 |
load_plugin_textdomain( 'ewww-image-optimizer', false, plugin_dir_path( __FILE__ ) . 'languages/' );
|
128 |
}
|
129 |
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Inform the user that only ewww-image-optimizer-cloud is permitted on Kinsta.
|
133 |
-
*/
|
134 |
-
function ewww_image_optimizer_notice_kinsta() {
|
135 |
-
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' ) .
|
136 |
-
' <a href="admin.php?action=ewwwio_install_cloud_plugin">' . esc_html__( 'Install now.', 'ewww-image-optimizer' ) . '</a></p></div>';
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Inform the user that only ewww-image-optimizer-cloud is permitted on Flywheel.
|
141 |
-
*/
|
142 |
-
function ewww_image_optimizer_notice_flywheel() {
|
143 |
-
echo "<div id='ewww-image-optimizer-warning-flywheel' class='error'><p>" . esc_html__( 'The regular version of the EWWW Image Optimizer plugin is not permitted on Flywheel sites. Please deactivate EWWW Image Optimizer and install EWWW Image Optimizer Cloud to optimize your images.', 'ewww-image-optimizer' ) .
|
144 |
-
' <a href="admin.php?action=ewwwio_install_cloud_plugin">' . esc_html__( 'Install now.', 'ewww-image-optimizer' ) . '</a></p></div>';
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Inform the user that only ewww-image-optimizer-cloud is permitted on WP NET (nz).
|
149 |
-
*/
|
150 |
-
function ewww_image_optimizer_notice_wpnetnz() {
|
151 |
-
echo "<div id='ewww-image-optimizer-warning-wpnetnz' class='error'><p>" . esc_html__( 'The regular version of the EWWW Image Optimizer plugin is not permitted on WP NET sites. Please deactivate EWWW Image Optimizer and install EWWW Image Optimizer Cloud to optimize your images.', 'ewww-image-optimizer' ) .
|
152 |
-
' <a href="admin.php?action=ewwwio_install_cloud_plugin">' . esc_html__( 'Install now.', 'ewww-image-optimizer' ) . '</a></p></div>';
|
153 |
-
}
|
13 |
Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
|
14 |
Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
|
15 |
Author: Exactly WWW
|
16 |
+
Version: 6.0.0
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
127 |
load_plugin_textdomain( 'ewww-image-optimizer', false, plugin_dir_path( __FILE__ ) . 'languages/' );
|
128 |
}
|
129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/eio-beacon.js
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
$('#ewww-copy-debug').on( 'click', function() {
|
3 |
+
selectText('ewww-debug-info');
|
4 |
+
try {
|
5 |
+
var successful = document.execCommand('copy');
|
6 |
+
if ( successful ) {
|
7 |
+
unselectText();
|
8 |
+
}
|
9 |
+
} catch(err) {
|
10 |
+
console.log('browser cannot copy');
|
11 |
+
console.log(err);
|
12 |
+
}
|
13 |
+
});
|
14 |
+
function HSregister() {
|
15 |
+
if (typeof(Beacon) !== 'undefined' ) {
|
16 |
+
$('.ewww-overrides-nav').on( 'click', function() {
|
17 |
+
Beacon('article', '59710ce4042863033a1b45a6', { type: 'modal' });
|
18 |
+
return false;
|
19 |
+
});
|
20 |
+
$('.ewww-contact-root').on( 'click', function() {
|
21 |
+
Beacon('navigate', '/ask/')
|
22 |
+
Beacon('open');
|
23 |
+
return false;
|
24 |
+
});
|
25 |
+
$('.ewww-docs-root').on( 'click', function() {
|
26 |
+
Beacon('navigate', '/answers/')
|
27 |
+
Beacon('open');
|
28 |
+
return false;
|
29 |
+
});
|
30 |
+
$('.ewww-help-beacon-multi').on( 'click', function() {
|
31 |
+
var hsids = $(this).attr('data-beacon-articles');
|
32 |
+
hsids = hsids.split(',');
|
33 |
+
Beacon('suggest', hsids);
|
34 |
+
Beacon('navigate', '/answers/');
|
35 |
+
Beacon('open');
|
36 |
+
return false;
|
37 |
+
});
|
38 |
+
$('.ewww-help-beacon-single').on( 'click', function() {
|
39 |
+
var hsid = $(this).attr('data-beacon-article');
|
40 |
+
Beacon('article', hsid, { type: 'modal' });
|
41 |
+
return false;
|
42 |
+
});
|
43 |
+
}
|
44 |
+
}
|
45 |
+
HSregister();
|
46 |
+
});
|
47 |
+
function selectText(containerid) {
|
48 |
+
var debug_node = document.getElementById(containerid);
|
49 |
+
if (document.selection) {
|
50 |
+
var range = document.body.createTextRange();
|
51 |
+
range.moveToElementText(debug_node);
|
52 |
+
range.select();
|
53 |
+
} else if (window.getSelection) {
|
54 |
+
window.getSelection().selectAllChildren(debug_node);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
function unselectText() {
|
58 |
+
var sel;
|
59 |
+
if ( (sel = document.selection) && sel.empty) {
|
60 |
+
sel.empty();
|
61 |
+
} else if (window.getSelection) {
|
62 |
+
window.getSelection().removeAllRanges();
|
63 |
+
}
|
64 |
+
}
|
includes/eio-bulk.js
ADDED
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
var ewww_error_counter = 30;
|
3 |
+
$("#ewww-delay-slider").slider({
|
4 |
+
min: 0,
|
5 |
+
max: 30,
|
6 |
+
value: $("#ewww-delay").val(),
|
7 |
+
slide: function(event, ui) {
|
8 |
+
$("#ewww-delay").val(ui.value);
|
9 |
+
}
|
10 |
+
});
|
11 |
+
var ewwwdelayinput = document.getElementById("ewww-delay");
|
12 |
+
if (ewwwdelayinput) {
|
13 |
+
ewwwdelayinput.onblur = function() {
|
14 |
+
if (isNaN(this.value)) {
|
15 |
+
this.value = 0;
|
16 |
+
} else {
|
17 |
+
this.value = Math.ceil(this.value);
|
18 |
+
}
|
19 |
+
};
|
20 |
+
}
|
21 |
+
var ewww_attachments = ewww_vars.attachments;
|
22 |
+
var ewww_i = 0;
|
23 |
+
var ewww_k = 0;
|
24 |
+
var ewww_import_total = 0;
|
25 |
+
var ewww_force = 0;
|
26 |
+
var ewww_force_smart = 0;
|
27 |
+
var ewww_webp_only = 0;
|
28 |
+
var ewww_delay = 0;
|
29 |
+
var ewww_batch_limit = 0;
|
30 |
+
var ewww_aux = false;
|
31 |
+
var ewww_main = false;
|
32 |
+
var ewww_quota_update = 0;
|
33 |
+
var ewww_scan_failures = 0;
|
34 |
+
var ewww_bulk_start_time = 0;
|
35 |
+
var ewww_bulk_elapsed_time = 0;
|
36 |
+
var ewww_time_per_image = 0;
|
37 |
+
var ewww_time_remaining = 0;
|
38 |
+
var ewww_days_remaining = 0;
|
39 |
+
var ewww_hours_remaining = 0;
|
40 |
+
var ewww_minutes_remaining = 0;
|
41 |
+
var ewww_seconds_remaining = 0;
|
42 |
+
var ewww_countdown = false;
|
43 |
+
var ewww_tiny_skip = '';
|
44 |
+
// initialize the ajax actions for the appropriate bulk page
|
45 |
+
var ewww_quota_update_data = {
|
46 |
+
action: 'bulk_quota_update',
|
47 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
48 |
+
};
|
49 |
+
if (ewww_vars.gallery == 'flag') {
|
50 |
+
var ewww_init_action = 'bulk_flag_init';
|
51 |
+
var ewww_loop_action = 'bulk_flag_loop';
|
52 |
+
var ewww_cleanup_action = 'bulk_flag_cleanup';
|
53 |
+
} else if (ewww_vars.gallery == 'nextgen') {
|
54 |
+
var ewww_preview_action = 'bulk_ngg_preview';
|
55 |
+
var ewww_init_action = 'bulk_ngg_init';
|
56 |
+
var ewww_loop_action = 'bulk_ngg_loop';
|
57 |
+
var ewww_cleanup_action = 'bulk_ngg_cleanup';
|
58 |
+
} else {
|
59 |
+
var ewww_scan_action = 'bulk_scan';
|
60 |
+
var ewww_init_action = 'bulk_init';
|
61 |
+
var ewww_loop_action = 'bulk_loop';
|
62 |
+
var ewww_cleanup_action = 'bulk_cleanup';
|
63 |
+
ewww_main = true;
|
64 |
+
}
|
65 |
+
var ewww_init_data = {
|
66 |
+
action: ewww_init_action,
|
67 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
68 |
+
};
|
69 |
+
var ewww_table_action = 'bulk_aux_images_table';
|
70 |
+
var ewww_table_count_action = 'bulk_aux_images_table_count';
|
71 |
+
var ewww_import_init_action = 'bulk_import_init';
|
72 |
+
var ewww_import_loop_action = 'bulk_import_loop';
|
73 |
+
$(document).on('click', '.ewww-show-debug-meta', function() {
|
74 |
+
var post_id = $(this).data('id');
|
75 |
+
$('.ewww-debug-meta-' + post_id).toggle();
|
76 |
+
});
|
77 |
+
$('.ewww-hndle').click(function() {
|
78 |
+
return;
|
79 |
+
$(this).next('.inside').toggle();
|
80 |
+
var button = $(this).prev('.button-link');
|
81 |
+
if ('true' == button.attr('aria-expanded')) {
|
82 |
+
button.attr('aria-expanded', 'false');
|
83 |
+
button.closest('.postbox').addClass('closed');
|
84 |
+
button.children('.toggle-indicator').attr('aria-hidden', 'true');
|
85 |
+
} else {
|
86 |
+
button.attr('aria-expanded', 'true');
|
87 |
+
button.closest('.postbox').removeClass('closed');
|
88 |
+
button.children('.toggle-indicator').attr('aria-hidden', 'false');
|
89 |
+
}
|
90 |
+
});
|
91 |
+
$('.ewww-handlediv').click(function() {
|
92 |
+
$(this).parent().children('.inside').toggle();
|
93 |
+
if ('true' == $(this).attr('aria-expanded')) {
|
94 |
+
$(this).attr('aria-expanded', 'false');
|
95 |
+
$(this).closest('.postbox').addClass('closed');
|
96 |
+
$(this).children('.toggle-indicator').attr('aria-hidden', 'true');
|
97 |
+
} else {
|
98 |
+
$(this).attr('aria-expanded', 'true');
|
99 |
+
$(this).closest('.postbox').removeClass('closed');
|
100 |
+
$(this).children('.toggle-indicator').attr('aria-hidden', 'false');
|
101 |
+
}
|
102 |
+
});
|
103 |
+
$('#ewww-aux-start').submit(function() {
|
104 |
+
ewww_aux = true;
|
105 |
+
if ($('#ewww-force:checkbox:checked').val()) {
|
106 |
+
ewww_force = 1;
|
107 |
+
}
|
108 |
+
if ($('#ewww-force-smart:checkbox:checked').val()) {
|
109 |
+
ewww_force_smart = 1;
|
110 |
+
}
|
111 |
+
if ($('#ewww-webp-only:checkbox:checked').val()) {
|
112 |
+
ewww_webp_only = 1;
|
113 |
+
}
|
114 |
+
$('#ewww-aux-start').hide();
|
115 |
+
$('.ewww-bulk-info').hide();
|
116 |
+
$('.ewww-aux-table').hide();
|
117 |
+
$('#ewww-show-table').hide();
|
118 |
+
$('#ewww-scanning').show();
|
119 |
+
ewwwStartScan();
|
120 |
+
return false;
|
121 |
+
});
|
122 |
+
function ewwwStartScan() {
|
123 |
+
var ewww_scan_data = {
|
124 |
+
action: ewww_scan_action,
|
125 |
+
ewww_force: ewww_force,
|
126 |
+
ewww_force_smart: ewww_force_smart,
|
127 |
+
ewww_webp_only: ewww_webp_only,
|
128 |
+
ewww_scan: true,
|
129 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
130 |
+
};
|
131 |
+
$.post(ajaxurl, ewww_scan_data, function(response) {
|
132 |
+
var is_json = true;
|
133 |
+
try {
|
134 |
+
var ewww_response = JSON.parse(response);
|
135 |
+
} catch (err) {
|
136 |
+
is_json = false;
|
137 |
+
}
|
138 |
+
if ( ! is_json ) {
|
139 |
+
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_vars.invalid_response + '</b></span>');
|
140 |
+
console.log( response );
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
ewww_init_data = {
|
144 |
+
action: ewww_init_action,
|
145 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
146 |
+
};
|
147 |
+
if ( ewww_response.error ) {
|
148 |
+
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_response.error + '</b></span>');
|
149 |
+
} else if ( ewww_response.remaining ) {
|
150 |
+
$('.ewww-aux-table').hide();
|
151 |
+
$('#ewww-show-table').hide();
|
152 |
+
//if ( ! ewww_response.notice ) {
|
153 |
+
// ewww_response.notice = '';
|
154 |
+
//}
|
155 |
+
$('#ewww-scanning').html( ewww_response.remaining );
|
156 |
+
if ( ewww_response.notice ) {
|
157 |
+
$('#ewww-scanning').append( '<br>' + ewww_response.notice );
|
158 |
+
}
|
159 |
+
if ( ewww_response.tiny_skip ) {
|
160 |
+
$('#ewww-scanning').append( '<br>' + ewww_response.tiny_skip );
|
161 |
+
ewww_tiny_skip = ewww_response.tiny_skip;
|
162 |
+
console.log( 'skipped some tiny images' );
|
163 |
+
}
|
164 |
+
if ( ewww_response.bad_attachment ) {
|
165 |
+
$('#ewww-scanning').append( '<br>' + ewww_vars.bad_attachment + ' ' + ewww_response.bad_attachment );
|
166 |
+
}
|
167 |
+
ewww_scan_failures = 0;
|
168 |
+
ewwwStartScan();
|
169 |
+
} else if ( ewww_response.ready ) {
|
170 |
+
ewww_attachments = ewww_response.ready;
|
171 |
+
$('#ewww-scanning').html(ewww_response.message);
|
172 |
+
if ( ewww_tiny_skip ) {
|
173 |
+
$('#ewww-scanning').append( '<br><i>' + ewww_tiny_skip + '</i>' );
|
174 |
+
console.log( 'done, skipped some tiny images' );
|
175 |
+
}
|
176 |
+
$('#ewww-bulk-first').val(ewww_response.start_button);
|
177 |
+
$('#ewww-bulk-start').show();
|
178 |
+
} else if ( ewww_response.ready === 0 ) {
|
179 |
+
$('#ewww-scanning').hide();
|
180 |
+
$('#ewww-nothing').show();
|
181 |
+
if ( ewww_tiny_skip ) {
|
182 |
+
$('#ewww-nothing').append( '<br><i>' + ewww_tiny_skip + '</i>' );
|
183 |
+
console.log( 'done, skipped some tiny images' );
|
184 |
+
}
|
185 |
+
}
|
186 |
+
})
|
187 |
+
.fail(function() {
|
188 |
+
ewww_scan_failures++;
|
189 |
+
if (ewww_scan_failures > 10) {
|
190 |
+
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_vars.scan_fail + ':</b> ' + ewww_vars.bulk_fail_more + '</span>');
|
191 |
+
} else {
|
192 |
+
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_vars.scan_incomplete + '</b></span>');
|
193 |
+
setTimeout(function() {
|
194 |
+
ewwwStartScan();
|
195 |
+
}, 1000);
|
196 |
+
}
|
197 |
+
});
|
198 |
+
}
|
199 |
+
$('#ewww-bulk-start').submit(function() {
|
200 |
+
ewwwStartOpt();
|
201 |
+
return false;
|
202 |
+
});
|
203 |
+
function ewwwUpdateQuota() {
|
204 |
+
if ($('#ewww-bulk-credits-available').length > 0) {
|
205 |
+
ewww_quota_update_data.ewww_wpnonce = ewww_vars._wpnonce;
|
206 |
+
$.post(ajaxurl, ewww_quota_update_data, function(response) {
|
207 |
+
$('#ewww-bulk-credits-available').html(response);
|
208 |
+
});
|
209 |
+
}
|
210 |
+
}
|
211 |
+
function ewwwStartOpt () {
|
212 |
+
ewww_k = 0;
|
213 |
+
ewww_quota_update = setInterval( ewwwUpdateQuota, 60000 );
|
214 |
+
$('#ewww-bulk-stop').submit(function() {
|
215 |
+
ewww_k = 9;
|
216 |
+
$('#ewww-bulk-stop').hide();
|
217 |
+
return false;
|
218 |
+
});
|
219 |
+
if ( ! $('#ewww-delay').val().match( /^[1-9][0-9]*$/) ) {
|
220 |
+
ewww_delay = 0;
|
221 |
+
} else {
|
222 |
+
ewww_delay = $('#ewww-delay').val();
|
223 |
+
}
|
224 |
+
if (ewww_delay) {
|
225 |
+
ewww_batch_limit = 1;
|
226 |
+
$('#ewww-bulk-last h2').html( ewww_vars.last_image_header );
|
227 |
+
}
|
228 |
+
$('.ewww-aux-table').hide();
|
229 |
+
$('#ewww-bulk-stop').show();
|
230 |
+
$('.ewww-bulk-form').hide();
|
231 |
+
$('.ewww-bulk-info').hide();
|
232 |
+
$('#ewww-bulk-forms').hide();
|
233 |
+
$('h2').hide();
|
234 |
+
$.post(ajaxurl, ewww_init_data, function(response) {
|
235 |
+
var is_json = true;
|
236 |
+
try {
|
237 |
+
var ewww_init_response = JSON.parse(response);
|
238 |
+
} catch (err) {
|
239 |
+
is_json = false;
|
240 |
+
}
|
241 |
+
if ( ! is_json || ! response ) {
|
242 |
+
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_vars.invalid_response + '</b></p>');
|
243 |
+
console.log( response );
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
if ( ewww_init_response.error ) {
|
247 |
+
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_init_response.error + '</b></p>');
|
248 |
+
if ( ewww_init_response.data ) {
|
249 |
+
console.log( ewww_init_response.data );
|
250 |
+
}
|
251 |
+
} else {
|
252 |
+
if ( ewww_init_response.start_time ) {
|
253 |
+
ewww_bulk_start_time = ewww_init_response.start_time;
|
254 |
+
}
|
255 |
+
$('#ewww-bulk-loading').html(ewww_init_response.results);
|
256 |
+
$('#ewww-bulk-progressbar').progressbar({ max: ewww_attachments });
|
257 |
+
$('#ewww-bulk-counter').html( ewww_vars.optimized + ' 0/' + ewww_attachments);
|
258 |
+
ewwwProcessImage();
|
259 |
+
}
|
260 |
+
});
|
261 |
+
}
|
262 |
+
function ewwwProcessImage() {
|
263 |
+
if ($('#ewww-force:checkbox:checked').val()) {
|
264 |
+
ewww_force = 1;
|
265 |
+
}
|
266 |
+
if ($('#ewww-force-smart:checkbox:checked').val()) {
|
267 |
+
ewww_force_smart = 1;
|
268 |
+
}
|
269 |
+
if ($('#ewww-webp-only:checkbox:checked').val()) {
|
270 |
+
ewww_webp_only = 1;
|
271 |
+
}
|
272 |
+
var ewww_loop_data = {
|
273 |
+
action: ewww_loop_action,
|
274 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
275 |
+
ewww_force: ewww_force,
|
276 |
+
ewww_force_smart: ewww_force_smart,
|
277 |
+
ewww_webp_only: ewww_webp_only,
|
278 |
+
ewww_batch_limit: ewww_batch_limit,
|
279 |
+
ewww_error_counter: ewww_error_counter,
|
280 |
+
};
|
281 |
+
var ewww_jqxhr = $.post(ajaxurl, ewww_loop_data, function(response) {
|
282 |
+
var is_json = true;
|
283 |
+
try {
|
284 |
+
var ewww_response = JSON.parse(response);
|
285 |
+
} catch (err) {
|
286 |
+
is_json = false;
|
287 |
+
}
|
288 |
+
if ( ! is_json || ! response ) {
|
289 |
+
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_vars.invalid_response + '</b></p>');
|
290 |
+
clearInterval(ewww_quota_update);
|
291 |
+
clearInterval(ewww_countdown);
|
292 |
+
if ( ! response ) {
|
293 |
+
console.log( 'empty response' );
|
294 |
+
} else {
|
295 |
+
console.log( response );
|
296 |
+
}
|
297 |
+
return false;
|
298 |
+
}
|
299 |
+
ewww_i += ewww_response.completed;
|
300 |
+
$('#ewww-bulk-progressbar').progressbar( "option", "value", ewww_i );
|
301 |
+
$('#ewww-bulk-counter').html(ewww_vars.optimized + ' ' + ewww_i + '/' + ewww_attachments);
|
302 |
+
if ( ewww_response.update_meta ) {
|
303 |
+
var ewww_updatemeta_data = {
|
304 |
+
action: 'ewww_bulk_update_meta',
|
305 |
+
attachment_id: ewww_response.update_meta,
|
306 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
307 |
+
};
|
308 |
+
$.post(ajaxurl, ewww_updatemeta_data);
|
309 |
+
}
|
310 |
+
if ( ewww_response.error ) {
|
311 |
+
$('#ewww-bulk-loading img').hide();
|
312 |
+
$('#ewww-bulk-progressbar').hide();
|
313 |
+
$('#ewww-bulk-timer').hide();
|
314 |
+
$('#ewww-bulk-counter').hide();
|
315 |
+
$('#ewww-bulk-stop').hide();
|
316 |
+
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_response.error + '</b></p>');
|
317 |
+
clearInterval(ewww_quota_update);
|
318 |
+
clearInterval(ewww_countdown);
|
319 |
+
ewwwUpdateQuota();
|
320 |
+
}
|
321 |
+
else if (ewww_k == 9) {
|
322 |
+
if ( ewww_response.results ) {
|
323 |
+
$('#ewww-bulk-last .inside').html( ewww_response.results );
|
324 |
+
$('#ewww-bulk-status .inside').append( ewww_response.results );
|
325 |
+
}
|
326 |
+
clearInterval(ewww_quota_update);
|
327 |
+
clearInterval(ewww_countdown);
|
328 |
+
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.operation_stopped + '</b></p>');
|
329 |
+
}
|
330 |
+
else if ( response == 0 ) {
|
331 |
+
clearInterval(ewww_quota_update);
|
332 |
+
clearInterval(ewww_countdown);
|
333 |
+
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.operation_stopped + '</b></p>');
|
334 |
+
}
|
335 |
+
else if ( ewww_i < ewww_attachments && ! ewww_response.done ) {
|
336 |
+
if ( ewww_bulk_start_time && ewww_response.current_time ) {
|
337 |
+
ewww_bulk_elapsed_time = ewww_response.current_time - ewww_bulk_start_time;
|
338 |
+
ewww_time_per_image = ewww_bulk_elapsed_time / ewww_i;
|
339 |
+
ewww_time_remaining = Math.floor((ewww_attachments - ewww_i) * ewww_time_per_image);
|
340 |
+
ewwwTimeIncrementsUpdate();
|
341 |
+
if ( ! ewww_countdown) {
|
342 |
+
$('#ewww-bulk-timer').html(ewww_days_remaining + ':' + ewww_hours_remaining + ':' + ewww_minutes_remaining + ':' + ewww_seconds_remaining + ' ' + ewww_vars.time_remaining);
|
343 |
+
ewww_countdown = setInterval( ewwwCountDown, 1000 );
|
344 |
+
}
|
345 |
+
}
|
346 |
+
$('#ewww-bulk-widgets').show();
|
347 |
+
$('#ewww-bulk-status h2').show();
|
348 |
+
$('#ewww-bulk-last h2').show();
|
349 |
+
if ( ewww_response.results ) {
|
350 |
+
$('#ewww-bulk-last .inside').html( ewww_response.results );
|
351 |
+
$('#ewww-bulk-status .inside').append( ewww_response.results );
|
352 |
+
}
|
353 |
+
if ( ewww_response.next_file ) {
|
354 |
+
$('#ewww-bulk-loading').html(ewww_response.next_file);
|
355 |
+
}
|
356 |
+
if ( ewww_response.new_nonce ) {
|
357 |
+
ewww_vars._wpnonce = ewww_response.new_nonce;
|
358 |
+
}
|
359 |
+
ewww_error_counter = 30;
|
360 |
+
setTimeout(ewwwProcessImage, ewww_delay * 1000);
|
361 |
+
}
|
362 |
+
else {
|
363 |
+
if ( ewww_response.results ) {
|
364 |
+
$('#ewww-bulk-widgets').show();
|
365 |
+
$('#ewww-bulk-status h2').show();
|
366 |
+
$('#ewww-bulk-status .inside').append( ewww_response.results );
|
367 |
+
}
|
368 |
+
var ewww_cleanup_data = {
|
369 |
+
action: ewww_cleanup_action,
|
370 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
371 |
+
};
|
372 |
+
$.post(ajaxurl, ewww_cleanup_data, function(response) {
|
373 |
+
$('#ewww-bulk-loading').html(response);
|
374 |
+
$('#ewww-bulk-stop').hide();
|
375 |
+
$('#ewww-bulk-last').hide();
|
376 |
+
ewwwAuxCleanup();
|
377 |
+
});
|
378 |
+
}
|
379 |
+
})
|
380 |
+
.fail(function() {
|
381 |
+
if (ewww_error_counter == 0) {
|
382 |
+
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.operation_interrupted + ':</b> ' + ewww_vars.bulk_fail_more + '</p>');
|
383 |
+
} else {
|
384 |
+
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.temporary_failure + ' ' + ewww_error_counter + ' (' + ewww_vars.bulk_fail_more + ')</b></p>');
|
385 |
+
ewww_error_counter--;
|
386 |
+
setTimeout(function() {
|
387 |
+
ewwwProcessImage();
|
388 |
+
}, 1000);
|
389 |
+
}
|
390 |
+
});
|
391 |
+
}
|
392 |
+
function ewwwAuxCleanup() {
|
393 |
+
if (ewww_main == true) {
|
394 |
+
clearInterval(ewww_quota_update);
|
395 |
+
clearInterval(ewww_countdown);
|
396 |
+
var ewww_table_count_data = {
|
397 |
+
action: ewww_table_count_action,
|
398 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
399 |
+
ewww_inline: 1,
|
400 |
+
};
|
401 |
+
$.post(ajaxurl, ewww_table_count_data, function(response) {
|
402 |
+
ewww_vars.image_count = response;
|
403 |
+
});
|
404 |
+
$('#ewww-show-table').show();
|
405 |
+
$('#ewww-table-info').show();
|
406 |
+
$('#ewww-bulk-timer').hide();
|
407 |
+
if (ewww_aux == true) {
|
408 |
+
$('#ewww-aux-first').hide();
|
409 |
+
} else {
|
410 |
+
$('#ewww-bulk-first').hide();
|
411 |
+
}
|
412 |
+
ewww_attachments = ewww_vars.attachments;
|
413 |
+
ewww_init_action = 'bulk_init';
|
414 |
+
ewww_filename_action = 'bulk_filename';
|
415 |
+
ewww_loop_action = 'bulk_loop';
|
416 |
+
ewww_cleanup_action = 'bulk_cleanup';
|
417 |
+
ewww_init_data = {
|
418 |
+
action: ewww_init_action,
|
419 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
420 |
+
};
|
421 |
+
ewww_aux = false;
|
422 |
+
ewww_i = 0;
|
423 |
+
ewww_force = 0;
|
424 |
+
ewww_force_smart = 0;
|
425 |
+
ewww_webp_only = 0;
|
426 |
+
}
|
427 |
+
}
|
428 |
+
function ewwwCountDown() {
|
429 |
+
if (ewww_time_remaining > 1) {
|
430 |
+
ewww_time_remaining--;
|
431 |
+
}
|
432 |
+
ewwwTimeIncrementsUpdate();
|
433 |
+
$('#ewww-bulk-timer').html(ewww_days_remaining + ':' + ewww_hours_remaining + ':' + ewww_minutes_remaining + ':' + ewww_seconds_remaining + ' ' + ewww_vars.time_remaining);
|
434 |
+
}
|
435 |
+
function ewwwTimeIncrementsUpdate() {
|
436 |
+
ewww_days_remaining = Math.floor(ewww_time_remaining / 86400);
|
437 |
+
ewww_hours_remaining = Math.floor((ewww_time_remaining - (ewww_days_remaining * 86400)) / 3600);
|
438 |
+
ewww_minutes_remaining = Math.floor((ewww_time_remaining - (ewww_days_remaining * 86400) - (ewww_hours_remaining * 3600)) / 60);
|
439 |
+
ewww_seconds_remaining = ewww_time_remaining - (ewww_days_remaining * 86400) - (ewww_hours_remaining * 3600) - (ewww_minutes_remaining * 60);
|
440 |
+
if (ewww_days_remaining < 10) { ewww_days_remaining = '0'+ewww_days_remaining; }
|
441 |
+
if (ewww_hours_remaining < 10) { ewww_hours_remaining = '0'+ewww_hours_remaining; }
|
442 |
+
if (ewww_minutes_remaining < 10) { ewww_minutes_remaining = '0'+ewww_minutes_remaining; }
|
443 |
+
if (ewww_seconds_remaining < 10) { ewww_seconds_remaining = '0'+ewww_seconds_remaining; }
|
444 |
+
}
|
445 |
+
});
|
includes/eio-settings.js
ADDED
@@ -0,0 +1,460 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
// Wizard bits:
|
3 |
+
$('input:radio[name="ewww_image_optimizer_budget"]').on(
|
4 |
+
'change',
|
5 |
+
function() {
|
6 |
+
if (this.checked && this.value === 'pay') {
|
7 |
+
$('.ewwwio-premium-setup').show();
|
8 |
+
} else {
|
9 |
+
$('.ewwwio-premium-setup').hide();
|
10 |
+
}
|
11 |
+
}
|
12 |
+
);
|
13 |
+
var ewww_wizard_required_checkboxes = $('#ewwwio-wizard-step-1 :checkbox[required]');
|
14 |
+
ewww_wizard_required_checkboxes.on(
|
15 |
+
'change',
|
16 |
+
function() {
|
17 |
+
if (ewww_wizard_required_checkboxes.is(':checked')) {
|
18 |
+
ewww_wizard_required_checkboxes.removeAttr('required');
|
19 |
+
} else {
|
20 |
+
ewww_wizard_required_checkboxes.attr('required', 'required');
|
21 |
+
}
|
22 |
+
}
|
23 |
+
);
|
24 |
+
$('#ewwwio-wizard-step-1').on(
|
25 |
+
'submit',
|
26 |
+
function() {
|
27 |
+
return;
|
28 |
+
$(this).hide();
|
29 |
+
$('#ewwwio-wizard-step-2').show();
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
);
|
33 |
+
$('.ewwwio-wizard-back').on(
|
34 |
+
'click',
|
35 |
+
function() {
|
36 |
+
return;
|
37 |
+
$('#ewwwio-wizard-step-2').hide();
|
38 |
+
$('#ewwwio-wizard-step-1').show();
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
);
|
42 |
+
function removeQueryArg(url) {
|
43 |
+
return url.split('?')[0];
|
44 |
+
}
|
45 |
+
$('.fade').fadeTo(5000,1).fadeOut(3000);
|
46 |
+
var speed_bar_width = $('#ewww-speed-fill').data('score');
|
47 |
+
$('#ewww-speed-fill').animate( {
|
48 |
+
width: speed_bar_width + '%',
|
49 |
+
}, 1000 );
|
50 |
+
var ewww_save_bar_width = $('#ewww-savings-fill').data('score');
|
51 |
+
$('#ewww-savings-fill').animate( {
|
52 |
+
width: ewww_save_bar_width + '%',
|
53 |
+
}, 1000 );
|
54 |
+
var easy_save_bar_width = $('#easyio-savings-fill').data('score');
|
55 |
+
$('#easyio-savings-fill').animate( {
|
56 |
+
width: easy_save_bar_width + '%',
|
57 |
+
}, 1000 );
|
58 |
+
$('#ewww-show-recommendations a').on(
|
59 |
+
'click',
|
60 |
+
function() {
|
61 |
+
$('.ewww-recommend').toggle();
|
62 |
+
$('#ewww-show-recommendations a').toggle();
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
);
|
66 |
+
$('#ewww_image_optimizer_cloud_key').on('keydown', function(event){
|
67 |
+
if (event.which === 13) {
|
68 |
+
$('#ewwwio-api-activate').trigger('click');
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
});
|
72 |
+
$('#ewwwio-api-activate').on('click', function() {
|
73 |
+
var ewww_post_action = 'ewww_cloud_key_verify';
|
74 |
+
var ewww_post_data = {
|
75 |
+
action: ewww_post_action,
|
76 |
+
compress_api_key: $('#ewww_image_optimizer_cloud_key').val(),
|
77 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
78 |
+
};
|
79 |
+
$('#ewwwio-api-activate').hide();
|
80 |
+
$('#ewwwio-api-activation-processing').show();
|
81 |
+
$('#ewwwio-api-activation-result').hide();
|
82 |
+
$.post(ajaxurl, ewww_post_data, function(response) {
|
83 |
+
try {
|
84 |
+
var ewww_response = JSON.parse(response);
|
85 |
+
} catch (err) {
|
86 |
+
$('#ewwwio-api-activation-processing').hide();
|
87 |
+
$('#ewwwio-api-activation-result').html(ewww_vars.invalid_response);
|
88 |
+
$('#ewwwio-api-activation-result').addClass('error');
|
89 |
+
$('#ewwwio-api-activation-result').show();
|
90 |
+
console.log( response );
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
if ( ewww_response.error ) {
|
94 |
+
$('#ewwwio-api-activation-processing').hide();
|
95 |
+
$('#ewwwio-api-activate').show();
|
96 |
+
$('#ewwwio-api-activation-result').html(ewww_response.error);
|
97 |
+
$('#ewwwio-api-activation-result').addClass('error');
|
98 |
+
$('#ewwwio-api-activation-result').show();
|
99 |
+
} else if ( ! ewww_response.success ) {
|
100 |
+
$('#ewwwio-api-activation-processing').hide();
|
101 |
+
$('#ewwwio-api-activation-result').html(ewww_vars.invalid_response);
|
102 |
+
$('#ewwwio-api-activation-result').addClass('error');
|
103 |
+
$('#ewwwio-api-activation-result').show();
|
104 |
+
console.log( response );
|
105 |
+
} else {
|
106 |
+
$('#ewwwio-api-activation-processing').hide();
|
107 |
+
$('#ewwwio-api-activate').html('<span class="dashicons dashicons-yes"></span>');
|
108 |
+
$('#ewwwio-api-activate').show();
|
109 |
+
$('#ewwwio-api-activation-result').html(ewww_response.success);
|
110 |
+
$('#ewwwio-api-activation-result').removeClass('error');
|
111 |
+
$('#ewwwio-api-activation-result').show();
|
112 |
+
ewwwCloudEnable();
|
113 |
+
}
|
114 |
+
});
|
115 |
+
return false;
|
116 |
+
});
|
117 |
+
function ewwwCloudEnable() {
|
118 |
+
if (
|
119 |
+
$('#ewww_image_optimizer_jpg_level').val() < 20 &&
|
120 |
+
$('#ewww_image_optimizer_png_level').val() < 20 &&
|
121 |
+
$('#ewww_image_optimizer_gif_level').val() < 20 &&
|
122 |
+
$('#ewww_image_optimizer_pdf_level').val() < 10
|
123 |
+
) {
|
124 |
+
$('#ewww_image_optimizer_jpg_level option').prop('disabled', false);
|
125 |
+
$('#ewww_image_optimizer_png_level option').prop('disabled', false);
|
126 |
+
$('#ewww_image_optimizer_pdf_level option').prop('disabled', false);
|
127 |
+
$('#ewww_image_optimizer_svg_level option').prop('disabled', false);
|
128 |
+
$('#ewww_image_optimizer_backup_files').prop('disabled', false);
|
129 |
+
$('#ewww_image_optimizer_jpg_level').val(30);
|
130 |
+
$('#ewww_image_optimizer_png_level').val(20);
|
131 |
+
$('#ewww_image_optimizer_gif_level').val(10);
|
132 |
+
$('#ewww_image_optimizer_pdf_level').val(10);
|
133 |
+
$('#ewww_image_optimizer_svg_level').val(10);
|
134 |
+
$('#ewww_image_optimizer_backup_files').prop('checked', true);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
$('#ewwwio-easy-activate').on( 'click', function() {
|
138 |
+
var ewww_post_action = 'ewww_exactdn_activate';
|
139 |
+
var ewww_post_data = {
|
140 |
+
action: ewww_post_action,
|
141 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
142 |
+
};
|
143 |
+
$('#ewwwio-easy-activate').hide();
|
144 |
+
$('#ewwwio-easy-activation-result').hide();
|
145 |
+
$('#ewwwio-easy-activation-processing').show();
|
146 |
+
$.post(ajaxurl, ewww_post_data, function(response) {
|
147 |
+
try {
|
148 |
+
var ewww_response = JSON.parse(response);
|
149 |
+
} catch (err) {
|
150 |
+
$('#ewwwio-easy-activation-processing').hide();
|
151 |
+
$('#ewwwio-easy-activation-result').html(ewww_vars.invalid_response);
|
152 |
+
$('#ewwwio-easy-activation-result').addClass('error');
|
153 |
+
$('#ewwwio-easy-activation-result').show();
|
154 |
+
console.log( response );
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
if ( ewww_response.error ) {
|
158 |
+
$('#ewwwio-easy-activation-processing').hide();
|
159 |
+
$('#ewwwio-easy-activate').show();
|
160 |
+
$('#ewwwio-easy-activation-result').html(ewww_response.error);
|
161 |
+
$('#ewwwio-easy-activation-result').addClass('error');
|
162 |
+
$('#ewwwio-easy-activation-result').show();
|
163 |
+
} else if ( ! ewww_response.success ) {
|
164 |
+
$('#ewwwio-easy-activation-processing').hide();
|
165 |
+
$('#ewwwio-easy-activation-result').html(ewww_vars.invalid_response);
|
166 |
+
$('#ewwwio-easy-activation-result').addClass('error');
|
167 |
+
$('#ewwwio-easy-activation-result').show();
|
168 |
+
console.log( response );
|
169 |
+
} else {
|
170 |
+
$('#ewwwio-easy-activation-processing').hide();
|
171 |
+
$('#ewwwio-easy-activation-result').html(ewww_response.success);
|
172 |
+
$('#ewwwio-easy-activation-result').removeClass('error');
|
173 |
+
$('#ewwwio-easy-activation-result').show();
|
174 |
+
$('.ewwwio-exactdn-options input').prop('disabled', false);
|
175 |
+
$('.ewwwio-exactdn-options').show();
|
176 |
+
}
|
177 |
+
});
|
178 |
+
return false;
|
179 |
+
});
|
180 |
+
$('#ewww_image_optimizer_webp').on(
|
181 |
+
'click',
|
182 |
+
function() {
|
183 |
+
if ( $(this).prop('checked') && ewww_vars.save_space ) {
|
184 |
+
$('#ewwwio-webp-storage-warning').fadeIn();
|
185 |
+
return false;
|
186 |
+
} else if ($(this).prop('checked')) {
|
187 |
+
$('.ewww_image_optimizer_webp_setting_container').fadeIn();
|
188 |
+
if ($('#ewww_image_optimizer_webp_for_cdn').prop('checked') || $('#ewww_image_optimizer_picture_webp').prop('checked')) {
|
189 |
+
$('.ewww_image_optimizer_webp_rewrite_setting_container').fadeIn();
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
$('.ewww_image_optimizer_webp_setting_container').fadeOut();
|
193 |
+
$('.ewww_image_optimizer_webp_rewrite_setting_container').fadeOut();
|
194 |
+
}
|
195 |
+
}
|
196 |
+
);
|
197 |
+
$('#ewwwio-cancel-webp').on(
|
198 |
+
'click',
|
199 |
+
function() {
|
200 |
+
$('#ewwwio-webp-storage-warning').fadeOut();
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
);
|
204 |
+
$('#ewwwio-easyio-webp-info').on(
|
205 |
+
'click',
|
206 |
+
function() {
|
207 |
+
$('#ewwwio-webp-storage-warning').fadeOut();
|
208 |
+
$('.ewwwio-premium-setup').show();
|
209 |
+
}
|
210 |
+
)
|
211 |
+
$('#ewwwio-confirm-webp').on(
|
212 |
+
'click',
|
213 |
+
function() {
|
214 |
+
$('#ewwwio-webp-storage-warning').fadeOut();
|
215 |
+
$('#ewww_image_optimizer_webp').prop('checked', true);
|
216 |
+
$('.ewww_image_optimizer_webp_setting_container').fadeIn();
|
217 |
+
if ($('#ewww_image_optimizer_webp_for_cdn').prop('checked') || $('#ewww_image_optimizer_picture_webp').prop('checked')) {
|
218 |
+
$('.ewww_image_optimizer_webp_rewrite_setting_container').fadeIn();
|
219 |
+
}
|
220 |
+
return false;
|
221 |
+
}
|
222 |
+
);
|
223 |
+
$('#ewww-webp-rewrite #ewww-webp-insert').on( 'click', function() {
|
224 |
+
var ewww_webp_rewrite_action = 'ewww_webp_rewrite';
|
225 |
+
var ewww_webp_rewrite_data = {
|
226 |
+
action: ewww_webp_rewrite_action,
|
227 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
228 |
+
};
|
229 |
+
$.post(ajaxurl, ewww_webp_rewrite_data, function(response) {
|
230 |
+
$('#ewww-webp-rewrite-result').html(response);
|
231 |
+
$('#ewww-webp-rewrite-result').show();
|
232 |
+
$('#ewww-webp-rewrite-status').hide();
|
233 |
+
$('#webp-rewrite-rules').hide();
|
234 |
+
$('#ewww-webp-insert').hide();
|
235 |
+
ewww_webp_image = document.getElementById('ewww-webp-image').src;
|
236 |
+
document.getElementById('ewww-webp-image').src = removeQueryArg(ewww_webp_image) + '?m=' + new Date().getTime();
|
237 |
+
});
|
238 |
+
return false;
|
239 |
+
});
|
240 |
+
$('#ewww-webp-rewrite #ewww-webp-remove').on( 'click', function() {
|
241 |
+
var ewww_webp_rewrite_action = 'ewww_webp_unwrite';
|
242 |
+
var ewww_webp_rewrite_data = {
|
243 |
+
action: ewww_webp_rewrite_action,
|
244 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
245 |
+
};
|
246 |
+
$.post(ajaxurl, ewww_webp_rewrite_data, function(response) {
|
247 |
+
$('#ewww-webp-rewrite-result').html(response);
|
248 |
+
$('#ewww-webp-rewrite-result').show();
|
249 |
+
$('#ewww-webp-rewrite-status').hide();
|
250 |
+
$('#ewww-webp-remove').hide();
|
251 |
+
ewww_webp_image = document.getElementById('ewww-webp-image').src;
|
252 |
+
document.getElementById('ewww-webp-image').src = removeQueryArg(ewww_webp_image) + '?m' + new Date().getTime();
|
253 |
+
});
|
254 |
+
return false;
|
255 |
+
});
|
256 |
+
$('#exactdn_site_url').on( 'mouseenter',
|
257 |
+
function() {
|
258 |
+
$('#exactdn-site-url-copy').fadeIn();
|
259 |
+
}
|
260 |
+
);
|
261 |
+
$('#exactdn_site_url').on( 'mouseleave',
|
262 |
+
function() {
|
263 |
+
$('#exactdn-site-url-copy').fadeOut();
|
264 |
+
$('#exactdn-site-url-copied').fadeOut();
|
265 |
+
}
|
266 |
+
);
|
267 |
+
$('#exactdn_site_url').on( 'click', function() {
|
268 |
+
this.select();
|
269 |
+
this.setSelectionRange(0,300); // For mobile.
|
270 |
+
try {
|
271 |
+
var successful = document.execCommand('copy');
|
272 |
+
if ( successful ) {
|
273 |
+
unselectText();
|
274 |
+
$('#exactdn-site-url-copy').hide();
|
275 |
+
$('#exactdn-site-url-copied').fadeIn();
|
276 |
+
}
|
277 |
+
} catch(err) {
|
278 |
+
console.log('browser cannot copy');
|
279 |
+
console.log(err);
|
280 |
+
}
|
281 |
+
});
|
282 |
+
$('#ewww_image_optimizer_exactdn').on( 'click', function() {
|
283 |
+
if($(this).prop('checked')) {
|
284 |
+
$('.ewwwio-exactdn-options').show();
|
285 |
+
} else {
|
286 |
+
$('.ewwwio-exactdn-options').hide();
|
287 |
+
}
|
288 |
+
});
|
289 |
+
$('#ewww_image_optimizer_lazy_load').on( 'click', function() {
|
290 |
+
if($(this).prop('checked')) {
|
291 |
+
$('#ewww_image_optimizer_ll_exclude_container').fadeIn();
|
292 |
+
$('#ewww_image_optimizer_lqip_container').fadeIn();
|
293 |
+
} else {
|
294 |
+
$('#ewww_image_optimizer_ll_exclude_container').fadeOut();
|
295 |
+
$('#ewww_image_optimizer_lqip_container').fadeOut();
|
296 |
+
}
|
297 |
+
});
|
298 |
+
$('#ewww_image_optimizer_webp_for_cdn, #ewww_image_optimizer_picture_webp').on(
|
299 |
+
'click',
|
300 |
+
function() {
|
301 |
+
if ( $(this).prop('checked') && ewww_vars.cloud_media ) {
|
302 |
+
var webp_delivery_confirm = confirm(ewww_vars.webp_cloud_warning);
|
303 |
+
if (! webp_delivery_confirm) {
|
304 |
+
return false;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
if ( ! $('#ewww_image_optimizer_webp_for_cdn').prop('checked') && ! $('#ewww_image_optimizer_picture_webp').prop('checked') ) {
|
308 |
+
$('.ewww_image_optimizer_webp_rewrite_setting_container').fadeOut();
|
309 |
+
} else {
|
310 |
+
$('.ewww_image_optimizer_webp_rewrite_setting_container').fadeIn();
|
311 |
+
}
|
312 |
+
}
|
313 |
+
);
|
314 |
+
//$('#ewww-webp-settings').hide();
|
315 |
+
//$('#ewww-exactdn-settings').hide();
|
316 |
+
$('#ewww-general-settings').show();
|
317 |
+
$('li.ewww-general-nav').addClass('ewww-selected');
|
318 |
+
if($('#ewww_image_optimizer_debug').length){
|
319 |
+
$('#ewww-resize-settings').hide();
|
320 |
+
console.log($('#ewww_image_optimizer_debug').length);
|
321 |
+
}
|
322 |
+
// New tabs.
|
323 |
+
$('#ewww-local-settings').hide();
|
324 |
+
$('#ewww-advanced-settings').hide();
|
325 |
+
|
326 |
+
//$('#ewww-optimization-settings').hide();
|
327 |
+
$('#ewww-conversion-settings').hide();
|
328 |
+
$('#ewww-support-settings').hide();
|
329 |
+
$('#ewww-contribute-settings').hide();
|
330 |
+
$('.ewww-webp-nav').on('click', function() {
|
331 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
332 |
+
$('li.ewww-webp-nav').addClass('ewww-selected');
|
333 |
+
$('.ewww-tab a').trigger('blur');
|
334 |
+
$('#ewww-webp-settings').show();
|
335 |
+
$('#ewww-general-settings').hide();
|
336 |
+
$('#ewww-local-settings').hide();
|
337 |
+
$('#ewww-advanced-settings').hide();
|
338 |
+
$('#ewww-resize-settings').hide();
|
339 |
+
$('#ewww-conversion-settings').hide();
|
340 |
+
$('#ewww-support-settings').hide();
|
341 |
+
$('#ewww-contribute-settings').hide();
|
342 |
+
});
|
343 |
+
$('.ewww-general-nav').on('click', function() {
|
344 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
345 |
+
$('li.ewww-general-nav').addClass('ewww-selected');
|
346 |
+
$('.ewww-tab a').trigger('blur');
|
347 |
+
$('#ewww-webp-settings').hide();
|
348 |
+
$('#ewww-general-settings').show();
|
349 |
+
$('#ewww-local-settings').hide();
|
350 |
+
$('#ewww-advanced-settings').hide();
|
351 |
+
$('#ewww-resize-settings').hide();
|
352 |
+
$('#ewww-conversion-settings').hide();
|
353 |
+
$('#ewww-support-settings').hide();
|
354 |
+
$('#ewww-contribute-settings').hide();
|
355 |
+
});
|
356 |
+
$('.ewww-exactdn-nav').on('click', function() {
|
357 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
358 |
+
$('li.ewww-exactdn-nav').addClass('ewww-selected');
|
359 |
+
$('.ewww-tab a').trigger('blur');
|
360 |
+
$('#ewww-webp-settings').hide();
|
361 |
+
$('#ewww-general-settings').hide();
|
362 |
+
$('#ewww-exactdn-settings').show();
|
363 |
+
$('#ewww-optimization-settings').hide();
|
364 |
+
$('#ewww-resize-settings').hide();
|
365 |
+
$('#ewww-conversion-settings').hide();
|
366 |
+
$('#ewww-support-settings').hide();
|
367 |
+
$('#ewww-contribute-settings').hide();
|
368 |
+
});
|
369 |
+
$('.ewww-optimization-nav').on('click', function() {
|
370 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
371 |
+
$('li.ewww-optimization-nav').addClass('ewww-selected');
|
372 |
+
$('.ewww-tab a').trigger('blur');
|
373 |
+
$('#ewww-webp-settings').hide();
|
374 |
+
$('#ewww-general-settings').hide();
|
375 |
+
$('#ewww-exactdn-settings').hide();
|
376 |
+
$('#ewww-optimization-settings').show();
|
377 |
+
$('#ewww-resize-settings').hide();
|
378 |
+
$('#ewww-conversion-settings').hide();
|
379 |
+
$('#ewww-support-settings').hide();
|
380 |
+
$('#ewww-contribute-settings').hide();
|
381 |
+
});
|
382 |
+
$('.ewww-local-nav').on( 'click', function() {
|
383 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
384 |
+
$('li.ewww-local-nav').addClass('ewww-selected');
|
385 |
+
$('.ewww-tab a').trigger('blur');
|
386 |
+
$('#ewww-webp-settings').hide();
|
387 |
+
$('#ewww-general-settings').hide();
|
388 |
+
$('#ewww-local-settings').show();
|
389 |
+
$('#ewww-advanced-settings').hide();
|
390 |
+
$('#ewww-resize-settings').hide();
|
391 |
+
$('#ewww-conversion-settings').hide();
|
392 |
+
$('#ewww-support-settings').hide();
|
393 |
+
$('#ewww-contribute-settings').hide();
|
394 |
+
});
|
395 |
+
$('.ewww-advanced-nav').on( 'click', function() {
|
396 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
397 |
+
$('li.ewww-advanced-nav').addClass('ewww-selected');
|
398 |
+
$('.ewww-tab a').trigger('blur');
|
399 |
+
$('#ewww-webp-settings').hide();
|
400 |
+
$('#ewww-general-settings').hide();
|
401 |
+
$('#ewww-local-settings').hide();
|
402 |
+
$('#ewww-advanced-settings').show();
|
403 |
+
$('#ewww-resize-settings').hide();
|
404 |
+
$('#ewww-conversion-settings').hide();
|
405 |
+
$('#ewww-support-settings').hide();
|
406 |
+
$('#ewww-contribute-settings').hide();
|
407 |
+
});
|
408 |
+
$('.ewww-resize-nav').on( 'click', function() {
|
409 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
410 |
+
$('li.ewww-resize-nav').addClass('ewww-selected');
|
411 |
+
$('.ewww-tab a').trigger('blur');
|
412 |
+
$('#ewww-webp-settings').hide();
|
413 |
+
$('#ewww-general-settings').hide();
|
414 |
+
$('#ewww-local-settings').hide();
|
415 |
+
$('#ewww-advanced-settings').hide();
|
416 |
+
$('#ewww-resize-settings').show();
|
417 |
+
$('#ewww-conversion-settings').hide();
|
418 |
+
$('#ewww-support-settings').hide();
|
419 |
+
$('#ewww-contribute-settings').hide();
|
420 |
+
});
|
421 |
+
$('.ewww-conversion-nav').on( 'click', function() {
|
422 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
423 |
+
$('li.ewww-conversion-nav').addClass('ewww-selected');
|
424 |
+
$('.ewww-tab a').trigger('blur');
|
425 |
+
$('#ewww-webp-settings').hide();
|
426 |
+
$('#ewww-general-settings').hide();
|
427 |
+
$('#ewww-local-settings').hide();
|
428 |
+
$('#ewww-advanced-settings').hide();
|
429 |
+
$('#ewww-resize-settings').hide();
|
430 |
+
$('#ewww-conversion-settings').show();
|
431 |
+
$('#ewww-support-settings').hide();
|
432 |
+
$('#ewww-contribute-settings').hide();
|
433 |
+
});
|
434 |
+
$('.ewww-support-nav').on( 'click', function() {
|
435 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
436 |
+
$('li.ewww-support-nav').addClass('ewww-selected');
|
437 |
+
$('.ewww-tab a').trigger('blur');
|
438 |
+
$('#ewww-webp-settings').hide();
|
439 |
+
$('#ewww-general-settings').hide();
|
440 |
+
$('#ewww-local-settings').hide();
|
441 |
+
$('#ewww-advanced-settings').hide();
|
442 |
+
$('#ewww-resize-settings').hide();
|
443 |
+
$('#ewww-conversion-settings').hide();
|
444 |
+
$('#ewww-support-settings').show();
|
445 |
+
$('#ewww-contribute-settings').hide();
|
446 |
+
});
|
447 |
+
$('.ewww-contribute-nav').on( 'click', function() {
|
448 |
+
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
449 |
+
$('li.ewww-contribute-nav').addClass('ewww-selected');
|
450 |
+
$('.ewww-tab a').trigger('blur');
|
451 |
+
$('#ewww-webp-settings').hide();
|
452 |
+
$('#ewww-general-settings').hide();
|
453 |
+
$('#ewww-local-settings').hide();
|
454 |
+
$('#ewww-advanced-settings').hide();
|
455 |
+
$('#ewww-resize-settings').hide();
|
456 |
+
$('#ewww-conversion-settings').hide();
|
457 |
+
$('#ewww-support-settings').hide();
|
458 |
+
$('#ewww-contribute-settings').show();
|
459 |
+
});
|
460 |
+
});
|
includes/eio-tools.js
CHANGED
@@ -5,7 +5,7 @@ jQuery(document).ready(function($) {
|
|
5 |
var ewww_search_total = 0;
|
6 |
var ewww_clean_meta_total = 0;
|
7 |
var ewww_table_debug = 0;
|
8 |
-
$('#ewww-show-table').submit
|
9 |
ewww_pointer = 0;
|
10 |
ewww_total_pages = Math.ceil(ewww_vars.image_count / 50);
|
11 |
$('.displaying-num').text(ewww_vars.count_string);
|
@@ -13,16 +13,16 @@ jQuery(document).ready(function($) {
|
|
13 |
$('#ewww-show-table').hide();
|
14 |
$('#ewww-debug-table-info').hide();
|
15 |
$('#ewww-show-debug-table').hide();
|
16 |
-
|
17 |
-
|
18 |
ewww_wpnonce: ewww_vars._wpnonce,
|
19 |
ewww_offset: ewww_pointer,
|
20 |
ewww_debug: ewww_table_debug,
|
21 |
ewww_total_pages: ewww_total_pages,
|
22 |
-
|
23 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
24 |
try {
|
25 |
-
var ewww_response =
|
26 |
} catch (err) {
|
27 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
28 |
console.log( response );
|
@@ -56,7 +56,7 @@ jQuery(document).ready(function($) {
|
|
56 |
});
|
57 |
return false;
|
58 |
});
|
59 |
-
$('#ewww-show-debug-table').submit
|
60 |
ewww_table_debug = 1;
|
61 |
ewww_pointer = 0;
|
62 |
$('#ewww-show-table').submit();
|
@@ -64,7 +64,7 @@ jQuery(document).ready(function($) {
|
|
64 |
document.documentElement.scrollTop = 0; // For everyone else.
|
65 |
return false;
|
66 |
});
|
67 |
-
$('.ewww-search-form').submit
|
68 |
ewww_pointer = 0;
|
69 |
var ewww_search = $('.ewww-search-input').val();
|
70 |
var ewww_table_data = {
|
@@ -77,7 +77,7 @@ jQuery(document).ready(function($) {
|
|
77 |
};
|
78 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
79 |
try {
|
80 |
-
var ewww_response =
|
81 |
} catch (err) {
|
82 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
83 |
console.log( response );
|
@@ -102,7 +102,7 @@ jQuery(document).ready(function($) {
|
|
102 |
$('.last-page').show();
|
103 |
return false;
|
104 |
});
|
105 |
-
$('.next-page').click
|
106 |
var ewww_search = $('.ewww-search-input').val();
|
107 |
ewww_pointer++;
|
108 |
var ewww_table_data = {
|
@@ -115,7 +115,7 @@ jQuery(document).ready(function($) {
|
|
115 |
};
|
116 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
117 |
try {
|
118 |
-
var ewww_response =
|
119 |
} catch (err) {
|
120 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
121 |
console.log( response );
|
@@ -141,7 +141,7 @@ jQuery(document).ready(function($) {
|
|
141 |
$('.first-page').show();
|
142 |
return false;
|
143 |
});
|
144 |
-
$('.prev-page').click
|
145 |
var ewww_search = $('.ewww-search-input').val();
|
146 |
ewww_pointer--;
|
147 |
var ewww_table_data = {
|
@@ -154,7 +154,7 @@ jQuery(document).ready(function($) {
|
|
154 |
};
|
155 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
156 |
try {
|
157 |
-
var ewww_response =
|
158 |
} catch (err) {
|
159 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
160 |
console.log( response );
|
@@ -176,7 +176,7 @@ jQuery(document).ready(function($) {
|
|
176 |
$('.last-page').show();
|
177 |
return false;
|
178 |
});
|
179 |
-
$('.last-page').click
|
180 |
var ewww_search = $('.ewww-search-input').val();
|
181 |
ewww_pointer = ewww_total_pages - 1;
|
182 |
if (ewww_search || ewww_table_debug) {
|
@@ -192,7 +192,7 @@ jQuery(document).ready(function($) {
|
|
192 |
};
|
193 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
194 |
try {
|
195 |
-
var ewww_response =
|
196 |
} catch (err) {
|
197 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
198 |
console.log( response );
|
@@ -212,7 +212,7 @@ jQuery(document).ready(function($) {
|
|
212 |
$('.first-page').show();
|
213 |
return false;
|
214 |
});
|
215 |
-
$('.first-page').click
|
216 |
ewww_pointer = 0;
|
217 |
var ewww_search = $('.ewww-search-input').val();
|
218 |
var ewww_table_data = {
|
@@ -225,7 +225,7 @@ jQuery(document).ready(function($) {
|
|
225 |
};
|
226 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
227 |
try {
|
228 |
-
var ewww_response =
|
229 |
} catch (err) {
|
230 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
231 |
console.log( response );
|
@@ -250,7 +250,7 @@ jQuery(document).ready(function($) {
|
|
250 |
});
|
251 |
return false;
|
252 |
});
|
253 |
-
$('#ewww-clear-table').submit
|
254 |
var ewww_table_data = {
|
255 |
action: 'bulk_aux_images_table_clear',
|
256 |
ewww_wpnonce: ewww_vars._wpnonce,
|
@@ -265,15 +265,78 @@ jQuery(document).ready(function($) {
|
|
265 |
}
|
266 |
return false;
|
267 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
var ewww_total_converted = 0;
|
269 |
-
$('#ewww-clean-converted').submit
|
270 |
var ewww_converted_data = {
|
271 |
action: 'bulk_aux_images_count_converted',
|
272 |
ewww_wpnonce: ewww_vars._wpnonce,
|
273 |
};
|
274 |
$.post(ajaxurl, ewww_converted_data, function(response) {
|
275 |
try {
|
276 |
-
var ewww_response =
|
277 |
} catch (err) {
|
278 |
$('#ewww-clean-converted-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
279 |
console.log( response );
|
@@ -287,11 +350,11 @@ jQuery(document).ready(function($) {
|
|
287 |
$('#ewww-clean-converted-progress').html('<p> 0/' + ewww_total_converted + '</p>');
|
288 |
$('#ewww-clean-converted-progressbar').show();
|
289 |
$('#ewww-clean-converted-progress').show();
|
290 |
-
|
291 |
});
|
292 |
return false;
|
293 |
});
|
294 |
-
function
|
295 |
var ewww_converted_data = {
|
296 |
action: 'bulk_aux_images_converted_clean',
|
297 |
ewww_wpnonce: ewww_vars._wpnonce,
|
@@ -318,12 +381,12 @@ jQuery(document).ready(function($) {
|
|
318 |
converted_offset += ewww_response.completed;
|
319 |
$('#ewww-clean-converted-progressbar').progressbar("option", "value", converted_offset);
|
320 |
$('#ewww-clean-converted-progress').html('<p>' + converted_offset + '/' + ewww_total_converted + '</p>');
|
321 |
-
|
322 |
});
|
323 |
}
|
324 |
var ewww_total_webp = 0;
|
325 |
var ewww_webp_attachments = false;
|
326 |
-
$('#ewww-clean-webp').submit
|
327 |
var ewww_webp_data = {
|
328 |
action: 'ewwwio_get_all_attachments',
|
329 |
ewww_wpnonce: ewww_vars._wpnonce,
|
@@ -417,7 +480,7 @@ jQuery(document).ready(function($) {
|
|
417 |
ewwwRemoveWebP(webp_offset);
|
418 |
});
|
419 |
}
|
420 |
-
$('#ewww-clean-table').submit
|
421 |
ewww_total_pages = Math.ceil(ewww_vars.image_count / 500);
|
422 |
$('.ewww-tool-info').hide();
|
423 |
$('.ewww-tool-form').hide();
|
@@ -439,7 +502,7 @@ jQuery(document).ready(function($) {
|
|
439 |
};
|
440 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
441 |
try {
|
442 |
-
var ewww_response =
|
443 |
} catch (err) {
|
444 |
$('#ewww-clean-table-progressbar').hide();
|
445 |
$('#ewww-clean-table-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
@@ -461,7 +524,7 @@ jQuery(document).ready(function($) {
|
|
461 |
ewwwCleanup(total_pages);
|
462 |
});
|
463 |
}
|
464 |
-
$('#ewww-clean-meta').submit
|
465 |
$('.ewww-tool-info').hide();
|
466 |
$('.ewww-tool-form').hide();
|
467 |
$('.ewww-tool-divider').hide();
|
@@ -481,7 +544,7 @@ jQuery(document).ready(function($) {
|
|
481 |
};
|
482 |
$.post(ajaxurl, ewww_cleanmeta_data, function(response) {
|
483 |
try {
|
484 |
-
var ewww_response =
|
485 |
} catch (err) {
|
486 |
$('#ewww-clean-meta-progressbar').hide();
|
487 |
$('#ewww-clean-meta-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
@@ -507,52 +570,51 @@ jQuery(document).ready(function($) {
|
|
507 |
ewwwCleanupMeta();
|
508 |
});
|
509 |
}
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
|
|
527 |
});
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
}
|
553 |
-
|
554 |
-
alert(ewww_response.error);
|
555 |
-
return false;
|
556 |
-
}
|
557 |
});
|
558 |
-
}
|
5 |
var ewww_search_total = 0;
|
6 |
var ewww_clean_meta_total = 0;
|
7 |
var ewww_table_debug = 0;
|
8 |
+
$('#ewww-show-table').on('submit',function() {
|
9 |
ewww_pointer = 0;
|
10 |
ewww_total_pages = Math.ceil(ewww_vars.image_count / 50);
|
11 |
$('.displaying-num').text(ewww_vars.count_string);
|
13 |
$('#ewww-show-table').hide();
|
14 |
$('#ewww-debug-table-info').hide();
|
15 |
$('#ewww-show-debug-table').hide();
|
16 |
+
var ewww_table_data = {
|
17 |
+
action: ewww_table_action,
|
18 |
ewww_wpnonce: ewww_vars._wpnonce,
|
19 |
ewww_offset: ewww_pointer,
|
20 |
ewww_debug: ewww_table_debug,
|
21 |
ewww_total_pages: ewww_total_pages,
|
22 |
+
};
|
23 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
24 |
try {
|
25 |
+
var ewww_response = JSON.parse(response);
|
26 |
} catch (err) {
|
27 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
28 |
console.log( response );
|
56 |
});
|
57 |
return false;
|
58 |
});
|
59 |
+
$('#ewww-show-debug-table').on( 'submit', function() {
|
60 |
ewww_table_debug = 1;
|
61 |
ewww_pointer = 0;
|
62 |
$('#ewww-show-table').submit();
|
64 |
document.documentElement.scrollTop = 0; // For everyone else.
|
65 |
return false;
|
66 |
});
|
67 |
+
$('.ewww-search-form').on( 'submit', function() {
|
68 |
ewww_pointer = 0;
|
69 |
var ewww_search = $('.ewww-search-input').val();
|
70 |
var ewww_table_data = {
|
77 |
};
|
78 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
79 |
try {
|
80 |
+
var ewww_response = JSON.parse(response);
|
81 |
} catch (err) {
|
82 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
83 |
console.log( response );
|
102 |
$('.last-page').show();
|
103 |
return false;
|
104 |
});
|
105 |
+
$('.next-page').on( 'click', function() {
|
106 |
var ewww_search = $('.ewww-search-input').val();
|
107 |
ewww_pointer++;
|
108 |
var ewww_table_data = {
|
115 |
};
|
116 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
117 |
try {
|
118 |
+
var ewww_response = JSON.parse(response);
|
119 |
} catch (err) {
|
120 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
121 |
console.log( response );
|
141 |
$('.first-page').show();
|
142 |
return false;
|
143 |
});
|
144 |
+
$('.prev-page').on( 'click', function() {
|
145 |
var ewww_search = $('.ewww-search-input').val();
|
146 |
ewww_pointer--;
|
147 |
var ewww_table_data = {
|
154 |
};
|
155 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
156 |
try {
|
157 |
+
var ewww_response = JSON.parse(response);
|
158 |
} catch (err) {
|
159 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
160 |
console.log( response );
|
176 |
$('.last-page').show();
|
177 |
return false;
|
178 |
});
|
179 |
+
$('.last-page').on( 'click', function() {
|
180 |
var ewww_search = $('.ewww-search-input').val();
|
181 |
ewww_pointer = ewww_total_pages - 1;
|
182 |
if (ewww_search || ewww_table_debug) {
|
192 |
};
|
193 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
194 |
try {
|
195 |
+
var ewww_response = JSON.parse(response);
|
196 |
} catch (err) {
|
197 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
198 |
console.log( response );
|
212 |
$('.first-page').show();
|
213 |
return false;
|
214 |
});
|
215 |
+
$('.first-page').on( 'click', function() {
|
216 |
ewww_pointer = 0;
|
217 |
var ewww_search = $('.ewww-search-input').val();
|
218 |
var ewww_table_data = {
|
225 |
};
|
226 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
227 |
try {
|
228 |
+
var ewww_response = JSON.parse(response);
|
229 |
} catch (err) {
|
230 |
$('#ewww-bulk-table').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
231 |
console.log( response );
|
250 |
});
|
251 |
return false;
|
252 |
});
|
253 |
+
$('#ewww-clear-table').on( 'submit', function() {
|
254 |
var ewww_table_data = {
|
255 |
action: 'bulk_aux_images_table_clear',
|
256 |
ewww_wpnonce: ewww_vars._wpnonce,
|
265 |
}
|
266 |
return false;
|
267 |
});
|
268 |
+
var ewww_total_originals = 0;
|
269 |
+
var ewww_original_attachments = false;
|
270 |
+
$('#ewww-clean-originals').on( 'submit', function() {
|
271 |
+
if (!confirm(ewww_vars.tool_warning)) {
|
272 |
+
return false;
|
273 |
+
}
|
274 |
+
var ewww_originals_data = {
|
275 |
+
action: 'ewwwio_get_all_attachments',
|
276 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
277 |
+
};
|
278 |
+
$.post(ajaxurl, ewww_originals_data, function(response) {
|
279 |
+
try {
|
280 |
+
ewww_original_attachments = JSON.parse(response);
|
281 |
+
} catch (err) {
|
282 |
+
$('#ewww-clean-originals-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
283 |
+
console.log(err);
|
284 |
+
console.log(response);
|
285 |
+
return false;
|
286 |
+
}
|
287 |
+
ewww_total_originals = ewww_original_attachments.length;
|
288 |
+
$('.ewww-tool-info').hide();
|
289 |
+
$('.ewww-tool-form').hide();
|
290 |
+
$('.ewww-tool-divider').hide();
|
291 |
+
$('#ewww-clean-originals-progressbar').progressbar({ max: ewww_total_originals });
|
292 |
+
$('#ewww-clean-originals-progress').html('<p> 0/' + ewww_total_originals + '</p>');
|
293 |
+
$('#ewww-clean-originals-progressbar').show();
|
294 |
+
$('#ewww-clean-originals-progress').show();
|
295 |
+
ewwwDeleteOriginalByID();
|
296 |
+
});
|
297 |
+
return false;
|
298 |
+
});
|
299 |
+
function ewwwDeleteOriginalByID(){
|
300 |
+
var attachment_id = ewww_original_attachments.pop();
|
301 |
+
var ewww_originals_data = {
|
302 |
+
action: 'bulk_aux_images_delete_original',
|
303 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
304 |
+
attachment_id: attachment_id,
|
305 |
+
};
|
306 |
+
$.post(ajaxurl, ewww_originals_data, function(response) {
|
307 |
+
try {
|
308 |
+
var ewww_response = JSON.parse(response);
|
309 |
+
} catch (err) {
|
310 |
+
$('#ewww-clean-originals-progressbar').hide();
|
311 |
+
$('#ewww-clean-originals-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
312 |
+
console.log(err);
|
313 |
+
console.log(response);
|
314 |
+
return false;
|
315 |
+
}
|
316 |
+
if ( ewww_response.error ) {
|
317 |
+
$('#ewww-clean-originals-progressbar').hide();
|
318 |
+
$('#ewww-clean-originals-progress').html('<span style="color: red"><b>' + ewww_response.error + '</b></span>');
|
319 |
+
return false;
|
320 |
+
}
|
321 |
+
if(!ewww_original_attachments.length) {
|
322 |
+
$('#ewww-clean-originals-progress').html(ewww_vars.finished);
|
323 |
+
return false;
|
324 |
+
}
|
325 |
+
var completed = ewww_total_originals - ewww_original_attachments.length;
|
326 |
+
$('#ewww-clean-originals-progressbar').progressbar("option", "value", completed);
|
327 |
+
$('#ewww-clean-originals-progress').html('<p>' + completed + '/' + ewww_total_originals + '</p>');
|
328 |
+
ewwwDeleteOriginalByID();
|
329 |
+
});
|
330 |
+
}
|
331 |
var ewww_total_converted = 0;
|
332 |
+
$('#ewww-clean-converted').on( 'submit', function() {
|
333 |
var ewww_converted_data = {
|
334 |
action: 'bulk_aux_images_count_converted',
|
335 |
ewww_wpnonce: ewww_vars._wpnonce,
|
336 |
};
|
337 |
$.post(ajaxurl, ewww_converted_data, function(response) {
|
338 |
try {
|
339 |
+
var ewww_response = JSON.parse(response);
|
340 |
} catch (err) {
|
341 |
$('#ewww-clean-converted-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
342 |
console.log( response );
|
350 |
$('#ewww-clean-converted-progress').html('<p> 0/' + ewww_total_converted + '</p>');
|
351 |
$('#ewww-clean-converted-progressbar').show();
|
352 |
$('#ewww-clean-converted-progress').show();
|
353 |
+
ewwwCleanConvertedOriginals(0);
|
354 |
});
|
355 |
return false;
|
356 |
});
|
357 |
+
function ewwwCleanConvertedOriginals(converted_offset){
|
358 |
var ewww_converted_data = {
|
359 |
action: 'bulk_aux_images_converted_clean',
|
360 |
ewww_wpnonce: ewww_vars._wpnonce,
|
381 |
converted_offset += ewww_response.completed;
|
382 |
$('#ewww-clean-converted-progressbar').progressbar("option", "value", converted_offset);
|
383 |
$('#ewww-clean-converted-progress').html('<p>' + converted_offset + '/' + ewww_total_converted + '</p>');
|
384 |
+
ewwwCleanConvertedOriginals(converted_offset);
|
385 |
});
|
386 |
}
|
387 |
var ewww_total_webp = 0;
|
388 |
var ewww_webp_attachments = false;
|
389 |
+
$('#ewww-clean-webp').on( 'submit', function() {
|
390 |
var ewww_webp_data = {
|
391 |
action: 'ewwwio_get_all_attachments',
|
392 |
ewww_wpnonce: ewww_vars._wpnonce,
|
480 |
ewwwRemoveWebP(webp_offset);
|
481 |
});
|
482 |
}
|
483 |
+
$('#ewww-clean-table').on( 'submit', function() {
|
484 |
ewww_total_pages = Math.ceil(ewww_vars.image_count / 500);
|
485 |
$('.ewww-tool-info').hide();
|
486 |
$('.ewww-tool-form').hide();
|
502 |
};
|
503 |
$.post(ajaxurl, ewww_table_data, function(response) {
|
504 |
try {
|
505 |
+
var ewww_response = JSON.parse(response);
|
506 |
} catch (err) {
|
507 |
$('#ewww-clean-table-progressbar').hide();
|
508 |
$('#ewww-clean-table-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
524 |
ewwwCleanup(total_pages);
|
525 |
});
|
526 |
}
|
527 |
+
$('#ewww-clean-meta').on( 'submit', function() {
|
528 |
$('.ewww-tool-info').hide();
|
529 |
$('.ewww-tool-form').hide();
|
530 |
$('.ewww-tool-divider').hide();
|
544 |
};
|
545 |
$.post(ajaxurl, ewww_cleanmeta_data, function(response) {
|
546 |
try {
|
547 |
+
var ewww_response = JSON.parse(response);
|
548 |
} catch (err) {
|
549 |
$('#ewww-clean-meta-progressbar').hide();
|
550 |
$('#ewww-clean-meta-progress').html('<span style="color: red"><b>' + ewww_vars.invalid_response + '</b></span>');
|
570 |
ewwwCleanupMeta();
|
571 |
});
|
572 |
}
|
573 |
+
$('.ewww-aux-table').on( 'click', '.ewww-remove-image', function() {
|
574 |
+
var imageID = $(this).data('id');
|
575 |
+
var ewww_image_removal = {
|
576 |
+
action: 'bulk_aux_images_remove',
|
577 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
578 |
+
ewww_image_id: imageID,
|
579 |
+
};
|
580 |
+
$.post(ajaxurl, ewww_image_removal, function(response) {
|
581 |
+
if(response == '1') {
|
582 |
+
$('#ewww-image-' + imageID).remove();
|
583 |
+
var ewww_prev_count = ewww_vars.image_count;
|
584 |
+
ewww_vars.image_count--;
|
585 |
+
ewww_vars.count_string = ewww_vars.count_string.replace( ewww_prev_count, ewww_vars.image_count );
|
586 |
+
$('.displaying-num').text(ewww_vars.count_string);
|
587 |
+
} else {
|
588 |
+
alert(ewww_vars.remove_failed);
|
589 |
+
}
|
590 |
+
});
|
591 |
+
return false;
|
592 |
});
|
593 |
+
$('.ewww-aux-table').on( 'click', '.ewww-restore-image', function() {
|
594 |
+
var imageID = $(this).data('id');
|
595 |
+
var ewww_image_restore = {
|
596 |
+
action: 'ewww_manual_cloud_restore_single',
|
597 |
+
ewww_wpnonce: ewww_vars._wpnonce,
|
598 |
+
ewww_image_id: imageID,
|
599 |
+
};
|
600 |
+
var original_html = $('#ewww-image-' + imageID + ' td:last-child').html();
|
601 |
+
$('#ewww-image-' + imageID + ' td:last-child').html(ewww_vars.restoring);
|
602 |
+
$.post(ajaxurl, ewww_image_restore, function(response) {
|
603 |
+
var is_json = true;
|
604 |
+
try {
|
605 |
+
var ewww_response = JSON.parse(response);
|
606 |
+
} catch (err) {
|
607 |
+
alert( ewww_vars.invalid_response );
|
608 |
+
console.log( response );
|
609 |
+
return false;
|
610 |
+
}
|
611 |
+
if ( ewww_response.success == '1') {
|
612 |
+
$('#ewww-image-' + imageID + ' td:last-child').html(ewww_vars.original_restored);
|
613 |
+
} else if (ewww_response.error) {
|
614 |
+
$('#ewww-image-' + imageID + ' td:last-child').html(original_html);
|
615 |
+
alert(ewww_response.error);
|
616 |
+
}
|
617 |
+
});
|
618 |
+
return false;
|
|
|
|
|
|
|
619 |
});
|
620 |
+
});
|
includes/eio.js
DELETED
@@ -1,725 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
var ewww_error_counter = 30;
|
3 |
-
$('#ewww-copy-debug').click(function() {
|
4 |
-
selectText('ewww-debug-info');
|
5 |
-
try {
|
6 |
-
var successful = document.execCommand('copy');
|
7 |
-
if ( successful ) {
|
8 |
-
unselectText();
|
9 |
-
}
|
10 |
-
} catch(err) {
|
11 |
-
console.log('browser cannot copy');
|
12 |
-
console.log(err);
|
13 |
-
}
|
14 |
-
});
|
15 |
-
$('.ewww-hndle').click(function() {
|
16 |
-
$(this).next('.inside').toggle();
|
17 |
-
var button = $(this).prev('.button-link');
|
18 |
-
if ('true' == button.attr('aria-expanded')) {
|
19 |
-
button.attr('aria-expanded', 'false');
|
20 |
-
button.closest('.postbox').addClass('closed');
|
21 |
-
button.children('.toggle-indicator').attr('aria-hidden', 'true');
|
22 |
-
} else {
|
23 |
-
button.attr('aria-expanded', 'true');
|
24 |
-
button.closest('.postbox').removeClass('closed');
|
25 |
-
button.children('.toggle-indicator').attr('aria-hidden', 'false');
|
26 |
-
}
|
27 |
-
});
|
28 |
-
$('.ewww-handlediv').click(function() {
|
29 |
-
$(this).parent().children('.inside').toggle();
|
30 |
-
if ('true' == $(this).attr('aria-expanded')) {
|
31 |
-
$(this).attr('aria-expanded', 'false');
|
32 |
-
$(this).closest('.postbox').addClass('closed');
|
33 |
-
$(this).children('.toggle-indicator').attr('aria-hidden', 'true');
|
34 |
-
} else {
|
35 |
-
$(this).attr('aria-expanded', 'true');
|
36 |
-
$(this).closest('.postbox').removeClass('closed');
|
37 |
-
$(this).children('.toggle-indicator').attr('aria-hidden', 'false');
|
38 |
-
}
|
39 |
-
});
|
40 |
-
function HSregister() {
|
41 |
-
if (typeof(Beacon) !== 'undefined' ) {
|
42 |
-
$('.ewww-overrides-nav').click(function() {
|
43 |
-
event.preventDefault();
|
44 |
-
Beacon('article', '59710ce4042863033a1b45a6', { type: 'modal' });
|
45 |
-
});
|
46 |
-
$('.ewww-docs-root').click(function() {
|
47 |
-
event.preventDefault();
|
48 |
-
Beacon('navigate', '/answers/')
|
49 |
-
Beacon('open');
|
50 |
-
});
|
51 |
-
$('.ewww-help-beacon-multi').click(function() {
|
52 |
-
var hsids = $(this).attr('data-beacon-articles');
|
53 |
-
hsids = hsids.split(',');
|
54 |
-
event.preventDefault();
|
55 |
-
Beacon('suggest', hsids);
|
56 |
-
Beacon('navigate', '/answers/');
|
57 |
-
Beacon('open');
|
58 |
-
});
|
59 |
-
$('.ewww-help-beacon-single').click(function() {
|
60 |
-
var hsid = $(this).attr('data-beacon-article');
|
61 |
-
event.preventDefault();
|
62 |
-
Beacon('article', hsid, { type: 'modal' });
|
63 |
-
});
|
64 |
-
}
|
65 |
-
}
|
66 |
-
HSregister();
|
67 |
-
if (!ewww_vars.scan_fail) {
|
68 |
-
function removeQueryArg(url) {
|
69 |
-
return url.split('?')[0];
|
70 |
-
}
|
71 |
-
$('#ewww-webp-rewrite #ewww-webp-insert').click(function() {
|
72 |
-
var ewww_webp_rewrite_action = 'ewww_webp_rewrite';
|
73 |
-
var ewww_webp_rewrite_data = {
|
74 |
-
action: ewww_webp_rewrite_action,
|
75 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
76 |
-
};
|
77 |
-
$.post(ajaxurl, ewww_webp_rewrite_data, function(response) {
|
78 |
-
$('#ewww-webp-rewrite-status').html('<b>' + response + '</b>');
|
79 |
-
ewww_webp_image = document.getElementById("webp-image").src;
|
80 |
-
document.getElementById("webp-image").src = removeQueryArg(ewww_webp_image) + '?m=' + new Date().getTime();
|
81 |
-
});
|
82 |
-
return false;
|
83 |
-
});
|
84 |
-
$('#ewww-webp-rewrite #ewww-webp-remove').click(function() {
|
85 |
-
var ewww_webp_rewrite_action = 'ewww_webp_unwrite';
|
86 |
-
var ewww_webp_rewrite_data = {
|
87 |
-
action: ewww_webp_rewrite_action,
|
88 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
89 |
-
};
|
90 |
-
$.post(ajaxurl, ewww_webp_rewrite_data, function(response) {
|
91 |
-
$('#ewww-webp-rewrite-status').html('<b>' + response + '</b>');
|
92 |
-
ewww_webp_image = document.getElementById("webp-image").src;
|
93 |
-
document.getElementById("webp-image").src = removeQueryArg(ewww_webp_image) + '?m' + new Date().getTime();
|
94 |
-
});
|
95 |
-
return false;
|
96 |
-
});
|
97 |
-
$('#ewww-webp-settings').hide();
|
98 |
-
if (exactdn_enabled) {
|
99 |
-
$('#ewww-exactdn-settings').show();
|
100 |
-
$('#ewww-general-settings').hide();
|
101 |
-
$('li.ewww-exactdn-nav').addClass('ewww-selected');
|
102 |
-
} else {
|
103 |
-
$('#ewww-exactdn-settings').hide();
|
104 |
-
$('#ewww-general-settings').show();
|
105 |
-
$('li.ewww-general-nav').addClass('ewww-selected');
|
106 |
-
}
|
107 |
-
if($('#ewww_image_optimizer_debug').length){
|
108 |
-
$('#ewww-resize-settings').hide();
|
109 |
-
console.log($('#ewww_image_optimizer_debug').length);
|
110 |
-
}
|
111 |
-
$('#ewww-optimization-settings').hide();
|
112 |
-
$('#ewww-conversion-settings').hide();
|
113 |
-
$('#ewww-support-settings').hide();
|
114 |
-
$('#ewww-contribute-settings').hide();
|
115 |
-
$('.ewww-webp-nav').click(function() {
|
116 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
117 |
-
$('li.ewww-webp-nav').addClass('ewww-selected');
|
118 |
-
$('.ewww-tab a').blur();
|
119 |
-
$('#ewww-webp-settings').show();
|
120 |
-
$('#ewww-general-settings').hide();
|
121 |
-
$('#ewww-exactdn-settings').hide();
|
122 |
-
$('#ewww-optimization-settings').hide();
|
123 |
-
$('#ewww-resize-settings').hide();
|
124 |
-
$('#ewww-conversion-settings').hide();
|
125 |
-
$('#ewww-support-settings').hide();
|
126 |
-
$('#ewww-contribute-settings').hide();
|
127 |
-
});
|
128 |
-
$('.ewww-general-nav').click(function() {
|
129 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
130 |
-
$('li.ewww-general-nav').addClass('ewww-selected');
|
131 |
-
$('.ewww-tab a').blur();
|
132 |
-
$('#ewww-webp-settings').hide();
|
133 |
-
$('#ewww-general-settings').show();
|
134 |
-
$('#ewww-exactdn-settings').hide();
|
135 |
-
$('#ewww-optimization-settings').hide();
|
136 |
-
$('#ewww-resize-settings').hide();
|
137 |
-
$('#ewww-conversion-settings').hide();
|
138 |
-
$('#ewww-support-settings').hide();
|
139 |
-
$('#ewww-contribute-settings').hide();
|
140 |
-
});
|
141 |
-
$('.ewww-exactdn-nav').click(function() {
|
142 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
143 |
-
$('li.ewww-exactdn-nav').addClass('ewww-selected');
|
144 |
-
$('.ewww-tab a').blur();
|
145 |
-
$('#ewww-webp-settings').hide();
|
146 |
-
$('#ewww-general-settings').hide();
|
147 |
-
$('#ewww-exactdn-settings').show();
|
148 |
-
$('#ewww-optimization-settings').hide();
|
149 |
-
$('#ewww-resize-settings').hide();
|
150 |
-
$('#ewww-conversion-settings').hide();
|
151 |
-
$('#ewww-support-settings').hide();
|
152 |
-
$('#ewww-contribute-settings').hide();
|
153 |
-
});
|
154 |
-
$('.ewww-optimization-nav').click(function() {
|
155 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
156 |
-
$('li.ewww-optimization-nav').addClass('ewww-selected');
|
157 |
-
$('.ewww-tab a').blur();
|
158 |
-
$('#ewww-webp-settings').hide();
|
159 |
-
$('#ewww-general-settings').hide();
|
160 |
-
$('#ewww-exactdn-settings').hide();
|
161 |
-
$('#ewww-optimization-settings').show();
|
162 |
-
$('#ewww-resize-settings').hide();
|
163 |
-
$('#ewww-conversion-settings').hide();
|
164 |
-
$('#ewww-support-settings').hide();
|
165 |
-
$('#ewww-contribute-settings').hide();
|
166 |
-
});
|
167 |
-
$('.ewww-resize-nav').click(function() {
|
168 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
169 |
-
$('li.ewww-resize-nav').addClass('ewww-selected');
|
170 |
-
$('.ewww-tab a').blur();
|
171 |
-
$('#ewww-webp-settings').hide();
|
172 |
-
$('#ewww-general-settings').hide();
|
173 |
-
$('#ewww-exactdn-settings').hide();
|
174 |
-
$('#ewww-optimization-settings').hide();
|
175 |
-
$('#ewww-resize-settings').show();
|
176 |
-
$('#ewww-conversion-settings').hide();
|
177 |
-
$('#ewww-support-settings').hide();
|
178 |
-
$('#ewww-contribute-settings').hide();
|
179 |
-
});
|
180 |
-
$('.ewww-conversion-nav').click(function() {
|
181 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
182 |
-
$('li.ewww-conversion-nav').addClass('ewww-selected');
|
183 |
-
$('.ewww-tab a').blur();
|
184 |
-
$('#ewww-webp-settings').hide();
|
185 |
-
$('#ewww-general-settings').hide();
|
186 |
-
$('#ewww-exactdn-settings').hide();
|
187 |
-
$('#ewww-optimization-settings').hide();
|
188 |
-
$('#ewww-resize-settings').hide();
|
189 |
-
$('#ewww-conversion-settings').show();
|
190 |
-
$('#ewww-support-settings').hide();
|
191 |
-
$('#ewww-contribute-settings').hide();
|
192 |
-
});
|
193 |
-
$('.ewww-support-nav').click(function() {
|
194 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
195 |
-
$('li.ewww-support-nav').addClass('ewww-selected');
|
196 |
-
$('.ewww-tab a').blur();
|
197 |
-
$('#ewww-webp-settings').hide();
|
198 |
-
$('#ewww-general-settings').hide();
|
199 |
-
$('#ewww-exactdn-settings').hide();
|
200 |
-
$('#ewww-optimization-settings').hide();
|
201 |
-
$('#ewww-resize-settings').hide();
|
202 |
-
$('#ewww-conversion-settings').hide();
|
203 |
-
$('#ewww-support-settings').show();
|
204 |
-
$('#ewww-contribute-settings').hide();
|
205 |
-
});
|
206 |
-
$('.ewww-contribute-nav').click(function() {
|
207 |
-
$('.ewww-tab-nav li').removeClass('ewww-selected');
|
208 |
-
$('li.ewww-contribute-nav').addClass('ewww-selected');
|
209 |
-
$('.ewww-tab a').blur();
|
210 |
-
$('#ewww-webp-settings').hide();
|
211 |
-
$('#ewww-general-settings').hide();
|
212 |
-
$('#ewww-exactdn-settings').hide();
|
213 |
-
$('#ewww-optimization-settings').hide();
|
214 |
-
$('#ewww-resize-settings').hide();
|
215 |
-
$('#ewww-conversion-settings').hide();
|
216 |
-
$('#ewww-support-settings').hide();
|
217 |
-
$('#ewww-contribute-settings').show();
|
218 |
-
});
|
219 |
-
$('.ewww-guage').tooltip({
|
220 |
-
items: '.ewww-guage',
|
221 |
-
content: function() {
|
222 |
-
return $(this).next('.ewww-recommend').html();
|
223 |
-
},
|
224 |
-
open: function( event, ui ) {
|
225 |
-
HSregister();
|
226 |
-
},
|
227 |
-
close: function(event, ui) {
|
228 |
-
ui.tooltip.hover(function() {
|
229 |
-
$(this).stop(true).fadeTo(400, 1);
|
230 |
-
},
|
231 |
-
function() {
|
232 |
-
$(this).fadeOut('400', function() {
|
233 |
-
$(this).remove();
|
234 |
-
});
|
235 |
-
});
|
236 |
-
},
|
237 |
-
});
|
238 |
-
return false;
|
239 |
-
} else {
|
240 |
-
$(function() {
|
241 |
-
$("#ewww-delay-slider").slider({
|
242 |
-
min: 0,
|
243 |
-
max: 30,
|
244 |
-
value: $("#ewww-delay").val(),
|
245 |
-
slide: function(event, ui) {
|
246 |
-
$("#ewww-delay").val(ui.value);
|
247 |
-
}
|
248 |
-
});
|
249 |
-
});
|
250 |
-
var ewwwdelayinput = document.getElementById("ewww-delay");
|
251 |
-
if (ewwwdelayinput) {
|
252 |
-
ewwwdelayinput.onblur = function() {
|
253 |
-
if (isNaN(this.value)) {
|
254 |
-
this.value = 0;
|
255 |
-
} else {
|
256 |
-
this.value = Math.ceil(this.value);
|
257 |
-
}
|
258 |
-
};
|
259 |
-
}
|
260 |
-
var ewww_attachments = ewww_vars.attachments;
|
261 |
-
var ewww_i = 0;
|
262 |
-
var ewww_k = 0;
|
263 |
-
var ewww_import_total = 0;
|
264 |
-
var ewww_force = 0;
|
265 |
-
var ewww_force_smart = 0;
|
266 |
-
var ewww_webp_only = 0;
|
267 |
-
var ewww_delay = 0;
|
268 |
-
var ewww_batch_limit = 0;
|
269 |
-
var ewww_aux = false;
|
270 |
-
var ewww_main = false;
|
271 |
-
var ewww_quota_update = 0;
|
272 |
-
var ewww_scan_failures = 0;
|
273 |
-
var ewww_bulk_start_time = 0;
|
274 |
-
var ewww_bulk_elapsed_time = 0;
|
275 |
-
var ewww_time_per_image = 0;
|
276 |
-
var ewww_time_remaining = 0;
|
277 |
-
var ewww_days_remaining = 0;
|
278 |
-
var ewww_hours_remaining = 0;
|
279 |
-
var ewww_minutes_remaining = 0;
|
280 |
-
var ewww_seconds_remaining = 0;
|
281 |
-
var ewww_countdown = false;
|
282 |
-
var ewww_tiny_skip = '';
|
283 |
-
// initialize the ajax actions for the appropriate bulk page
|
284 |
-
var ewww_quota_update_data = {
|
285 |
-
action: 'bulk_quota_update',
|
286 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
287 |
-
};
|
288 |
-
if (ewww_vars.gallery == 'flag') {
|
289 |
-
var ewww_init_action = 'bulk_flag_init';
|
290 |
-
var ewww_loop_action = 'bulk_flag_loop';
|
291 |
-
var ewww_cleanup_action = 'bulk_flag_cleanup';
|
292 |
-
} else if (ewww_vars.gallery == 'nextgen') {
|
293 |
-
var ewww_preview_action = 'bulk_ngg_preview';
|
294 |
-
var ewww_init_action = 'bulk_ngg_init';
|
295 |
-
var ewww_loop_action = 'bulk_ngg_loop';
|
296 |
-
var ewww_cleanup_action = 'bulk_ngg_cleanup';
|
297 |
-
} else {
|
298 |
-
var ewww_scan_action = 'bulk_scan';
|
299 |
-
var ewww_init_action = 'bulk_init';
|
300 |
-
var ewww_loop_action = 'bulk_loop';
|
301 |
-
var ewww_cleanup_action = 'bulk_cleanup';
|
302 |
-
ewww_main = true;
|
303 |
-
}
|
304 |
-
var ewww_init_data = {
|
305 |
-
action: ewww_init_action,
|
306 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
307 |
-
};
|
308 |
-
var ewww_table_action = 'bulk_aux_images_table';
|
309 |
-
var ewww_table_count_action = 'bulk_aux_images_table_count';
|
310 |
-
var ewww_import_init_action = 'bulk_import_init';
|
311 |
-
var ewww_import_loop_action = 'bulk_import_loop';
|
312 |
-
$(document).on('click', '.ewww-show-debug-meta', function() {
|
313 |
-
var post_id = $(this).data('id');
|
314 |
-
$('.ewww-debug-meta-' + post_id).toggle();
|
315 |
-
});
|
316 |
-
$('#ewww-aux-start').submit(function() {
|
317 |
-
ewww_aux = true;
|
318 |
-
if ($('#ewww-force:checkbox:checked').val()) {
|
319 |
-
ewww_force = 1;
|
320 |
-
}
|
321 |
-
if ($('#ewww-force-smart:checkbox:checked').val()) {
|
322 |
-
ewww_force_smart = 1;
|
323 |
-
}
|
324 |
-
if ($('#ewww-webp-only:checkbox:checked').val()) {
|
325 |
-
ewww_webp_only = 1;
|
326 |
-
}
|
327 |
-
$('#ewww-aux-start').hide();
|
328 |
-
$('.ewww-bulk-info').hide();
|
329 |
-
$('.ewww-aux-table').hide();
|
330 |
-
$('#ewww-show-table').hide();
|
331 |
-
$('#ewww-scanning').show();
|
332 |
-
ewwwStartScan();
|
333 |
-
return false;
|
334 |
-
});
|
335 |
-
function ewwwStartScan() {
|
336 |
-
var ewww_scan_data = {
|
337 |
-
action: ewww_scan_action,
|
338 |
-
ewww_force: ewww_force,
|
339 |
-
ewww_force_smart: ewww_force_smart,
|
340 |
-
ewww_webp_only: ewww_webp_only,
|
341 |
-
ewww_scan: true,
|
342 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
343 |
-
};
|
344 |
-
$.post(ajaxurl, ewww_scan_data, function(response) {
|
345 |
-
var is_json = true;
|
346 |
-
try {
|
347 |
-
var ewww_response = $.parseJSON(response);
|
348 |
-
} catch (err) {
|
349 |
-
is_json = false;
|
350 |
-
}
|
351 |
-
if ( ! is_json ) {
|
352 |
-
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_vars.invalid_response + '</b></span>');
|
353 |
-
console.log( response );
|
354 |
-
return false;
|
355 |
-
}
|
356 |
-
ewww_init_data = {
|
357 |
-
action: ewww_init_action,
|
358 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
359 |
-
};
|
360 |
-
if ( ewww_response.error ) {
|
361 |
-
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_response.error + '</b></span>');
|
362 |
-
} else if ( ewww_response.remaining ) {
|
363 |
-
$('.ewww-aux-table').hide();
|
364 |
-
$('#ewww-show-table').hide();
|
365 |
-
//if ( ! ewww_response.notice ) {
|
366 |
-
// ewww_response.notice = '';
|
367 |
-
//}
|
368 |
-
$('#ewww-scanning').html( ewww_response.remaining );
|
369 |
-
if ( ewww_response.notice ) {
|
370 |
-
$('#ewww-scanning').append( '<br>' + ewww_response.notice );
|
371 |
-
}
|
372 |
-
if ( ewww_response.tiny_skip ) {
|
373 |
-
$('#ewww-scanning').append( '<br>' + ewww_response.tiny_skip );
|
374 |
-
ewww_tiny_skip = ewww_response.tiny_skip;
|
375 |
-
console.log( 'skipped some tiny images' );
|
376 |
-
}
|
377 |
-
if ( ewww_response.bad_attachment ) {
|
378 |
-
$('#ewww-scanning').append( '<br>' + ewww_vars.bad_attachment + ' ' + ewww_response.bad_attachment );
|
379 |
-
}
|
380 |
-
ewww_scan_failures = 0;
|
381 |
-
ewwwStartScan();
|
382 |
-
} else if ( ewww_response.ready ) {
|
383 |
-
ewww_attachments = ewww_response.ready;
|
384 |
-
$('#ewww-scanning').html(ewww_response.message);
|
385 |
-
if ( ewww_tiny_skip ) {
|
386 |
-
$('#ewww-scanning').append( '<br><i>' + ewww_tiny_skip + '</i>' );
|
387 |
-
console.log( 'done, skipped some tiny images' );
|
388 |
-
}
|
389 |
-
$('#ewww-bulk-first').val(ewww_response.start_button);
|
390 |
-
$('#ewww-bulk-start').show();
|
391 |
-
} else if ( ewww_response.ready === 0 ) {
|
392 |
-
$('#ewww-scanning').hide();
|
393 |
-
$('#ewww-nothing').show();
|
394 |
-
if ( ewww_tiny_skip ) {
|
395 |
-
$('#ewww-nothing').append( '<br><i>' + ewww_tiny_skip + '</i>' );
|
396 |
-
console.log( 'done, skipped some tiny images' );
|
397 |
-
}
|
398 |
-
}
|
399 |
-
})
|
400 |
-
.fail(function() {
|
401 |
-
ewww_scan_failures++;
|
402 |
-
if (ewww_scan_failures > 10) {
|
403 |
-
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_vars.scan_fail + ':</b> ' + ewww_vars.bulk_fail_more + '</span>');
|
404 |
-
} else {
|
405 |
-
$('#ewww-scanning').html('<span class="ewww-bulk-error"><b>' + ewww_vars.scan_incomplete + '</b></span>');
|
406 |
-
setTimeout(function() {
|
407 |
-
ewwwStartScan();
|
408 |
-
}, 1000);
|
409 |
-
}
|
410 |
-
});
|
411 |
-
}
|
412 |
-
$('#ewww-bulk-start').submit(function() {
|
413 |
-
ewwwStartOpt();
|
414 |
-
return false;
|
415 |
-
});
|
416 |
-
}
|
417 |
-
function ewwwUpdateQuota() {
|
418 |
-
if ($('#ewww-bulk-credits-available').length > 0) {
|
419 |
-
ewww_quota_update_data.ewww_wpnonce = ewww_vars._wpnonce;
|
420 |
-
$.post(ajaxurl, ewww_quota_update_data, function(response) {
|
421 |
-
$('#ewww-bulk-credits-available').html(response);
|
422 |
-
});
|
423 |
-
}
|
424 |
-
}
|
425 |
-
function ewwwStartOpt () {
|
426 |
-
ewww_k = 0;
|
427 |
-
ewww_quota_update = setInterval( ewwwUpdateQuota, 60000 );
|
428 |
-
$('#ewww-bulk-stop').submit(function() {
|
429 |
-
ewww_k = 9;
|
430 |
-
$('#ewww-bulk-stop').hide();
|
431 |
-
return false;
|
432 |
-
});
|
433 |
-
if ( ! $('#ewww-delay').val().match( /^[1-9][0-9]*$/) ) {
|
434 |
-
ewww_delay = 0;
|
435 |
-
} else {
|
436 |
-
ewww_delay = $('#ewww-delay').val();
|
437 |
-
}
|
438 |
-
if (ewww_delay) {
|
439 |
-
ewww_batch_limit = 1;
|
440 |
-
$('#ewww-bulk-last h2').html( ewww_vars.last_image_header );
|
441 |
-
}
|
442 |
-
$('.ewww-aux-table').hide();
|
443 |
-
$('#ewww-bulk-stop').show();
|
444 |
-
$('.ewww-bulk-form').hide();
|
445 |
-
$('.ewww-bulk-info').hide();
|
446 |
-
$('#ewww-bulk-forms').hide();
|
447 |
-
$('h2').hide();
|
448 |
-
$.post(ajaxurl, ewww_init_data, function(response) {
|
449 |
-
var is_json = true;
|
450 |
-
try {
|
451 |
-
var ewww_init_response = $.parseJSON(response);
|
452 |
-
} catch (err) {
|
453 |
-
is_json = false;
|
454 |
-
}
|
455 |
-
if ( ! is_json || ! response ) {
|
456 |
-
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_vars.invalid_response + '</b></p>');
|
457 |
-
console.log( response );
|
458 |
-
return false;
|
459 |
-
}
|
460 |
-
if ( ewww_init_response.error ) {
|
461 |
-
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_init_response.error + '</b></p>');
|
462 |
-
if ( ewww_init_response.data ) {
|
463 |
-
console.log( ewww_init_response.data );
|
464 |
-
}
|
465 |
-
} else {
|
466 |
-
if ( ewww_init_response.start_time ) {
|
467 |
-
ewww_bulk_start_time = ewww_init_response.start_time;
|
468 |
-
}
|
469 |
-
$('#ewww-bulk-loading').html(ewww_init_response.results);
|
470 |
-
$('#ewww-bulk-progressbar').progressbar({ max: ewww_attachments });
|
471 |
-
$('#ewww-bulk-counter').html( ewww_vars.optimized + ' 0/' + ewww_attachments);
|
472 |
-
ewwwProcessImage();
|
473 |
-
}
|
474 |
-
});
|
475 |
-
}
|
476 |
-
function ewwwProcessImage() {
|
477 |
-
if ($('#ewww-force:checkbox:checked').val()) {
|
478 |
-
ewww_force = 1;
|
479 |
-
}
|
480 |
-
if ($('#ewww-force-smart:checkbox:checked').val()) {
|
481 |
-
ewww_force_smart = 1;
|
482 |
-
}
|
483 |
-
if ($('#ewww-webp-only:checkbox:checked').val()) {
|
484 |
-
ewww_webp_only = 1;
|
485 |
-
}
|
486 |
-
var ewww_loop_data = {
|
487 |
-
action: ewww_loop_action,
|
488 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
489 |
-
ewww_force: ewww_force,
|
490 |
-
ewww_force_smart: ewww_force_smart,
|
491 |
-
ewww_webp_only: ewww_webp_only,
|
492 |
-
ewww_batch_limit: ewww_batch_limit,
|
493 |
-
ewww_error_counter: ewww_error_counter,
|
494 |
-
};
|
495 |
-
var ewww_jqxhr = $.post(ajaxurl, ewww_loop_data, function(response) {
|
496 |
-
var is_json = true;
|
497 |
-
try {
|
498 |
-
var ewww_response = $.parseJSON(response);
|
499 |
-
} catch (err) {
|
500 |
-
is_json = false;
|
501 |
-
}
|
502 |
-
if ( ! is_json || ! response ) {
|
503 |
-
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_vars.invalid_response + '</b></p>');
|
504 |
-
clearInterval(ewww_quota_update);
|
505 |
-
clearInterval(ewww_countdown);
|
506 |
-
if ( ! response ) {
|
507 |
-
console.log( 'empty response' );
|
508 |
-
} else {
|
509 |
-
console.log( response );
|
510 |
-
}
|
511 |
-
return false;
|
512 |
-
}
|
513 |
-
ewww_i += ewww_response.completed;
|
514 |
-
$('#ewww-bulk-progressbar').progressbar( "option", "value", ewww_i );
|
515 |
-
$('#ewww-bulk-counter').html(ewww_vars.optimized + ' ' + ewww_i + '/' + ewww_attachments);
|
516 |
-
if ( ewww_response.update_meta ) {
|
517 |
-
var ewww_updatemeta_data = {
|
518 |
-
action: 'ewww_bulk_update_meta',
|
519 |
-
attachment_id: ewww_response.update_meta,
|
520 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
521 |
-
};
|
522 |
-
$.post(ajaxurl, ewww_updatemeta_data);
|
523 |
-
}
|
524 |
-
if ( ewww_response.error ) {
|
525 |
-
$('#ewww-bulk-loading img').hide();
|
526 |
-
$('#ewww-bulk-progressbar').hide();
|
527 |
-
$('#ewww-bulk-timer').hide();
|
528 |
-
$('#ewww-bulk-counter').hide();
|
529 |
-
$('#ewww-bulk-stop').hide();
|
530 |
-
$('#ewww-bulk-loading').append('<p class="ewww-bulk-error"><b>' + ewww_response.error + '</b></p>');
|
531 |
-
clearInterval(ewww_quota_update);
|
532 |
-
clearInterval(ewww_countdown);
|
533 |
-
ewwwUpdateQuota();
|
534 |
-
}
|
535 |
-
else if (ewww_k == 9) {
|
536 |
-
if ( ewww_response.results ) {
|
537 |
-
$('#ewww-bulk-last .inside').html( ewww_response.results );
|
538 |
-
$('#ewww-bulk-status .inside').append( ewww_response.results );
|
539 |
-
}
|
540 |
-
clearInterval(ewww_quota_update);
|
541 |
-
clearInterval(ewww_countdown);
|
542 |
-
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.operation_stopped + '</b></p>');
|
543 |
-
}
|
544 |
-
else if ( response == 0 ) {
|
545 |
-
clearInterval(ewww_quota_update);
|
546 |
-
clearInterval(ewww_countdown);
|
547 |
-
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.operation_stopped + '</b></p>');
|
548 |
-
}
|
549 |
-
else if ( ewww_i < ewww_attachments && ! ewww_response.done ) {
|
550 |
-
if ( ewww_bulk_start_time && ewww_response.current_time ) {
|
551 |
-
ewww_bulk_elapsed_time = ewww_response.current_time - ewww_bulk_start_time;
|
552 |
-
ewww_time_per_image = ewww_bulk_elapsed_time / ewww_i;
|
553 |
-
ewww_time_remaining = Math.floor((ewww_attachments - ewww_i) * ewww_time_per_image);
|
554 |
-
ewwwTimeIncrementsUpdate();
|
555 |
-
if ( ! ewww_countdown) {
|
556 |
-
$('#ewww-bulk-timer').html(ewww_days_remaining + ':' + ewww_hours_remaining + ':' + ewww_minutes_remaining + ':' + ewww_seconds_remaining + ' ' + ewww_vars.time_remaining);
|
557 |
-
ewww_countdown = setInterval( ewwwCountDown, 1000 );
|
558 |
-
}
|
559 |
-
}
|
560 |
-
$('#ewww-bulk-widgets').show();
|
561 |
-
$('#ewww-bulk-status h2').show();
|
562 |
-
$('#ewww-bulk-last h2').show();
|
563 |
-
if ( ewww_response.results ) {
|
564 |
-
$('#ewww-bulk-last .inside').html( ewww_response.results );
|
565 |
-
$('#ewww-bulk-status .inside').append( ewww_response.results );
|
566 |
-
}
|
567 |
-
if ( ewww_response.next_file ) {
|
568 |
-
$('#ewww-bulk-loading').html(ewww_response.next_file);
|
569 |
-
}
|
570 |
-
if ( ewww_response.new_nonce ) {
|
571 |
-
ewww_vars._wpnonce = ewww_response.new_nonce;
|
572 |
-
}
|
573 |
-
ewww_error_counter = 30;
|
574 |
-
setTimeout(ewwwProcessImage, ewww_delay * 1000);
|
575 |
-
}
|
576 |
-
else {
|
577 |
-
if ( ewww_response.results ) {
|
578 |
-
$('#ewww-bulk-widgets').show();
|
579 |
-
$('#ewww-bulk-status h2').show();
|
580 |
-
$('#ewww-bulk-status .inside').append( ewww_response.results );
|
581 |
-
}
|
582 |
-
var ewww_cleanup_data = {
|
583 |
-
action: ewww_cleanup_action,
|
584 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
585 |
-
};
|
586 |
-
$.post(ajaxurl, ewww_cleanup_data, function(response) {
|
587 |
-
$('#ewww-bulk-loading').html(response);
|
588 |
-
$('#ewww-bulk-stop').hide();
|
589 |
-
$('#ewww-bulk-last').hide();
|
590 |
-
ewwwAuxCleanup();
|
591 |
-
});
|
592 |
-
}
|
593 |
-
})
|
594 |
-
.fail(function() {
|
595 |
-
if (ewww_error_counter == 0) {
|
596 |
-
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.operation_interrupted + ':</b> ' + ewww_vars.bulk_fail_more + '</p>');
|
597 |
-
} else {
|
598 |
-
$('#ewww-bulk-loading').html('<p class="ewww-bulk-error"><b>' + ewww_vars.temporary_failure + ' ' + ewww_error_counter + ' (' + ewww_vars.bulk_fail_more + ')</b></p>');
|
599 |
-
ewww_error_counter--;
|
600 |
-
setTimeout(function() {
|
601 |
-
ewwwProcessImage();
|
602 |
-
}, 1000);
|
603 |
-
}
|
604 |
-
});
|
605 |
-
}
|
606 |
-
function ewwwAuxCleanup() {
|
607 |
-
if (ewww_main == true) {
|
608 |
-
clearInterval(ewww_quota_update);
|
609 |
-
clearInterval(ewww_countdown);
|
610 |
-
var ewww_table_count_data = {
|
611 |
-
action: ewww_table_count_action,
|
612 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
613 |
-
ewww_inline: 1,
|
614 |
-
};
|
615 |
-
$.post(ajaxurl, ewww_table_count_data, function(response) {
|
616 |
-
ewww_vars.image_count = response;
|
617 |
-
});
|
618 |
-
$('#ewww-show-table').show();
|
619 |
-
$('#ewww-table-info').show();
|
620 |
-
$('#ewww-bulk-timer').hide();
|
621 |
-
if (ewww_aux == true) {
|
622 |
-
$('#ewww-aux-first').hide();
|
623 |
-
} else {
|
624 |
-
$('#ewww-bulk-first').hide();
|
625 |
-
}
|
626 |
-
ewww_attachments = ewww_vars.attachments;
|
627 |
-
ewww_init_action = 'bulk_init';
|
628 |
-
ewww_filename_action = 'bulk_filename';
|
629 |
-
ewww_loop_action = 'bulk_loop';
|
630 |
-
ewww_cleanup_action = 'bulk_cleanup';
|
631 |
-
ewww_init_data = {
|
632 |
-
action: ewww_init_action,
|
633 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
634 |
-
};
|
635 |
-
ewww_aux = false;
|
636 |
-
ewww_i = 0;
|
637 |
-
ewww_force = 0;
|
638 |
-
ewww_force_smart = 0;
|
639 |
-
ewww_webp_only = 0;
|
640 |
-
}
|
641 |
-
}
|
642 |
-
function ewwwCountDown() {
|
643 |
-
if (ewww_time_remaining > 1) {
|
644 |
-
ewww_time_remaining--;
|
645 |
-
}
|
646 |
-
ewwwTimeIncrementsUpdate();
|
647 |
-
$('#ewww-bulk-timer').html(ewww_days_remaining + ':' + ewww_hours_remaining + ':' + ewww_minutes_remaining + ':' + ewww_seconds_remaining + ' ' + ewww_vars.time_remaining);
|
648 |
-
}
|
649 |
-
function ewwwTimeIncrementsUpdate() {
|
650 |
-
ewww_days_remaining = Math.floor(ewww_time_remaining / 86400);
|
651 |
-
ewww_hours_remaining = Math.floor((ewww_time_remaining - (ewww_days_remaining * 86400)) / 3600);
|
652 |
-
ewww_minutes_remaining = Math.floor((ewww_time_remaining - (ewww_days_remaining * 86400) - (ewww_hours_remaining * 3600)) / 60);
|
653 |
-
ewww_seconds_remaining = ewww_time_remaining - (ewww_days_remaining * 86400) - (ewww_hours_remaining * 3600) - (ewww_minutes_remaining * 60);
|
654 |
-
if (ewww_days_remaining < 10) { ewww_days_remaining = '0'+ewww_days_remaining; }
|
655 |
-
if (ewww_hours_remaining < 10) { ewww_hours_remaining = '0'+ewww_hours_remaining; }
|
656 |
-
if (ewww_minutes_remaining < 10) { ewww_minutes_remaining = '0'+ewww_minutes_remaining; }
|
657 |
-
if (ewww_seconds_remaining < 10) { ewww_seconds_remaining = '0'+ewww_seconds_remaining; }
|
658 |
-
}
|
659 |
-
});
|
660 |
-
function ewwwRemoveImage(imageID) {
|
661 |
-
var ewww_image_removal = {
|
662 |
-
action: 'bulk_aux_images_remove',
|
663 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
664 |
-
ewww_image_id: imageID,
|
665 |
-
};
|
666 |
-
jQuery.post(ajaxurl, ewww_image_removal, function(response) {
|
667 |
-
if(response == '1') {
|
668 |
-
jQuery('#ewww-image-' + imageID).remove();
|
669 |
-
var ewww_prev_count = ewww_vars.image_count;
|
670 |
-
ewww_vars.image_count--;
|
671 |
-
ewww_vars.count_string = ewww_vars.count_string.replace( ewww_prev_count, ewww_vars.image_count );
|
672 |
-
jQuery('.displaying-num').text(ewww_vars.count_string);
|
673 |
-
} else {
|
674 |
-
alert(ewww_vars.remove_failed);
|
675 |
-
}
|
676 |
-
});
|
677 |
-
}
|
678 |
-
function ewwwRestoreImage(imageID) {
|
679 |
-
var ewww_image_restore = {
|
680 |
-
action: 'ewww_manual_cloud_restore_single',
|
681 |
-
ewww_wpnonce: ewww_vars._wpnonce,
|
682 |
-
ewww_image_id: imageID,
|
683 |
-
};
|
684 |
-
var original_html = jQuery('#ewww-image-' + imageID + ' td:last-child').html();
|
685 |
-
jQuery('#ewww-image-' + imageID + ' td:last-child').html(ewww_vars.restoring);
|
686 |
-
jQuery.post(ajaxurl, ewww_image_restore, function(response) {
|
687 |
-
var is_json = true;
|
688 |
-
try {
|
689 |
-
var ewww_response = jQuery.parseJSON(response);
|
690 |
-
} catch (err) {
|
691 |
-
is_json = false;
|
692 |
-
}
|
693 |
-
if ( ! is_json ) {
|
694 |
-
alert( ewww_vars.invalid_response );
|
695 |
-
console.log( response );
|
696 |
-
return false;
|
697 |
-
}
|
698 |
-
if ( ewww_response.success == '1') {
|
699 |
-
jQuery('#ewww-image-' + imageID + ' td:last-child').html(ewww_vars.original_restored);
|
700 |
-
return false;
|
701 |
-
} else if (ewww_response.error) {
|
702 |
-
jQuery('#ewww-image-' + imageID + ' td:last-child').html(original_html);
|
703 |
-
alert(ewww_response.error);
|
704 |
-
return false;
|
705 |
-
}
|
706 |
-
});
|
707 |
-
}
|
708 |
-
function selectText(containerid) {
|
709 |
-
var debug_node = document.getElementById(containerid);
|
710 |
-
if (document.selection) {
|
711 |
-
var range = document.body.createTextRange();
|
712 |
-
range.moveToElementText(debug_node);
|
713 |
-
range.select();
|
714 |
-
} else if (window.getSelection) {
|
715 |
-
window.getSelection().selectAllChildren(debug_node);
|
716 |
-
}
|
717 |
-
}
|
718 |
-
function unselectText() {
|
719 |
-
var sel;
|
720 |
-
if ( (sel = document.selection) && sel.empty) {
|
721 |
-
sel.empty();
|
722 |
-
} else if (window.getSelection) {
|
723 |
-
window.getSelection().removeAllRanges();
|
724 |
-
}
|
725 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/flag.js
CHANGED
@@ -9,7 +9,7 @@ jQuery(document).on( 'click', '.ewww-manual-optimize', function() {
|
|
9 |
};
|
10 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_vars.optimizing );
|
11 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
12 |
-
var ewww_manual_response =
|
13 |
if (ewww_manual_response.error) {
|
14 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_manual_response.error );
|
15 |
} else if (ewww_manual_response.success) {
|
@@ -28,7 +28,7 @@ jQuery(document).on( 'click', '.ewww-manual-cloud-restore', function() {
|
|
28 |
};
|
29 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_vars.restoring );
|
30 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
31 |
-
var ewww_manual_response =
|
32 |
if (ewww_manual_response.error) {
|
33 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_manual_response.error );
|
34 |
} else if (ewww_manual_response.success) {
|
9 |
};
|
10 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_vars.optimizing );
|
11 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
12 |
+
var ewww_manual_response = JSON.parse(response);
|
13 |
if (ewww_manual_response.error) {
|
14 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_manual_response.error );
|
15 |
} else if (ewww_manual_response.success) {
|
28 |
};
|
29 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_vars.restoring );
|
30 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
31 |
+
var ewww_manual_response = JSON.parse(response);
|
32 |
if (ewww_manual_response.error) {
|
33 |
jQuery('#ewww-flag-status-' + post_id ).html( ewww_manual_response.error );
|
34 |
} else if (ewww_manual_response.success) {
|
includes/jquery-ui-1.10.1.custom.css
CHANGED
@@ -370,12 +370,9 @@ body .ui-tooltip {
|
|
370 |
top: auto;
|
371 |
}
|
372 |
/* media library actions and details */
|
373 |
-
a.
|
374 |
cursor: pointer;
|
375 |
}
|
376 |
-
.ewww-attachment-detail-container {
|
377 |
-
display: none;
|
378 |
-
}
|
379 |
.ewww-attachment-detail table td, .ewww-attachment-detail table th {
|
380 |
padding: 8px 10px;
|
381 |
}
|
@@ -431,7 +428,7 @@ button.ewww-handlediv {
|
|
431 |
.js .postbox.closed .ewww-handlediv .toggle-indicator:before {
|
432 |
content: "\f140";
|
433 |
}
|
434 |
-
.ewww-bulk-error {
|
435 |
color: red;
|
436 |
}
|
437 |
.ewww-bulk-error a, .ewww-bulk-error a:visited {
|
@@ -487,7 +484,9 @@ button.ewww-handlediv {
|
|
487 |
.ewww-tab-nav { list-style: none; margin: 10px 0 0; padding-left: 5px; border-bottom: 1px solid #ccc; }
|
488 |
/* optimization status section */
|
489 |
#ewww-widgets {
|
490 |
-
|
|
|
|
|
491 |
}
|
492 |
#ewww-status .inside {
|
493 |
margin: 0;
|
@@ -519,6 +518,9 @@ button.ewww-handlediv {
|
|
519 |
.ewww-blocks #ewww-notices {
|
520 |
text-align: left;
|
521 |
}
|
|
|
|
|
|
|
522 |
.ewww-guage {
|
523 |
position: relative;
|
524 |
margin: 0 auto 1rem;
|
@@ -537,6 +539,9 @@ button.ewww-handlediv {
|
|
537 |
.ewww-inactive {
|
538 |
stroke: #e6e6e6;
|
539 |
}
|
|
|
|
|
|
|
540 |
#ewww-compress, #ewww-savings, #easyio-savings {
|
541 |
flex: 1 1 120px;
|
542 |
}
|
@@ -592,20 +597,76 @@ button.ewww-handlediv {
|
|
592 |
}
|
593 |
#easyio-savings-guage .ewww-score {
|
594 |
font-size: 1rem;
|
595 |
-
color: #3eadc9;
|
596 |
color: #1d3c71;
|
597 |
white-space: nowrap;
|
598 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
599 |
.ewww-recommend {
|
600 |
display: none;
|
|
|
|
|
|
|
|
|
601 |
}
|
602 |
-
.ui-tooltip ul.ewww-tooltip {
|
603 |
list-style: disc outside none;
|
604 |
}
|
605 |
-
.ui-tooltip ul.ewww-tooltip li {
|
606 |
margin-left: 1em;
|
607 |
}
|
608 |
/* other settings UI */
|
|
|
|
|
|
|
609 |
p.debug-actions {
|
610 |
clear: both;
|
611 |
}
|
@@ -616,20 +677,181 @@ p.debug-actions {
|
|
616 |
height: 300px;
|
617 |
width: 800px;
|
618 |
}
|
619 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
margin-top: 10px;
|
621 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
padding: 15px;
|
623 |
background-color: #3eadc9;
|
624 |
-
clear: both;
|
625 |
}
|
626 |
-
#ewwwio-banner
|
627 |
-
|
628 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
}
|
630 |
#ewwwio-banner p {
|
631 |
color: #fff;
|
632 |
-
margin-bottom: 1.0em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
}
|
634 |
h3 a.ewww-upgrade {
|
635 |
font-weight:bold;
|
@@ -639,10 +861,6 @@ h3 a.ewww-upgrade {
|
|
639 |
.ewww-help-beacon-multi, .ewww-help-beacon-single, .ewww-help-external {
|
640 |
margin: 3px;
|
641 |
}
|
642 |
-
/* iframe ewww.io */
|
643 |
-
.top-bar {
|
644 |
-
display: none;
|
645 |
-
}
|
646 |
/* mobile rules */
|
647 |
@media screen and (max-width: 868px) {
|
648 |
.ewww-blocks {
|
@@ -662,12 +880,14 @@ h3 a.ewww-upgrade {
|
|
662 |
display: none;
|
663 |
}
|
664 |
}
|
665 |
-
@media screen and (max-width:
|
|
|
|
|
|
|
|
|
666 |
.ewww-blocks div.ewww-status-detail {
|
667 |
padding: 1em;
|
668 |
}
|
669 |
-
}
|
670 |
-
@media screen and (max-width: 782px) {
|
671 |
.ewww-tab-nav {
|
672 |
border-style: none;
|
673 |
}
|
@@ -683,6 +903,14 @@ h3 a.ewww-upgrade {
|
|
683 |
padding: 2px 3px;
|
684 |
|
685 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
p.debug-actions {
|
687 |
margin-top: 30px;
|
688 |
clear: none;
|
@@ -693,4 +921,10 @@ h3 a.ewww-upgrade {
|
|
693 |
#ewww-settings-disable-resizes th, #ewww-settings-disable-resizes td {
|
694 |
display: table-cell;
|
695 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
696 |
}
|
370 |
top: auto;
|
371 |
}
|
372 |
/* media library actions and details */
|
373 |
+
a.ewww-remove-image, a.ewww-restore-image {
|
374 |
cursor: pointer;
|
375 |
}
|
|
|
|
|
|
|
376 |
.ewww-attachment-detail table td, .ewww-attachment-detail table th {
|
377 |
padding: 8px 10px;
|
378 |
}
|
428 |
.js .postbox.closed .ewww-handlediv .toggle-indicator:before {
|
429 |
content: "\f140";
|
430 |
}
|
431 |
+
.ewww-bulk-error, .ewww-ajax-error {
|
432 |
color: red;
|
433 |
}
|
434 |
.ewww-bulk-error a, .ewww-bulk-error a:visited {
|
484 |
.ewww-tab-nav { list-style: none; margin: 10px 0 0; padding-left: 5px; border-bottom: 1px solid #ccc; }
|
485 |
/* optimization status section */
|
486 |
#ewww-widgets {
|
487 |
+
width: 100%;
|
488 |
+
/* max-width: 1400px; */
|
489 |
+
clear: right;
|
490 |
}
|
491 |
#ewww-status .inside {
|
492 |
margin: 0;
|
518 |
.ewww-blocks #ewww-notices {
|
519 |
text-align: left;
|
520 |
}
|
521 |
+
#ewww-notices p:first-child {
|
522 |
+
margin-top: 0;
|
523 |
+
}
|
524 |
.ewww-guage {
|
525 |
position: relative;
|
526 |
margin: 0 auto 1rem;
|
539 |
.ewww-inactive {
|
540 |
stroke: #e6e6e6;
|
541 |
}
|
542 |
+
#ewww-score-bars {
|
543 |
+
flex:1 1 auto;
|
544 |
+
}
|
545 |
#ewww-compress, #ewww-savings, #easyio-savings {
|
546 |
flex: 1 1 120px;
|
547 |
}
|
597 |
}
|
598 |
#easyio-savings-guage .ewww-score {
|
599 |
font-size: 1rem;
|
|
|
600 |
color: #1d3c71;
|
601 |
white-space: nowrap;
|
602 |
}
|
603 |
+
.ewww-bar-container {
|
604 |
+
background-color: #e6e6e6;
|
605 |
+
/* border: 1px solid #ccd0d4; */
|
606 |
+
border-radius: 6px;
|
607 |
+
/* box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); */
|
608 |
+
height: 12px;
|
609 |
+
width: 100%;
|
610 |
+
overflow: hidden;
|
611 |
+
}
|
612 |
+
.ewww-bar-fill {
|
613 |
+
margin: 0;
|
614 |
+
height: 100%;
|
615 |
+
width: 0;
|
616 |
+
}
|
617 |
+
#ewww-speed-container .ewww-red {
|
618 |
+
background-color: #dc3232;
|
619 |
+
}
|
620 |
+
#ewww-speed-container .ewww-orange {
|
621 |
+
background-color: #ffb900;
|
622 |
+
}
|
623 |
+
#ewww-speed-container .ewww-green {
|
624 |
+
background-color: #46b450;
|
625 |
+
}
|
626 |
+
#ewww-savings-container .ewww-bar-fill {
|
627 |
+
background-color: #3eadc9;
|
628 |
+
}
|
629 |
+
#easyio-savings-container .ewww-bar-fill {
|
630 |
+
background-color: #1d3c71;
|
631 |
+
}
|
632 |
+
.ewww-bar-caption {
|
633 |
+
display: flex;
|
634 |
+
align-items: center;
|
635 |
+
justify-content: center;
|
636 |
+
}
|
637 |
+
.ewww-bar-caption p {
|
638 |
+
margin: 0.5em 0;
|
639 |
+
flex: 1;
|
640 |
+
text-align: center;
|
641 |
+
}
|
642 |
+
.ewww-bar-score {
|
643 |
+
font-size: 1.0rem;
|
644 |
+
font-weight: bold;
|
645 |
+
line-height: 1.5;
|
646 |
+
}
|
647 |
+
#ewww-savings-flex .ewww-bar-score {
|
648 |
+
color: #3eadc9;
|
649 |
+
}
|
650 |
+
#easyio-savings-flex .ewww-bar-score {
|
651 |
+
color: #1d3c71;
|
652 |
+
}
|
653 |
.ewww-recommend {
|
654 |
display: none;
|
655 |
+
text-align: left;
|
656 |
+
border-top: 1px solid #ccd0d4;
|
657 |
+
border-bottom: 1px solid #ccd0d4;
|
658 |
+
margin-bottom: 10px;
|
659 |
}
|
660 |
+
.ui-tooltip ul.ewww-tooltip/*, .ewww-recommend ul.ewww-tooltip*/ {
|
661 |
list-style: disc outside none;
|
662 |
}
|
663 |
+
.ui-tooltip ul.ewww-tooltip li/*, .ewww-recommend ul.ewww-tooltip li*/ {
|
664 |
margin-left: 1em;
|
665 |
}
|
666 |
/* other settings UI */
|
667 |
+
#ewww-rescue-mode {
|
668 |
+
margin: 10px 0;
|
669 |
+
}
|
670 |
p.debug-actions {
|
671 |
clear: both;
|
672 |
}
|
677 |
height: 300px;
|
678 |
width: 800px;
|
679 |
}
|
680 |
+
#ewww-webp-rewrite #webp-rewrite-rules {
|
681 |
+
background-color: white;
|
682 |
+
border: 1px solid #ccd0d4;
|
683 |
+
clear: both;
|
684 |
+
padding: 10px;
|
685 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
686 |
+
}
|
687 |
+
#ewww-webp-rewrite button {
|
688 |
+
margin-top: 1em;
|
689 |
+
}
|
690 |
+
#ewww-webp-image {
|
691 |
+
float: right;
|
692 |
+
padding: 0 0 10px 10px;
|
693 |
+
/*padding: 0 1px 10px 10px;*/
|
694 |
+
}
|
695 |
+
div#ewww-webp-rewrite-status {
|
696 |
+
font-weight: bold;
|
697 |
+
}
|
698 |
+
p#ewww-webp-rewrite-status {
|
699 |
+
font-style: italic;
|
700 |
+
}
|
701 |
+
#ewwwio-easy-activate, #ewwwio-easy-deactivate {
|
702 |
margin-top: 10px;
|
703 |
+
}
|
704 |
+
.ewwwio-notice {
|
705 |
+
background-color: white;
|
706 |
+
border: 1px solid #ccd0d4;
|
707 |
+
border-left: 4px solid #3eadc9;
|
708 |
+
margin: 10px 10px 15px 0;
|
709 |
+
padding: 12px;
|
710 |
+
}
|
711 |
+
.ewwwio-notice.notice-warning {
|
712 |
+
border-left-color: #ffb900;
|
713 |
+
}
|
714 |
+
.ewwwio-notice.notice-success {
|
715 |
+
border-left-color: #46b450;
|
716 |
+
}
|
717 |
+
#ewwwio-api-activation-result, #ewwwio-easy-activation-result, #ewww-webp-rewrite-result {
|
718 |
+
display: none;
|
719 |
+
background-color: white;
|
720 |
+
border: 1px solid #ccd0d4;
|
721 |
+
border-left: 4px solid #3eadc9;
|
722 |
+
margin: 10px 10px 15px 0;
|
723 |
+
padding: 12px;
|
724 |
+
font-weight: bold;
|
725 |
+
}
|
726 |
+
#ewww-webp-rewrite-result {
|
727 |
+
margin-right: 110px;
|
728 |
+
}
|
729 |
+
#ewwwio-api-activation-result.error, #ewwwio-easy-activation-result.error, #ewww-webp-rewrite-result.error {
|
730 |
+
border-left-color: #dc3232;
|
731 |
+
}
|
732 |
+
#ewww-webp-rewrite-result p {
|
733 |
+
/* margin: 0.5em 0; */
|
734 |
+
}
|
735 |
+
#ewww_image_optimizer_cloud_key_container th, #ewww_image_optimizer_exactdn_container th, #swis_promo_container th {
|
736 |
+
color: #3eadc9;
|
737 |
+
}
|
738 |
+
#ewww_image_optimizer_cloud_key_container td, #ewww_image_optimizer_exactdn_container td, #swis_promo_container td {
|
739 |
+
background-color: white;
|
740 |
+
border: 1px solid #ccd0d4;
|
741 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
742 |
+
}
|
743 |
+
#ewww_image_optimizer_cloud_key_container .dashicons-yes {
|
744 |
+
font-size: 30px;
|
745 |
+
}
|
746 |
+
#ewwwio-exactdn-anchor {
|
747 |
+
display: block;
|
748 |
+
position: relative;
|
749 |
+
top: -40px;
|
750 |
+
visibility: hidden;
|
751 |
+
}
|
752 |
+
#exactdn_site_url {
|
753 |
+
cursor: pointer;
|
754 |
+
}
|
755 |
+
/* .top-bar is for the ewww.io iframe(s) */
|
756 |
+
.ewww-attachment-detail-container, .top-bar, #exactdn-site-url-copied, #exactdn-site-url-copy, #ewwwio-api-activation-processing, #ewwwio-easy-activation-processing, #ewwwio-webp-storage-warning {
|
757 |
+
display: none;
|
758 |
+
}
|
759 |
+
#ewwwio-rescue ul {
|
760 |
+
list-style: disc;
|
761 |
+
margin-left: 10px;
|
762 |
+
}
|
763 |
+
#ewwwio-wizard, #ewwwio-rescue {
|
764 |
+
display: flex;
|
765 |
+
max-width: 450px;
|
766 |
+
flex-direction: column;
|
767 |
+
margin: auto;
|
768 |
+
padding: 5% 0;
|
769 |
+
}
|
770 |
+
#ewwwio-rescue .ewww-help-beacon-single {
|
771 |
+
margin: 0px;
|
772 |
+
}
|
773 |
+
#ewwwio-wizard-header, #ewwwio-rescue-header {
|
774 |
+
background-color: #3eadc9;
|
775 |
+
}
|
776 |
+
#ewwwio-wizard-header img, #ewwwio-rescue-header img {
|
777 |
+
margin: 15px auto;
|
778 |
+
display: block;
|
779 |
+
}
|
780 |
+
#ewwwio-wizard-body, #ewwwio-rescue-body {
|
781 |
+
background-color: #fff;
|
782 |
+
padding: 20px;
|
783 |
+
}
|
784 |
+
.ewwwio-intro-text {
|
785 |
+
font-weight: bold;
|
786 |
+
font-size: 1.3em;
|
787 |
+
margin: 1em 0;
|
788 |
+
}
|
789 |
+
.ewwwio-wizard-form {
|
790 |
+
margin: auto 0;
|
791 |
+
}
|
792 |
+
.ewwwio-wizard-form-group {
|
793 |
+
margin-bottom: 2em;
|
794 |
+
}
|
795 |
+
.ewwwio-wizard-form .ewwwio-premium-setup {
|
796 |
+
display: none;
|
797 |
+
margin-left: 2em;
|
798 |
+
}
|
799 |
+
.ewwwio-wizard-form .ewwwio-premium-setup label {
|
800 |
+
font-weight: bold;
|
801 |
+
}
|
802 |
+
.ewwwio-wizard-form .description {
|
803 |
+
margin-bottom: 20px;
|
804 |
+
color: #666;
|
805 |
+
}
|
806 |
+
.ewwwio-wizard-form #ewww_image_optimizer_cloud_key {
|
807 |
+
width: 100%;
|
808 |
+
max-width: 300px;
|
809 |
+
}
|
810 |
+
.ewwwio-flex-space-between {
|
811 |
+
display: flex;
|
812 |
+
justify-content: space-between;
|
813 |
+
}
|
814 |
+
#ewwwio-banner {
|
815 |
+
display: flex;
|
816 |
+
margin: 0px;
|
817 |
padding: 15px;
|
818 |
background-color: #3eadc9;
|
|
|
819 |
}
|
820 |
+
#ewwwio-banner div {
|
821 |
+
width: 100%;
|
822 |
+
}
|
823 |
+
#ewwwio-banner img:first-child {
|
824 |
+
margin: auto 10px auto 0;
|
825 |
+
}
|
826 |
+
#ewwwio-banner a.ewww-help-beacon-single img {
|
827 |
+
padding: 0;
|
828 |
+
}
|
829 |
+
#ewwwio-banner p:first-of-type {
|
830 |
+
/* margin-top: 0; */
|
831 |
}
|
832 |
#ewwwio-banner p {
|
833 |
color: #fff;
|
834 |
+
/* margin-bottom: 1.0em; */
|
835 |
+
/* line-height: 1; */
|
836 |
+
}
|
837 |
+
#ewwwio-banner #ewww-review a:first-child {
|
838 |
+
padding-left: 20px;
|
839 |
+
}
|
840 |
+
#ewwwio-banner #ewww-review {
|
841 |
+
white-space: nowrap;
|
842 |
+
}
|
843 |
+
#ewwwio-banner a {
|
844 |
+
color: #272727;
|
845 |
+
}
|
846 |
+
#ewwwio-banner a span.dashicons {
|
847 |
+
color: #fff;
|
848 |
+
text-decoration: none;
|
849 |
+
font-size: 16px;
|
850 |
+
width: 16px;
|
851 |
+
height: 16px;
|
852 |
+
}
|
853 |
+
#ewwwio-banner #ewww-news-button {
|
854 |
+
margin-top: 0;
|
855 |
}
|
856 |
h3 a.ewww-upgrade {
|
857 |
font-weight:bold;
|
861 |
.ewww-help-beacon-multi, .ewww-help-beacon-single, .ewww-help-external {
|
862 |
margin: 3px;
|
863 |
}
|
|
|
|
|
|
|
|
|
864 |
/* mobile rules */
|
865 |
@media screen and (max-width: 868px) {
|
866 |
.ewww-blocks {
|
880 |
display: none;
|
881 |
}
|
882 |
}
|
883 |
+
@media screen and (max-width: 600px) {
|
884 |
+
#ewwwio-banner img:first-child {
|
885 |
+
width: 100px;
|
886 |
+
height: auto;
|
887 |
+
}
|
888 |
.ewww-blocks div.ewww-status-detail {
|
889 |
padding: 1em;
|
890 |
}
|
|
|
|
|
891 |
.ewww-tab-nav {
|
892 |
border-style: none;
|
893 |
}
|
903 |
padding: 2px 3px;
|
904 |
|
905 |
}
|
906 |
+
}
|
907 |
+
@media screen and (max-width: 782px) {
|
908 |
+
#ewwwio-banner .ewwwio-flex-space-between {
|
909 |
+
flex-direction: column-reverse;
|
910 |
+
}
|
911 |
+
#ewwwio-banner #ewww-review a:first-child {
|
912 |
+
padding-left: 0;
|
913 |
+
}
|
914 |
p.debug-actions {
|
915 |
margin-top: 30px;
|
916 |
clear: none;
|
921 |
#ewww-settings-disable-resizes th, #ewww-settings-disable-resizes td {
|
922 |
display: table-cell;
|
923 |
}
|
924 |
+
#ewwwio-wizard-form input[type="checkbox"], #ewwwio-wizard-form input[type="radio"] {
|
925 |
+
margin-top: 5px;
|
926 |
+
}
|
927 |
+
#ewww_image_optimizer_cloud_key_container td, #ewww_image_optimizer_exactdn_container td, #swis_promo_container td {
|
928 |
+
padding: 10px;
|
929 |
+
}
|
930 |
}
|
includes/lazysizes-post.js
CHANGED
@@ -109,7 +109,15 @@ function constrainSrc(url,objectWidth,objectHeight,objectType){
|
|
109 |
return url;
|
110 |
}
|
111 |
document.addEventListener('lazybeforesizes', function(e){
|
112 |
-
console.log(e);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
});
|
114 |
document.addEventListener('lazybeforeunveil', function(e){
|
115 |
var target = e.target;
|
@@ -140,8 +148,8 @@ document.addEventListener('lazybeforeunveil', function(e){
|
|
140 |
}
|
141 |
if (!shouldAutoScale(target)||!shouldAutoScale(target.parentNode)){
|
142 |
var newSrc = false;
|
143 |
-
} else if ( window.lazySizes.hC(target,'et_pb_jt_filterable_grid_item_image')) {
|
144 |
-
console.log('
|
145 |
var newSrc = constrainSrc(src,targetWidth,targetHeight,'img-crop');
|
146 |
} else {
|
147 |
console.log('plain old img, constraining');
|
109 |
return url;
|
110 |
}
|
111 |
document.addEventListener('lazybeforesizes', function(e){
|
112 |
+
console.log('auto-sizing to: ' + e.detail.width);
|
113 |
+
if (e.target._lazysizesWidth === undefined) {
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
console.log('previous width was ' + e.target._lazysizesWidth);
|
117 |
+
if (e.detail.width < e.target._lazysizesWidth) {
|
118 |
+
console.log('no way! ' + e.detail.width + ' is smaller than ' + e.target._lazysizesWidth);
|
119 |
+
e.detail.width = e.target._lazysizesWidth;
|
120 |
+
}
|
121 |
});
|
122 |
document.addEventListener('lazybeforeunveil', function(e){
|
123 |
var target = e.target;
|
148 |
}
|
149 |
if (!shouldAutoScale(target)||!shouldAutoScale(target.parentNode)){
|
150 |
var newSrc = false;
|
151 |
+
} else if ( window.lazySizes.hC(target,'et_pb_jt_filterable_grid_item_image') || window.lazySizes.hC(target,'ss-foreground-image') ) {
|
152 |
+
console.log('img that needs a hard crop');
|
153 |
var newSrc = constrainSrc(src,targetWidth,targetHeight,'img-crop');
|
154 |
} else {
|
155 |
console.log('plain old img, constraining');
|
includes/lazysizes.js
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
(function(window, factory) {
|
2 |
var lazySizes = factory(window, window.document, Date);
|
3 |
window.lazySizes = lazySizes;
|
1 |
+
// version 5.2.2
|
2 |
(function(window, factory) {
|
3 |
var lazySizes = factory(window, window.document, Date);
|
4 |
window.lazySizes = lazySizes;
|
includes/lazysizes.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var ewww_webp_supported=!1;function lazysizesWebP(e,t){var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t()},a.onerror=function(){t()},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function shouldAutoScale(e){if(1==eio_lazy_vars.skip_autoscale)return!1;if(e.hasAttributes())for(var t=e.attributes,a=/skip-autoscale/,i=t.length-1;0<=i;i--){if(a.test(t[i].name))return!1;if(a.test(t[i].value))return!1}return!0}function constrainSrc(e,t,a,i){if(null===e)return e;var r=/w=(\d+)/,n=/fit=(\d+),(\d+)/,o=/resize=(\d+),(\d+)/,s=decodeURIComponent(e);if("undefined"==typeof eio_lazy_vars&&(eio_lazy_vars={exactdn_domain:".exactdn.com"}),0<e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)){var l=o.exec(s);if(l&&t<l[1])return s.replace(o,"resize="+t+","+a);var c=r.exec(e);if(c&&t<=c[1]){if("bg-cover"!==i&&"img-crop"!==i)return e.replace(r,"w="+t);var d=c[1]-t;return 20<d||a<1080?e.replace(r,"resize="+t+","+a):e}var u=n.exec(s);if(u&&t<u[1]){if("bg-cover"!==i&&"img-crop"!==i)return s.replace(n,"fit="+t+","+a);var f=u[1]-t,A=u[2]-a;return 20<f||20<A?e.replace(r,"resize="+t+","+a):e}if(!c&&!u&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"&h="+a:e+"&w="+t}return-1==e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)?"img"===i?e+"?fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"?h="+a:e+"?w="+t:e}window.lazySizesConfig=window.lazySizesConfig||{},window.lazySizesConfig.init=!1,function(e,t){var a=function(i,A,n){"use strict";var g,h;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in h=i.lazySizesConfig||i.lazysizesConfig||{},t)e in h||(h[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:h,noSupport:!0};var z=A.documentElement,r=i.HTMLPictureElement,o="addEventListener",v="getAttribute",e=i[o].bind(i),u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],c={},p=Array.prototype.forEach,d=function(e,t){return c[t]||(c[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),c[t].test(e[v]("class")||"")&&c[t]},m=function(e,t){d(e,t)||e.setAttribute("class",(e[v]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=d(e,t))&&e.setAttribute("class",(e[v]("class")||"").replace(a," "))},b=function(t,a,e){var i=e?o:"removeEventListener";e&&b(t,a),l.forEach(function(e){t[i](e,a)})},w=function(e,t,a,i,r){var n=A.createEvent("Event");return a||(a={}),a.instance=g,n.initEvent(t,!i,!r),n.detail=a,e.dispatchEvent(n),n},_=function(e,t){var a;!r&&(a=i.picturefill||h.pf)?(t&&t.src&&!e[v]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},C=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<h.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],_e=[],Ce=we,Ee=function(){var e=Ce;for(Ce=we.length?_e:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(Ce.push(e),be||(be=!0,(A.hidden?u:a)(Ee)))},Se._lsFlush=Ee,Se),t=function(a,e){return e?function(){S(a)}:function(){var e=this,t=arguments;S(function(){a.apply(e,t)})}},x=function(e){var t,a,i=function(){t=null,e()},r=function(){var e=n.now()-a;e<99?u(r,99-e):(s||i)(i)};return function(){a=n.now(),t||(t=u(r,99))}},W=(ee=/^img$/i,te=/^iframe$/i,ae="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ie=0,re=0,ne=-1,oe=function(e){re--,(!e||re<0||!e.target)&&(re=0)},se=function(e){return null==$&&($="hidden"==C(A.body,"visibility")),$||!("hidden"==C(e.parentNode,"visibility")&&"hidden"==C(e,"visibility"))},le=function(e,t){var a,i=e,r=se(e);for(I-=t,G+=t,J-=t,O+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=z;)(r=0<(C(i,"opacity")||1))&&"visible"!=C(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},ce=function(){var e,t,a,i,r,n,o,s,l,c,d,u,f=g.elements;if((H=h.loadMode)&&re<8&&(e=f.length)){for(t=0,ne++;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(!ae||g.prematureUnveil&&g.prematureUnveil(f[t]))ze(f[t]);else if((s=f[t][v]("data-expand"))&&(n=1*s)||(n=ie),c||(c=!h.expand||h.expand<1?500<z.clientHeight&&500<z.clientWidth?500:370:h.expand,g._defEx=c,d=c*h.expFactor,u=h.hFac,$=null,ie<d&&re<1&&2<ne&&2<H&&!A.hidden?(ie=d,ne=0):ie=1<H&&1<ne&&re<6?c:0),l!==n&&(U=innerWidth+n*u,F=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(G=a.bottom)>=o&&(I=a.top)<=F&&(O=a.right)>=o*u&&(J=a.left)<=U&&(G||O||J||I)&&(h.loadHidden||se(f[t]))&&(P&&re<3&&!s&&(H<3||ne<4)||le(f[t],n))){if(ze(f[t]),r=!0,9<re)break}else!r&&P&&!i&&re<4&&ne<4&&2<H&&(k[0]||h.preloadAfterLoad)&&(k[0]||!s&&(G||O||J||I||"auto"!=f[t][v](h.sizesAttr)))&&(i=k[0]||f[t]);i&&!r&&ze(i)}},q=ce,V=0,X=h.throttleDelay,Y=h.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==h.ricTimeout&&(Y=h.ricTimeout)}:t(function(){u(K)},!0),de=function(e){var t;(e=!0===e)&&(Y=33),j||(j=!0,(t=X-(n.now()-V))<0&&(t=0),e||t<9?Z():u(Z,t))},ue=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(oe(e),m(t,h.loadedClass),y(t,h.loadingClass),b(t,Ae),w(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[v](h.srcsetAttr);(t=h.customMedia[e[v]("data-media")||e[v]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},he=t(function(t,e,a,i,r){var n,o,s,l,c,d;(c=w(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?m(t,h.autosizesClass):t.setAttribute("sizes",i)),o=t[v](h.srcsetAttr),n=t[v](h.srcAttr),r&&(s=t.parentNode,l=s&&f.test(s.nodeName||"")),d=e.firesLoad||"src"in t&&(o||n||l),c={target:t},m(t,h.loadingClass),d&&(clearTimeout(D),D=u(oe,2500),b(t,Ae,!0)),l&&p.call(s.getElementsByTagName("source"),ge),o?t.setAttribute("srcset",o):n&&!l&&(te.test(t.nodeName)?function(t,a){try{t.contentWindow.location.replace(a)}catch(e){t.src=a}}(t,n):t.src=n),r&&(o||l)&&_(t,{src:n})),t._lazyRace&&delete t._lazyRace,y(t,h.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;d&&!e||(e&&m(t,"ls-is-cached"),ue(c),t._lazyCache=!0,u(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ze=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[v](h.sizesAttr)||e[v]("sizes")),r="auto"==i;(!r&&P||!a||!e[v]("src")&&!e.srcset||e.complete||d(e,h.errorClass)||!d(e,h.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&M.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,he(e,t,r,i,a))}},ve=x(function(){h.loadMode=3,de()}),pe=function(){3==h.loadMode&&(h.loadMode=2),ve()},me=function(){P||(n.now()-T<999?u(me,999):(P=!0,h.loadMode=3,de(),e("scroll",pe,!0)))},{_:function(){T=n.now(),g.elements=A.getElementsByClassName(h.lazyClass),k=A.getElementsByClassName(h.lazyClass+" "+h.preloadClass),e("scroll",de,!0),e("resize",de,!0),e("pageshow",function(e){if(e.persisted){var t=A.querySelectorAll("."+h.loadingClass);t.length&&t.forEach&&a(function(){t.forEach(function(e){e.complete&&ze(e)})})}}),i.MutationObserver?new MutationObserver(de).observe(z,{childList:!0,subtree:!0,attributes:!0}):(z[o]("DOMNodeInserted",de,!0),z[o]("DOMAttrModified",de,!0),setInterval(de,999)),e("hashchange",de,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,de,!0)}),/d$|^c/.test(A.readyState)?me():(e("load",me),A[o]("DOMContentLoaded",de),u(me,2e4)),g.elements.length?(ce(),S._lsFlush()):de()},checkElems:de,unveil:ze,_aLSL:pe}),M=(R=t(function(e,t,a,i){var r,n,o;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),f.test(t.nodeName||""))for(r=t.getElementsByTagName("source"),n=0,o=r.length;n<o;n++)r[n].setAttribute("sizes",i);a.detail.dataAttr||_(e,a.detail)}),L=function(e,t,a){var i,r=e.parentNode;r&&(a=E(e,r,a),(i=w(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=i.detail.width)&&a!==e._lazysizesWidth&&R(e,r,i,a))},Q=x(function(){var e,t=N.length;if(t)for(e=0;e<t;e++)L(N[e])}),{_:function(){N=A.getElementsByClassName(h.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:L}),B=function(){!B.i&&A.getElementsByClassName&&(B.i=!0,M._(),W._())};var N,R,L,Q;var k,P,D,H,T,U,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,ce,de,ue,fe,Ae,ge,he,ze,ve,pe,me;var ye,be,we,_e,Ce,Ee,Se;return u(function(){h.init&&B()}),g={cfg:h,autoSizer:M,loader:W,init:B,uP:_,aC:m,rC:y,hC:d,fire:w,gW:E,rAF:S}}(e,e.document,Date);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforesizes",function(e){}),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=t.clientWidth&&1.25*t.clientWidth<t.naturalWidth,n=t.clientHeight&&1.25*t.clientHeight<t.naturalHeight;if(r||n){var o=Math.round(t.offsetWidth*i),s=Math.round(t.offsetHeight*i),l=t.getAttribute("data-src"),c=t.getAttribute("data-src-webp");if(ewww_webp_supported&&c&&-1==l.search("webp=1")&&(l=c),shouldAutoScale(t)&&shouldAutoScale(t.parentNode))if(window.lazySizes.hC(t,"et_pb_jt_filterable_grid_item_image"))d=constrainSrc(l,o,s,"img-crop");else d=constrainSrc(l,o,s,"img");else var d=!1;d&&l!=d&&t.setAttribute("data-src",d)}}if(ewww_webp_supported){if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if(!(c=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",c)}}),function(e,t){var a=function(){t(e.lazySizes),e.removeEventListener("lazyunveilread",a,!0)};t=t.bind(null,e,e.document),"object"==typeof module&&module.exports?t(require("lazysizes")):e.lazySizes?a():e.addEventListener("lazyunveilread",a,!0)}(window,function(o,e,s){"use strict";var l;e.addEventListener&&(l=/\(|\)|\s|'/,addEventListener("lazybeforeunveil",function(e){var t,a;if(e.detail.instance==s&&(!e.defaultPrevented&&("none"==e.target.preload&&(e.target.preload="auto"),t=e.target.getAttribute("data-bg")))){ewww_webp_supported&&(a=e.target.getAttribute("data-bg-webp"))&&(t=a);var i=o.devicePixelRatio||1,r=Math.round(e.target.offsetWidth*i),n=Math.round(e.target.offsetHeight*i);shouldAutoScale(e.target)&&shouldAutoScale(e.target.parentNode)&&(t=o.lazySizes.hC(e.target,"wp-block-cover")?(o.lazySizes.hC(e.target,"has-parallax")&&(r=Math.round(o.screen.width*i),n=Math.round(o.screen.height*i)),constrainSrc(t,r,n,"bg-cover")):o.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,r,n,"bg-cover"):constrainSrc(t,r,n,"bg")),e.target.style.backgroundImage="url("+(l.test(t)?JSON.stringify(t):t)+")"}},!1))});
|
1 |
+
var ewww_webp_supported=!1;function lazysizesWebP(e,t){var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t()},a.onerror=function(){t()},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function shouldAutoScale(e){if(1==eio_lazy_vars.skip_autoscale)return!1;if(e.hasAttributes())for(var t=e.attributes,a=/skip-autoscale/,i=t.length-1;0<=i;i--){if(a.test(t[i].name))return!1;if(a.test(t[i].value))return!1}return!0}function constrainSrc(e,t,a,i){if(null===e)return e;var r=/w=(\d+)/,n=/fit=(\d+),(\d+)/,o=/resize=(\d+),(\d+)/,s=decodeURIComponent(e);if("undefined"==typeof eio_lazy_vars&&(eio_lazy_vars={exactdn_domain:".exactdn.com"}),0<e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)){var l=o.exec(s);if(l&&t<l[1])return s.replace(o,"resize="+t+","+a);var c=r.exec(e);if(c&&t<=c[1]){if("bg-cover"!==i&&"img-crop"!==i)return e.replace(r,"w="+t);var d=c[1]-t;return 20<d||a<1080?e.replace(r,"resize="+t+","+a):e}var u=n.exec(s);if(u&&t<u[1]){if("bg-cover"!==i&&"img-crop"!==i)return s.replace(n,"fit="+t+","+a);var f=u[1]-t,A=u[2]-a;return 20<f||20<A?e.replace(r,"resize="+t+","+a):e}if(!c&&!u&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"&h="+a:e+"&w="+t}return-1==e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)?"img"===i?e+"?fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"?h="+a:e+"?w="+t:e}window.lazySizesConfig=window.lazySizesConfig||{},window.lazySizesConfig.init=!1,function(e,t){var a=function(i,A,n){"use strict";var g,h;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in h=i.lazySizesConfig||i.lazysizesConfig||{},t)e in h||(h[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:h,noSupport:!0};var z=A.documentElement,r=i.HTMLPictureElement,o="addEventListener",v="getAttribute",e=i[o].bind(i),u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],c={},p=Array.prototype.forEach,d=function(e,t){return c[t]||(c[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),c[t].test(e[v]("class")||"")&&c[t]},m=function(e,t){d(e,t)||e.setAttribute("class",(e[v]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=d(e,t))&&e.setAttribute("class",(e[v]("class")||"").replace(a," "))},b=function(t,a,e){var i=e?o:"removeEventListener";e&&b(t,a),l.forEach(function(e){t[i](e,a)})},w=function(e,t,a,i,r){var n=A.createEvent("Event");return a||(a={}),a.instance=g,n.initEvent(t,!i,!r),n.detail=a,e.dispatchEvent(n),n},_=function(e,t){var a;!r&&(a=i.picturefill||h.pf)?(t&&t.src&&!e[v]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},C=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<h.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],_e=[],Ce=we,Ee=function(){var e=Ce;for(Ce=we.length?_e:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(Ce.push(e),be||(be=!0,(A.hidden?u:a)(Ee)))},Se._lsFlush=Ee,Se),t=function(a,e){return e?function(){S(a)}:function(){var e=this,t=arguments;S(function(){a.apply(e,t)})}},W=function(e){var t,a,i=function(){t=null,e()},r=function(){var e=n.now()-a;e<99?u(r,99-e):(s||i)(i)};return function(){a=n.now(),t||(t=u(r,99))}},x=(ee=/^img$/i,te=/^iframe$/i,ae="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ie=0,re=0,ne=-1,oe=function(e){re--,(!e||re<0||!e.target)&&(re=0)},se=function(e){return null==$&&($="hidden"==C(A.body,"visibility")),$||!("hidden"==C(e.parentNode,"visibility")&&"hidden"==C(e,"visibility"))},le=function(e,t){var a,i=e,r=se(e);for(I-=t,G+=t,J-=t,O+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=z;)(r=0<(C(i,"opacity")||1))&&"visible"!=C(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},ce=function(){var e,t,a,i,r,n,o,s,l,c,d,u,f=g.elements;if((H=h.loadMode)&&re<8&&(e=f.length)){for(t=0,ne++;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(!ae||g.prematureUnveil&&g.prematureUnveil(f[t]))ze(f[t]);else if((s=f[t][v]("data-expand"))&&(n=1*s)||(n=ie),c||(c=!h.expand||h.expand<1?500<z.clientHeight&&500<z.clientWidth?500:370:h.expand,g._defEx=c,d=c*h.expFactor,u=h.hFac,$=null,ie<d&&re<1&&2<ne&&2<H&&!A.hidden?(ie=d,ne=0):ie=1<H&&1<ne&&re<6?c:0),l!==n&&(U=innerWidth+n*u,F=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(G=a.bottom)>=o&&(I=a.top)<=F&&(O=a.right)>=o*u&&(J=a.left)<=U&&(G||O||J||I)&&(h.loadHidden||se(f[t]))&&(P&&re<3&&!s&&(H<3||ne<4)||le(f[t],n))){if(ze(f[t]),r=!0,9<re)break}else!r&&P&&!i&&re<4&&ne<4&&2<H&&(k[0]||h.preloadAfterLoad)&&(k[0]||!s&&(G||O||J||I||"auto"!=f[t][v](h.sizesAttr)))&&(i=k[0]||f[t]);i&&!r&&ze(i)}},q=ce,V=0,X=h.throttleDelay,Y=h.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==h.ricTimeout&&(Y=h.ricTimeout)}:t(function(){u(K)},!0),de=function(e){var t;(e=!0===e)&&(Y=33),j||(j=!0,(t=X-(n.now()-V))<0&&(t=0),e||t<9?Z():u(Z,t))},ue=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(oe(e),m(t,h.loadedClass),y(t,h.loadingClass),b(t,Ae),w(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[v](h.srcsetAttr);(t=h.customMedia[e[v]("data-media")||e[v]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},he=t(function(t,e,a,i,r){var n,o,s,l,c,d;(c=w(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?m(t,h.autosizesClass):t.setAttribute("sizes",i)),o=t[v](h.srcsetAttr),n=t[v](h.srcAttr),r&&(s=t.parentNode,l=s&&f.test(s.nodeName||"")),d=e.firesLoad||"src"in t&&(o||n||l),c={target:t},m(t,h.loadingClass),d&&(clearTimeout(D),D=u(oe,2500),b(t,Ae,!0)),l&&p.call(s.getElementsByTagName("source"),ge),o?t.setAttribute("srcset",o):n&&!l&&(te.test(t.nodeName)?function(t,a){try{t.contentWindow.location.replace(a)}catch(e){t.src=a}}(t,n):t.src=n),r&&(o||l)&&_(t,{src:n})),t._lazyRace&&delete t._lazyRace,y(t,h.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;d&&!e||(e&&m(t,"ls-is-cached"),ue(c),t._lazyCache=!0,u(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ze=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[v](h.sizesAttr)||e[v]("sizes")),r="auto"==i;(!r&&P||!a||!e[v]("src")&&!e.srcset||e.complete||d(e,h.errorClass)||!d(e,h.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&M.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,he(e,t,r,i,a))}},ve=W(function(){h.loadMode=3,de()}),pe=function(){3==h.loadMode&&(h.loadMode=2),ve()},me=function(){P||(n.now()-T<999?u(me,999):(P=!0,h.loadMode=3,de(),e("scroll",pe,!0)))},{_:function(){T=n.now(),g.elements=A.getElementsByClassName(h.lazyClass),k=A.getElementsByClassName(h.lazyClass+" "+h.preloadClass),e("scroll",de,!0),e("resize",de,!0),e("pageshow",function(e){if(e.persisted){var t=A.querySelectorAll("."+h.loadingClass);t.length&&t.forEach&&a(function(){t.forEach(function(e){e.complete&&ze(e)})})}}),i.MutationObserver?new MutationObserver(de).observe(z,{childList:!0,subtree:!0,attributes:!0}):(z[o]("DOMNodeInserted",de,!0),z[o]("DOMAttrModified",de,!0),setInterval(de,999)),e("hashchange",de,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,de,!0)}),/d$|^c/.test(A.readyState)?me():(e("load",me),A[o]("DOMContentLoaded",de),u(me,2e4)),g.elements.length?(ce(),S._lsFlush()):de()},checkElems:de,unveil:ze,_aLSL:pe}),M=(R=t(function(e,t,a,i){var r,n,o;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),f.test(t.nodeName||""))for(r=t.getElementsByTagName("source"),n=0,o=r.length;n<o;n++)r[n].setAttribute("sizes",i);a.detail.dataAttr||_(e,a.detail)}),L=function(e,t,a){var i,r=e.parentNode;r&&(a=E(e,r,a),(i=w(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=i.detail.width)&&a!==e._lazysizesWidth&&R(e,r,i,a))},Q=W(function(){var e,t=N.length;if(t)for(e=0;e<t;e++)L(N[e])}),{_:function(){N=A.getElementsByClassName(h.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:L}),B=function(){!B.i&&A.getElementsByClassName&&(B.i=!0,M._(),x._())};var N,R,L,Q;var k,P,D,H,T,U,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,ce,de,ue,fe,Ae,ge,he,ze,ve,pe,me;var ye,be,we,_e,Ce,Ee,Se;return u(function(){h.init&&B()}),g={cfg:h,autoSizer:M,loader:x,init:B,uP:_,aC:m,rC:y,hC:d,fire:w,gW:E,rAF:S}}(e,e.document,Date);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforesizes",function(e){void 0!==e.target._lazysizesWidth&&e.detail.width<e.target._lazysizesWidth&&(e.detail.width=e.target._lazysizesWidth)}),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=t.clientWidth&&1.25*t.clientWidth<t.naturalWidth,n=t.clientHeight&&1.25*t.clientHeight<t.naturalHeight;if(r||n){var o=Math.round(t.offsetWidth*i),s=Math.round(t.offsetHeight*i),l=t.getAttribute("data-src"),c=t.getAttribute("data-src-webp");if(ewww_webp_supported&&c&&-1==l.search("webp=1")&&(l=c),shouldAutoScale(t)&&shouldAutoScale(t.parentNode))if(window.lazySizes.hC(t,"et_pb_jt_filterable_grid_item_image")||window.lazySizes.hC(t,"ss-foreground-image"))d=constrainSrc(l,o,s,"img-crop");else d=constrainSrc(l,o,s,"img");else var d=!1;d&&l!=d&&t.setAttribute("data-src",d)}}if(ewww_webp_supported){if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if(!(c=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",c)}}),function(e,t){var a=function(){t(e.lazySizes),e.removeEventListener("lazyunveilread",a,!0)};t=t.bind(null,e,e.document),"object"==typeof module&&module.exports?t(require("lazysizes")):e.lazySizes?a():e.addEventListener("lazyunveilread",a,!0)}(window,function(o,e,s){"use strict";var l;e.addEventListener&&(l=/\(|\)|\s|'/,addEventListener("lazybeforeunveil",function(e){var t,a;if(e.detail.instance==s&&(!e.defaultPrevented&&("none"==e.target.preload&&(e.target.preload="auto"),t=e.target.getAttribute("data-bg")))){ewww_webp_supported&&(a=e.target.getAttribute("data-bg-webp"))&&(t=a);var i=o.devicePixelRatio||1,r=Math.round(e.target.offsetWidth*i),n=Math.round(e.target.offsetHeight*i);shouldAutoScale(e.target)&&shouldAutoScale(e.target.parentNode)&&(t=o.lazySizes.hC(e.target,"wp-block-cover")?(o.lazySizes.hC(e.target,"has-parallax")&&(r=Math.round(o.screen.width*i),n=Math.round(o.screen.height*i)),constrainSrc(t,r,n,"bg-cover")):o.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,r,n,"bg-cover"):constrainSrc(t,r,n,"bg")),e.target.style.backgroundImage="url("+(l.test(t)?JSON.stringify(t):t)+")"}},!1))});
|
includes/load_webp.js
CHANGED
@@ -461,15 +461,20 @@ var Arrive = (function(window, $, undefined) {
|
|
461 |
|
462 |
})(window, typeof jQuery === 'undefined' ? null : jQuery, undefined);
|
463 |
|
|
|
464 |
// webp detection adapted from https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_using_javascript
|
465 |
function check_webp_feature(feature, callback) {
|
|
|
|
|
|
|
|
|
466 |
var kTestImages = {
|
467 |
alpha: "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",
|
468 |
animation: "UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"
|
469 |
};
|
470 |
var img = new Image();
|
471 |
img.onload = function () {
|
472 |
-
|
473 |
callback(ewww_webp_supported);
|
474 |
};
|
475 |
img.onerror = function () {
|
@@ -659,17 +664,33 @@ function ewwwWebPInit(ewww_webp_supported) {
|
|
659 |
document.arrive('.ewww_webp_lazy_load', function() {
|
660 |
ewwwLoadImages(ewww_webp_supported);
|
661 |
});
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
|
674 |
}
|
675 |
function ewwwAttr(elem, attr, value) {
|
@@ -677,6 +698,58 @@ function ewwwAttr(elem, attr, value) {
|
|
677 |
elem.setAttribute(attr, value);
|
678 |
}
|
679 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
function ewwwNggParseGalleries(ewww_webp_supported) {
|
681 |
if (ewww_webp_supported) {
|
682 |
for(var galleryIndex in galleries) {
|
461 |
|
462 |
})(window, typeof jQuery === 'undefined' ? null : jQuery, undefined);
|
463 |
|
464 |
+
var ewww_webp_supported = false;
|
465 |
// webp detection adapted from https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_using_javascript
|
466 |
function check_webp_feature(feature, callback) {
|
467 |
+
if (ewww_webp_supported) {
|
468 |
+
callback(ewww_webp_supported);
|
469 |
+
return;
|
470 |
+
}
|
471 |
var kTestImages = {
|
472 |
alpha: "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",
|
473 |
animation: "UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"
|
474 |
};
|
475 |
var img = new Image();
|
476 |
img.onload = function () {
|
477 |
+
ewww_webp_supported = (img.width > 0) && (img.height > 0);
|
478 |
callback(ewww_webp_supported);
|
479 |
};
|
480 |
img.onerror = function () {
|
664 |
document.arrive('.ewww_webp_lazy_load', function() {
|
665 |
ewwwLoadImages(ewww_webp_supported);
|
666 |
});
|
667 |
+
document.arrive('videos', function() {
|
668 |
+
ewwwLoadImages(ewww_webp_supported);
|
669 |
+
});
|
670 |
+
if (document.readyState == 'loading') {
|
671 |
+
console.log('deferring ewwwJSONParserInit until DOMContentLoaded')
|
672 |
+
document.addEventListener('DOMContentLoaded', ewwwJSONParserInit);
|
673 |
+
} else {
|
674 |
+
console.log(document.readyState);
|
675 |
+
console.log('running JSON parsers post haste')
|
676 |
+
if ( typeof galleries !== 'undefined' ) {
|
677 |
+
console.log('galleries found, parsing')
|
678 |
+
ewwwNggParseGalleries(ewww_webp_supported);
|
679 |
+
}
|
680 |
+
ewwwWooParseVariations(ewww_webp_supported);
|
681 |
+
//clearInterval(ewww_ngg_galleries);
|
682 |
+
}
|
683 |
+
// var ewww_ngg_galleries_timer = 0;
|
684 |
+
// var ewww_ngg_galleries = setInterval(function() {
|
685 |
+
// if ( typeof galleries !== 'undefined' ) {
|
686 |
+
// ewwwNggParseGalleries(ewww_webp_supported);
|
687 |
+
// clearInterval(ewww_ngg_galleries);
|
688 |
+
// }
|
689 |
+
// ewww_ngg_galleries_timer += 25;
|
690 |
+
// if (ewww_ngg_galleries_timer > 1000) {
|
691 |
+
// clearInterval(ewww_ngg_galleries);
|
692 |
+
// }
|
693 |
+
//}, 25);
|
694 |
|
695 |
}
|
696 |
function ewwwAttr(elem, attr, value) {
|
698 |
elem.setAttribute(attr, value);
|
699 |
}
|
700 |
}
|
701 |
+
function ewwwJSONParserInit() {
|
702 |
+
if ( typeof galleries !== 'undefined' ) {
|
703 |
+
check_webp_feature('alpha', ewwwNggParseGalleries);
|
704 |
+
}
|
705 |
+
check_webp_feature('alpha', ewwwWooParseVariations);
|
706 |
+
}
|
707 |
+
function ewwwWooParseVariations(ewww_webp_supported) {
|
708 |
+
if (!ewww_webp_supported) {
|
709 |
+
return;
|
710 |
+
}
|
711 |
+
var elems = document.querySelectorAll('form.variations_form');
|
712 |
+
for (var i = 0, len = elems.length; i < len; i++){
|
713 |
+
var variations = elems[i].getAttribute('data-product_variations');
|
714 |
+
var variations_changed = false;
|
715 |
+
try {
|
716 |
+
variations = JSON.parse(variations);
|
717 |
+
//console.log(variations);
|
718 |
+
console.log('parsing WC variations');
|
719 |
+
for ( var num in variations ) {
|
720 |
+
if (variations[ num ] !== undefined && variations[ num ].image !== undefined) {
|
721 |
+
console.log(variations[num].image);
|
722 |
+
if (variations[num].image.src_webp !== undefined) {
|
723 |
+
variations[num].image.src = variations[num].image.src_webp;
|
724 |
+
variations_changed = true;
|
725 |
+
}
|
726 |
+
if (variations[num].image.srcset_webp !== undefined) {
|
727 |
+
variations[num].image.srcset = variations[num].image.srcset_webp;
|
728 |
+
variations_changed = true;
|
729 |
+
}
|
730 |
+
if (variations[num].image.full_src_webp !== undefined) {
|
731 |
+
variations[num].image.full_src = variations[num].image.full_src_webp;
|
732 |
+
variations_changed = true;
|
733 |
+
}
|
734 |
+
if (variations[num].image.gallery_thumbnail_src_webp !== undefined) {
|
735 |
+
variations[num].image.gallery_thumbnail_src = variations[num].image.gallery_thumbnail_src_webp;
|
736 |
+
variations_changed = true;
|
737 |
+
}
|
738 |
+
if (variations[num].image.thumb_src_webp !== undefined) {
|
739 |
+
variations[num].image.thumb_src = variations[num].image.thumb_src_webp;
|
740 |
+
variations_changed = true;
|
741 |
+
}
|
742 |
+
}
|
743 |
+
}
|
744 |
+
if (variations_changed) {
|
745 |
+
ewwwAttr(elems[i], 'data-product_variations', JSON.stringify(variations));
|
746 |
+
}
|
747 |
+
} catch (err) {
|
748 |
+
console.log(err);
|
749 |
+
console.log(response);
|
750 |
+
}
|
751 |
+
}
|
752 |
+
}
|
753 |
function ewwwNggParseGalleries(ewww_webp_supported) {
|
754 |
if (ewww_webp_supported) {
|
755 |
for(var galleryIndex in galleries) {
|
includes/load_webp.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var Arrive=function(s,e,c){"use strict";if(s.MutationObserver&&"undefined"!=typeof HTMLElement){var a,t,r=0,u=(a=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,{matchesSelector:function(e,t){return e instanceof HTMLElement&&a.call(e,t)},addMethod:function(e,t,a){var r=e[t];e[t]=function(){return a.length==arguments.length?a.apply(this,arguments):"function"==typeof r?r.apply(this,arguments):void 0}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var a,r=0;a=e[r];r++)a&&a.callback&&a.callback.call(a.elem,a.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,a,r){for(var i,n=0;i=e[n];n++)a(i,t,r)&&r.push({callback:t.callback,elem:i}),0<i.childNodes.length&&u.checkChildNodesRecursively(i.childNodes,t,a,r)},mergeArrays:function(e,t){var a,r={};for(a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);for(a in t)t.hasOwnProperty(a)&&(r[a]=t[a]);return r},toElementsArray:function(e){return void 0===e||"number"==typeof e.length&&e!==s||(e=[e]),e}}),w=((t=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null}).prototype.addEvent=function(e,t,a,r){var i={target:e,selector:t,options:a,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},t.prototype.removeEvent=function(e){for(var t,a=this._eventsBucket.length-1;t=this._eventsBucket[a];a--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(a,1);r&&r.length&&(r[0].callback=null)}},t.prototype.beforeAdding=function(e){this._beforeAdding=e},t.prototype.beforeRemoving=function(e){this._beforeRemoving=e},t),l=function(i,n){var l=new w,o=this,d={fireOnAttributesModification:!1};return l.beforeAdding(function(t){var e,a=t.target;a!==s.document&&a!==s||(a=document.getElementsByTagName("html")[0]),e=new MutationObserver(function(e){n.call(this,e,t)});var r=i(t.options);e.observe(a,r),t.observer=e,t.me=o}),l.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,a){t=u.mergeArrays(d,t);for(var r=u.toElementsArray(this),i=0;i<r.length;i++)l.addEvent(r[i],e,t,a)},this.unbindEvent=function(){var a=u.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<a.length;t++)if(this===c||e.target===a[t])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(a){var e,r=u.toElementsArray(this),i=a;e="function"==typeof a?function(e){for(var t=0;t<r.length;t++)if((this===c||e.target===r[t])&&e.callback===i)return!0;return!1}:function(e){for(var t=0;t<r.length;t++)if((this===c||e.target===r[t])&&e.selector===a)return!0;return!1},l.removeEvent(e)},this.unbindEventWithSelectorAndCallback=function(a,r){var i=u.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<i.length;t++)if((this===c||e.target===i[t])&&e.selector===a&&e.callback===r)return!0;return!1})},this},i=new function(){var d={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};function n(e,t,a){return!(!u.matchesSelector(e,t.selector)||(e._id===c&&(e._id=r++),-1!=t.firedElems.indexOf(e._id))||(t.firedElems.push(e._id),0))}var s=(i=new l(function(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t},function(e,i){e.forEach(function(e){var t=e.addedNodes,a=e.target,r=[];null!==t&&0<t.length?u.checkChildNodesRecursively(t,i,n,r):"attributes"===e.type&&n(a,i)&&r.push({callback:i.callback,elem:a}),u.callCallbacks(r,i)})})).bindEvent;return i.bindEvent=function(e,t,a){t=void 0===a?(a=t,d):u.mergeArrays(d,t);var r=u.toElementsArray(this);if(t.existing){for(var i=[],n=0;n<r.length;n++)for(var l=r[n].querySelectorAll(e),o=0;o<l.length;o++)i.push({callback:a,elem:l[o]});if(t.onceOnly&&i.length)return a.call(i[0].elem,i[0].elem);setTimeout(u.callCallbacks,1,i)}s.call(this,e,t,a)},i},o=new function(){var r={};function i(e,t){return u.matchesSelector(e,t.selector)}var n=(o=new l(function(){return{childList:!0,subtree:!0}},function(e,r){e.forEach(function(e){var t=e.removedNodes,a=[];null!==t&&0<t.length&&u.checkChildNodesRecursively(t,r,i,a),u.callCallbacks(a,r)})})).bindEvent;return o.bindEvent=function(e,t,a){t=void 0===a?(a=t,r):u.mergeArrays(r,t),n.call(this,e,t,a)},o};e&&g(e.fn),g(HTMLElement.prototype),g(NodeList.prototype),g(HTMLCollection.prototype),g(HTMLDocument.prototype),g(Window.prototype);var n={};return d(i,n,"unbindAllArrive"),d(o,n,"unbindAllLeave"),n}function d(e,t,a){u.addMethod(t,a,e.unbindEvent),u.addMethod(t,a,e.unbindEventWithSelectorOrCallback),u.addMethod(t,a,e.unbindEventWithSelectorAndCallback)}function g(e){e.arrive=i.bindEvent,d(i,e,"unbindArrive"),e.leave=o.bindEvent,d(o,e,"unbindLeave")}}(window,"undefined"==typeof jQuery?null:jQuery,void 0);function check_webp_feature(e,t){var a=new Image;a.onload=function(){var e=0<a.width&&0<a.height;t(e)},a.onerror=function(){t(!1)},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function ewwwLoadImages(e){var n="data-";function t(e,t){for(var a=["accesskey","align","alt","border","class","contenteditable","contextmenu","crossorigin","dir","draggable","dropzone","height","hidden","hspace","id","ismap","lang","longdesc","sizes","spellcheck","style","tabindex","title","translate","usemap","vspace","width","data-animation","data-attachment-id","data-auto-height","data-caption","data-comments-opened","data-delay","data-event-trigger","data-flex_fx","data-height","data-hide-on-end","data-highlight-color","data-highlight-border-color","data-highlight-border-opacity","data-highlight-border-width","data-highlight-opacity","data-image-meta","data-image-title","data-image-description","data-interval","data-large_image_width","data-large_image_height","data-lazy","data-lazy-type","data-mode","data-name","data-no-lazy","data-orig-size","data-partial","data-per-view","data-permalink","data-pin-description","data-pin-id","data-pin-media","data-pin-url","data-rel","data-ride","data-shadow","data-shadow-direction","data-slide","data-slide-to","data-target","data-vc-zoom","data-width","data-wrap"],r=0,i=a.length;r<i;r++)ewwwAttr(t,a[r],e.getAttribute(n+a[r]));return t}if(e){for(var a=document.querySelectorAll(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a, .ngg-galleria-offscreen-seo-wrapper a"),r=0,i=a.length;r<i;r++)ewwwAttr(a[r],"data-src",a[r].getAttribute("data-webp")),ewwwAttr(a[r],"data-thumbnail",a[r].getAttribute("data-webp-thumbnail"));for(r=0,i=(o=document.querySelectorAll(".rev_slider ul li")).length;r<i;r++){ewwwAttr(o[r],"data-thumb",o[r].getAttribute("data-webp-thumb"));for(var l=1;l<11;)ewwwAttr(o[r],"data-param"+l,o[r].getAttribute("data-webp-param"+l)),l++}var o;for(r=0,i=(o=document.querySelectorAll(".rev_slider img")).length;r<i;r++)ewwwAttr(o[r],"data-lazyload",o[r].getAttribute("data-webp-lazyload"));var d=document.querySelectorAll("div.woocommerce-product-gallery__image");for(r=0,i=d.length;r<i;r++)ewwwAttr(d[r],"data-thumb",d[r].getAttribute("data-webp-thumb"))}var s=document.querySelectorAll("video");for(r=0,i=s.length;r<i;r++)ewwwAttr(s[r],"poster",e?s[r].getAttribute("data-poster-webp"):s[r].getAttribute("data-poster-image"));var c=document.querySelectorAll("img.ewww_webp_lazy_load");for(r=0,i=c.length;r<i;r++){if(e){ewwwAttr(c[r],"data-lazy-srcset",c[r].getAttribute("data-lazy-srcset-webp")),ewwwAttr(c[r],"data-srcset",c[r].getAttribute("data-srcset-webp")),ewwwAttr(c[r],"data-lazy-src",c[r].getAttribute("data-lazy-src-webp")),ewwwAttr(c[r],"data-src",c[r].getAttribute("data-src-webp")),ewwwAttr(c[r],"data-orig-file",c[r].getAttribute("data-webp-orig-file")),ewwwAttr(c[r],"data-medium-file",c[r].getAttribute("data-webp-medium-file")),ewwwAttr(c[r],"data-large-file",c[r].getAttribute("data-webp-large-file"));var u=c[r].getAttribute("srcset");null!=u&&!1!==u&&u.includes("R0lGOD")&&ewwwAttr(c[r],"src",c[r].getAttribute("data-lazy-src-webp"))}c[r].className=c[r].className.replace(/\bewww_webp_lazy_load\b/,"")}var w=document.querySelectorAll(".ewww_webp");for(r=0,i=w.length;r<i;r++){var g=document.createElement("img");e?(ewwwAttr(g,"src",w[r].getAttribute("data-webp")),ewwwAttr(g,"srcset",w[r].getAttribute("data-srcset-webp")),ewwwAttr(g,"data-orig-file",w[r].getAttribute("data-orig-file")),ewwwAttr(g,"data-orig-file",w[r].getAttribute("data-webp-orig-file")),ewwwAttr(g,"data-medium-file",w[r].getAttribute("data-medium-file")),ewwwAttr(g,"data-medium-file",w[r].getAttribute("data-webp-medium-file")),ewwwAttr(g,"data-large-file",w[r].getAttribute("data-large-file")),ewwwAttr(g,"data-large-file",w[r].getAttribute("data-webp-large-file")),ewwwAttr(g,"data-large_image",w[r].getAttribute("data-large_image")),ewwwAttr(g,"data-large_image",w[r].getAttribute("data-webp-large_image")),ewwwAttr(g,"data-src",w[r].getAttribute("data-src")),ewwwAttr(g,"data-src",w[r].getAttribute("data-webp-src"))):(ewwwAttr(g,"src",w[r].getAttribute("data-img")),ewwwAttr(g,"srcset",w[r].getAttribute("data-srcset-img")),ewwwAttr(g,"data-orig-file",w[r].getAttribute("data-orig-file")),ewwwAttr(g,"data-medium-file",w[r].getAttribute("data-medium-file")),ewwwAttr(g,"data-large-file",w[r].getAttribute("data-large-file")),ewwwAttr(g,"data-large_image",w[r].getAttribute("data-large_image")),ewwwAttr(g,"data-src",w[r].getAttribute("data-src"))),g=t(w[r],g),w[r].parentNode.insertBefore(g,w[r].nextSibling),w[r].className=w[r].className.replace(/\bewww_webp\b/,"")}window.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()}))}function ewwwWebPInit(e){ewwwLoadImages(e),ewwwNggLoadGalleries(e),document.arrive(".ewww_webp",function(){ewwwLoadImages(e)}),document.arrive(".ewww_webp_lazy_load",function(){ewwwLoadImages(e)});var t=0,a=setInterval(function(){"undefined"!=typeof galleries&&(ewwwNggParseGalleries(e),clearInterval(a)),1e3<(t+=25)&&clearInterval(a)},25)}function ewwwAttr(e,t,a){null!=a&&!1!==a&&e.setAttribute(t,a)}function ewwwNggParseGalleries(e){if(e)for(var t in galleries){var a=galleries[t];galleries[t].images_list=ewwwNggParseImageList(a.images_list)}}function ewwwNggLoadGalleries(e){e&&document.addEventListener("ngg.galleria.themeadded",function(e,t){window.ngg_galleria._create_backup=window.ngg_galleria.create,window.ngg_galleria.create=function(e,t){var a=$(e).data("id");return galleries["gallery_"+a].images_list=ewwwNggParseImageList(galleries["gallery_"+a].images_list),window.ngg_galleria._create_backup(e,t)}})}function ewwwNggParseImageList(e){for(var t in e){var a=e[t];if(void 0!==a["image-webp"]&&(e[t].image=a["image-webp"],delete e[t]["image-webp"]),void 0!==a["thumb-webp"]&&(e[t].thumb=a["thumb-webp"],delete e[t]["thumb-webp"]),void 0!==a.full_image_webp&&(e[t].full_image=a.full_image_webp,delete e[t].full_image_webp),void 0!==a.srcsets)for(var r in a.srcsets)nggSrcset=a.srcsets[r],void 0!==a.srcsets[r+"-webp"]&&(e[t].srcsets[r]=a.srcsets[r+"-webp"],delete e[t].srcsets[r+"-webp"]);if(void 0!==a.full_srcsets)for(var i in a.full_srcsets)nggFSrcset=a.full_srcsets[i],void 0!==a.full_srcsets[i+"-webp"]&&(e[t].full_srcsets[i]=a.full_srcsets[i+"-webp"],delete e[t].full_srcsets[i+"-webp"])}return e}check_webp_feature("alpha",ewwwWebPInit);
|
1 |
+
var Arrive=function(d,e,w){"use strict";if(d.MutationObserver&&"undefined"!=typeof HTMLElement){var a,t,r=0,c=(a=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,{matchesSelector:function(e,t){return e instanceof HTMLElement&&a.call(e,t)},addMethod:function(e,t,a){var r=e[t];e[t]=function(){return a.length==arguments.length?a.apply(this,arguments):"function"==typeof r?r.apply(this,arguments):void 0}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var a,r=0;a=e[r];r++)a&&a.callback&&a.callback.call(a.elem,a.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,a,r){for(var i,n=0;i=e[n];n++)a(i,t,r)&&r.push({callback:t.callback,elem:i}),0<i.childNodes.length&&c.checkChildNodesRecursively(i.childNodes,t,a,r)},mergeArrays:function(e,t){var a,r={};for(a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);for(a in t)t.hasOwnProperty(a)&&(r[a]=t[a]);return r},toElementsArray:function(e){return void 0===e||"number"==typeof e.length&&e!==d||(e=[e]),e}}),u=((t=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null}).prototype.addEvent=function(e,t,a,r){var i={target:e,selector:t,options:a,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},t.prototype.removeEvent=function(e){for(var t,a=this._eventsBucket.length-1;t=this._eventsBucket[a];a--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(a,1);r&&r.length&&(r[0].callback=null)}},t.prototype.beforeAdding=function(e){this._beforeAdding=e},t.prototype.beforeRemoving=function(e){this._beforeRemoving=e},t),l=function(i,n){var l=new u,o=this,s={fireOnAttributesModification:!1};return l.beforeAdding(function(t){var e,a=t.target;a!==d.document&&a!==d||(a=document.getElementsByTagName("html")[0]),e=new MutationObserver(function(e){n.call(this,e,t)});var r=i(t.options);e.observe(a,r),t.observer=e,t.me=o}),l.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,a){t=c.mergeArrays(s,t);for(var r=c.toElementsArray(this),i=0;i<r.length;i++)l.addEvent(r[i],e,t,a)},this.unbindEvent=function(){var a=c.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<a.length;t++)if(this===w||e.target===a[t])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(a){var e,r=c.toElementsArray(this),i=a;e="function"==typeof a?function(e){for(var t=0;t<r.length;t++)if((this===w||e.target===r[t])&&e.callback===i)return!0;return!1}:function(e){for(var t=0;t<r.length;t++)if((this===w||e.target===r[t])&&e.selector===a)return!0;return!1},l.removeEvent(e)},this.unbindEventWithSelectorAndCallback=function(a,r){var i=c.toElementsArray(this);l.removeEvent(function(e){for(var t=0;t<i.length;t++)if((this===w||e.target===i[t])&&e.selector===a&&e.callback===r)return!0;return!1})},this},i=new function(){var s={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};function n(e,t,a){return!(!c.matchesSelector(e,t.selector)||(e._id===w&&(e._id=r++),-1!=t.firedElems.indexOf(e._id))||(t.firedElems.push(e._id),0))}var d=(i=new l(function(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t},function(e,i){e.forEach(function(e){var t=e.addedNodes,a=e.target,r=[];null!==t&&0<t.length?c.checkChildNodesRecursively(t,i,n,r):"attributes"===e.type&&n(a,i)&&r.push({callback:i.callback,elem:a}),c.callCallbacks(r,i)})})).bindEvent;return i.bindEvent=function(e,t,a){t=void 0===a?(a=t,s):c.mergeArrays(s,t);var r=c.toElementsArray(this);if(t.existing){for(var i=[],n=0;n<r.length;n++)for(var l=r[n].querySelectorAll(e),o=0;o<l.length;o++)i.push({callback:a,elem:l[o]});if(t.onceOnly&&i.length)return a.call(i[0].elem,i[0].elem);setTimeout(c.callCallbacks,1,i)}d.call(this,e,t,a)},i},o=new function(){var r={};function i(e,t){return c.matchesSelector(e,t.selector)}var n=(o=new l(function(){return{childList:!0,subtree:!0}},function(e,r){e.forEach(function(e){var t=e.removedNodes,a=[];null!==t&&0<t.length&&c.checkChildNodesRecursively(t,r,i,a),c.callCallbacks(a,r)})})).bindEvent;return o.bindEvent=function(e,t,a){t=void 0===a?(a=t,r):c.mergeArrays(r,t),n.call(this,e,t,a)},o};e&&g(e.fn),g(HTMLElement.prototype),g(NodeList.prototype),g(HTMLCollection.prototype),g(HTMLDocument.prototype),g(Window.prototype);var n={};return s(i,n,"unbindAllArrive"),s(o,n,"unbindAllLeave"),n}function s(e,t,a){c.addMethod(t,a,e.unbindEvent),c.addMethod(t,a,e.unbindEventWithSelectorOrCallback),c.addMethod(t,a,e.unbindEventWithSelectorAndCallback)}function g(e){e.arrive=i.bindEvent,s(i,e,"unbindArrive"),e.leave=o.bindEvent,s(o,e,"unbindLeave")}}(window,"undefined"==typeof jQuery?null:jQuery,void 0),ewww_webp_supported=!1;function check_webp_feature(e,t){if(ewww_webp_supported)t(ewww_webp_supported);else{var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t(ewww_webp_supported)},a.onerror=function(){t(!1)},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}}function ewwwLoadImages(e){var n="data-";function t(e,t){for(var a=["accesskey","align","alt","border","class","contenteditable","contextmenu","crossorigin","dir","draggable","dropzone","height","hidden","hspace","id","ismap","lang","longdesc","sizes","spellcheck","style","tabindex","title","translate","usemap","vspace","width","data-animation","data-attachment-id","data-auto-height","data-caption","data-comments-opened","data-delay","data-event-trigger","data-flex_fx","data-height","data-hide-on-end","data-highlight-color","data-highlight-border-color","data-highlight-border-opacity","data-highlight-border-width","data-highlight-opacity","data-image-meta","data-image-title","data-image-description","data-interval","data-large_image_width","data-large_image_height","data-lazy","data-lazy-type","data-mode","data-name","data-no-lazy","data-orig-size","data-partial","data-per-view","data-permalink","data-pin-description","data-pin-id","data-pin-media","data-pin-url","data-rel","data-ride","data-shadow","data-shadow-direction","data-slide","data-slide-to","data-target","data-vc-zoom","data-width","data-wrap"],r=0,i=a.length;r<i;r++)ewwwAttr(t,a[r],e.getAttribute(n+a[r]));return t}if(e){for(var a=document.querySelectorAll(".batch-image img, .image-wrapper a, .ngg-pro-masonry-item a, .ngg-galleria-offscreen-seo-wrapper a"),r=0,i=a.length;r<i;r++)ewwwAttr(a[r],"data-src",a[r].getAttribute("data-webp")),ewwwAttr(a[r],"data-thumbnail",a[r].getAttribute("data-webp-thumbnail"));for(r=0,i=(o=document.querySelectorAll(".rev_slider ul li")).length;r<i;r++){ewwwAttr(o[r],"data-thumb",o[r].getAttribute("data-webp-thumb"));for(var l=1;l<11;)ewwwAttr(o[r],"data-param"+l,o[r].getAttribute("data-webp-param"+l)),l++}var o;for(r=0,i=(o=document.querySelectorAll(".rev_slider img")).length;r<i;r++)ewwwAttr(o[r],"data-lazyload",o[r].getAttribute("data-webp-lazyload"));var s=document.querySelectorAll("div.woocommerce-product-gallery__image");for(r=0,i=s.length;r<i;r++)ewwwAttr(s[r],"data-thumb",s[r].getAttribute("data-webp-thumb"))}var d=document.querySelectorAll("video");for(r=0,i=d.length;r<i;r++)ewwwAttr(d[r],"poster",e?d[r].getAttribute("data-poster-webp"):d[r].getAttribute("data-poster-image"));var w=document.querySelectorAll("img.ewww_webp_lazy_load");for(r=0,i=w.length;r<i;r++){if(e){ewwwAttr(w[r],"data-lazy-srcset",w[r].getAttribute("data-lazy-srcset-webp")),ewwwAttr(w[r],"data-srcset",w[r].getAttribute("data-srcset-webp")),ewwwAttr(w[r],"data-lazy-src",w[r].getAttribute("data-lazy-src-webp")),ewwwAttr(w[r],"data-src",w[r].getAttribute("data-src-webp")),ewwwAttr(w[r],"data-orig-file",w[r].getAttribute("data-webp-orig-file")),ewwwAttr(w[r],"data-medium-file",w[r].getAttribute("data-webp-medium-file")),ewwwAttr(w[r],"data-large-file",w[r].getAttribute("data-webp-large-file"));var c=w[r].getAttribute("srcset");null!=c&&!1!==c&&c.includes("R0lGOD")&&ewwwAttr(w[r],"src",w[r].getAttribute("data-lazy-src-webp"))}w[r].className=w[r].className.replace(/\bewww_webp_lazy_load\b/,"")}var u=document.querySelectorAll(".ewww_webp");for(r=0,i=u.length;r<i;r++){var g=document.createElement("img");e?(ewwwAttr(g,"src",u[r].getAttribute("data-webp")),ewwwAttr(g,"srcset",u[r].getAttribute("data-srcset-webp")),ewwwAttr(g,"data-orig-file",u[r].getAttribute("data-orig-file")),ewwwAttr(g,"data-orig-file",u[r].getAttribute("data-webp-orig-file")),ewwwAttr(g,"data-medium-file",u[r].getAttribute("data-medium-file")),ewwwAttr(g,"data-medium-file",u[r].getAttribute("data-webp-medium-file")),ewwwAttr(g,"data-large-file",u[r].getAttribute("data-large-file")),ewwwAttr(g,"data-large-file",u[r].getAttribute("data-webp-large-file")),ewwwAttr(g,"data-large_image",u[r].getAttribute("data-large_image")),ewwwAttr(g,"data-large_image",u[r].getAttribute("data-webp-large_image")),ewwwAttr(g,"data-src",u[r].getAttribute("data-src")),ewwwAttr(g,"data-src",u[r].getAttribute("data-webp-src"))):(ewwwAttr(g,"src",u[r].getAttribute("data-img")),ewwwAttr(g,"srcset",u[r].getAttribute("data-srcset-img")),ewwwAttr(g,"data-orig-file",u[r].getAttribute("data-orig-file")),ewwwAttr(g,"data-medium-file",u[r].getAttribute("data-medium-file")),ewwwAttr(g,"data-large-file",u[r].getAttribute("data-large-file")),ewwwAttr(g,"data-large_image",u[r].getAttribute("data-large_image")),ewwwAttr(g,"data-src",u[r].getAttribute("data-src"))),g=t(u[r],g),u[r].parentNode.insertBefore(g,u[r].nextSibling),u[r].className=u[r].className.replace(/\bewww_webp\b/,"")}window.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()}))}function ewwwWebPInit(e){ewwwLoadImages(e),ewwwNggLoadGalleries(e),document.arrive(".ewww_webp",function(){ewwwLoadImages(e)}),document.arrive(".ewww_webp_lazy_load",function(){ewwwLoadImages(e)}),document.arrive("videos",function(){ewwwLoadImages(e)}),"loading"==document.readyState?document.addEventListener("DOMContentLoaded",ewwwJSONParserInit):("undefined"!=typeof galleries&&ewwwNggParseGalleries(e),ewwwWooParseVariations(e))}function ewwwAttr(e,t,a){null!=a&&!1!==a&&e.setAttribute(t,a)}function ewwwJSONParserInit(){"undefined"!=typeof galleries&&check_webp_feature("alpha",ewwwNggParseGalleries),check_webp_feature("alpha",ewwwWooParseVariations)}function ewwwWooParseVariations(e){if(e)for(var t=document.querySelectorAll("form.variations_form"),a=0,r=t.length;a<r;a++){var i=t[a].getAttribute("data-product_variations"),n=!1;try{for(var l in i=JSON.parse(i))void 0!==i[l]&&void 0!==i[l].image&&(void 0!==i[l].image.src_webp&&(i[l].image.src=i[l].image.src_webp,n=!0),void 0!==i[l].image.srcset_webp&&(i[l].image.srcset=i[l].image.srcset_webp,n=!0),void 0!==i[l].image.full_src_webp&&(i[l].image.full_src=i[l].image.full_src_webp,n=!0),void 0!==i[l].image.gallery_thumbnail_src_webp&&(i[l].image.gallery_thumbnail_src=i[l].image.gallery_thumbnail_src_webp,n=!0),void 0!==i[l].image.thumb_src_webp&&(i[l].image.thumb_src=i[l].image.thumb_src_webp,n=!0));n&&ewwwAttr(t[a],"data-product_variations",JSON.stringify(i))}catch(e){}}}function ewwwNggParseGalleries(e){if(e)for(var t in galleries){var a=galleries[t];galleries[t].images_list=ewwwNggParseImageList(a.images_list)}}function ewwwNggLoadGalleries(e){e&&document.addEventListener("ngg.galleria.themeadded",function(e,t){window.ngg_galleria._create_backup=window.ngg_galleria.create,window.ngg_galleria.create=function(e,t){var a=$(e).data("id");return galleries["gallery_"+a].images_list=ewwwNggParseImageList(galleries["gallery_"+a].images_list),window.ngg_galleria._create_backup(e,t)}})}function ewwwNggParseImageList(e){for(var t in e){var a=e[t];if(void 0!==a["image-webp"]&&(e[t].image=a["image-webp"],delete e[t]["image-webp"]),void 0!==a["thumb-webp"]&&(e[t].thumb=a["thumb-webp"],delete e[t]["thumb-webp"]),void 0!==a.full_image_webp&&(e[t].full_image=a.full_image_webp,delete e[t].full_image_webp),void 0!==a.srcsets)for(var r in a.srcsets)nggSrcset=a.srcsets[r],void 0!==a.srcsets[r+"-webp"]&&(e[t].srcsets[r]=a.srcsets[r+"-webp"],delete e[t].srcsets[r+"-webp"]);if(void 0!==a.full_srcsets)for(var i in a.full_srcsets)nggFSrcset=a.full_srcsets[i],void 0!==a.full_srcsets[i+"-webp"]&&(e[t].full_srcsets[i]=a.full_srcsets[i+"-webp"],delete e[t].full_srcsets[i+"-webp"])}return e}check_webp_feature("alpha",ewwwWebPInit);
|
includes/media.js
CHANGED
@@ -10,7 +10,7 @@ jQuery(document).on('click', '.ewww-manual-optimize', function() {
|
|
10 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
11 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.optimizing );
|
12 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
13 |
-
var ewww_manual_response =
|
14 |
if (ewww_manual_response.error) {
|
15 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
16 |
} else if (ewww_manual_response.success) {
|
@@ -36,7 +36,7 @@ jQuery(document).on('click', '.ewww-manual-convert', function() {
|
|
36 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
37 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.optimizing );
|
38 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
39 |
-
var ewww_manual_response =
|
40 |
if (ewww_manual_response.error) {
|
41 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
42 |
} else if (ewww_manual_response.success) {
|
@@ -60,7 +60,7 @@ jQuery(document).on('click', '.ewww-manual-restore', function() {
|
|
60 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
61 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.restoring );
|
62 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
63 |
-
var ewww_manual_response =
|
64 |
if (ewww_manual_response.error) {
|
65 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
66 |
} else if (ewww_manual_response.success) {
|
@@ -84,7 +84,7 @@ jQuery(document).on('click', '.ewww-manual-cloud-restore', function() {
|
|
84 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
85 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.restoring );
|
86 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
87 |
-
var ewww_manual_response =
|
88 |
if (ewww_manual_response.error) {
|
89 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
90 |
} else if (ewww_manual_response.success) {
|
10 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
11 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.optimizing );
|
12 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
13 |
+
var ewww_manual_response = JSON.parse(response);
|
14 |
if (ewww_manual_response.error) {
|
15 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
16 |
} else if (ewww_manual_response.success) {
|
36 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
37 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.optimizing );
|
38 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
39 |
+
var ewww_manual_response = JSON.parse(response);
|
40 |
if (ewww_manual_response.error) {
|
41 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
42 |
} else if (ewww_manual_response.success) {
|
60 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
61 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.restoring );
|
62 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
63 |
+
var ewww_manual_response = JSON.parse(response);
|
64 |
if (ewww_manual_response.error) {
|
65 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
66 |
} else if (ewww_manual_response.success) {
|
84 |
post_id = jQuery(this).closest('.ewww-media-status').data('id');
|
85 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_vars.restoring );
|
86 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
87 |
+
var ewww_manual_response = JSON.parse(response);
|
88 |
if (ewww_manual_response.error) {
|
89 |
jQuery('#ewww-media-status-' + post_id ).html( ewww_manual_response.error );
|
90 |
} else if (ewww_manual_response.success) {
|
includes/nextcellent.js
CHANGED
@@ -9,7 +9,7 @@ jQuery(document).on( 'click', '.ewww-manual-optimize', function() {
|
|
9 |
};
|
10 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_vars.optimizing );
|
11 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
12 |
-
var ewww_manual_response =
|
13 |
if (ewww_manual_response.error) {
|
14 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_manual_response.error );
|
15 |
} else if (ewww_manual_response.success) {
|
@@ -28,7 +28,7 @@ jQuery(document).on( 'click', '.ewww-manual-cloud-restore', function() {
|
|
28 |
};
|
29 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_vars.restoring );
|
30 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
31 |
-
var ewww_manual_response =
|
32 |
if (ewww_manual_response.error) {
|
33 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_manual_response.error );
|
34 |
} else if (ewww_manual_response.success) {
|
9 |
};
|
10 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_vars.optimizing );
|
11 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
12 |
+
var ewww_manual_response = JSON.parse(response);
|
13 |
if (ewww_manual_response.error) {
|
14 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_manual_response.error );
|
15 |
} else if (ewww_manual_response.success) {
|
28 |
};
|
29 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_vars.restoring );
|
30 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
31 |
+
var ewww_manual_response = JSON.parse(response);
|
32 |
if (ewww_manual_response.error) {
|
33 |
jQuery('#ewww-nextcellent-status-' + post_id ).html( ewww_manual_response.error );
|
34 |
} else if (ewww_manual_response.success) {
|
includes/nextgen.js
CHANGED
@@ -9,7 +9,7 @@ jQuery(document).on( 'click', '.ewww-manual-optimize', function() {
|
|
9 |
};
|
10 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_vars.optimizing );
|
11 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
12 |
-
var ewww_manual_response =
|
13 |
if (ewww_manual_response.error) {
|
14 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_manual_response.error );
|
15 |
} else if (ewww_manual_response.success) {
|
@@ -28,7 +28,7 @@ jQuery(document).on( 'click', '.ewww-manual-cloud-restore', function() {
|
|
28 |
};
|
29 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_vars.restoring );
|
30 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
31 |
-
var ewww_manual_response =
|
32 |
if (ewww_manual_response.error) {
|
33 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_manual_response.error );
|
34 |
} else if (ewww_manual_response.success) {
|
9 |
};
|
10 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_vars.optimizing );
|
11 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
12 |
+
var ewww_manual_response = JSON.parse(response);
|
13 |
if (ewww_manual_response.error) {
|
14 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_manual_response.error );
|
15 |
} else if (ewww_manual_response.success) {
|
28 |
};
|
29 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_vars.restoring );
|
30 |
jQuery.post(ajaxurl, ewww_manual_optimize_data, function(response) {
|
31 |
+
var ewww_manual_response = JSON.parse(response);
|
32 |
if (ewww_manual_response.error) {
|
33 |
jQuery('#ewww-nextgen-status-' + post_id ).html( ewww_manual_response.error );
|
34 |
} else if (ewww_manual_response.success) {
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: nosilver4u
|
|
3 |
Donate link: https://ewww.io/donate/
|
4 |
Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale
|
5 |
Requires at least: 5.3
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag:
|
9 |
License: GPLv3
|
10 |
|
11 |
Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
|
@@ -132,6 +132,31 @@ That's not a question, but since I made it up, I'll answer it. See this resource
|
|
132 |
* Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io)
|
133 |
* If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
= 5.8.2 =
|
136 |
* security: improper nonce verification for Nextgen bulk optimizer initialization (minor severity)
|
137 |
* changed: Easy IO verification performed via API for better reliability
|
3 |
Donate link: https://ewww.io/donate/
|
4 |
Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization, lossless, lossy, seo, scale
|
5 |
Requires at least: 5.3
|
6 |
+
Tested up to: 5.6
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 6.0.0
|
9 |
License: GPLv3
|
10 |
|
11 |
Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
|
132 |
* Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io)
|
133 |
* If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
|
134 |
|
135 |
+
= 6.0.0 =
|
136 |
+
* added: tool to delete originals from WP 5.3+ auto-scaling behavior (Tools menu)
|
137 |
+
* added: JS WebP recognizes video elements added via JS (e.g. infinite scroll)
|
138 |
+
* added: automatically convert GIF to PNG during new uploads, unless animated
|
139 |
+
* added: JS WebP and picture WebP auto-detect configuration for S3 Uploads and WP Stateless
|
140 |
+
* added: Lazy Load for external CSS and separate style blocks (div elements only for now)
|
141 |
+
* added: Easy IO/CDN rewriting for Ultimate Member AJAX-powered activity wall
|
142 |
+
* changed: settings UI revamped with wizard for first-time installs
|
143 |
+
* changed: automatic PNG to JPG threshold lowered to 250kb
|
144 |
+
* changed: extensions for WP_Image_Editor now disabled by default, use EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR constant to enable them
|
145 |
+
* changed: JS WebP can be used with picture WebP + Lazy Load to support CSS background images
|
146 |
+
* changed: better compatibility with Theia Smart Thumbnails
|
147 |
+
* changed: Lazy Load auto-sizing will no longer decrease the image size, only increasing is allowed
|
148 |
+
* changed: filter to include additional HTML element types via eio_allowed_background_image_elements filter for Lazy Load and Easy IO
|
149 |
+
* fixed: compatibility between Easy IO and Autoptimize
|
150 |
+
* fixed: Easy IO uses hard crop when constraining an image via a width/height found in the style attribute
|
151 |
+
* fixed: Easy IO uses hard-coded wp-content/ and wp-includes/ paths in some cases
|
152 |
+
* fixed: Easy IO not activating properly when plugin is activated network-wide for multi-site installs
|
153 |
+
* fixed: database upgrade throws errors on MariaDB 10.4.x
|
154 |
+
* fixed: WebP .htaccess error in Vary header rule
|
155 |
+
* fixed: Easy IO doubles part of image URL when there are no thumbnails, but one is requested by a plugin or theme
|
156 |
+
* fixed: Easy IO minifier breaks Beaver Builder
|
157 |
+
* fixed: Lazy Load breaks Beaver Builder text editor
|
158 |
+
* removed: JS defer with Easy IO, use SWIS Performance instead: https://ewww.io/swis/
|
159 |
+
|
160 |
= 5.8.2 =
|
161 |
* security: improper nonce verification for Nextgen bulk optimizer initialization (minor severity)
|
162 |
* changed: Easy IO verification performed via API for better reliability
|
unique.php
CHANGED
@@ -191,7 +191,7 @@ function ewww_image_optimizer_notice_hosting_requires_api() {
|
|
191 |
}
|
192 |
echo "<div id='ewww-image-optimizer-warning-exec' class='notice notice-warning is-dismissible'><p>" .
|
193 |
/* translators: %s: Name of a web host, like WordPress.com or Pantheon. */
|
194 |
-
sprintf( esc_html__( '
|
195 |
'<br><strong>' .
|
196 |
/* translators: %s: link to 'start your free trial' */
|
197 |
sprintf( esc_html__( 'Dismiss this notice to continue with free cloud-based JPG compression or %s.', 'ewww-image-optimizer' ), "<a href='https://ewww.io/plans/'>" . esc_html__( 'start your premium trial', 'ewww-image-optimizer' ) . '</a>' );
|
@@ -553,6 +553,15 @@ function ewww_image_optimizer_dismiss_exec_notice() {
|
|
553 |
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
|
554 |
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
555 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
update_option( 'ewww_image_optimizer_jpg_level', 10 );
|
557 |
update_option( 'ewww_image_optimizer_png_level', 0 );
|
558 |
update_option( 'ewww_image_optimizer_gif_level', 0 );
|
@@ -560,7 +569,6 @@ function ewww_image_optimizer_dismiss_exec_notice() {
|
|
560 |
update_option( 'ewww_image_optimizer_svg_level', 0 );
|
561 |
update_option( 'ewww_image_optimizer_dismiss_exec_notice', 1 );
|
562 |
update_site_option( 'ewww_image_optimizer_dismiss_exec_notice', 1 );
|
563 |
-
wp_die();
|
564 |
}
|
565 |
|
566 |
/**
|
@@ -574,24 +582,16 @@ function ewww_image_optimizer_notice_utils( $quiet = null ) {
|
|
574 |
if ( ewww_image_optimizer_exec_check() ) {
|
575 |
// Need to be a little particular with the quiet parameter.
|
576 |
if ( 'quiet' !== $quiet && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_dismiss_exec_notice' ) ) {
|
577 |
-
$exactdn_dismiss = ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ? true : false;
|
578 |
ob_start();
|
579 |
-
$notice_class = 'notice notice-warning is-dismissible';
|
580 |
-
$notice_action = __( 'An API key or Easy IO subscription will allow you to offload the compression to our dedicated servers instead.', 'ewww-image-optimizer' );
|
581 |
-
/* translators: %s: link to 'start your free trial' */
|
582 |
-
$notice_action = sprintf( __( 'You may ask your system administrator to enable exec(), dismiss this notice to continue with free cloud-based compression or %s.', 'ewww-image-optimizer' ), "<a href='https://ewww.io/plans/'>" . __( 'start your premium trial', 'ewww-image-optimizer' ) . '</a>' ) . '</p></div>';
|
583 |
-
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
584 |
-
$notice_action = __( 'Sites that use Easy IO already have built-in image optimization and may dismiss this notice to disable local compression.', 'ewww-image-optimizer' );
|
585 |
-
}
|
586 |
// Display a warning if exec() is disabled, can't run local tools without it.
|
587 |
-
echo "<div id='ewww-image-optimizer-warning-exec' class='
|
588 |
-
esc_html__( '
|
589 |
'<strong>' .
|
590 |
( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) || get_option( 'easyio_exactdn' ) ?
|
591 |
esc_html__( 'Sites that use Easy IO already have built-in image optimization and may dismiss this notice to disable local compression.', 'ewww-image-optimizer' )
|
592 |
:
|
593 |
/* translators: %s: link to 'start your free trial' */
|
594 |
-
sprintf( esc_html__( 'You may ask your system administrator to enable exec(), dismiss this notice to continue with free cloud-based compression or %s.', 'ewww-image-optimizer' ), "<a href='https://ewww.io/plans/'>" . esc_html__( 'start your premium trial', 'ewww-image-optimizer' ) . '</a>' )
|
595 |
);
|
596 |
ewwwio_help_link( 'https://docs.ewww.io/article/29-what-is-exec-and-why-do-i-need-it', '592dd12d0428634b4a338c39' );
|
597 |
echo '</strong></p></div>';
|
@@ -749,10 +749,18 @@ function ewww_image_optimizer_notice_utils( $quiet = null ) {
|
|
749 |
'<a href="https://docs.ewww.io/article/95-installing-svgcleaner" data-beacon-article="5f7921c9cff47e001a58adbc">' . esc_html__( 'manually', 'ewww-image-optimizer' ) . '</a>'
|
750 |
) .
|
751 |
'</p></div>';
|
752 |
-
}
|
753 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
sprintf(
|
755 |
-
/* translators: 1-6: jpegtran, optipng, pngout, pngquant, gifsicle, and cwebp (links) 7: Settings Page (link)
|
756 |
esc_html__( 'EWWW Image Optimizer uses %1$s, %2$s, %3$s, %4$s, %5$s, and %6$s. You are missing: %7$s. Please install via the %8$s or the %9$s.', 'ewww-image-optimizer' ),
|
757 |
"<a href='http://jpegclub.org/jpegtran/'>jpegtran</a>",
|
758 |
"<a href='http://optipng.sourceforge.net/'>optipng</a>",
|
@@ -765,6 +773,19 @@ function ewww_image_optimizer_notice_utils( $quiet = null ) {
|
|
765 |
"<a href='https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something' data-beacon-article='585371e3c697912ffd6c0ba1' target='_blank'>" . esc_html__( 'Installation Instructions', 'ewww-image-optimizer' ) . '</a>'
|
766 |
) .
|
767 |
'</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
768 |
}
|
769 |
ewwwio_memory( __FUNCTION__ );
|
770 |
}
|
@@ -2030,14 +2051,11 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2030 |
}
|
2031 |
break;
|
2032 |
}
|
|
|
2033 |
if ( 10 === (int) $compression_level && EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
2034 |
list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type );
|
2035 |
break;
|
2036 |
}
|
2037 |
-
// If we get this far, we are using local (jpegtran) optimization, so do an autorotate on the image.
|
2038 |
-
ewww_image_optimizer_autorotate( $file );
|
2039 |
-
// Get the (possibly new) original image size.
|
2040 |
-
$orig_size = ewww_image_optimizer_filesize( $file );
|
2041 |
if ( $convert ) {
|
2042 |
$tools = ewww_image_optimizer_path_check(
|
2043 |
! $skip['jpegtran'],
|
@@ -2059,6 +2077,14 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2059 |
false
|
2060 |
);
|
2061 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2062 |
if ( ! empty( $ewww_webp_only ) ) {
|
2063 |
$optimize = false;
|
2064 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) ) {
|
191 |
}
|
192 |
echo "<div id='ewww-image-optimizer-warning-exec' class='notice notice-warning is-dismissible'><p>" .
|
193 |
/* translators: %s: Name of a web host, like WordPress.com or Pantheon. */
|
194 |
+
sprintf( esc_html__( '%s sites require cloud-based optimization, because server-based optimization is disallowed. Those who upgrade to our premium service receive much higher compression, PNG/GIF/PDF compression, WebP conversion, and image backups.', 'ewww-image-optimizer' ), esc_html( $webhost ) ) .
|
195 |
'<br><strong>' .
|
196 |
/* translators: %s: link to 'start your free trial' */
|
197 |
sprintf( esc_html__( 'Dismiss this notice to continue with free cloud-based JPG compression or %s.', 'ewww-image-optimizer' ), "<a href='https://ewww.io/plans/'>" . esc_html__( 'start your premium trial', 'ewww-image-optimizer' ) . '</a>' );
|
553 |
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
|
554 |
wp_die( esc_html__( 'Access denied.', 'ewww-image-optimizer' ) );
|
555 |
}
|
556 |
+
ewww_image_optimizer_enable_free_exec();
|
557 |
+
die();
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Put site in "free exec" mode with JPG-only API compression, and suppress the exec() notice.
|
562 |
+
*/
|
563 |
+
function ewww_image_optimizer_enable_free_exec() {
|
564 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
565 |
update_option( 'ewww_image_optimizer_jpg_level', 10 );
|
566 |
update_option( 'ewww_image_optimizer_png_level', 0 );
|
567 |
update_option( 'ewww_image_optimizer_gif_level', 0 );
|
569 |
update_option( 'ewww_image_optimizer_svg_level', 0 );
|
570 |
update_option( 'ewww_image_optimizer_dismiss_exec_notice', 1 );
|
571 |
update_site_option( 'ewww_image_optimizer_dismiss_exec_notice', 1 );
|
|
|
572 |
}
|
573 |
|
574 |
/**
|
582 |
if ( ewww_image_optimizer_exec_check() ) {
|
583 |
// Need to be a little particular with the quiet parameter.
|
584 |
if ( 'quiet' !== $quiet && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_dismiss_exec_notice' ) ) {
|
|
|
585 |
ob_start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
// Display a warning if exec() is disabled, can't run local tools without it.
|
587 |
+
echo "<div id='ewww-image-optimizer-warning-exec' class='notice notice-warning is-dismissible'><p>" .
|
588 |
+
esc_html__( 'Sites where the exec() function is banned require cloud-based optimization, because free server-based optimization will not work. Those who upgrade to our premium service receive much higher compression, PNG/GIF/PDF compression, WebP conversion, and image backups.', 'ewww-image-optimizer' ) . '<br>' .
|
589 |
'<strong>' .
|
590 |
( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) || get_option( 'easyio_exactdn' ) ?
|
591 |
esc_html__( 'Sites that use Easy IO already have built-in image optimization and may dismiss this notice to disable local compression.', 'ewww-image-optimizer' )
|
592 |
:
|
593 |
/* translators: %s: link to 'start your free trial' */
|
594 |
+
sprintf( esc_html__( 'You may ask your system administrator to enable exec(), dismiss this notice to continue with free cloud-based JPG compression or %s.', 'ewww-image-optimizer' ), "<a href='https://ewww.io/plans/'>" . esc_html__( 'start your premium trial', 'ewww-image-optimizer' ) . '</a>' )
|
595 |
);
|
596 |
ewwwio_help_link( 'https://docs.ewww.io/article/29-what-is-exec-and-why-do-i-need-it', '592dd12d0428634b4a338c39' );
|
597 |
echo '</strong></p></div>';
|
749 |
'<a href="https://docs.ewww.io/article/95-installing-svgcleaner" data-beacon-article="5f7921c9cff47e001a58adbc">' . esc_html__( 'manually', 'ewww-image-optimizer' ) . '</a>'
|
750 |
) .
|
751 |
'</p></div>';
|
752 |
+
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_dismiss_exec_notice' ) ) {
|
753 |
+
$dismissible = false;
|
754 |
+
if (
|
755 |
+
in_array( 'jpegtran', $missing, true ) &&
|
756 |
+
in_array( 'optipng', $missing, true ) &&
|
757 |
+
in_array( 'gifsicle', $missing, true )
|
758 |
+
) {
|
759 |
+
$dismissible = true;
|
760 |
+
}
|
761 |
+
echo "<div id='ewww-image-optimizer-warning-opt-missing' class='notice notice-error" . ( $dismissible ? ' is-dismissible' : '' ) . "'><p>" .
|
762 |
sprintf(
|
763 |
+
/* translators: 1-6: jpegtran, optipng, pngout, pngquant, gifsicle, and cwebp (links) 7: comma-separated list of missing tools 8: Settings Page (link) 9: Installation Instructions (link) */
|
764 |
esc_html__( 'EWWW Image Optimizer uses %1$s, %2$s, %3$s, %4$s, %5$s, and %6$s. You are missing: %7$s. Please install via the %8$s or the %9$s.', 'ewww-image-optimizer' ),
|
765 |
"<a href='http://jpegclub.org/jpegtran/'>jpegtran</a>",
|
766 |
"<a href='http://optipng.sourceforge.net/'>optipng</a>",
|
773 |
"<a href='https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something' data-beacon-article='585371e3c697912ffd6c0ba1' target='_blank'>" . esc_html__( 'Installation Instructions', 'ewww-image-optimizer' ) . '</a>'
|
774 |
) .
|
775 |
'</p></div>';
|
776 |
+
echo
|
777 |
+
"<script>\n" .
|
778 |
+
"jQuery(document).on('click', '#ewww-image-optimizer-warning-opt-missing .notice-dismiss', function() {\n" .
|
779 |
+
"\tvar ewww_dismiss_exec_data = {\n" .
|
780 |
+
"\t\taction: 'ewww_dismiss_exec_notice',\n" .
|
781 |
+
"\t};\n" .
|
782 |
+
"\tjQuery.post(ajaxurl, ewww_dismiss_exec_data, function(response) {\n" .
|
783 |
+
"\t\tif (response) {\n" .
|
784 |
+
"\t\t\tconsole.log(response);\n" .
|
785 |
+
"\t\t}\n" .
|
786 |
+
"\t});\n" .
|
787 |
+
"});\n" .
|
788 |
+
"</script>\n";
|
789 |
}
|
790 |
ewwwio_memory( __FUNCTION__ );
|
791 |
}
|
2051 |
}
|
2052 |
break;
|
2053 |
}
|
2054 |
+
// For exec-deprived servers.
|
2055 |
if ( 10 === (int) $compression_level && EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
2056 |
list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type );
|
2057 |
break;
|
2058 |
}
|
|
|
|
|
|
|
|
|
2059 |
if ( $convert ) {
|
2060 |
$tools = ewww_image_optimizer_path_check(
|
2061 |
! $skip['jpegtran'],
|
2077 |
false
|
2078 |
);
|
2079 |
}
|
2080 |
+
if ( 10 === (int) $compression_level && defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) && ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
2081 |
+
list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type );
|
2082 |
+
break;
|
2083 |
+
}
|
2084 |
+
// If we get this far, we are using local (jpegtran) optimization, so do an autorotate on the image.
|
2085 |
+
ewww_image_optimizer_autorotate( $file );
|
2086 |
+
// Get the (possibly new) original image size.
|
2087 |
+
$orig_size = ewww_image_optimizer_filesize( $file );
|
2088 |
if ( ! empty( $ewww_webp_only ) ) {
|
2089 |
$optimize = false;
|
2090 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) ) {
|