Version Description
- added: SVG optimization, huge thanks to @samsk for making this happen!
- added: WebP quality setting, changed default to 75
- fixed: Lazy Load and other front-end parsers breaks JSON-encoded img elements
- fixed: Easy IO adds excess markup for images with height and/or width set to 'auto'
- fixed: memory_limit check should be case-insensitive: g vs. G
- fixed: PHP error during detection of Cache Enabler's WebP option
- fixed: table upgrade routine error when primary key already exists
- fixed: deleting files by always using realpath, props @ocean90
- fixed: Easy IO skips images in AJAX Load More requests
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 5.8.0 |
Comparing to | |
See all releases |
Code changes from version 5.7.1 to 5.8.0
- .travis.yml +4 -7
- aux-optimize.php +5 -2
- bulk.php +12 -2
- changelog.txt +11 -0
- classes/class-eio-base.php +1 -1
- classes/class-eio-lazy-load.php +22 -13
- classes/class-eio-page-parser.php +2 -2
- classes/class-ewww-flag.php +1 -1
- classes/class-ewww-nextcellent.php +1 -1
- classes/class-ewww-nextgen.php +7 -1
- classes/class-ewwwio-gd-editor.php +1 -1
- classes/class-ewwwio-imagick-editor.php +1 -1
- classes/class-exactdn.php +51 -10
- common.php +285 -57
- ewww-image-optimizer.php +1 -1
- includes/eio.js +17 -12
- includes/jquery-ui-1.10.1.custom.css +57 -33
- readme.txt +12 -1
- tests/test-convert.php +1 -0
- tests/test-optimize.php +86 -8
- unique.php +341 -38
.travis.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
os: linux
|
2 |
|
|
|
|
|
3 |
language: php
|
4 |
|
5 |
notifications:
|
@@ -13,26 +15,21 @@ branches:
|
|
13 |
|
14 |
php:
|
15 |
- 5.6
|
16 |
-
- 7.
|
17 |
|
18 |
services:
|
19 |
- mysql
|
20 |
|
21 |
env:
|
22 |
- WP_VERSION=latest WP_MULTISITE=0
|
23 |
-
- WP_VERSION=5.4 WP_MULTISITE=0
|
24 |
- WP_VERSION=5.2 WP_MULTISITE=0
|
25 |
|
26 |
jobs:
|
27 |
include:
|
28 |
- php: 5.6
|
29 |
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
30 |
-
- php: 7.2
|
31 |
-
env: WP_VERSION=latest
|
32 |
-
- php: 7.3
|
33 |
-
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
34 |
- php: 7.4
|
35 |
-
env: WP_VERSION=latest
|
36 |
|
37 |
before_script:
|
38 |
- export PATH="$HOME/.config/composer/vendor/bin:$PATH"
|
1 |
os: linux
|
2 |
|
3 |
+
dist: xenial
|
4 |
+
|
5 |
language: php
|
6 |
|
7 |
notifications:
|
15 |
|
16 |
php:
|
17 |
- 5.6
|
18 |
+
- 7.4
|
19 |
|
20 |
services:
|
21 |
- mysql
|
22 |
|
23 |
env:
|
24 |
- WP_VERSION=latest WP_MULTISITE=0
|
|
|
25 |
- WP_VERSION=5.2 WP_MULTISITE=0
|
26 |
|
27 |
jobs:
|
28 |
include:
|
29 |
- php: 5.6
|
30 |
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
|
|
|
|
|
|
|
|
31 |
- php: 7.4
|
32 |
+
env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
|
33 |
|
34 |
before_script:
|
35 |
- export PATH="$HOME/.config/composer/vendor/bin:$PATH"
|
aux-optimize.php
CHANGED
@@ -1087,6 +1087,9 @@ function ewww_image_optimizer_image_scan( $dir, $started = 0 ) {
|
|
1087 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) ) {
|
1088 |
$enabled_types[] = 'application/pdf';
|
1089 |
}
|
|
|
|
|
|
|
1090 |
foreach ( $iterator as $file ) {
|
1091 |
if ( get_transient( 'ewww_image_optimizer_aux_iterator' ) && get_transient( 'ewww_image_optimizer_aux_iterator' ) > $file_counter ) {
|
1092 |
continue;
|
@@ -1404,13 +1407,13 @@ function ewww_image_optimizer_aux_images_script( $hook = '' ) {
|
|
1404 |
}
|
1405 |
$mimetype = ewww_image_optimizer_mimetype( $path, 'i' );
|
1406 |
// This is a brand new image.
|
1407 |
-
if ( preg_match( '/^image\/(jpeg|png|gif)/', $mimetype ) && empty( $already_optimized ) ) {
|
1408 |
$slide_paths[] = array(
|
1409 |
'path' => ewww_image_optimizer_relativize_path( $path ),
|
1410 |
'orig_size' => $image_size,
|
1411 |
);
|
1412 |
// This is a changed image.
|
1413 |
-
} elseif ( preg_match( '/^image\/(jpeg|png|gif)/', $mimetype ) && ! empty( $already_optimized ) && (int) $already_optimized['image_size'] !== $image_size ) {
|
1414 |
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->ewwwio_images SET pending = 1 WHERE id = %d", $already_optimized['id'] ) );
|
1415 |
}
|
1416 |
}
|
1087 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) ) {
|
1088 |
$enabled_types[] = 'application/pdf';
|
1089 |
}
|
1090 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) ) {
|
1091 |
+
$enabled_types[] = 'image/svg+xml';
|
1092 |
+
}
|
1093 |
foreach ( $iterator as $file ) {
|
1094 |
if ( get_transient( 'ewww_image_optimizer_aux_iterator' ) && get_transient( 'ewww_image_optimizer_aux_iterator' ) > $file_counter ) {
|
1095 |
continue;
|
1407 |
}
|
1408 |
$mimetype = ewww_image_optimizer_mimetype( $path, 'i' );
|
1409 |
// This is a brand new image.
|
1410 |
+
if ( preg_match( '/^image\/(jpeg|png|gif|svg\+xml)/', $mimetype ) && empty( $already_optimized ) ) {
|
1411 |
$slide_paths[] = array(
|
1412 |
'path' => ewww_image_optimizer_relativize_path( $path ),
|
1413 |
'orig_size' => $image_size,
|
1414 |
);
|
1415 |
// This is a changed image.
|
1416 |
+
} elseif ( preg_match( '/^image\/(jpeg|png|gif|svg\+xml)/', $mimetype ) && ! empty( $already_optimized ) && (int) $already_optimized['image_size'] !== $image_size ) {
|
1417 |
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->ewwwio_images SET pending = 1 WHERE id = %d", $already_optimized['id'] ) );
|
1418 |
}
|
1419 |
}
|
bulk.php
CHANGED
@@ -241,7 +241,14 @@ function ewww_image_optimizer_bulk_preview() {
|
|
241 |
echo '<a id="ewww-bulk-credits-available" target="_blank" style="margin-left:20px" class="page-title-action" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
242 |
echo '<hr class="wp-header-end">';
|
243 |
}
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
// Retrieve the value of the 'bulk resume' option and set the button text for the form to use.
|
246 |
$resume = get_option( 'ewww_image_optimizer_bulk_resume' );
|
247 |
if ( empty( $resume ) ) {
|
@@ -1012,6 +1019,9 @@ function ewww_image_optimizer_media_scan( $hook = '' ) {
|
|
1012 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) ) {
|
1013 |
$enabled_types[] = 'application/pdf';
|
1014 |
}
|
|
|
|
|
|
|
1015 |
|
1016 |
ewww_image_optimizer_debug_log();
|
1017 |
$starting_memory_usage = memory_get_usage( true );
|
@@ -1889,7 +1899,7 @@ function ewww_image_optimizer_bulk_loop( $hook = '', $delay = 0 ) {
|
|
1889 |
// Gotta make sure we don't delete a pending record if the license is exceeded, so the license check goes first.
|
1890 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
1891 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
1892 |
-
$output['error'] = esc_html__( 'License Exceeded', 'ewww-image-optimizer' );
|
1893 |
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1894 |
delete_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1895 |
ewwwio_ob_clean();
|
241 |
echo '<a id="ewww-bulk-credits-available" target="_blank" style="margin-left:20px" class="page-title-action" href="https://ewww.io/my-account/">' . esc_html__( 'Image credits available:', 'ewww-image-optimizer' ) . ' ' . esc_html( ewww_image_optimizer_cloud_quota() ) . '</a>';
|
242 |
echo '<hr class="wp-header-end">';
|
243 |
}
|
244 |
+
if (
|
245 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
246 |
+
ewww_image_optimizer_easy_active()
|
247 |
+
) {
|
248 |
+
echo '<div id="ewww-bulk-warning" class="ewww-bulk-info notice notice-warning"><p>' . esc_html__( 'Easy IO is automatically optimizing your site! Bulk Optimization of local images is not necessary unless you wish to save storage space. Please be sure you have a backup of your images before proceeding.', 'ewww-image-optimizer' ) . '</p></div>';
|
249 |
+
} else {
|
250 |
+
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>';
|
251 |
+
}
|
252 |
// Retrieve the value of the 'bulk resume' option and set the button text for the form to use.
|
253 |
$resume = get_option( 'ewww_image_optimizer_bulk_resume' );
|
254 |
if ( empty( $resume ) ) {
|
1019 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) ) {
|
1020 |
$enabled_types[] = 'application/pdf';
|
1021 |
}
|
1022 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) ) {
|
1023 |
+
$enabled_types[] = 'image/svg+xml';
|
1024 |
+
}
|
1025 |
|
1026 |
ewww_image_optimizer_debug_log();
|
1027 |
$starting_memory_usage = memory_get_usage( true );
|
1899 |
// Gotta make sure we don't delete a pending record if the license is exceeded, so the license check goes first.
|
1900 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
1901 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
1902 |
+
$output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
|
1903 |
delete_transient( 'ewww_image_optimizer_bulk_counter_measures' );
|
1904 |
delete_transient( 'ewww_image_optimizer_bulk_current_image' );
|
1905 |
ewwwio_ob_clean();
|
changelog.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 5.7.1 =
|
2 |
* added: alert on domain change for Easy IO, like if you clone from a production environment to staging
|
3 |
* changed: Easy IO domain and plan_id refresh automatically when visiting settings page
|
1 |
+
= 5.8.0 =
|
2 |
+
* added: SVG optimization, huge thanks to @samsk for making this happen!
|
3 |
+
* added: WebP quality setting, changed default to 75
|
4 |
+
* fixed: Lazy Load and other front-end parsers breaks JSON-encoded img elements
|
5 |
+
* fixed: Easy IO adds excess markup for images with height and/or width set to 'auto'
|
6 |
+
* fixed: memory_limit check should be case-insensitive: g vs. G
|
7 |
+
* fixed: PHP error during detection of Cache Enabler's WebP option
|
8 |
+
* fixed: table upgrade routine error when primary key already exists
|
9 |
+
* fixed: deleting files by always using realpath, props @ocean90
|
10 |
+
* fixed: Easy IO skips images in AJAX Load More requests
|
11 |
+
|
12 |
= 5.7.1 =
|
13 |
* added: alert on domain change for Easy IO, like if you clone from a production environment to staging
|
14 |
* changed: Easy IO domain and plan_id refresh automatically when visiting settings page
|
classes/class-eio-base.php
CHANGED
@@ -426,7 +426,7 @@ if ( ! class_exists( 'EIO_Base' ) ) {
|
|
426 |
// Unlimited, set to 32GB.
|
427 |
$memory_limit = '32000M';
|
428 |
}
|
429 |
-
if (
|
430 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024 * 1024;
|
431 |
} else {
|
432 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024;
|
426 |
// Unlimited, set to 32GB.
|
427 |
$memory_limit = '32000M';
|
428 |
}
|
429 |
+
if ( stripos( $memory_limit, 'g' ) ) {
|
430 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024 * 1024;
|
431 |
} else {
|
432 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024;
|
classes/class-eio-lazy-load.php
CHANGED
@@ -366,6 +366,26 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
366 |
$this->set_attribute( $image, 'data-src', $file, true );
|
367 |
$srcset = $this->get_attribute( $image, 'srcset' );
|
368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
$disable_native_lazy = false;
|
370 |
// Ignore native lazy loading images.
|
371 |
$loading_attr = $this->get_attribute( $image, 'loading' );
|
@@ -373,6 +393,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
373 |
$disable_native_lazy = true;
|
374 |
}
|
375 |
if (
|
|
|
376 |
( ! defined( 'EWWWIO_DISABLE_NATIVE_LAZY' ) || ! EWWWIO_DISABLE_NATIVE_LAZY ) &&
|
377 |
( ! defined( 'EASYIO_DISABLE_NATIVE_LAZY' ) || ! EASYIO_DISABLE_NATIVE_LAZY ) &&
|
378 |
! $disable_native_lazy
|
@@ -380,19 +401,6 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
380 |
$this->set_attribute( $image, 'loading', 'lazy' );
|
381 |
}
|
382 |
|
383 |
-
if (
|
384 |
-
! empty( $_POST['action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
|
385 |
-
! empty( $_POST['vc_action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
|
386 |
-
! empty( $_POST['tag'] ) && // phpcs:ignore WordPress.Security.NonceVerification
|
387 |
-
'vc_get_vc_grid_data' === $_POST['action'] && // phpcs:ignore WordPress.Security.NonceVerification
|
388 |
-
'vc_get_vc_grid_data' === $_POST['vc_action'] && // phpcs:ignore WordPress.Security.NonceVerification
|
389 |
-
'vc_media_grid' === $_POST['tag'] // phpcs:ignore WordPress.Security.NonceVerification
|
390 |
-
) {
|
391 |
-
return $image;
|
392 |
-
}
|
393 |
-
$width_attr = $this->get_attribute( $image, 'width' );
|
394 |
-
$height_attr = $this->get_attribute( $image, 'height' );
|
395 |
-
$placeholder_src = $this->placeholder_src;
|
396 |
if ( false === strpos( $file, 'nggid' ) && ! preg_match( '#\.svg(\?|$)#', $file ) && $this->parsing_exactdn && strpos( $file, $this->exactdn_domain ) ) {
|
397 |
$this->debug_message( 'using lqip' );
|
398 |
list( $width, $height ) = $this->get_dimensions_from_filename( $file, true );
|
@@ -544,6 +552,7 @@ if ( ! class_exists( 'EIO_Lazy_Load' ) ) {
|
|
544 |
if (
|
545 |
'a' === $exclusion ||
|
546 |
'div' === $exclusion ||
|
|
|
547 |
'li' === $exclusion ||
|
548 |
'picture' === $exclusion ||
|
549 |
'section' === $exclusion ||
|
366 |
$this->set_attribute( $image, 'data-src', $file, true );
|
367 |
$srcset = $this->get_attribute( $image, 'srcset' );
|
368 |
|
369 |
+
if (
|
370 |
+
! empty( $_POST['action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
|
371 |
+
! empty( $_POST['vc_action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
|
372 |
+
! empty( $_POST['tag'] ) && // phpcs:ignore WordPress.Security.NonceVerification
|
373 |
+
'vc_get_vc_grid_data' === $_POST['action'] && // phpcs:ignore WordPress.Security.NonceVerification
|
374 |
+
'vc_get_vc_grid_data' === $_POST['vc_action'] && // phpcs:ignore WordPress.Security.NonceVerification
|
375 |
+
'vc_media_grid' === $_POST['tag'] // phpcs:ignore WordPress.Security.NonceVerification
|
376 |
+
) {
|
377 |
+
return $image;
|
378 |
+
}
|
379 |
+
|
380 |
+
// Check to see if they added img as an exclusion.
|
381 |
+
if ( in_array( 'img', $this->user_element_exclusions, true ) ) {
|
382 |
+
return $image;
|
383 |
+
}
|
384 |
+
|
385 |
+
$width_attr = $this->get_attribute( $image, 'width' );
|
386 |
+
$height_attr = $this->get_attribute( $image, 'height' );
|
387 |
+
$placeholder_src = $this->placeholder_src;
|
388 |
+
|
389 |
$disable_native_lazy = false;
|
390 |
// Ignore native lazy loading images.
|
391 |
$loading_attr = $this->get_attribute( $image, 'loading' );
|
393 |
$disable_native_lazy = true;
|
394 |
}
|
395 |
if (
|
396 |
+
is_numeric( $width_attr ) && is_numeric( $height_attr ) &&
|
397 |
( ! defined( 'EWWWIO_DISABLE_NATIVE_LAZY' ) || ! EWWWIO_DISABLE_NATIVE_LAZY ) &&
|
398 |
( ! defined( 'EASYIO_DISABLE_NATIVE_LAZY' ) || ! EASYIO_DISABLE_NATIVE_LAZY ) &&
|
399 |
! $disable_native_lazy
|
401 |
$this->set_attribute( $image, 'loading', 'lazy' );
|
402 |
}
|
403 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
if ( false === strpos( $file, 'nggid' ) && ! preg_match( '#\.svg(\?|$)#', $file ) && $this->parsing_exactdn && strpos( $file, $this->exactdn_domain ) ) {
|
405 |
$this->debug_message( 'using lqip' );
|
406 |
list( $width, $height ) = $this->get_dimensions_from_filename( $file, true );
|
552 |
if (
|
553 |
'a' === $exclusion ||
|
554 |
'div' === $exclusion ||
|
555 |
+
'img' === $exclusion ||
|
556 |
'li' === $exclusion ||
|
557 |
'picture' === $exclusion ||
|
558 |
'section' === $exclusion ||
|
classes/class-eio-page-parser.php
CHANGED
@@ -52,11 +52,11 @@ if ( ! class_exists( 'EIO_Page_Parser' ) ) {
|
|
52 |
if ( $hyperlinks ) {
|
53 |
$this->debug_message( 'using figure+hyperlink(a) patterns with src required' );
|
54 |
$search_pattern = '#(?:<figure[^>]*?\s+?class\s*=\s*["\'](?P<figure_class>[\w\s-]+?)["\'][^>]*?>\s*)?(?:<a[^>]*?\s+?href\s*=\s*["\'](?P<link_url>[^\s]+?)["\'][^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*("|\')(?P<img_url>(?!\4).+?)\4[^>]*?>){1}(?:\s*</a>)?#is';
|
55 |
-
$unquoted_pattern = '#(?:<figure[^>]*?\s+?class\s*=\s*(?P<figure_class>[\w-]+)[^>]*?>\s*)?(?:<a[^>]*?\s+?href\s*=\s*(?P<link_url>[^"\'][^\s>]+)[^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*(?P<img_url>[^"\'][^\s>]+)[^>]*?>){1}(?:\s*</a>)?#is';
|
56 |
} elseif ( $src_required ) {
|
57 |
$this->debug_message( 'using plain img pattern, src still required' );
|
58 |
$search_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*("|\')(?P<img_url>(?!\2).+?)\2[^>]*?>)#is';
|
59 |
-
$unquoted_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*(?P<img_url>[^"\'][^\s>]+)[^>]*?>)#is';
|
60 |
}
|
61 |
if ( preg_match_all( $search_pattern, $content, $images ) ) {
|
62 |
$this->debug_message( 'found ' . count( $images[0] ) . ' image elements with quoted pattern' );
|
52 |
if ( $hyperlinks ) {
|
53 |
$this->debug_message( 'using figure+hyperlink(a) patterns with src required' );
|
54 |
$search_pattern = '#(?:<figure[^>]*?\s+?class\s*=\s*["\'](?P<figure_class>[\w\s-]+?)["\'][^>]*?>\s*)?(?:<a[^>]*?\s+?href\s*=\s*["\'](?P<link_url>[^\s]+?)["\'][^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*("|\')(?P<img_url>(?!\4).+?)\4[^>]*?>){1}(?:\s*</a>)?#is';
|
55 |
+
$unquoted_pattern = '#(?:<figure[^>]*?\s+?class\s*=\s*(?P<figure_class>[\w-]+)[^>]*?>\s*)?(?:<a[^>]*?\s+?href\s*=\s*(?P<link_url>[^"\'\\\\][^\s>]+)[^>]*?>\s*)?(?P<img_tag><img[^>]*?\s+?src\s*=\s*(?P<img_url>[^"\'\\\\][^\s>]+)[^>]*?>){1}(?:\s*</a>)?#is';
|
56 |
} elseif ( $src_required ) {
|
57 |
$this->debug_message( 'using plain img pattern, src still required' );
|
58 |
$search_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*("|\')(?P<img_url>(?!\2).+?)\2[^>]*?>)#is';
|
59 |
+
$unquoted_pattern = '#(?P<img_tag><img[^>]*?\s+?src\s*=\s*(?P<img_url>[^"\'\\\\][^\s>]+)[^>]*?>)#is';
|
60 |
}
|
61 |
if ( preg_match_all( $search_pattern, $content, $images ) ) {
|
62 |
$this->debug_message( 'found ' . count( $images[0] ) . ' image elements with quoted pattern' );
|
classes/class-ewww-flag.php
CHANGED
@@ -614,7 +614,7 @@ if ( ! class_exists( 'EWWW_Flag' ) ) {
|
|
614 |
$fres = ewww_image_optimizer( $file_path, 3, false, false, true );
|
615 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
616 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
617 |
-
$output['error'] = esc_html__( 'License Exceeded', 'ewww-image-optimizer' );
|
618 |
ewwwio_ob_clean();
|
619 |
wp_die( wp_json_encode( $output ) );
|
620 |
}
|
614 |
$fres = ewww_image_optimizer( $file_path, 3, false, false, true );
|
615 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
616 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
617 |
+
$output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
|
618 |
ewwwio_ob_clean();
|
619 |
wp_die( wp_json_encode( $output ) );
|
620 |
}
|
classes/class-ewww-nextcellent.php
CHANGED
@@ -616,7 +616,7 @@ if ( ! class_exists( 'EWWW_Nextcellent' ) ) {
|
|
616 |
list( $fres, $tres ) = $this->ewww_ngg_optimize( $id );
|
617 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
618 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
619 |
-
$output['error'] = esc_html__( 'License Exceeded', 'ewww-image-optimizer' );
|
620 |
ewwwio_ob_clean();
|
621 |
wp_die( wp_json_encode( $output ) );
|
622 |
}
|
616 |
list( $fres, $tres ) = $this->ewww_ngg_optimize( $id );
|
617 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
618 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
619 |
+
$output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
|
620 |
ewwwio_ob_clean();
|
621 |
wp_die( wp_json_encode( $output ) );
|
622 |
}
|
classes/class-ewww-nextgen.php
CHANGED
@@ -288,7 +288,13 @@ if ( ! class_exists( 'EWWW_Nextgen' ) ) {
|
|
288 |
$success = $this->ewww_manage_image_custom_column( '', $image );
|
289 |
if ( get_transient( 'ewww_image_optimizer_cloud_status' ) === 'exceeded' || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
|
290 |
ewwwio_ob_clean();
|
291 |
-
wp_die(
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
if ( ! wp_doing_ajax() ) {
|
294 |
// Get the referring page, and send the user back there.
|
288 |
$success = $this->ewww_manage_image_custom_column( '', $image );
|
289 |
if ( get_transient( 'ewww_image_optimizer_cloud_status' ) === 'exceeded' || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
|
290 |
ewwwio_ob_clean();
|
291 |
+
wp_die(
|
292 |
+
wp_json_encode(
|
293 |
+
array(
|
294 |
+
'error' => '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License exceeded', 'ewww-image-optimizer' ) . '</a>',
|
295 |
+
)
|
296 |
+
)
|
297 |
+
);
|
298 |
}
|
299 |
if ( ! wp_doing_ajax() ) {
|
300 |
// Get the referring page, and send the user back there.
|
classes/class-ewwwio-gd-editor.php
CHANGED
@@ -259,7 +259,7 @@ if ( class_exists( 'Bbpp_Animated_Gif' ) ) {
|
|
259 |
}
|
260 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
261 |
if ( 'image/gif' === $this->mime_type && function_exists( 'ewww_image_optimizer_path_check' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
262 |
-
ewww_image_optimizer_path_check( false, false, true, false, false, false );
|
263 |
}
|
264 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
265 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
259 |
}
|
260 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
261 |
if ( 'image/gif' === $this->mime_type && function_exists( 'ewww_image_optimizer_path_check' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
262 |
+
ewww_image_optimizer_path_check( false, false, true, false, false, false, false );
|
263 |
}
|
264 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
265 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
classes/class-ewwwio-imagick-editor.php
CHANGED
@@ -314,7 +314,7 @@ if ( class_exists( 'WP_Thumb_Image_Editor_Imagick' ) ) {
|
|
314 |
}
|
315 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
316 |
if ( 'image/gif' === $this->mime_type && function_exists( 'ewww_image_optimizer_path_check' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
317 |
-
ewww_image_optimizer_path_check( false, false, true, false, false, false );
|
318 |
}
|
319 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
320 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
314 |
}
|
315 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
316 |
if ( 'image/gif' === $this->mime_type && function_exists( 'ewww_image_optimizer_path_check' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
317 |
+
ewww_image_optimizer_path_check( false, false, true, false, false, false, false );
|
318 |
}
|
319 |
if ( 'image/gif' === $this->mime_type && ( ! defined( 'EWWW_IMAGE_OPTIMIZER_GIFSICLE' ) || ! EWWW_IMAGE_OPTIMIZER_GIFSICLE ) ) {
|
320 |
if ( false === strpos( $ewww_status, 'great' ) ) {
|
classes/class-exactdn.php
CHANGED
@@ -172,6 +172,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
172 |
|
173 |
// Overrides for admin-ajax images.
|
174 |
add_filter( 'exactdn_admin_allow_image_downsize', array( $this, 'allow_admin_image_downsize' ), 10, 2 );
|
|
|
175 |
// Overrides for "pass through" images.
|
176 |
add_filter( 'exactdn_pre_args', array( $this, 'exactdn_remove_args' ), 10, 3 );
|
177 |
// Overrides for user exclusions.
|
@@ -300,10 +301,6 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
300 |
|
301 |
$site_url = $this->content_url();
|
302 |
$home_url = home_url();
|
303 |
-
$originip = '';
|
304 |
-
if ( ! empty( $_SERVER['SERVER_ADDR'] ) ) {
|
305 |
-
$originip = sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) );
|
306 |
-
}
|
307 |
|
308 |
$url = 'http://optimize.exactlywww.com/exactdn/activate.php';
|
309 |
$ssl = wp_http_supports( array( 'ssl' ) );
|
@@ -318,7 +315,6 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
318 |
'body' => array(
|
319 |
'site_url' => $site_url,
|
320 |
'home_url' => $home_url,
|
321 |
-
'originip' => $originip,
|
322 |
),
|
323 |
)
|
324 |
);
|
@@ -404,7 +400,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
404 |
}
|
405 |
|
406 |
$this->check_verify_method();
|
407 |
-
$this->set_exactdn_option( 'checkin', time() +
|
408 |
|
409 |
// Set a default error.
|
410 |
global $exactdn_activate_error;
|
@@ -902,9 +898,6 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
902 |
// Find the width and height attributes.
|
903 |
$width = $this->get_img_width( $images['img_tag'][ $index ] );
|
904 |
$height = $this->get_img_height( $images['img_tag'][ $index ] );
|
905 |
-
// Falsify them if empty.
|
906 |
-
$width = $width ? $width : false;
|
907 |
-
$height = $height ? $height : false;
|
908 |
|
909 |
// Can't pass both a relative width and height, so unset the dimensions in favor of not breaking the horizontal layout.
|
910 |
if ( false !== strpos( $width, '%' ) && false !== strpos( $height, '%' ) ) {
|
@@ -912,6 +905,10 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
912 |
$height = false;
|
913 |
}
|
914 |
|
|
|
|
|
|
|
|
|
915 |
// Detect WP registered image size from HTML class.
|
916 |
if ( preg_match( '#class=["|\']?[^"\']*size-([^"\'\s]+)[^"\']*["|\']?#i', $images['img_tag'][ $index ], $size ) ) {
|
917 |
$size = array_pop( $size );
|
@@ -1469,6 +1466,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
1469 |
if ( ! empty( $_POST['action'] ) && 'mabel-rpn-getnew-purchased-products' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1470 |
return true;
|
1471 |
}
|
|
|
|
|
|
|
1472 |
return $allow;
|
1473 |
}
|
1474 |
|
@@ -2544,6 +2544,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2544 |
if ( strpos( $image_url, 'easyio/lazy/placeholder' ) ) {
|
2545 |
return array();
|
2546 |
}
|
|
|
|
|
|
|
2547 |
if ( strpos( $image_url, '/dummy.png' ) ) {
|
2548 |
return array();
|
2549 |
}
|
@@ -2772,7 +2775,7 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2772 |
}
|
2773 |
|
2774 |
$jpg_quality = apply_filters( 'jpeg_quality', null, 'image_resize' );
|
2775 |
-
$webp_quality = apply_filters( '
|
2776 |
|
2777 |
$more_args = array();
|
2778 |
if ( false === strpos( $image_url, 'strip=all' ) && $this->get_option( $this->prefix . 'metadata_remove' ) ) {
|
@@ -2793,6 +2796,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2793 |
if ( $this->plan_id > 1 && false === strpos( $image_url, 'quality=' ) && ! is_null( $jpg_quality ) && 82 !== (int) $jpg_quality ) {
|
2794 |
$more_args['quality'] = $jpg_quality;
|
2795 |
}
|
|
|
|
|
|
|
2796 |
// Merge given args with the automatic (option-based) args, and also makes sure args is an array if it was previously a string.
|
2797 |
$args = wp_parse_args( $args, $more_args );
|
2798 |
|
@@ -2982,6 +2988,41 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2982 |
}
|
2983 |
return $domains;
|
2984 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2985 |
}
|
2986 |
|
2987 |
global $exactdn;
|
172 |
|
173 |
// Overrides for admin-ajax images.
|
174 |
add_filter( 'exactdn_admin_allow_image_downsize', array( $this, 'allow_admin_image_downsize' ), 10, 2 );
|
175 |
+
add_filter( 'exactdn_admin_allow_image_srcset', array( $this, 'allow_admin_image_downsize' ), 10, 2 );
|
176 |
// Overrides for "pass through" images.
|
177 |
add_filter( 'exactdn_pre_args', array( $this, 'exactdn_remove_args' ), 10, 3 );
|
178 |
// Overrides for user exclusions.
|
301 |
|
302 |
$site_url = $this->content_url();
|
303 |
$home_url = home_url();
|
|
|
|
|
|
|
|
|
304 |
|
305 |
$url = 'http://optimize.exactlywww.com/exactdn/activate.php';
|
306 |
$ssl = wp_http_supports( array( 'ssl' ) );
|
315 |
'body' => array(
|
316 |
'site_url' => $site_url,
|
317 |
'home_url' => $home_url,
|
|
|
318 |
),
|
319 |
)
|
320 |
);
|
400 |
}
|
401 |
|
402 |
$this->check_verify_method();
|
403 |
+
$this->set_exactdn_option( 'checkin', time() + DAY_IN_SECONDS );
|
404 |
|
405 |
// Set a default error.
|
406 |
global $exactdn_activate_error;
|
898 |
// Find the width and height attributes.
|
899 |
$width = $this->get_img_width( $images['img_tag'][ $index ] );
|
900 |
$height = $this->get_img_height( $images['img_tag'][ $index ] );
|
|
|
|
|
|
|
901 |
|
902 |
// Can't pass both a relative width and height, so unset the dimensions in favor of not breaking the horizontal layout.
|
903 |
if ( false !== strpos( $width, '%' ) && false !== strpos( $height, '%' ) ) {
|
905 |
$height = false;
|
906 |
}
|
907 |
|
908 |
+
// Falsify them if empty.
|
909 |
+
$width = $width && is_numeric( $width ) ? $width : false;
|
910 |
+
$height = $height && is_numeric( $height ) ? $height : false;
|
911 |
+
|
912 |
// Detect WP registered image size from HTML class.
|
913 |
if ( preg_match( '#class=["|\']?[^"\']*size-([^"\'\s]+)[^"\']*["|\']?#i', $images['img_tag'][ $index ], $size ) ) {
|
914 |
$size = array_pop( $size );
|
1466 |
if ( ! empty( $_POST['action'] ) && 'mabel-rpn-getnew-purchased-products' === $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1467 |
return true;
|
1468 |
}
|
1469 |
+
if ( ! empty( $_REQUEST['action'] ) && 'alm_get_posts' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1470 |
+
return true;
|
1471 |
+
}
|
1472 |
return $allow;
|
1473 |
}
|
1474 |
|
2544 |
if ( strpos( $image_url, 'easyio/lazy/placeholder' ) ) {
|
2545 |
return array();
|
2546 |
}
|
2547 |
+
if ( strpos( $image_url, 'swis/lazy/placeholder' ) ) {
|
2548 |
+
return array();
|
2549 |
+
}
|
2550 |
if ( strpos( $image_url, '/dummy.png' ) ) {
|
2551 |
return array();
|
2552 |
}
|
2775 |
}
|
2776 |
|
2777 |
$jpg_quality = apply_filters( 'jpeg_quality', null, 'image_resize' );
|
2778 |
+
$webp_quality = apply_filters( 'webp_quality', 75, 'image/webp' );
|
2779 |
|
2780 |
$more_args = array();
|
2781 |
if ( false === strpos( $image_url, 'strip=all' ) && $this->get_option( $this->prefix . 'metadata_remove' ) ) {
|
2796 |
if ( $this->plan_id > 1 && false === strpos( $image_url, 'quality=' ) && ! is_null( $jpg_quality ) && 82 !== (int) $jpg_quality ) {
|
2797 |
$more_args['quality'] = $jpg_quality;
|
2798 |
}
|
2799 |
+
if ( $this->plan_id > 1 && false === strpos( $image_url, 'quality=' ) && 75 !== (int) $web_quality && $webp_quality < $jpg_quality ) {
|
2800 |
+
$more_args['quality'] = $webp_quality;
|
2801 |
+
}
|
2802 |
// Merge given args with the automatic (option-based) args, and also makes sure args is an array if it was previously a string.
|
2803 |
$args = wp_parse_args( $args, $more_args );
|
2804 |
|
2988 |
}
|
2989 |
return $domains;
|
2990 |
}
|
2991 |
+
|
2992 |
+
/**
|
2993 |
+
* Checks the configured alias for savings information.
|
2994 |
+
*
|
2995 |
+
* @return array The original size of all images that have been compressed by Easy IO along with how much was saved.
|
2996 |
+
*/
|
2997 |
+
function savings() {
|
2998 |
+
$this->debug_message( '<b>' . __METHOD__ . '()</b>' );
|
2999 |
+
$url = 'http://optimize.exactlywww.com/exactdn/savings.php';
|
3000 |
+
$ssl = wp_http_supports( array( 'ssl' ) );
|
3001 |
+
if ( $ssl ) {
|
3002 |
+
$url = set_url_scheme( $url, 'https' );
|
3003 |
+
}
|
3004 |
+
add_filter( 'http_headers_useragent', $this->prefix . 'cloud_useragent', PHP_INT_MAX );
|
3005 |
+
$result = wp_remote_post(
|
3006 |
+
$url,
|
3007 |
+
array(
|
3008 |
+
'timeout' => 10,
|
3009 |
+
'body' => array(
|
3010 |
+
'alias' => $this->exactdn_domain,
|
3011 |
+
),
|
3012 |
+
)
|
3013 |
+
);
|
3014 |
+
if ( is_wp_error( $result ) ) {
|
3015 |
+
$error_message = $result->get_error_message();
|
3016 |
+
$this->debug_message( "savings request failed: $error_message" );
|
3017 |
+
} elseif ( ! empty( $result['body'] ) ) {
|
3018 |
+
$this->debug_message( "savings data retrieved: {$result['body']}" );
|
3019 |
+
$response = json_decode( $result['body'], true );
|
3020 |
+
if ( is_array( $response ) && ! empty( $response['original'] ) && ! empty( $response['savings'] ) ) {
|
3021 |
+
return $response;
|
3022 |
+
}
|
3023 |
+
}
|
3024 |
+
return false;
|
3025 |
+
}
|
3026 |
}
|
3027 |
|
3028 |
global $exactdn;
|
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 = '';
|
@@ -102,6 +102,8 @@ add_filter( 'myarcade_filter_thumbnail', 'ewww_image_optimizer_myarcade_thumbnai
|
|
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 |
// Prevent WP from over-riding EWWW IO's resize settings.
|
106 |
add_filter( 'big_image_size_threshold', 'ewww_image_optimizer_adjust_big_image_threshold', 10, 3 );
|
107 |
// Makes sure the plugin bypasses any files affected by the Folders to Ignore setting.
|
@@ -331,9 +333,9 @@ function ewww_image_optimizer_get_plugin_version( $plugin_file ) {
|
|
331 |
*/
|
332 |
function ewww_image_optimizer_ce_webp_enabled() {
|
333 |
if ( class_exists( 'Cache_Enabler' ) ) {
|
334 |
-
$ce_options =
|
335 |
-
if ( $ce_options['webp'] ) {
|
336 |
-
ewwwio_debug_message( 'Cache Enabler
|
337 |
return true;
|
338 |
}
|
339 |
}
|
@@ -765,6 +767,8 @@ function ewww_image_optimizer_admin_init() {
|
|
765 |
update_site_option( 'ewww_image_optimizer_gif_level', $ewww_image_optimizer_gif_level );
|
766 |
$ewww_image_optimizer_pdf_level = empty( $_POST['ewww_image_optimizer_pdf_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_pdf_level'];
|
767 |
update_site_option( 'ewww_image_optimizer_pdf_level', $ewww_image_optimizer_pdf_level );
|
|
|
|
|
768 |
$ewww_image_optimizer_delete_originals = ( empty( $_POST['ewww_image_optimizer_delete_originals'] ) ? false : true );
|
769 |
update_site_option( 'ewww_image_optimizer_delete_originals', $ewww_image_optimizer_delete_originals );
|
770 |
$ewww_image_optimizer_jpg_to_png = ( empty( $_POST['ewww_image_optimizer_jpg_to_png'] ) ? false : true );
|
@@ -779,6 +783,8 @@ function ewww_image_optimizer_admin_init() {
|
|
779 |
update_site_option( 'ewww_image_optimizer_jpg_background', ewww_image_optimizer_jpg_background( $ewww_image_optimizer_jpg_background ) );
|
780 |
$ewww_image_optimizer_jpg_quality = empty( $_POST['ewww_image_optimizer_jpg_quality'] ) ? '' : (int) $_POST['ewww_image_optimizer_jpg_quality'];
|
781 |
update_site_option( 'ewww_image_optimizer_jpg_quality', ewww_image_optimizer_jpg_quality( $ewww_image_optimizer_jpg_quality ) );
|
|
|
|
|
782 |
$ewww_image_optimizer_disable_convert_links = ( empty( $_POST['ewww_image_optimizer_disable_convert_links'] ) ? false : true );
|
783 |
update_site_option( 'ewww_image_optimizer_disable_convert_links', $ewww_image_optimizer_disable_convert_links );
|
784 |
$ewww_image_optimizer_backup_files = ( empty( $_POST['ewww_image_optimizer_backup_files'] ) ? false : true );
|
@@ -858,16 +864,19 @@ function ewww_image_optimizer_admin_init() {
|
|
858 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) &&
|
859 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) &&
|
860 |
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) &&
|
861 |
-
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' )
|
|
|
862 |
) {
|
863 |
ewww_image_optimizer_set_defaults();
|
864 |
update_option( 'ewww_image_optimizer_disable_pngout', true );
|
|
|
865 |
update_option( 'ewww_image_optimizer_optipng_level', 2 );
|
866 |
update_option( 'ewww_image_optimizer_pngout_level', 2 );
|
867 |
update_option( 'ewww_image_optimizer_metadata_remove', true );
|
868 |
update_option( 'ewww_image_optimizer_jpg_level', '10' );
|
869 |
update_option( 'ewww_image_optimizer_png_level', '10' );
|
870 |
update_option( 'ewww_image_optimizer_gif_level', '10' );
|
|
|
871 |
}
|
872 |
// Register all the common EWWW IO settings.
|
873 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_cloud_key', 'ewww_image_optimizer_cloud_key_sanitize' );
|
@@ -877,9 +886,11 @@ function ewww_image_optimizer_admin_init() {
|
|
877 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_png_level', 'intval' );
|
878 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_gif_level', 'intval' );
|
879 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_pdf_level', 'intval' );
|
|
|
880 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_backup_files', 'boolval' );
|
881 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_enable_cloudinary', 'boolval' );
|
882 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_quality', 'ewww_image_optimizer_jpg_quality' );
|
|
|
883 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_parallel_optimization', 'boolval' );
|
884 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_auto', 'boolval' );
|
885 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_include_media_paths', 'boolval' );
|
@@ -944,11 +955,23 @@ function ewww_image_optimizer_admin_init() {
|
|
944 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_exactdn_sp_conflict' );
|
945 |
}
|
946 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
947 |
|
948 |
// Alert user if multiple re-optimizations detected.
|
949 |
-
|
950 |
-
|
951 |
-
|
|
|
952 |
if (
|
953 |
is_super_admin() &&
|
954 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_review_time' ) &&
|
@@ -973,6 +996,10 @@ function ewww_image_optimizer_admin_init() {
|
|
973 |
add_action( 'admin_notices', 'ewww_image_optimizer_pngout_installed' );
|
974 |
add_action( 'network_admin_notices', 'ewww_image_optimizer_pngout_installed' );
|
975 |
}
|
|
|
|
|
|
|
|
|
976 |
if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
|
977 |
ewww_image_optimizer_privacy_policy_content();
|
978 |
ewww_image_optimizer_ajax_compat_check();
|
@@ -1170,6 +1197,7 @@ function ewww_image_optimizer_single_size_optimize( $id, $size ) {
|
|
1170 |
'image/png',
|
1171 |
'image/gif',
|
1172 |
'application/pdf',
|
|
|
1173 |
);
|
1174 |
if ( ! in_array( $type, $supported_types, true ) ) {
|
1175 |
ewwwio_debug_message( "mimetype not supported: $id" );
|
@@ -1292,6 +1320,9 @@ function ewww_image_optimizer_disable_tools() {
|
|
1292 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CWEBP' ) ) {
|
1293 |
define( 'EWWW_IMAGE_OPTIMIZER_CWEBP', false );
|
1294 |
}
|
|
|
|
|
|
|
1295 |
ewwwio_memory( __FUNCTION__ );
|
1296 |
}
|
1297 |
|
@@ -1409,12 +1440,11 @@ function ewww_image_optimizer_install_table() {
|
|
1409 |
// See if the path column exists, and what collation it uses to determine the column index size.
|
1410 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ewwwio_images'" ) === $wpdb->ewwwio_images ) {
|
1411 |
ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
|
|
|
|
|
|
|
1412 |
if ( $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'id'", ARRAY_A ) ) {
|
1413 |
-
$
|
1414 |
-
// Possibly use AND NOT Non_unique (double-negativity fun).
|
1415 |
-
if ( $wpdb->query( "ALTER TABLE $wpdb->ewwwio_images ADD PRIMARY KEY(id)" ) ) {
|
1416 |
-
$wpdb->query( "ALTER TABLE $wpdb->ewwwio_images DROP INDEX id" );
|
1417 |
-
}
|
1418 |
}
|
1419 |
// Check if the old path_image_size index exists, and drop it.
|
1420 |
if ( $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'path_image_size'", ARRAY_A ) ) {
|
@@ -1752,6 +1782,27 @@ function ewww_image_optimizer_pngout_installed() {
|
|
1752 |
}
|
1753 |
}
|
1754 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1755 |
/**
|
1756 |
* Display a notice that we could not activate an ExactDN domain.
|
1757 |
*/
|
@@ -3077,6 +3128,46 @@ function ewww_image_optimizer_set_jpg_quality( $quality ) {
|
|
3077 |
return min( 92, $quality );
|
3078 |
}
|
3079 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3080 |
/**
|
3081 |
* Check default WP threshold and adjust to comply with normal EWWW IO behavior.
|
3082 |
*
|
@@ -3265,15 +3356,20 @@ function ewwwio_delete_file( $file, $dir = '' ) {
|
|
3265 |
if ( ! empty( $dir ) ) {
|
3266 |
return wp_delete_file_from_directory( $file, $dir );
|
3267 |
}
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
|
|
|
|
|
|
|
|
|
|
3271 |
}
|
3272 |
-
if ( false !== strpos( $file,
|
3273 |
-
return wp_delete_file_from_directory( $file,
|
3274 |
}
|
3275 |
-
if ( false !== strpos( $file,
|
3276 |
-
return wp_delete_file_from_directory( $file,
|
3277 |
}
|
3278 |
return false;
|
3279 |
}
|
@@ -3381,10 +3477,16 @@ function ewww_image_optimizer_manual() {
|
|
3381 |
}
|
3382 |
if ( get_transient( 'ewww_image_optimizer_cloud_status' ) === 'exceeded' || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
|
3383 |
if ( ! wp_doing_ajax() ) {
|
3384 |
-
wp_die( esc_html__( 'License exceeded', 'ewww-image-optimizer' ) );
|
3385 |
}
|
3386 |
ewwwio_ob_clean();
|
3387 |
-
wp_die(
|
|
|
|
|
|
|
|
|
|
|
|
|
3388 |
}
|
3389 |
$success = ewww_image_optimizer_custom_column_capture( 'ewww-image-optimizer', $attachment_id, $new_meta );
|
3390 |
ewww_image_optimizer_debug_log();
|
@@ -3563,7 +3665,7 @@ function ewww_image_optimizer_cloud_restore_single_image( $image ) {
|
|
3563 |
ewwwio_memory( __FUNCTION__ );
|
3564 |
return false;
|
3565 |
} elseif ( ! empty( $result['body'] ) && strpos( $result['body'], 'missing' ) === false ) {
|
3566 |
-
$enabled_types = array( 'image/jpeg', 'image/png', 'image/gif', 'application/pdf' );
|
3567 |
if ( ! is_dir( dirname( $image['path'] ) ) ) {
|
3568 |
wp_mkdir_p( dirname( $image['path'] ) );
|
3569 |
}
|
@@ -3962,6 +4064,7 @@ function ewww_image_optimizer_cloud_enable() {
|
|
3962 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_png_level', 20 );
|
3963 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_gif_level', 10 );
|
3964 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_pdf_level', 10 );
|
|
|
3965 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_backup_files', 1 );
|
3966 |
}
|
3967 |
|
@@ -4279,7 +4382,7 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
4279 |
}
|
4280 |
if ( 'image/webp' === $newtype ) {
|
4281 |
$webp = 1;
|
4282 |
-
$jpg_quality = apply_filters( '
|
4283 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP' ) || ! EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP ) {
|
4284 |
$lossy = 0;
|
4285 |
}
|
@@ -4290,12 +4393,14 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
4290 |
$webp = 0;
|
4291 |
}
|
4292 |
if ( $jpg_quality < 50 ) {
|
4293 |
-
$jpg_quality =
|
4294 |
}
|
4295 |
-
|
|
|
|
|
|
|
|
|
4296 |
$png_compress = 1;
|
4297 |
-
} else {
|
4298 |
-
$png_compress = 0;
|
4299 |
}
|
4300 |
if ( ! $webp && ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' )
|
4301 |
&& strpos( $file, '/wp-admin/' ) === false
|
@@ -4401,6 +4506,9 @@ function ewww_image_optimizer_cloud_optimizer( $file, $type, $convert = false, $
|
|
4401 |
$error_message = $response->get_error_message();
|
4402 |
ewwwio_debug_message( "optimize failed: $error_message" );
|
4403 |
return array( $file, false, 'cloud optimize failed', 0, '' );
|
|
|
|
|
|
|
4404 |
} else {
|
4405 |
$tempfile = $file . '.tmp';
|
4406 |
file_put_contents( $tempfile, $response['body'] );
|
@@ -5125,7 +5233,6 @@ function ewww_image_optimizer_update_table( $attachment, $opt_size, $orig_size,
|
|
5125 |
} else {
|
5126 |
$ewwwdb = $wpdb;
|
5127 |
}
|
5128 |
-
ewww_image_optimizer_update_savings( $opt_size, $orig_size );
|
5129 |
global $ewww_image;
|
5130 |
// First check if the image was converted, so we don't orphan records.
|
5131 |
if ( $original && $original !== $attachment ) {
|
@@ -5166,6 +5273,7 @@ function ewww_image_optimizer_update_table( $attachment, $opt_size, $orig_size,
|
|
5166 |
// Store info on the current image for future reference.
|
5167 |
if ( empty( $already_optimized ) || ! is_array( $already_optimized ) ) {
|
5168 |
ewwwio_debug_message( "creating new record, path: $attachment, size: $opt_size" );
|
|
|
5169 |
if ( is_object( $ewww_image ) && $ewww_image instanceof EWWW_Image && $ewww_image->gallery ) {
|
5170 |
$updates['gallery'] = $ewww_image->gallery;
|
5171 |
}
|
@@ -5363,7 +5471,7 @@ function ewww_image_optimizer_aux_images_loop( $attachment = null, $auto = false
|
|
5363 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
5364 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
5365 |
if ( ! $auto ) {
|
5366 |
-
$output['error'] = esc_html__( 'License Exceeded', 'ewww-image-optimizer' );
|
5367 |
echo wp_json_encode( $output );
|
5368 |
}
|
5369 |
if ( $cli ) {
|
@@ -6794,6 +6902,9 @@ function ewww_image_optimizer_test_parallel_opt( $type = '', $id = 0 ) {
|
|
6794 |
if ( 'application/pdf' === $type ) {
|
6795 |
return false;
|
6796 |
}
|
|
|
|
|
|
|
6797 |
return true;
|
6798 |
}
|
6799 |
|
@@ -6922,6 +7033,7 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
|
|
6922 |
'image/png',
|
6923 |
'image/gif',
|
6924 |
'application/pdf',
|
|
|
6925 |
);
|
6926 |
if ( ! in_array( $type, $supported_types, true ) ) {
|
6927 |
ewwwio_debug_message( "mimetype not supported: $id" );
|
@@ -6984,9 +7096,12 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
|
|
6984 |
$meta['height'] = $new_dimensions[1];
|
6985 |
}
|
6986 |
}
|
6987 |
-
//
|
6988 |
-
|
6989 |
-
|
|
|
|
|
|
|
6990 |
ewwwio_debug_message( 'running in parallel' );
|
6991 |
$parallel_opt = true;
|
6992 |
} else {
|
@@ -7108,6 +7223,11 @@ function ewww_image_optimizer_resize_from_meta_data( $meta, $id = null, $log = t
|
|
7108 |
$size = 'pdf-full';
|
7109 |
ewwwio_debug_message( 'processing full size pdf preview' );
|
7110 |
}
|
|
|
|
|
|
|
|
|
|
|
7111 |
if ( $parallel_opt && ewwwio_is_file( $resize_path ) ) {
|
7112 |
$parallel_sizes[ $size ] = $resize_path;
|
7113 |
} else {
|
@@ -7385,6 +7505,7 @@ function ewww_image_optimizer_lr_sync_update( $meta, $id = null ) {
|
|
7385 |
'image/png',
|
7386 |
'image/gif',
|
7387 |
'application/pdf',
|
|
|
7388 |
);
|
7389 |
if ( ! in_array( $type, $supported_types, true ) ) {
|
7390 |
ewwwio_debug_message( "mimetype not supported: $id" );
|
@@ -7503,6 +7624,7 @@ function ewww_image_optimizer_as3cf_object_meta( $args ) {
|
|
7503 |
}
|
7504 |
return $args;
|
7505 |
}
|
|
|
7506 |
/**
|
7507 |
* Update the attachment's meta data after being converted.
|
7508 |
*
|
@@ -7596,15 +7718,18 @@ function ewww_image_optimizer_update_attachment( $meta, $id ) {
|
|
7596 |
} // End if().
|
7597 |
} // End foreach().
|
7598 |
} // End if().
|
7599 |
-
if ( preg_match( '
|
7600 |
$mime = 'image/jpeg';
|
7601 |
}
|
7602 |
-
if ( preg_match( '
|
7603 |
$mime = 'image/png';
|
7604 |
}
|
7605 |
-
if ( preg_match( '
|
7606 |
$mime = 'image/gif';
|
7607 |
}
|
|
|
|
|
|
|
7608 |
// Update the attachment post with the new mimetype and id.
|
7609 |
wp_update_post(
|
7610 |
array(
|
@@ -7859,6 +7984,8 @@ function ewww_image_optimizer_quick_mimetype( $path ) {
|
|
7859 |
return 'image/webp';
|
7860 |
case 'pdf':
|
7861 |
return 'application/pdf';
|
|
|
|
|
7862 |
default:
|
7863 |
if ( empty( $pathextension ) && ! ewww_image_optimizer_stream_wrapped( $path ) && ewwwio_is_file( $path ) ) {
|
7864 |
return ewww_image_optimizer_mimetype( $path, 'i' );
|
@@ -8157,12 +8284,33 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null ) {
|
|
8157 |
$convert_desc = '';
|
8158 |
}
|
8159 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8160 |
default:
|
8161 |
// Not a supported mimetype.
|
8162 |
$msg = '<div>' . esc_html__( 'Unsupported file type', 'ewww-image-optimizer' ) . '</div>';
|
8163 |
} // End switch().
|
8164 |
$compression_level = ewww_image_optimizer_get_level( $type );
|
8165 |
if ( ! empty( $msg ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
8166 |
echo wp_kses_post( $msg ) . '</div>';
|
8167 |
return;
|
8168 |
}
|
@@ -8225,7 +8373,11 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null ) {
|
|
8225 |
}
|
8226 |
} elseif ( ! $in_progress && current_user_can( apply_filters( 'ewww_image_optimizer_manual_permissions', '' ) ) ) {
|
8227 |
// Give the user the option to optimize the image right now.
|
8228 |
-
if (
|
|
|
|
|
|
|
|
|
8229 |
$sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
|
8230 |
if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
|
8231 |
$sizes_to_opt++;
|
@@ -8337,7 +8489,11 @@ function ewww_image_optimizer_custom_column( $column_name, $id, $meta = null ) {
|
|
8337 |
}
|
8338 |
} elseif ( ! $in_progress ) {
|
8339 |
// Otherwise, this must be an image we haven't processed.
|
8340 |
-
if (
|
|
|
|
|
|
|
|
|
8341 |
$sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
|
8342 |
if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
|
8343 |
$sizes_to_opt++;
|
@@ -8948,6 +9104,9 @@ function ewww_image_optimizer_get_level( $type ) {
|
|
8948 |
if ( 'application/pdf' === $type ) {
|
8949 |
return (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' );
|
8950 |
}
|
|
|
|
|
|
|
8951 |
return 0;
|
8952 |
}
|
8953 |
|
@@ -9566,6 +9725,7 @@ function ewwwio_debug_info() {
|
|
9566 |
ewwwio_debug_message( 'png level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) );
|
9567 |
ewwwio_debug_message( 'gif level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) );
|
9568 |
ewwwio_debug_message( 'pdf level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) );
|
|
|
9569 |
ewwwio_debug_message( 'bulk delay: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' ) );
|
9570 |
ewwwio_debug_message( 'backup mode: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' ) ? 'on' : 'off' ) );
|
9571 |
ewwwio_debug_message( 'cloudinary upload: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_cloudinary' ) ? 'on' : 'off' ) );
|
@@ -9586,8 +9746,10 @@ function ewwwio_debug_info() {
|
|
9586 |
ewwwio_debug_message( 'optipng level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) );
|
9587 |
ewwwio_debug_message( 'pngout disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_pngout' ) ? 'yes' : 'no' ) );
|
9588 |
ewwwio_debug_message( 'pngout level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ) );
|
|
|
9589 |
}
|
9590 |
ewwwio_debug_message( 'effective quality: ' . ewww_image_optimizer_set_jpg_quality( 82 ) );
|
|
|
9591 |
ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) ? 'on' : 'off' ) );
|
9592 |
ewwwio_debug_message( 'background optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ? 'on' : 'off' ) );
|
9593 |
if ( ! $ewwwio_upgrading && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ) {
|
@@ -9851,6 +10013,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9851 |
$speed_score += 20;
|
9852 |
}
|
9853 |
$exactdn_enabled = true;
|
|
|
9854 |
}
|
9855 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
9856 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
@@ -9899,12 +10062,13 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9899 |
}
|
9900 |
$skip = ewww_image_optimizer_skip_tools();
|
9901 |
if ( ewww_image_optimizer_easy_active() ) {
|
9902 |
-
$skip['jpegtran']
|
9903 |
-
$skip['optipng']
|
9904 |
-
$skip['gifsicle']
|
9905 |
-
$skip['pngout']
|
9906 |
-
$skip['pngquant']
|
9907 |
-
$skip['webp']
|
|
|
9908 |
}
|
9909 |
if ( ! $skip['jpegtran'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
9910 |
if ( EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
@@ -9984,6 +10148,15 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
9984 |
$speed_recommendations[] = __( 'Install WebP.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
9985 |
}
|
9986 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9987 |
if ( get_option( 'easyio_lazy_load' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
9988 |
$speed_score += 10;
|
9989 |
} else {
|
@@ -10088,8 +10261,8 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10088 |
<div id='ewww-status' class='postbox'>
|
10089 |
<h2 class='ewww-hndle'><?php esc_html_e( 'Optimization Status', 'ewww-image-optimizer' ); ?></h2>
|
10090 |
<div class='inside'>
|
10091 |
-
<div class="ewww-row
|
10092 |
-
<
|
10093 |
<div id="ewww-compress-guage" class="ewww-guage" data-score="<?php echo (int) $speed_score; ?>">
|
10094 |
<svg width="120" height="120">
|
10095 |
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
@@ -10111,12 +10284,12 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10111 |
<?php if ( $speed_score < 100 ) : ?>
|
10112 |
<p class="description"><?php esc_html_e( 'Hover over score for recommendations to improve the speed of your site.', 'ewww-image-optimizer' ); ?></p>
|
10113 |
<?php endif; ?>
|
10114 |
-
</div><!-- end .ewww-status-detail
|
10115 |
<?php
|
10116 |
if ( $total_savings > 0 ) {
|
10117 |
$savings_stroke_dashoffset = $guage_stroke_dasharray * ( 1 - $total_savings / $total_sizes[1] );
|
10118 |
?>
|
10119 |
-
<
|
10120 |
<div id="ewww-savings-guage" class="ewww-guage" data-score="<?php echo esc_attr( $total_savings / $total_sizes[1] ); ?>">
|
10121 |
<svg width="120" height="120">
|
10122 |
<title><?php echo esc_html( round( $total_savings / $total_sizes[1], 3 ) * 100 ); ?>%</title>
|
@@ -10125,12 +10298,31 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10125 |
</svg>
|
10126 |
<div class="ewww-score"><?php echo esc_html( ewww_image_optimizer_size_format( $total_savings, 2 ) ); ?></div>
|
10127 |
</div><!-- end .ewww-guage -->
|
10128 |
-
<p style="text-align:center"><strong><?php esc_html_e( 'Savings', 'ewww-image-optimizer' ); ?></strong></p>
|
10129 |
<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>
|
10130 |
-
</div><!-- end .ewww-status-detail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10131 |
<?php } ?>
|
10132 |
<!-- begin notices section -->
|
10133 |
-
<
|
10134 |
<?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
10135 |
<h3>
|
10136 |
<a href='https://ewww.io/plans/' target='_blank' class='ewww-upgrade'><?php esc_html_e( 'Premium Upgrades:', 'ewww-image-optimizer' ); ?></a>
|
@@ -10181,10 +10373,10 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10181 |
<?php endif; ?>
|
10182 |
</p>
|
10183 |
<?php elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! get_option( 'easyio_exactdn' ) ) : ?>
|
10184 |
-
<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
|
10185 |
<?php endif; ?>
|
10186 |
<?php if ( ! function_exists( 'swis' ) ) : ?>
|
10187 |
-
<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
|
10188 |
<?php endif; ?>
|
10189 |
<p>
|
10190 |
<strong><?php esc_html_e( 'Background optimization (faster uploads):', 'ewww-image-optimizer' ); ?></strong><br>
|
@@ -10212,8 +10404,8 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10212 |
</span>
|
10213 |
<?php endif; ?>
|
10214 |
</p>
|
10215 |
-
</div
|
10216 |
-
</
|
10217 |
</div><!-- end .inside -->
|
10218 |
</div>
|
10219 |
</div>
|
@@ -10282,6 +10474,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10282 |
<input type='hidden' id='ewww_image_optimizer_png_level' name='ewww_image_optimizer_png_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ); ?>'>
|
10283 |
<input type='hidden' id='ewww_image_optimizer_gif_level' name='ewww_image_optimizer_gif_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ); ?>'>
|
10284 |
<input type='hidden' id='ewww_image_optimizer_pdf_level' name='ewww_image_optimizer_pdf_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ); ?>'>
|
|
|
10285 |
<?php elseif ( 'singlesite' === $network && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
10286 |
<p><strong><?php esc_html_e( 'Easy IO is optimizing your site, no more configuration needed!', 'ewww-image-optimizer' ); ?></strong><br>
|
10287 |
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
@@ -10459,6 +10652,29 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10459 |
</select>
|
10460 |
</td>
|
10461 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10462 |
<tr>
|
10463 |
<th> </th>
|
10464 |
<td>
|
@@ -10557,7 +10773,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
10557 |
<?php esc_html_e( 'CDN Included', 'ewww-image-optimizer' ); ?><br>
|
10558 |
<?php if ( ! $exactdn_enabled ) : ?>
|
10559 |
<strong>
|
10560 |
-
<a href="https://ewww.io/
|
10561 |
<?php esc_html_e( 'Purchase a subscription for your site.', 'ewww-image-optimizer' ); ?>
|
10562 |
</a>
|
10563 |
</strong><br>
|
@@ -11054,6 +11270,15 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11054 |
</p>
|
11055 |
</td>
|
11056 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11057 |
<?php endif; ?>
|
11058 |
|
11059 |
<?php if ( ! $free_exec && ( ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) ) : ?>
|
@@ -11485,6 +11710,9 @@ function ewww_image_optimizer_remove_cloud_key( $redirect = true ) {
|
|
11485 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) > 0 ) {
|
11486 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_pdf_level', 0 );
|
11487 |
}
|
|
|
|
|
|
|
11488 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', 0 );
|
11489 |
delete_transient( 'ewww_image_optimizer_cloud_status' );
|
11490 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_backup_files', '' );
|
@@ -11783,7 +12011,7 @@ function ewwwio_memory_limit() {
|
|
11783 |
// Unlimited, set to 32GB.
|
11784 |
$memory_limit = '32000M';
|
11785 |
}
|
11786 |
-
if (
|
11787 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024 * 1024;
|
11788 |
} else {
|
11789 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024;
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '580.0' );
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
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.
|
108 |
add_filter( 'big_image_size_threshold', 'ewww_image_optimizer_adjust_big_image_threshold', 10, 3 );
|
109 |
// Makes sure the plugin bypasses any files affected by the Folders to Ignore setting.
|
333 |
*/
|
334 |
function ewww_image_optimizer_ce_webp_enabled() {
|
335 |
if ( class_exists( 'Cache_Enabler' ) ) {
|
336 |
+
$ce_options = get_option( 'cache_enabler', array() );
|
337 |
+
if ( ! empty( $ce_options['convert_image_urls_to_webp'] ) || ! empty( $ce_options['webp'] ) ) {
|
338 |
+
ewwwio_debug_message( 'Cache Enabler WebP option enabled' );
|
339 |
return true;
|
340 |
}
|
341 |
}
|
767 |
update_site_option( 'ewww_image_optimizer_gif_level', $ewww_image_optimizer_gif_level );
|
768 |
$ewww_image_optimizer_pdf_level = empty( $_POST['ewww_image_optimizer_pdf_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_pdf_level'];
|
769 |
update_site_option( 'ewww_image_optimizer_pdf_level', $ewww_image_optimizer_pdf_level );
|
770 |
+
$ewww_image_optimizer_svg_level = empty( $_POST['ewww_image_optimizer_svg_level'] ) ? '' : (int) $_POST['ewww_image_optimizer_svg_level'];
|
771 |
+
update_site_option( 'ewww_image_optimizer_svg_level', $ewww_image_optimizer_svg_level );
|
772 |
$ewww_image_optimizer_delete_originals = ( empty( $_POST['ewww_image_optimizer_delete_originals'] ) ? false : true );
|
773 |
update_site_option( 'ewww_image_optimizer_delete_originals', $ewww_image_optimizer_delete_originals );
|
774 |
$ewww_image_optimizer_jpg_to_png = ( empty( $_POST['ewww_image_optimizer_jpg_to_png'] ) ? false : true );
|
783 |
update_site_option( 'ewww_image_optimizer_jpg_background', ewww_image_optimizer_jpg_background( $ewww_image_optimizer_jpg_background ) );
|
784 |
$ewww_image_optimizer_jpg_quality = empty( $_POST['ewww_image_optimizer_jpg_quality'] ) ? '' : (int) $_POST['ewww_image_optimizer_jpg_quality'];
|
785 |
update_site_option( 'ewww_image_optimizer_jpg_quality', ewww_image_optimizer_jpg_quality( $ewww_image_optimizer_jpg_quality ) );
|
786 |
+
$ewww_image_optimizer_webp_quality = empty( $_POST['ewww_image_optimizer_webp_quality'] ) ? '' : (int) $_POST['ewww_image_optimizer_webp_quality'];
|
787 |
+
update_site_option( 'ewww_image_optimizer_webp_quality', ewww_image_optimizer_webp_quality( $ewww_image_optimizer_webp_quality ) );
|
788 |
$ewww_image_optimizer_disable_convert_links = ( empty( $_POST['ewww_image_optimizer_disable_convert_links'] ) ? false : true );
|
789 |
update_site_option( 'ewww_image_optimizer_disable_convert_links', $ewww_image_optimizer_disable_convert_links );
|
790 |
$ewww_image_optimizer_backup_files = ( empty( $_POST['ewww_image_optimizer_backup_files'] ) ? false : true );
|
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' );
|
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' );
|
955 |
add_action( 'admin_notices', 'ewww_image_optimizer_notice_exactdn_sp_conflict' );
|
956 |
}
|
957 |
}
|
958 |
+
global $exactdn;
|
959 |
+
if (
|
960 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_local_mode' ) &&
|
961 |
+
! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) &&
|
962 |
+
ewww_image_optimizer_easy_active()
|
963 |
+
) {
|
964 |
+
// Suppress the custom column in the media library if local mode is disabled and easy mode is active.
|
965 |
+
remove_filter( 'manage_media_columns', 'ewww_image_optimizer_columns' );
|
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' ) ) {
|
972 |
+
add_action( 'network_admin_notices', 'ewww_image_optimizer_notice_reoptimization' );
|
973 |
+
add_action( 'admin_notices', 'ewww_image_optimizer_notice_reoptimization' );
|
974 |
+
}
|
975 |
if (
|
976 |
is_super_admin() &&
|
977 |
ewww_image_optimizer_get_option( 'ewww_image_optimizer_review_time' ) &&
|
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 |
+
}
|
1003 |
if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
|
1004 |
ewww_image_optimizer_privacy_policy_content();
|
1005 |
ewww_image_optimizer_ajax_compat_check();
|
1197 |
'image/png',
|
1198 |
'image/gif',
|
1199 |
'application/pdf',
|
1200 |
+
'image/svg+xml',
|
1201 |
);
|
1202 |
if ( ! in_array( $type, $supported_types, true ) ) {
|
1203 |
ewwwio_debug_message( "mimetype not supported: $id" );
|
1320 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_CWEBP' ) ) {
|
1321 |
define( 'EWWW_IMAGE_OPTIMIZER_CWEBP', false );
|
1322 |
}
|
1323 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_SVGCLEANER' ) ) {
|
1324 |
+
define( 'EWWW_IMAGE_OPTIMIZER_SVGCLEANER', false );
|
1325 |
+
}
|
1326 |
ewwwio_memory( __FUNCTION__ );
|
1327 |
}
|
1328 |
|
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 |
+
if ( ! $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'PRIMARY'", ARRAY_A ) ) {
|
1444 |
+
$wpdb->query( "ALTER TABLE $wpdb->ewwwio_images ADD PRIMARY KEY(id)" );
|
1445 |
+
}
|
1446 |
if ( $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'id'", ARRAY_A ) ) {
|
1447 |
+
$wpdb->query( "ALTER TABLE $wpdb->ewwwio_images DROP INDEX id" );
|
|
|
|
|
|
|
|
|
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 ) ) {
|
1782 |
}
|
1783 |
}
|
1784 |
|
1785 |
+
/**
|
1786 |
+
* Display a success or failure message after SVGCLEANER installation.
|
1787 |
+
*/
|
1788 |
+
function ewww_image_optimizer_svgcleaner_installed() {
|
1789 |
+
if ( ! empty( $_REQUEST['ewww_svgcleaner'] ) && 'success' === $_REQUEST['ewww_svgcleaner'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1790 |
+
echo "<div id='ewww-image-optimizer-pngout-success' class='notice notice-success fade'>\n" .
|
1791 |
+
'<p>' . esc_html__( 'Svgcleaner was successfully installed.', 'ewww-image-optimizer' ) . "</p>\n" .
|
1792 |
+
"</div>\n";
|
1793 |
+
}
|
1794 |
+
if ( ! empty( $_REQUEST['ewww_svgcleaner'] ) && 'failed' === $_REQUEST['ewww_svgcleaner'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
1795 |
+
echo "<div id='ewww-image-optimizer-pngout-failure' class='notice notice-error'>\n" .
|
1796 |
+
'<p>' . sprintf(
|
1797 |
+
/* translators: 1: An error message 2: The folder where svgcleaner should be installed */
|
1798 |
+
esc_html__( 'Svgcleaner was not installed: %1$s. Make sure this folder is writable: %2$s', 'ewww-image-optimizer' ),
|
1799 |
+
( ! empty( $_REQUEST['ewww_error'] ) ? esc_html( sanitize_text_field( wp_unslash( $_REQUEST['ewww_error'] ) ) ) : esc_html( 'unknown error', 'ewww-image-optimizer' ) ), // phpcs:ignore WordPress.Security.NonceVerification
|
1800 |
+
esc_html( EWWW_IMAGE_OPTIMIZER_TOOL_PATH )
|
1801 |
+
) . "</p>\n" .
|
1802 |
+
"</div>\n";
|
1803 |
+
}
|
1804 |
+
}
|
1805 |
+
|
1806 |
/**
|
1807 |
* Display a notice that we could not activate an ExactDN domain.
|
1808 |
*/
|
3128 |
return min( 92, $quality );
|
3129 |
}
|
3130 |
|
3131 |
+
/**
|
3132 |
+
* Retrieves/sanitizes the WebP quality setting or returns null.
|
3133 |
+
*
|
3134 |
+
* @param int $quality The WebP quality level as set by the user.
|
3135 |
+
* @return int The sanitize WebP quality level.
|
3136 |
+
*/
|
3137 |
+
function ewww_image_optimizer_webp_quality( $quality = null ) {
|
3138 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3139 |
+
if ( is_null( $quality ) ) {
|
3140 |
+
// Retrieve the user-supplied value for jpg quality.
|
3141 |
+
$quality = ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_quality' );
|
3142 |
+
}
|
3143 |
+
// Verify that the quality level is an integer, 1-100.
|
3144 |
+
if ( preg_match( '/^(100|[1-9][0-9]?)$/', $quality ) ) {
|
3145 |
+
ewwwio_debug_message( "webp quality: $quality" );
|
3146 |
+
// Send back the valid quality level.
|
3147 |
+
return $quality;
|
3148 |
+
} else {
|
3149 |
+
if ( ! empty( $quality ) ) {
|
3150 |
+
add_settings_error( 'ewww_image_optimizer_webp_quality', 'ewwwio-webp-quality', esc_html__( 'Could not save the WebP quality, please enter an integer between 50 and 100.', 'ewww-image-optimizer' ) );
|
3151 |
+
}
|
3152 |
+
// Send back nothing.
|
3153 |
+
return null;
|
3154 |
+
}
|
3155 |
+
}
|
3156 |
+
|
3157 |
+
/**
|
3158 |
+
* Overrides the default WebP quality (if a user-defined value is set).
|
3159 |
+
*
|
3160 |
+
* @param int $quality The default WebP quality level.
|
3161 |
+
* @return int The default quality, or the user configured level.
|
3162 |
+
*/
|
3163 |
+
function ewww_image_optimizer_set_webp_quality( $quality ) {
|
3164 |
+
$new_quality = ewww_image_optimizer_webp_quality();
|
3165 |
+
if ( ! empty( $new_quality ) ) {
|
3166 |
+
return min( 92, $new_quality );
|
3167 |
+
}
|
3168 |
+
return min( 92, $quality );
|
3169 |
+
}
|
3170 |
+
|
3171 |
/**
|
3172 |
* Check default WP threshold and adjust to comply with normal EWWW IO behavior.
|
3173 |
*
|
3356 |
if ( ! empty( $dir ) ) {
|
3357 |
return wp_delete_file_from_directory( $file, $dir );
|
3358 |
}
|
3359 |
+
|
3360 |
+
$wp_dir = realpath( ABSPATH );
|
3361 |
+
$upload_dir = wp_get_upload_dir();
|
3362 |
+
$upload_dir = realpath( $upload_dir['basedir'] );
|
3363 |
+
$content_dir = realpath( WP_CONTENT_DIR );
|
3364 |
+
|
3365 |
+
if ( false !== strpos( $file, $upload_dir ) ) {
|
3366 |
+
return wp_delete_file_from_directory( $file, $upload_dir );
|
3367 |
}
|
3368 |
+
if ( false !== strpos( $file, $content_dir ) ) {
|
3369 |
+
return wp_delete_file_from_directory( $file, $content_dir );
|
3370 |
}
|
3371 |
+
if ( false !== strpos( $file, $wp_dir ) ) {
|
3372 |
+
return wp_delete_file_from_directory( $file, $wp_dir );
|
3373 |
}
|
3374 |
return false;
|
3375 |
}
|
3477 |
}
|
3478 |
if ( get_transient( 'ewww_image_optimizer_cloud_status' ) === 'exceeded' || ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_exceeded' ) > time() ) {
|
3479 |
if ( ! wp_doing_ajax() ) {
|
3480 |
+
wp_die( '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License exceeded', 'ewww-image-optimizer' ) . '</a>' );
|
3481 |
}
|
3482 |
ewwwio_ob_clean();
|
3483 |
+
wp_die(
|
3484 |
+
wp_json_encode(
|
3485 |
+
array(
|
3486 |
+
'error' => '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License exceeded', 'ewww-image-optimizer' ) . '</a>',
|
3487 |
+
)
|
3488 |
+
)
|
3489 |
+
);
|
3490 |
}
|
3491 |
$success = ewww_image_optimizer_custom_column_capture( 'ewww-image-optimizer', $attachment_id, $new_meta );
|
3492 |
ewww_image_optimizer_debug_log();
|
3665 |
ewwwio_memory( __FUNCTION__ );
|
3666 |
return false;
|
3667 |
} elseif ( ! empty( $result['body'] ) && strpos( $result['body'], 'missing' ) === false ) {
|
3668 |
+
$enabled_types = array( 'image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'image/svg+xml' );
|
3669 |
if ( ! is_dir( dirname( $image['path'] ) ) ) {
|
3670 |
wp_mkdir_p( dirname( $image['path'] ) );
|
3671 |
}
|
4064 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_png_level', 20 );
|
4065 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_gif_level', 10 );
|
4066 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_pdf_level', 10 );
|
4067 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_svg_level', 10 );
|
4068 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_backup_files', 1 );
|
4069 |
}
|
4070 |
|
4382 |
}
|
4383 |
if ( 'image/webp' === $newtype ) {
|
4384 |
$webp = 1;
|
4385 |
+
$jpg_quality = apply_filters( 'webp_quality', 75, 'image/webp' );
|
4386 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP' ) || ! EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP ) {
|
4387 |
$lossy = 0;
|
4388 |
}
|
4393 |
$webp = 0;
|
4394 |
}
|
4395 |
if ( $jpg_quality < 50 ) {
|
4396 |
+
$jpg_quality = 75;
|
4397 |
}
|
4398 |
+
$png_compress = 0;
|
4399 |
+
if ( 'image/svg+xml' === $type && 10 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) ) {
|
4400 |
+
$png_compress = 1;
|
4401 |
+
}
|
4402 |
+
if ( 'image/png' === $type && 30 === (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) ) {
|
4403 |
$png_compress = 1;
|
|
|
|
|
4404 |
}
|
4405 |
if ( ! $webp && ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' )
|
4406 |
&& strpos( $file, '/wp-admin/' ) === false
|
4506 |
$error_message = $response->get_error_message();
|
4507 |
ewwwio_debug_message( "optimize failed: $error_message" );
|
4508 |
return array( $file, false, 'cloud optimize failed', 0, '' );
|
4509 |
+
} elseif ( empty( $response['body'] ) ) {
|
4510 |
+
ewwwio_debug_message( 'cloud results: no savings' );
|
4511 |
+
return array( $file, false, '', filesize( $file ), $hash );
|
4512 |
} else {
|
4513 |
$tempfile = $file . '.tmp';
|
4514 |
file_put_contents( $tempfile, $response['body'] );
|
5233 |
} else {
|
5234 |
$ewwwdb = $wpdb;
|
5235 |
}
|
|
|
5236 |
global $ewww_image;
|
5237 |
// First check if the image was converted, so we don't orphan records.
|
5238 |
if ( $original && $original !== $attachment ) {
|
5273 |
// Store info on the current image for future reference.
|
5274 |
if ( empty( $already_optimized ) || ! is_array( $already_optimized ) ) {
|
5275 |
ewwwio_debug_message( "creating new record, path: $attachment, size: $opt_size" );
|
5276 |
+
ewww_image_optimizer_update_savings( $opt_size, $orig_size );
|
5277 |
if ( is_object( $ewww_image ) && $ewww_image instanceof EWWW_Image && $ewww_image->gallery ) {
|
5278 |
$updates['gallery'] = $ewww_image->gallery;
|
5279 |
}
|
5471 |
$ewww_status = get_transient( 'ewww_image_optimizer_cloud_status' );
|
5472 |
if ( ! empty( $ewww_status ) && preg_match( '/exceeded/', $ewww_status ) ) {
|
5473 |
if ( ! $auto ) {
|
5474 |
+
$output['error'] = '<a href="https://ewww.io/buy-credits/" target="_blank">' . esc_html__( 'License Exceeded', 'ewww-image-optimizer' ) . '</a>';
|
5475 |
echo wp_json_encode( $output );
|
5476 |
}
|
5477 |
if ( $cli ) {
|
6902 |
if ( 'application/pdf' === $type ) {
|
6903 |
return false;
|
6904 |
}
|
6905 |
+
if ( 'image/svg+xml' === $type ) {
|
6906 |
+
return false;
|
6907 |
+
}
|
6908 |
return true;
|
6909 |
}
|
6910 |
|
7033 |
'image/png',
|
7034 |
'image/gif',
|
7035 |
'application/pdf',
|
7036 |
+
'image/svg+xml',
|
7037 |
);
|
7038 |
if ( ! in_array( $type, $supported_types, true ) ) {
|
7039 |
ewwwio_debug_message( "mimetype not supported: $id" );
|
7096 |
$meta['height'] = $new_dimensions[1];
|
7097 |
}
|
7098 |
}
|
7099 |
+
// Run in parallel if it's enabled+safe (test_parallel_opt), and there are enough resizes to make it worthwhile or if the API is enabled.
|
7100 |
+
if (
|
7101 |
+
ewww_image_optimizer_test_parallel_opt( $type, $id ) &&
|
7102 |
+
isset( $meta['sizes'] ) &&
|
7103 |
+
( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) || count( $meta['sizes'] ) > 5 )
|
7104 |
+
) {
|
7105 |
ewwwio_debug_message( 'running in parallel' );
|
7106 |
$parallel_opt = true;
|
7107 |
} else {
|
7223 |
$size = 'pdf-full';
|
7224 |
ewwwio_debug_message( 'processing full size pdf preview' );
|
7225 |
}
|
7226 |
+
// Because some SVG plugins populate the resizes with the original path (since SVG is "scalable", of course).
|
7227 |
+
// Though it could happen for other types perhaps...
|
7228 |
+
if ( $resize_path === $file_path ) {
|
7229 |
+
continue;
|
7230 |
+
}
|
7231 |
if ( $parallel_opt && ewwwio_is_file( $resize_path ) ) {
|
7232 |
$parallel_sizes[ $size ] = $resize_path;
|
7233 |
} else {
|
7505 |
'image/png',
|
7506 |
'image/gif',
|
7507 |
'application/pdf',
|
7508 |
+
'image/svg+xml',
|
7509 |
);
|
7510 |
if ( ! in_array( $type, $supported_types, true ) ) {
|
7511 |
ewwwio_debug_message( "mimetype not supported: $id" );
|
7624 |
}
|
7625 |
return $args;
|
7626 |
}
|
7627 |
+
|
7628 |
/**
|
7629 |
* Update the attachment's meta data after being converted.
|
7630 |
*
|
7718 |
} // End if().
|
7719 |
} // End foreach().
|
7720 |
} // End if().
|
7721 |
+
if ( preg_match( '/\.jpg$/i', basename( $meta['file'] ) ) ) {
|
7722 |
$mime = 'image/jpeg';
|
7723 |
}
|
7724 |
+
if ( preg_match( '/\.png$/i', basename( $meta['file'] ) ) ) {
|
7725 |
$mime = 'image/png';
|
7726 |
}
|
7727 |
+
if ( preg_match( '/\.gif$/i', basename( $meta['file'] ) ) ) {
|
7728 |
$mime = 'image/gif';
|
7729 |
}
|
7730 |
+
if ( preg_match( '/\.svg$/i', basename( $meta['file'] ) ) ) {
|
7731 |
+
$mime = 'image/svg+xml';
|
7732 |
+
}
|
7733 |
// Update the attachment post with the new mimetype and id.
|
7734 |
wp_update_post(
|
7735 |
array(
|
7984 |
return 'image/webp';
|
7985 |
case 'pdf':
|
7986 |
return 'application/pdf';
|
7987 |
+
case 'svg':
|
7988 |
+
return 'image/svg+xml';
|
7989 |
default:
|
7990 |
if ( empty( $pathextension ) && ! ewww_image_optimizer_stream_wrapped( $path ) && ewwwio_is_file( $path ) ) {
|
7991 |
return ewww_image_optimizer_mimetype( $path, 'i' );
|
8284 |
$convert_desc = '';
|
8285 |
}
|
8286 |
break;
|
8287 |
+
case 'image/svg+xml':
|
8288 |
+
if ( ! $skip['svgcleaner'] && ! EWWW_IMAGE_OPTIMIZER_SVGCLEANER ) {
|
8289 |
+
$msg = '<div>' . sprintf(
|
8290 |
+
/* translators: %s: name of a tool like jpegtran */
|
8291 |
+
__( '%s is missing', 'ewww-image-optimizer' ),
|
8292 |
+
'<em>svgcleaner</em>'
|
8293 |
+
) . '</div>';
|
8294 |
+
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) ) {
|
8295 |
+
$msg = '<div>' . sprintf(
|
8296 |
+
/* translators: %s: JPG, PNG, GIF, PDF or SVG */
|
8297 |
+
__( '%s compression disabled', 'ewww-image-optimizer' ),
|
8298 |
+
'SVG'
|
8299 |
+
) . '</div>';
|
8300 |
+
}
|
8301 |
+
break;
|
8302 |
default:
|
8303 |
// Not a supported mimetype.
|
8304 |
$msg = '<div>' . esc_html__( 'Unsupported file type', 'ewww-image-optimizer' ) . '</div>';
|
8305 |
} // End switch().
|
8306 |
$compression_level = ewww_image_optimizer_get_level( $type );
|
8307 |
if ( ! empty( $msg ) ) {
|
8308 |
+
if ( ewww_image_optimizer_easy_active() ) {
|
8309 |
+
echo '<div>' . esc_html__( 'Easy IO enabled', 'ewww-image-optimizer' );
|
8310 |
+
ewwwio_help_link( 'https://docs.ewww.io/article/96-easy-io-is-it-working', '5f871dd2c9e77c0016217c4e' );
|
8311 |
+
echo '</div>';
|
8312 |
+
return;
|
8313 |
+
}
|
8314 |
echo wp_kses_post( $msg ) . '</div>';
|
8315 |
return;
|
8316 |
}
|
8373 |
}
|
8374 |
} elseif ( ! $in_progress && current_user_can( apply_filters( 'ewww_image_optimizer_manual_permissions', '' ) ) ) {
|
8375 |
// Give the user the option to optimize the image right now.
|
8376 |
+
if ( ewww_image_optimizer_easy_active() ) {
|
8377 |
+
echo '<div>' . esc_html__( 'Easy IO enabled', 'ewww-image-optimizer' );
|
8378 |
+
ewwwio_help_link( 'https://docs.ewww.io/article/96-easy-io-is-it-working', '5f871dd2c9e77c0016217c4e' );
|
8379 |
+
echo '</div>';
|
8380 |
+
} elseif ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
|
8381 |
$sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
|
8382 |
if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
|
8383 |
$sizes_to_opt++;
|
8489 |
}
|
8490 |
} elseif ( ! $in_progress ) {
|
8491 |
// Otherwise, this must be an image we haven't processed.
|
8492 |
+
if ( ewww_image_optimizer_easy_active() ) {
|
8493 |
+
echo '<div>' . esc_html__( 'Easy IO enabled', 'ewww-image-optimizer' );
|
8494 |
+
ewwwio_help_link( 'https://docs.ewww.io/article/96-easy-io-is-it-working', '5f871dd2c9e77c0016217c4e' );
|
8495 |
+
echo '</div>';
|
8496 |
+
} elseif ( isset( $meta['sizes'] ) && ewww_image_optimizer_iterable( $meta['sizes'] ) ) {
|
8497 |
$sizes_to_opt = ewww_image_optimizer_count_unoptimized_sizes( $meta['sizes'] ) + 1;
|
8498 |
if ( isset( $meta['original_image'] ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_include_originals' ) ) {
|
8499 |
$sizes_to_opt++;
|
9104 |
if ( 'application/pdf' === $type ) {
|
9105 |
return (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' );
|
9106 |
}
|
9107 |
+
if ( 'image/svg+xml' === $type ) {
|
9108 |
+
return (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' );
|
9109 |
+
}
|
9110 |
return 0;
|
9111 |
}
|
9112 |
|
9725 |
ewwwio_debug_message( 'png level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) );
|
9726 |
ewwwio_debug_message( 'gif level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ) );
|
9727 |
ewwwio_debug_message( 'pdf level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) );
|
9728 |
+
ewwwio_debug_message( 'svg level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) );
|
9729 |
ewwwio_debug_message( 'bulk delay: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_delay' ) );
|
9730 |
ewwwio_debug_message( 'backup mode: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_backup_files' ) ? 'on' : 'off' ) );
|
9731 |
ewwwio_debug_message( 'cloudinary upload: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_enable_cloudinary' ) ? 'on' : 'off' ) );
|
9746 |
ewwwio_debug_message( 'optipng level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_optipng_level' ) );
|
9747 |
ewwwio_debug_message( 'pngout disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_pngout' ) ? 'yes' : 'no' ) );
|
9748 |
ewwwio_debug_message( 'pngout level: ' . ewww_image_optimizer_get_option( 'ewww_image_optimizer_pngout_level' ) );
|
9749 |
+
ewwwio_debug_message( 'svgcleaner disabled: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_svgcleaner' ) ? 'yes' : 'no' ) );
|
9750 |
}
|
9751 |
ewwwio_debug_message( 'effective quality: ' . ewww_image_optimizer_set_jpg_quality( 82 ) );
|
9752 |
+
ewwwio_debug_message( 'effective WebP quality: ' . ewww_image_optimizer_set_webp_quality( 75 ) );
|
9753 |
ewwwio_debug_message( 'parallel optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_parallel_optimization' ) ? 'on' : 'off' ) );
|
9754 |
ewwwio_debug_message( 'background optimization: ' . ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ? 'on' : 'off' ) );
|
9755 |
if ( ! $ewwwio_upgrading && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_background_optimization' ) ) {
|
10013 |
$speed_score += 20;
|
10014 |
}
|
10015 |
$exactdn_enabled = true;
|
10016 |
+
$exactdn_savings = $exactdn->savings();
|
10017 |
}
|
10018 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
10019 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
10062 |
}
|
10063 |
$skip = ewww_image_optimizer_skip_tools();
|
10064 |
if ( ewww_image_optimizer_easy_active() ) {
|
10065 |
+
$skip['jpegtran'] = true;
|
10066 |
+
$skip['optipng'] = true;
|
10067 |
+
$skip['gifsicle'] = true;
|
10068 |
+
$skip['pngout'] = true;
|
10069 |
+
$skip['pngquant'] = true;
|
10070 |
+
$skip['webp'] = true;
|
10071 |
+
$skip['svgcleaner'] = true;
|
10072 |
}
|
10073 |
if ( ! $skip['jpegtran'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
10074 |
if ( EWWW_IMAGE_OPTIMIZER_JPEGTRAN ) {
|
10148 |
$speed_recommendations[] = __( 'Install WebP.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/6-the-plugin-says-i-m-missing-something', '585371e3c697912ffd6c0ba1' );
|
10149 |
}
|
10150 |
}
|
10151 |
+
if ( ! $skip['svgcleaner'] && ! EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
10152 |
+
|
10153 |
+
if ( EWWW_IMAGE_OPTIMIZER_SVGCLEANER ) {
|
10154 |
+
$svgcleaner_version = ewww_image_optimizer_tool_found( EWWW_IMAGE_OPTIMIZER_SVGCLEANER, 's' );
|
10155 |
+
}
|
10156 |
+
if ( empty( $svgcleaner_version ) ) {
|
10157 |
+
$speed_recommendations[] = '<a href="' . admin_url( 'admin.php?action=ewww_image_optimizer_install_svgcleaner' ) . '">' . __( 'Install svgcleaner', 'ewww-image-optimizer' ) . '</a>';
|
10158 |
+
}
|
10159 |
+
}
|
10160 |
if ( get_option( 'easyio_lazy_load' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
10161 |
$speed_score += 10;
|
10162 |
} else {
|
10261 |
<div id='ewww-status' class='postbox'>
|
10262 |
<h2 class='ewww-hndle'><?php esc_html_e( 'Optimization Status', 'ewww-image-optimizer' ); ?></h2>
|
10263 |
<div class='inside'>
|
10264 |
+
<div class="ewww-row ewww-blocks">
|
10265 |
+
<div id="ewww-compress" class="ewww-status-detail">
|
10266 |
<div id="ewww-compress-guage" class="ewww-guage" data-score="<?php echo (int) $speed_score; ?>">
|
10267 |
<svg width="120" height="120">
|
10268 |
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
10284 |
<?php if ( $speed_score < 100 ) : ?>
|
10285 |
<p class="description"><?php esc_html_e( 'Hover over score for recommendations to improve the speed of your site.', 'ewww-image-optimizer' ); ?></p>
|
10286 |
<?php endif; ?>
|
10287 |
+
</div><!-- end .ewww-status-detail -->
|
10288 |
<?php
|
10289 |
if ( $total_savings > 0 ) {
|
10290 |
$savings_stroke_dashoffset = $guage_stroke_dasharray * ( 1 - $total_savings / $total_sizes[1] );
|
10291 |
?>
|
10292 |
+
<div id="ewww-savings" class="ewww-status-detail">
|
10293 |
<div id="ewww-savings-guage" class="ewww-guage" data-score="<?php echo esc_attr( $total_savings / $total_sizes[1] ); ?>">
|
10294 |
<svg width="120" height="120">
|
10295 |
<title><?php echo esc_html( round( $total_savings / $total_sizes[1], 3 ) * 100 ); ?>%</title>
|
10298 |
</svg>
|
10299 |
<div class="ewww-score"><?php echo esc_html( ewww_image_optimizer_size_format( $total_savings, 2 ) ); ?></div>
|
10300 |
</div><!-- end .ewww-guage -->
|
10301 |
+
<p style="text-align:center"><strong><?php esc_html_e( 'Local Compression Savings', 'ewww-image-optimizer' ); ?></strong></p>
|
10302 |
<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>
|
10303 |
+
</div><!-- end .ewww-status-detail -->
|
10304 |
+
<?php } ?>
|
10305 |
+
<?php
|
10306 |
+
if ( $exactdn_enabled && ! empty( $exactdn_savings ) && ! empty( $exactdn_savings['original'] ) && ! empty( $exactdn_savings['savings'] ) ) {
|
10307 |
+
$savings_stroke_dashoffset = $guage_stroke_dasharray * ( 1 - $exactdn_savings['savings'] / $exactdn_savings['original'] );
|
10308 |
+
?>
|
10309 |
+
<div id="easyio-savings" class="ewww-status-detail">
|
10310 |
+
<div id="easyio-savings-guage" class="ewww-guage" data-score="<?php echo esc_attr( $exactdn_savings['savings'] / $exactdn_savings['original'] ); ?>">
|
10311 |
+
<svg width="120" height="120">
|
10312 |
+
<title><?php echo esc_html( round( $exactdn_savings['savings'] / $exactdn_savings['original'], 3 ) * 100 ); ?>%</title>
|
10313 |
+
<circle class="ewww-inactive" r="54" cy="60" cx="60" stroke-width="12" />
|
10314 |
+
<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;" />
|
10315 |
+
</svg>
|
10316 |
+
<div class="ewww-score"><?php echo esc_html( ewww_image_optimizer_size_format( $exactdn_savings['savings'], 2 ) ); ?></div>
|
10317 |
+
</div><!-- end .ewww-guage -->
|
10318 |
+
<p style="text-align:center">
|
10319 |
+
<strong><?php esc_html_e( 'Easy IO Savings', 'ewww-image-optimizer' ); ?></strong>
|
10320 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/96-easy-io-is-it-working', '5f871dd2c9e77c0016217c4e' ); ?>
|
10321 |
+
</p>
|
10322 |
+
</div><!-- end .ewww-status-detail -->
|
10323 |
<?php } ?>
|
10324 |
<!-- begin notices section -->
|
10325 |
+
<div id="ewww-notices" class="ewww-status-detail">
|
10326 |
<?php if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
10327 |
<h3>
|
10328 |
<a href='https://ewww.io/plans/' target='_blank' class='ewww-upgrade'><?php esc_html_e( 'Premium Upgrades:', 'ewww-image-optimizer' ); ?></a>
|
10373 |
<?php endif; ?>
|
10374 |
</p>
|
10375 |
<?php elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) && ! get_option( 'easyio_exactdn' ) ) : ?>
|
10376 |
+
<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>
|
10377 |
<?php endif; ?>
|
10378 |
<?php if ( ! function_exists( 'swis' ) ) : ?>
|
10379 |
+
<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>
|
10380 |
<?php endif; ?>
|
10381 |
<p>
|
10382 |
<strong><?php esc_html_e( 'Background optimization (faster uploads):', 'ewww-image-optimizer' ); ?></strong><br>
|
10404 |
</span>
|
10405 |
<?php endif; ?>
|
10406 |
</p>
|
10407 |
+
</div><!-- end .ewww-status-detail -->
|
10408 |
+
</div><!-- end .ewww-blocks --><!-- end .ewww-row -->
|
10409 |
</div><!-- end .inside -->
|
10410 |
</div>
|
10411 |
</div>
|
10474 |
<input type='hidden' id='ewww_image_optimizer_png_level' name='ewww_image_optimizer_png_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ); ?>'>
|
10475 |
<input type='hidden' id='ewww_image_optimizer_gif_level' name='ewww_image_optimizer_gif_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_gif_level' ); ?>'>
|
10476 |
<input type='hidden' id='ewww_image_optimizer_pdf_level' name='ewww_image_optimizer_pdf_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ); ?>'>
|
10477 |
+
<input type='hidden' id='ewww_image_optimizer_svg_level' name='ewww_image_optimizer_svg_level' value='<?php echo (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ); ?>'>
|
10478 |
<?php elseif ( 'singlesite' === $network && ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) : ?>
|
10479 |
<p><strong><?php esc_html_e( 'Easy IO is optimizing your site, no more configuration needed!', 'ewww-image-optimizer' ); ?></strong><br>
|
10480 |
<?php if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) : ?>
|
10652 |
</select>
|
10653 |
</td>
|
10654 |
</tr>
|
10655 |
+
<?php $disable_svg_level = ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_svgcleaner' ); ?>
|
10656 |
+
<tr>
|
10657 |
+
<th scope='row'>
|
10658 |
+
<label for='ewww_image_optimizer_svg_level'><?php esc_html_e( 'SVG Optimization Level', 'ewww-image-optimizer' ); ?></label>
|
10659 |
+
<?php ewwwio_help_link( 'https://docs.ewww.io/article/7-basic-configuration', '585373d5c697912ffd6c0bb2' ); ?>
|
10660 |
+
</th>
|
10661 |
+
<td>
|
10662 |
+
<select id='ewww_image_optimizer_svg_level' name='ewww_image_optimizer_svg_level'>
|
10663 |
+
<option value='0' <?php selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ), 0 ); ?>>
|
10664 |
+
<?php esc_html_e( 'No Compression', 'ewww-image-optimizer' ); ?>
|
10665 |
+
</option>
|
10666 |
+
<option <?php disabled( $disable_svg_level ); ?> value='1' <?php selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ), 1 ); ?>>
|
10667 |
+
<?php esc_html_e( 'Minimal', 'ewww-image-optimizer' ); ?>
|
10668 |
+
</option>
|
10669 |
+
<option <?php disabled( $disable_svg_level ); ?> value='10' <?php selected( ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ), 10 ); ?>>
|
10670 |
+
<?php esc_html_e( 'Default', 'ewww-image-optimizer' ); ?>
|
10671 |
+
</option>
|
10672 |
+
</select>
|
10673 |
+
<?php if ( $disable_svg_level || ( ! EWWW_IMAGE_OPTIMIZER_SVGCLEANER && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) ) : ?>
|
10674 |
+
<a href="<?php echo esc_url( admin_url( 'admin.php?action=ewww_image_optimizer_install_svgcleaner' ) ); ?>"><?php esc_html_e( 'Install svgcleaner', 'ewww-image-optimizer' ); ?></a>
|
10675 |
+
<?php endif; ?>
|
10676 |
+
</td>
|
10677 |
+
</tr>
|
10678 |
<tr>
|
10679 |
<th> </th>
|
10680 |
<td>
|
10773 |
<?php esc_html_e( 'CDN Included', 'ewww-image-optimizer' ); ?><br>
|
10774 |
<?php if ( ! $exactdn_enabled ) : ?>
|
10775 |
<strong>
|
10776 |
+
<a href="https://ewww.io/easy/" target="_blank">
|
10777 |
<?php esc_html_e( 'Purchase a subscription for your site.', 'ewww-image-optimizer' ); ?>
|
10778 |
</a>
|
10779 |
</strong><br>
|
11270 |
</p>
|
11271 |
</td>
|
11272 |
</tr>
|
11273 |
+
<tr>
|
11274 |
+
<th scope='row'>
|
11275 |
+
<label for='ewww_image_optimizer_webp_quality'><?php esc_html_e( 'WebP Quality Level', 'ewww-image-optimizer' ); ?></label>
|
11276 |
+
</th>
|
11277 |
+
<td>
|
11278 |
+
<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() ); ?>' />
|
11279 |
+
<?php esc_html_e( 'Default is 75, allowed range is 50-100.', 'ewww-image-optimizer' ); ?>
|
11280 |
+
</td>
|
11281 |
+
</tr>
|
11282 |
<?php endif; ?>
|
11283 |
|
11284 |
<?php if ( ! $free_exec && ( ! ewww_image_optimizer_ce_webp_enabled() && ! ewww_image_optimizer_easy_active() ) ) : ?>
|
11710 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_pdf_level' ) > 0 ) {
|
11711 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_pdf_level', 0 );
|
11712 |
}
|
11713 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_svgcleaner' ) ) {
|
11714 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_svg_level', 0 );
|
11715 |
+
}
|
11716 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_cloud_exceeded', 0 );
|
11717 |
delete_transient( 'ewww_image_optimizer_cloud_status' );
|
11718 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_backup_files', '' );
|
12011 |
// Unlimited, set to 32GB.
|
12012 |
$memory_limit = '32000M';
|
12013 |
}
|
12014 |
+
if ( stripos( $memory_limit, 'g' ) ) {
|
12015 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024 * 1024;
|
12016 |
} else {
|
12017 |
$memory_limit = intval( $memory_limit ) * 1024 * 1024;
|
ewww-image-optimizer.php
CHANGED
@@ -13,7 +13,7 @@ Plugin Name: EWWW Image Optimizer
|
|
13 |
Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
|
14 |
Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
|
15 |
Author: Exactly WWW
|
16 |
-
Version: 5.
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
13 |
Plugin URI: https://wordpress.org/plugins/ewww-image-optimizer/
|
14 |
Description: Reduce file sizes for images within WordPress including NextGEN Gallery and GRAND FlAGallery. Uses jpegtran, optipng/pngout, and gifsicle.
|
15 |
Author: Exactly WWW
|
16 |
+
Version: 5.8.0
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
includes/eio.js
CHANGED
@@ -349,7 +349,7 @@ jQuery(document).ready(function($) {
|
|
349 |
is_json = false;
|
350 |
}
|
351 |
if ( ! is_json ) {
|
352 |
-
$('#ewww-scanning').html('<span
|
353 |
console.log( response );
|
354 |
return false;
|
355 |
}
|
@@ -358,7 +358,7 @@ jQuery(document).ready(function($) {
|
|
358 |
ewww_wpnonce: ewww_vars._wpnonce,
|
359 |
};
|
360 |
if ( ewww_response.error ) {
|
361 |
-
$('#ewww-scanning').html('<span
|
362 |
} else if ( ewww_response.remaining ) {
|
363 |
$('.ewww-aux-table').hide();
|
364 |
$('#ewww-show-table').hide();
|
@@ -400,9 +400,9 @@ jQuery(document).ready(function($) {
|
|
400 |
.fail(function() {
|
401 |
ewww_scan_failures++;
|
402 |
if (ewww_scan_failures > 10) {
|
403 |
-
$('#ewww-scanning').html('<span
|
404 |
} else {
|
405 |
-
$('#ewww-scanning').html('<span
|
406 |
setTimeout(function() {
|
407 |
ewwwStartScan();
|
408 |
}, 1000);
|
@@ -453,12 +453,12 @@ jQuery(document).ready(function($) {
|
|
453 |
is_json = false;
|
454 |
}
|
455 |
if ( ! is_json || ! response ) {
|
456 |
-
$('#ewww-bulk-loading').append('<p
|
457 |
console.log( response );
|
458 |
return false;
|
459 |
}
|
460 |
if ( ewww_init_response.error ) {
|
461 |
-
$('#ewww-bulk-loading').append('<p
|
462 |
if ( ewww_init_response.data ) {
|
463 |
console.log( ewww_init_response.data );
|
464 |
}
|
@@ -500,7 +500,7 @@ jQuery(document).ready(function($) {
|
|
500 |
is_json = false;
|
501 |
}
|
502 |
if ( ! is_json || ! response ) {
|
503 |
-
$('#ewww-bulk-loading').append('<p
|
504 |
clearInterval(ewww_quota_update);
|
505 |
clearInterval(ewww_countdown);
|
506 |
if ( ! response ) {
|
@@ -522,7 +522,12 @@ jQuery(document).ready(function($) {
|
|
522 |
$.post(ajaxurl, ewww_updatemeta_data);
|
523 |
}
|
524 |
if ( ewww_response.error ) {
|
525 |
-
$('#ewww-bulk-loading').
|
|
|
|
|
|
|
|
|
|
|
526 |
clearInterval(ewww_quota_update);
|
527 |
clearInterval(ewww_countdown);
|
528 |
ewwwUpdateQuota();
|
@@ -534,12 +539,12 @@ jQuery(document).ready(function($) {
|
|
534 |
}
|
535 |
clearInterval(ewww_quota_update);
|
536 |
clearInterval(ewww_countdown);
|
537 |
-
$('#ewww-bulk-loading').html('<p
|
538 |
}
|
539 |
else if ( response == 0 ) {
|
540 |
clearInterval(ewww_quota_update);
|
541 |
clearInterval(ewww_countdown);
|
542 |
-
$('#ewww-bulk-loading').html('<p
|
543 |
}
|
544 |
else if ( ewww_i < ewww_attachments && ! ewww_response.done ) {
|
545 |
if ( ewww_bulk_start_time && ewww_response.current_time ) {
|
@@ -588,9 +593,9 @@ jQuery(document).ready(function($) {
|
|
588 |
})
|
589 |
.fail(function() {
|
590 |
if (ewww_error_counter == 0) {
|
591 |
-
$('#ewww-bulk-loading').html('<p
|
592 |
} else {
|
593 |
-
$('#ewww-bulk-loading').html('<p
|
594 |
ewww_error_counter--;
|
595 |
setTimeout(function() {
|
596 |
ewwwProcessImage();
|
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 |
}
|
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();
|
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);
|
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 |
}
|
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 ) {
|
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();
|
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 ) {
|
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();
|
includes/jquery-ui-1.10.1.custom.css
CHANGED
@@ -431,6 +431,12 @@ button.ewww-handlediv {
|
|
431 |
.js .postbox.closed .ewww-handlediv .toggle-indicator:before {
|
432 |
content: "\f140";
|
433 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
#ewww-bulk-controls {
|
435 |
border: solid 1px #e5e5e5;
|
436 |
background: #fff;
|
@@ -487,27 +493,30 @@ button.ewww-handlediv {
|
|
487 |
margin: 0;
|
488 |
padding: 0;
|
489 |
}
|
490 |
-
|
491 |
display: flex;
|
492 |
-
|
493 |
margin: 0;
|
494 |
padding: 0;
|
495 |
}
|
496 |
-
|
497 |
-
border-
|
498 |
}
|
499 |
-
.ewww-blocks
|
500 |
border-left: 1px solid #e2e2e2;
|
501 |
-
float: left;
|
502 |
margin: 0px;
|
503 |
-
padding:
|
504 |
}
|
505 |
-
.ewww-blocks
|
506 |
-
|
|
|
|
|
|
|
|
|
507 |
text-align: center;
|
508 |
-
margin: 2em;
|
509 |
}
|
510 |
-
.ewww-blocks
|
511 |
text-align: left;
|
512 |
}
|
513 |
.ewww-guage {
|
@@ -528,8 +537,11 @@ ul.ewww-blocks li:first-child {
|
|
528 |
.ewww-inactive {
|
529 |
stroke: #e6e6e6;
|
530 |
}
|
531 |
-
#ewww-compress {
|
532 |
-
|
|
|
|
|
|
|
533 |
}
|
534 |
#ewww-compress-guage .ewww-active {
|
535 |
stroke-linecap: round;
|
@@ -551,6 +563,11 @@ ul.ewww-blocks li:first-child {
|
|
551 |
stroke: #3eadc9;
|
552 |
stroke-linecap: round;
|
553 |
}
|
|
|
|
|
|
|
|
|
|
|
554 |
#ewww-compress-guage .ewww-score {
|
555 |
color: #444;
|
556 |
}
|
@@ -573,6 +590,12 @@ ul.ewww-blocks li:first-child {
|
|
573 |
color: #3eadc9;
|
574 |
white-space: nowrap;
|
575 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
.ewww-recommend {
|
577 |
display: none;
|
578 |
}
|
@@ -621,31 +644,30 @@ h3 a.ewww-upgrade {
|
|
621 |
display: none;
|
622 |
}
|
623 |
/* mobile rules */
|
624 |
-
@media screen and (max-width:
|
625 |
-
|
626 |
-
|
627 |
-
padding-top: 0px;
|
628 |
-
}
|
629 |
-
#ewww-widgets .postbox {
|
630 |
-
max-width: 215px;
|
631 |
-
min-width: 175px;
|
632 |
}
|
633 |
-
|
634 |
-
|
635 |
}
|
636 |
-
.ewww-
|
637 |
-
|
638 |
}
|
639 |
-
.ewww-blocks
|
640 |
-
|
|
|
641 |
}
|
642 |
-
|
643 |
-
|
644 |
-
clear: none;
|
645 |
}
|
646 |
-
|
647 |
-
|
|
|
|
|
648 |
}
|
|
|
|
|
649 |
.ewww-tab-nav {
|
650 |
border-style: none;
|
651 |
}
|
@@ -667,6 +689,8 @@ h3 a.ewww-upgrade {
|
|
667 |
}
|
668 |
#ewww-debug-info {
|
669 |
width: auto;
|
670 |
-
|
|
|
|
|
671 |
}
|
672 |
}
|
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 {
|
438 |
+
color: red;
|
439 |
+
}
|
440 |
#ewww-bulk-controls {
|
441 |
border: solid 1px #e5e5e5;
|
442 |
background: #fff;
|
493 |
margin: 0;
|
494 |
padding: 0;
|
495 |
}
|
496 |
+
.ewww-blocks {
|
497 |
display: flex;
|
498 |
+
flex-direction: row;
|
499 |
margin: 0;
|
500 |
padding: 0;
|
501 |
}
|
502 |
+
#ewww-status h2.ewww-hndle {
|
503 |
+
border-bottom: 0;
|
504 |
}
|
505 |
+
.ewww-blocks div.ewww-status-detail {
|
506 |
border-left: 1px solid #e2e2e2;
|
|
|
507 |
margin: 0px;
|
508 |
+
padding: 2em;
|
509 |
}
|
510 |
+
.ewww-blocks div.ewww-status-detail:first-child {
|
511 |
+
border-left: 0;
|
512 |
+
}
|
513 |
+
.ewww-blocks div.ewww-status-detail {
|
514 |
+
border-top: 1px solid #e2e2e2;
|
515 |
+
/* display: block; */
|
516 |
text-align: center;
|
517 |
+
/* margin: 2em; */
|
518 |
}
|
519 |
+
.ewww-blocks #ewww-notices {
|
520 |
text-align: left;
|
521 |
}
|
522 |
.ewww-guage {
|
537 |
.ewww-inactive {
|
538 |
stroke: #e6e6e6;
|
539 |
}
|
540 |
+
#ewww-compress, #ewww-savings, #easyio-savings {
|
541 |
+
flex: 1 1 120px;
|
542 |
+
}
|
543 |
+
#ewww-savings p {
|
544 |
+
margin: 0.5em 0;
|
545 |
}
|
546 |
#ewww-compress-guage .ewww-active {
|
547 |
stroke-linecap: round;
|
563 |
stroke: #3eadc9;
|
564 |
stroke-linecap: round;
|
565 |
}
|
566 |
+
#easyio-savings-guage .ewww-active {
|
567 |
+
stroke: #3eadc9;
|
568 |
+
stroke: #1d3c71;
|
569 |
+
stroke-linecap: round;
|
570 |
+
}
|
571 |
#ewww-compress-guage .ewww-score {
|
572 |
color: #444;
|
573 |
}
|
590 |
color: #3eadc9;
|
591 |
white-space: nowrap;
|
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 |
}
|
644 |
display: none;
|
645 |
}
|
646 |
/* mobile rules */
|
647 |
+
@media screen and (max-width: 868px) {
|
648 |
+
.ewww-blocks {
|
649 |
+
flex-wrap: wrap;
|
|
|
|
|
|
|
|
|
|
|
650 |
}
|
651 |
+
.ewww-blocks div.ewww-status-detail {
|
652 |
+
padding: 1em 2em;
|
653 |
}
|
654 |
+
.ewww-status-detail p {
|
655 |
+
margin: 0.5em 0;
|
656 |
}
|
657 |
+
.ewww-blocks #ewww-notices {
|
658 |
+
width: 100%;
|
659 |
+
border-left: 0;
|
660 |
}
|
661 |
+
.ewww-overrides-nav {
|
662 |
+
display: none;
|
|
|
663 |
}
|
664 |
+
}
|
665 |
+
@media screen and (max-width: 568px) {
|
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 |
}
|
689 |
}
|
690 |
#ewww-debug-info {
|
691 |
width: auto;
|
692 |
+
}
|
693 |
+
#ewww-settings-disable-resizes th, #ewww-settings-disable-resizes td {
|
694 |
+
display: table-cell;
|
695 |
}
|
696 |
}
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization,
|
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 5.
|
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,17 @@ 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.7.1 =
|
136 |
* added: alert on domain change for Easy IO, like if you clone from a production environment to staging
|
137 |
* changed: Easy IO domain and plan_id refresh automatically when visiting settings page
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 5.8.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 |
+
= 5.8.0 =
|
136 |
+
* added: SVG optimization, huge thanks to @samsk for making this happen!
|
137 |
+
* added: WebP quality setting, changed default to 75
|
138 |
+
* fixed: Lazy Load and other front-end parsers breaks JSON-encoded img elements
|
139 |
+
* fixed: Easy IO adds excess markup for images with height and/or width set to 'auto'
|
140 |
+
* fixed: memory_limit check should be case-insensitive: g vs. G
|
141 |
+
* fixed: PHP error during detection of Cache Enabler's WebP option
|
142 |
+
* fixed: table upgrade routine error when primary key already exists
|
143 |
+
* fixed: deleting files by always using realpath, props @ocean90
|
144 |
+
* fixed: Easy IO skips images in AJAX Load More requests
|
145 |
+
|
146 |
= 5.7.1 =
|
147 |
* added: alert on domain change for Easy IO, like if you clone from a production environment to staging
|
148 |
* changed: Easy IO domain and plan_id refresh automatically when visiting settings page
|
tests/test-convert.php
CHANGED
@@ -61,6 +61,7 @@ class EWWWIO_Convert_Tests extends WP_UnitTestCase {
|
|
61 |
update_site_option( 'ewww_image_optimizer_png_level', 40 );
|
62 |
ewww_image_optimizer_install_tools();
|
63 |
ewww_image_optimizer_install_pngout();
|
|
|
64 |
update_option( 'ewww_image_optimizer_webp', '' );
|
65 |
update_option( 'ewww_image_optimizer_png_level', 10 );
|
66 |
update_site_option( 'ewww_image_optimizer_webp', '' );
|
61 |
update_site_option( 'ewww_image_optimizer_png_level', 40 );
|
62 |
ewww_image_optimizer_install_tools();
|
63 |
ewww_image_optimizer_install_pngout();
|
64 |
+
ewww_image_optimizer_install_svgcleaner();
|
65 |
update_option( 'ewww_image_optimizer_webp', '' );
|
66 |
update_option( 'ewww_image_optimizer_png_level', 10 );
|
67 |
update_site_option( 'ewww_image_optimizer_webp', '' );
|
tests/test-optimize.php
CHANGED
@@ -39,6 +39,13 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
39 |
*/
|
40 |
public static $test_pdf = '';
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* Downloads test images.
|
44 |
*/
|
@@ -47,22 +54,26 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
47 |
$temp_upload_dir = trailingslashit( $wp_upload_dir['basedir'] ) . 'testing/';
|
48 |
wp_mkdir_p( $temp_upload_dir );
|
49 |
|
50 |
-
$test_jpg
|
51 |
rename( $test_jpg, $temp_upload_dir . basename( $test_jpg ) );
|
52 |
self::$test_jpg = $temp_upload_dir . basename( $test_jpg );
|
53 |
|
54 |
-
$test_png
|
55 |
rename( $test_png, $temp_upload_dir . basename( $test_png ) );
|
56 |
self::$test_png = $temp_upload_dir . basename( $test_png );
|
57 |
|
58 |
-
$test_gif
|
59 |
rename( $test_gif, $temp_upload_dir . basename( $test_gif ) );
|
60 |
self::$test_gif = $temp_upload_dir . basename( $test_gif );
|
61 |
|
62 |
-
$test_pdf
|
63 |
rename( $test_pdf, $temp_upload_dir . basename( $test_pdf ) );
|
64 |
self::$test_pdf = $temp_upload_dir . basename( $test_pdf );
|
65 |
|
|
|
|
|
|
|
|
|
66 |
ewww_image_optimizer_set_defaults();
|
67 |
update_option( 'ewww_image_optimizer_jpg_level', 10 );
|
68 |
update_option( 'ewww_image_optimizer_gif_level', 10 );
|
@@ -72,6 +83,7 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
72 |
update_site_option( 'ewww_image_optimizer_png_level', 40 );
|
73 |
ewww_image_optimizer_install_tools();
|
74 |
ewww_image_optimizer_install_pngout();
|
|
|
75 |
update_option( 'ewww_image_optimizer_webp', '' );
|
76 |
update_option( 'ewww_image_optimizer_png_level', 10 );
|
77 |
update_site_option( 'ewww_image_optimizer_webp', '' );
|
@@ -144,6 +156,20 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
144 |
return $results;
|
145 |
}
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
/**
|
148 |
* Test default JPG optimization with WebP.
|
149 |
*/
|
@@ -159,7 +185,7 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
159 |
update_site_option( 'ewww_image_optimizer_webp', '' );
|
160 |
$this->assertEquals( 1348837, filesize( $results[0] ) );
|
161 |
unlink( $results[0] );
|
162 |
-
$this->assertEquals(
|
163 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
164 |
unlink( $results[0] . '.webp' );
|
165 |
}
|
@@ -186,7 +212,7 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
186 |
$this->assertEquals( ewww_image_optimizer_get_orientation( $results[0], 'image/jpeg' ), 1 );
|
187 |
unlink( $results[0] );
|
188 |
// size of webp with meta.
|
189 |
-
$this->assertEquals(
|
190 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
191 |
unlink( $results[0] . '.webp' );
|
192 |
}
|
@@ -211,7 +237,7 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
211 |
update_site_option( 'ewww_image_optimizer_cloud_key', '' );
|
212 |
$this->assertEquals( 1335586, filesize( $results[0] ) );
|
213 |
unlink( $results[0] );
|
214 |
-
$this->assertEquals(
|
215 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
216 |
unlink( $results[0] . '.webp' );
|
217 |
}
|
@@ -240,7 +266,7 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
240 |
$this->assertEquals( ewww_image_optimizer_get_orientation( $results[0], 'image/jpeg' ), 1 );
|
241 |
unlink( $results[0] );
|
242 |
// size of webp with meta.
|
243 |
-
$this->assertEquals(
|
244 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
245 |
unlink( $results[0] . '.webp' );
|
246 |
}
|
@@ -473,6 +499,58 @@ class EWWWIO_Optimize_Tests extends WP_UnitTestCase {
|
|
473 |
unlink( $results[0] );
|
474 |
}
|
475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
/**
|
477 |
* Cleans up ewwwio_images table.
|
478 |
*/
|
39 |
*/
|
40 |
public static $test_pdf = '';
|
41 |
|
42 |
+
/**
|
43 |
+
* The location of the test SVG image.
|
44 |
+
*
|
45 |
+
* @var string $test_svg
|
46 |
+
*/
|
47 |
+
public static $test_svg = '';
|
48 |
+
|
49 |
/**
|
50 |
* Downloads test images.
|
51 |
*/
|
54 |
$temp_upload_dir = trailingslashit( $wp_upload_dir['basedir'] ) . 'testing/';
|
55 |
wp_mkdir_p( $temp_upload_dir );
|
56 |
|
57 |
+
$test_jpg = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/20170314_174658.jpg' );
|
58 |
rename( $test_jpg, $temp_upload_dir . basename( $test_jpg ) );
|
59 |
self::$test_jpg = $temp_upload_dir . basename( $test_jpg );
|
60 |
|
61 |
+
$test_png = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/books.png' );
|
62 |
rename( $test_png, $temp_upload_dir . basename( $test_png ) );
|
63 |
self::$test_png = $temp_upload_dir . basename( $test_png );
|
64 |
|
65 |
+
$test_gif = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/gifsiclelogo.gif' );
|
66 |
rename( $test_gif, $temp_upload_dir . basename( $test_gif ) );
|
67 |
self::$test_gif = $temp_upload_dir . basename( $test_gif );
|
68 |
|
69 |
+
$test_pdf = download_url( 'https://s3-us-west-2.amazonaws.com/exactlywww/tomtempleartist-bio-2008.pdf' );
|
70 |
rename( $test_pdf, $temp_upload_dir . basename( $test_pdf ) );
|
71 |
self::$test_pdf = $temp_upload_dir . basename( $test_pdf );
|
72 |
|
73 |
+
$test_svg = download_url( 'https://ewwwio-test.sfo2.digitaloceanspaces.com/unit-tests/image-x-generic.svg' );
|
74 |
+
rename( $test_svg, $temp_upload_dir . basename( $test_svg ) );
|
75 |
+
self::$test_svg = $temp_upload_dir . basename( $test_svg );
|
76 |
+
|
77 |
ewww_image_optimizer_set_defaults();
|
78 |
update_option( 'ewww_image_optimizer_jpg_level', 10 );
|
79 |
update_option( 'ewww_image_optimizer_gif_level', 10 );
|
83 |
update_site_option( 'ewww_image_optimizer_png_level', 40 );
|
84 |
ewww_image_optimizer_install_tools();
|
85 |
ewww_image_optimizer_install_pngout();
|
86 |
+
ewww_image_optimizer_install_svgcleaner();
|
87 |
update_option( 'ewww_image_optimizer_webp', '' );
|
88 |
update_option( 'ewww_image_optimizer_png_level', 10 );
|
89 |
update_site_option( 'ewww_image_optimizer_webp', '' );
|
156 |
return $results;
|
157 |
}
|
158 |
|
159 |
+
/**
|
160 |
+
* Copies the test SVG to a temp file, optimizes it, and returns the results.
|
161 |
+
*
|
162 |
+
* @return array The results of the ewww_image_optimizer() function.
|
163 |
+
*/
|
164 |
+
protected function optimize_svg() {
|
165 |
+
global $ewww_force;
|
166 |
+
$ewww_force = 1;
|
167 |
+
$filename = self::$test_svg . ".svg";
|
168 |
+
copy( self::$test_svg, $filename );
|
169 |
+
$results = ewww_image_optimizer( $filename );
|
170 |
+
return $results;
|
171 |
+
}
|
172 |
+
|
173 |
/**
|
174 |
* Test default JPG optimization with WebP.
|
175 |
*/
|
185 |
update_site_option( 'ewww_image_optimizer_webp', '' );
|
186 |
$this->assertEquals( 1348837, filesize( $results[0] ) );
|
187 |
unlink( $results[0] );
|
188 |
+
$this->assertEquals( 200048, filesize( $results[0] . '.webp' ) );
|
189 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
190 |
unlink( $results[0] . '.webp' );
|
191 |
}
|
212 |
$this->assertEquals( ewww_image_optimizer_get_orientation( $results[0], 'image/jpeg' ), 1 );
|
213 |
unlink( $results[0] );
|
214 |
// size of webp with meta.
|
215 |
+
$this->assertEquals( 219630, filesize( $results[0] . '.webp' ) );
|
216 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
217 |
unlink( $results[0] . '.webp' );
|
218 |
}
|
237 |
update_site_option( 'ewww_image_optimizer_cloud_key', '' );
|
238 |
$this->assertEquals( 1335586, filesize( $results[0] ) );
|
239 |
unlink( $results[0] );
|
240 |
+
$this->assertEquals( 171174, filesize( $results[0] . '.webp' ) );
|
241 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
242 |
unlink( $results[0] . '.webp' );
|
243 |
}
|
266 |
$this->assertEquals( ewww_image_optimizer_get_orientation( $results[0], 'image/jpeg' ), 1 );
|
267 |
unlink( $results[0] );
|
268 |
// size of webp with meta.
|
269 |
+
$this->assertEquals( 190760, filesize( $results[0] . '.webp' ) );
|
270 |
if ( ewwwio_is_file( $results[0] . '.webp' ) ) {
|
271 |
unlink( $results[0] . '.webp' );
|
272 |
}
|
499 |
unlink( $results[0] );
|
500 |
}
|
501 |
|
502 |
+
/**
|
503 |
+
* Test minimal SVG locally.
|
504 |
+
*/
|
505 |
+
function test_optimize_svg_01() {
|
506 |
+
update_option( 'ewww_image_optimizer_svg_level', 1 );
|
507 |
+
update_site_option( 'ewww_image_optimizer_svg_level', 1 );
|
508 |
+
$results = $this->optimize_svg();
|
509 |
+
$this->assertEquals( 10792, filesize( $results[0] ) );
|
510 |
+
unlink( $results[0] );
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Test default SVG locally.
|
515 |
+
*/
|
516 |
+
function test_optimize_svg_10() {
|
517 |
+
update_option( 'ewww_image_optimizer_svg_level', 10 );
|
518 |
+
update_site_option( 'ewww_image_optimizer_svg_level', 10 );
|
519 |
+
$results = $this->optimize_svg();
|
520 |
+
$this->assertEquals( 9518, filesize( $results[0] ) );
|
521 |
+
unlink( $results[0] );
|
522 |
+
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
* Test minimal SVG via API.
|
526 |
+
*/
|
527 |
+
function test_optimize_svg_01_api() {
|
528 |
+
update_option( 'ewww_image_optimizer_svg_level', 1 );
|
529 |
+
update_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
530 |
+
update_site_option( 'ewww_image_optimizer_svg_level', 1 );
|
531 |
+
update_site_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
532 |
+
$results = $this->optimize_svg();
|
533 |
+
update_option( 'ewww_image_optimizer_cloud_key', '' );
|
534 |
+
update_site_option( 'ewww_image_optimizer_cloud_key', '' );
|
535 |
+
$this->assertEquals( 10792, filesize( $results[0] ) );
|
536 |
+
unlink( $results[0] );
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Test default SVG via API.
|
541 |
+
*/
|
542 |
+
function test_optimize_svg_10_api() {
|
543 |
+
update_option( 'ewww_image_optimizer_svg_level', 10 );
|
544 |
+
update_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
545 |
+
update_site_option( 'ewww_image_optimizer_svg_level', 10 );
|
546 |
+
update_site_option( 'ewww_image_optimizer_cloud_key', 'abc123' );
|
547 |
+
$results = $this->optimize_svg();
|
548 |
+
update_option( 'ewww_image_optimizer_cloud_key', '' );
|
549 |
+
update_site_option( 'ewww_image_optimizer_cloud_key', '' );
|
550 |
+
$this->assertEquals( 9518, filesize( $results[0] ) );
|
551 |
+
unlink( $results[0] );
|
552 |
+
}
|
553 |
+
|
554 |
/**
|
555 |
* Cleans up ewwwio_images table.
|
556 |
*/
|
unique.php
CHANGED
@@ -14,6 +14,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
|
15 |
// Installation routine for PNGOUT.
|
16 |
add_action( 'admin_action_ewww_image_optimizer_install_pngout', 'ewww_image_optimizer_install_pngout_wrapper' );
|
|
|
|
|
17 |
// AJAX action hook to dismiss the exec notice May be extended to other notices in the future.
|
18 |
add_action( 'wp_ajax_ewww_dismiss_exec_notice', 'ewww_image_optimizer_dismiss_exec_notice' );
|
19 |
// Removes the binaries when the plugin is deactivated.
|
@@ -120,6 +122,9 @@ function ewww_image_optimizer_set_defaults() {
|
|
120 |
add_option( 'ewww_image_optimizer_png_level', '10' );
|
121 |
add_option( 'ewww_image_optimizer_gif_level', '10' );
|
122 |
add_option( 'ewww_image_optimizer_pdf_level', '0' );
|
|
|
|
|
|
|
123 |
add_option( 'ewww_image_optimizer_exactdn', false );
|
124 |
add_option( 'ewww_image_optimizer_exactdn_plan_id', 0 );
|
125 |
add_option( 'exactdn_all_the_things', true );
|
@@ -128,6 +133,7 @@ function ewww_image_optimizer_set_defaults() {
|
|
128 |
add_option( 'ewww_image_optimizer_lazy_load', false );
|
129 |
add_option( 'ewww_image_optimizer_ll_exclude', '' );
|
130 |
add_option( 'ewww_image_optimizer_disable_pngout', true );
|
|
|
131 |
add_option( 'ewww_image_optimizer_optipng_level', 2 );
|
132 |
add_option( 'ewww_image_optimizer_pngout_level', 2 );
|
133 |
add_option( 'ewww_image_optimizer_webp_for_cdn', false );
|
@@ -141,7 +147,11 @@ function ewww_image_optimizer_set_defaults() {
|
|
141 |
add_site_option( 'ewww_image_optimizer_png_level', '10' );
|
142 |
add_site_option( 'ewww_image_optimizer_gif_level', '10' );
|
143 |
add_site_option( 'ewww_image_optimizer_pdf_level', '0' );
|
|
|
|
|
|
|
144 |
add_site_option( 'ewww_image_optimizer_disable_pngout', true );
|
|
|
145 |
add_site_option( 'ewww_image_optimizer_optipng_level', 2 );
|
146 |
add_site_option( 'ewww_image_optimizer_pngout_level', 2 );
|
147 |
add_site_option( 'exactdn_all_the_things', true );
|
@@ -473,6 +483,7 @@ function ewww_image_optimizer_install_tools() {
|
|
473 |
* @type bool $pngout
|
474 |
* @type bool $pngquant
|
475 |
* @type bool $webp
|
|
|
476 |
* }
|
477 |
*/
|
478 |
function ewww_image_optimizer_skip_tools() {
|
@@ -481,9 +492,10 @@ function ewww_image_optimizer_skip_tools() {
|
|
481 |
$skip['optipng'] = false;
|
482 |
$skip['gifsicle'] = false;
|
483 |
// Except these which are off by default.
|
484 |
-
$skip['pngout']
|
485 |
-
$skip['pngquant']
|
486 |
-
$skip['webp']
|
|
|
487 |
// If the user has disabled a tool, we aren't going to bother checking to see if it is there.
|
488 |
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 || ( defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) && EWWW_IMAGE_OPTIMIZER_NOEXEC ) ) {
|
489 |
$skip['jpegtran'] = true;
|
@@ -503,6 +515,9 @@ function ewww_image_optimizer_skip_tools() {
|
|
503 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && ! ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) > 10 ) ) {
|
504 |
$skip['webp'] = false;
|
505 |
}
|
|
|
|
|
|
|
506 |
foreach ( $skip as $tool => $disabled ) {
|
507 |
if ( ! $disabled ) {
|
508 |
ewwwio_debug_message( "enabled: $tool" );
|
@@ -542,6 +557,7 @@ function ewww_image_optimizer_dismiss_exec_notice() {
|
|
542 |
update_option( 'ewww_image_optimizer_png_level', 0 );
|
543 |
update_option( 'ewww_image_optimizer_gif_level', 0 );
|
544 |
update_option( 'ewww_image_optimizer_pdf_level', 0 );
|
|
|
545 |
update_option( 'ewww_image_optimizer_dismiss_exec_notice', 1 );
|
546 |
update_site_option( 'ewww_image_optimizer_dismiss_exec_notice', 1 );
|
547 |
wp_die();
|
@@ -615,7 +631,7 @@ function ewww_image_optimizer_notice_utils( $quiet = null ) {
|
|
615 |
|
616 |
$skip = ewww_image_optimizer_skip_tools();
|
617 |
// Attempt to retrieve values for utility paths, and store them in the appropriate variables.
|
618 |
-
$required = ewww_image_optimizer_path_check( ! $skip['jpegtran'], ! $skip['optipng'], ! $skip['gifsicle'], ! $skip['pngout'], ! $skip['pngquant'], ! $skip['webp'] );
|
619 |
$missing = array();
|
620 |
// Go through each of the required tools.
|
621 |
foreach ( $required as $key => $req ) {
|
@@ -681,6 +697,16 @@ function ewww_image_optimizer_notice_utils( $quiet = null ) {
|
|
681 |
define( 'EWWW_IMAGE_OPTIMIZER_' . $key, $req );
|
682 |
}
|
683 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
} // End switch().
|
685 |
} // End foreach().
|
686 |
// Expand the missing utilities list for use in the error message.
|
@@ -713,6 +739,16 @@ function ewww_image_optimizer_notice_utils( $quiet = null ) {
|
|
713 |
'<a href="https://docs.ewww.io/article/13-installing-pngout" data-beacon-article="5854531bc697912ffd6c1afa">' . esc_html__( 'manually', 'ewww-image-optimizer' ) . '</a>'
|
714 |
) .
|
715 |
'</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
716 |
} else {
|
717 |
echo "<div id='ewww-image-optimizer-warning-opt-missing' class='notice notice-error'><p>" .
|
718 |
sprintf(
|
@@ -756,26 +792,29 @@ function ewww_image_optimizer_exec_check() {
|
|
756 |
* @param bool $p True to check pngout.
|
757 |
* @param bool $q True to check pngquant.
|
758 |
* @param bool $w True to check cwebp.
|
759 |
-
* @
|
|
|
760 |
* or false for disabled/missing tools.
|
761 |
*/
|
762 |
-
function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p = true, $q = true, $w = true ) {
|
763 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
764 |
-
$jpegtran
|
765 |
-
$optipng
|
766 |
-
$gifsicle
|
767 |
-
$pngout
|
768 |
-
$pngquant
|
769 |
-
$webp
|
|
|
770 |
ewww_image_optimizer_define_noexec();
|
771 |
if ( EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
772 |
return array(
|
773 |
-
'JPEGTRAN'
|
774 |
-
'OPTIPNG'
|
775 |
-
'GIFSICLE'
|
776 |
-
'PNGOUT'
|
777 |
-
'PNGQUANT'
|
778 |
-
'CWEBP'
|
|
|
779 |
);
|
780 |
}
|
781 |
if ( 'WINNT' === PHP_OS ) {
|
@@ -833,6 +872,16 @@ function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p =
|
|
833 |
$webp = EWWW_IMAGE_OPTIMIZER_CWEBP;
|
834 |
}
|
835 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
} else {
|
837 |
if ( $j ) {
|
838 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) ) {
|
@@ -913,6 +962,16 @@ function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p =
|
|
913 |
$webp = EWWW_IMAGE_OPTIMIZER_CWEBP;
|
914 |
}
|
915 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
916 |
} // End if().
|
917 |
if ( $jpegtran ) {
|
918 |
ewwwio_debug_message( "using: $jpegtran" );
|
@@ -932,14 +991,18 @@ function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p =
|
|
932 |
if ( $webp ) {
|
933 |
ewwwio_debug_message( "using: $webp" );
|
934 |
}
|
|
|
|
|
|
|
935 |
ewwwio_memory( __FUNCTION__ );
|
936 |
return array(
|
937 |
-
'JPEGTRAN'
|
938 |
-
'OPTIPNG'
|
939 |
-
'GIFSICLE'
|
940 |
-
'PNGOUT'
|
941 |
-
'PNGQUANT'
|
942 |
-
'CWEBP'
|
|
|
943 |
);
|
944 |
}
|
945 |
|
@@ -1135,6 +1198,10 @@ function ewww_image_optimizer_md5check( $path ) {
|
|
1135 |
'66568f3b31f8f22deef38aa6ba3d2be19516514e94b7d623cd2ce2a290ccdd69', // cwebp-sol 1.0.3, EWWW 5.1.0.
|
1136 |
'e1041c5486fb4e57e31155c45d66117f8fc270e5a56a1049408a05f54bd52969', // cwebp.exe 1.0.3, EWWW 5.1.0.
|
1137 |
// end cwebp.
|
|
|
|
|
|
|
|
|
1138 |
);
|
1139 |
foreach ( $valid_sums as $checksum ) {
|
1140 |
if ( $checksum === $binary_sum ) {
|
@@ -1204,6 +1271,11 @@ function ewww_image_optimizer_mimetype( $path, $case ) {
|
|
1204 |
ewwwio_debug_message( "ewwwio type: $type" );
|
1205 |
return $type;
|
1206 |
}
|
|
|
|
|
|
|
|
|
|
|
1207 |
ewwwio_debug_message( "match not found for image: $magic" );
|
1208 |
} else {
|
1209 |
ewwwio_debug_message( 'could not open for reading' );
|
@@ -1466,6 +1538,20 @@ function ewww_image_optimizer_tool_found( $path, $tool ) {
|
|
1466 |
return esc_html__( 'unknown', 'ewww-image-optimizer' );
|
1467 |
}
|
1468 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1469 |
} // End switch().
|
1470 |
ewwwio_debug_message( 'tool not found' );
|
1471 |
ewwwio_memory( __FUNCTION__ );
|
@@ -1606,6 +1692,7 @@ function ewww_image_optimizer_gifsicle_resize( $file, $dst_x, $dst_y, $src_x, $s
|
|
1606 |
true,
|
1607 |
false,
|
1608 |
false,
|
|
|
1609 |
false
|
1610 |
);
|
1611 |
if ( empty( $tools['GIFSICLE'] ) ) {
|
@@ -1687,6 +1774,7 @@ function ewww_image_optimizer_jpegtran_autorotate( $file, $type, $orientation )
|
|
1687 |
false,
|
1688 |
false,
|
1689 |
false,
|
|
|
1690 |
false
|
1691 |
);
|
1692 |
if ( empty( $tools['JPEGTRAN'] ) ) {
|
@@ -1841,12 +1929,13 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1841 |
}
|
1842 |
$skip = ewww_image_optimizer_skip_tools();
|
1843 |
if ( EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
1844 |
-
$skip['jpegtran']
|
1845 |
-
$skip['optipng']
|
1846 |
-
$skip['gifsicle']
|
1847 |
-
$skip['pngout']
|
1848 |
-
$skip['pngquant']
|
1849 |
-
$skip['webp']
|
|
|
1850 |
}
|
1851 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_skip_full' ) && $fullsize ) {
|
1852 |
$keep_metadata = true;
|
@@ -1955,7 +2044,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1955 |
false,
|
1956 |
! $skip['pngout'],
|
1957 |
! $skip['pngquant'],
|
1958 |
-
! $skip['webp']
|
|
|
1959 |
);
|
1960 |
} else {
|
1961 |
$tools = ewww_image_optimizer_path_check(
|
@@ -1964,7 +2054,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
1964 |
false,
|
1965 |
false,
|
1966 |
false,
|
1967 |
-
! $skip['webp']
|
|
|
1968 |
);
|
1969 |
}
|
1970 |
if ( ! empty( $ewww_webp_only ) ) {
|
@@ -2232,7 +2323,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2232 |
false,
|
2233 |
! $skip['pngout'],
|
2234 |
! $skip['pngquant'],
|
2235 |
-
! $skip['webp']
|
|
|
2236 |
);
|
2237 |
} else {
|
2238 |
$tools = ewww_image_optimizer_path_check(
|
@@ -2241,7 +2333,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2241 |
false,
|
2242 |
! $skip['pngout'],
|
2243 |
! $skip['pngquant'],
|
2244 |
-
! $skip['webp']
|
|
|
2245 |
);
|
2246 |
}
|
2247 |
// If png optimization is disabled.
|
@@ -2525,7 +2618,8 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2525 |
! $skip['gifsicle'],
|
2526 |
! $skip['pngout'],
|
2527 |
! $skip['pngquant'],
|
2528 |
-
! $skip['webp']
|
|
|
2529 |
);
|
2530 |
} else {
|
2531 |
$tools = ewww_image_optimizer_path_check(
|
@@ -2534,6 +2628,7 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2534 |
! $skip['gifsicle'],
|
2535 |
false,
|
2536 |
false,
|
|
|
2537 |
false
|
2538 |
);
|
2539 |
}
|
@@ -2662,8 +2757,95 @@ function ewww_image_optimizer( $file, $gallery_type = 4, $converted = false, $ne
|
|
2662 |
list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type );
|
2663 |
}
|
2664 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2665 |
default:
|
2666 |
-
// If not a JPG, PNG,
|
2667 |
return array( false, __( 'Unsupported file type', 'ewww-image-optimizer' ) . ": $type", $converted, $original );
|
2668 |
} // End switch().
|
2669 |
// Allow other plugins to run operations on the images after optimization.
|
@@ -2717,8 +2899,10 @@ function ewww_image_optimizer_webp_create( $file, $orig_size, $type, $tool, $rec
|
|
2717 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
|
2718 |
return '';
|
2719 |
} elseif ( ! ewwwio_is_file( $file ) ) {
|
|
|
2720 |
return esc_html__( 'Could not find file.', 'ewww-image-optimizer' );
|
2721 |
} elseif ( ! is_writable( $file ) ) {
|
|
|
2722 |
return esc_html__( 'File is not writable.', 'ewww-image-optimizer' );
|
2723 |
} elseif ( ewwwio_is_file( $webpfile ) && empty( $ewww_force ) && ! $recreate ) {
|
2724 |
ewwwio_debug_message( 'webp file exists, not forcing or recreating' );
|
@@ -2743,9 +2927,9 @@ function ewww_image_optimizer_webp_create( $file, $orig_size, $type, $tool, $rec
|
|
2743 |
// Copy all the metadata.
|
2744 |
$copy_opt = 'all';
|
2745 |
}
|
2746 |
-
$quality = (int) apply_filters( '
|
2747 |
if ( $quality < 50 ) {
|
2748 |
-
$quality =
|
2749 |
}
|
2750 |
if ( defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP' ) && EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP ) {
|
2751 |
$lossless = "-q $quality";
|
@@ -2931,6 +3115,125 @@ function ewww_image_optimizer_install_pngout() {
|
|
2931 |
return $sendback;
|
2932 |
}
|
2933 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2934 |
/**
|
2935 |
* Removes any binaries that have been installed in the wp-content/ewww/ folder.
|
2936 |
*/
|
14 |
|
15 |
// Installation routine for PNGOUT.
|
16 |
add_action( 'admin_action_ewww_image_optimizer_install_pngout', 'ewww_image_optimizer_install_pngout_wrapper' );
|
17 |
+
// Installation routine for SVGCLEANER.
|
18 |
+
add_action( 'admin_action_ewww_image_optimizer_install_svgcleaner', 'ewww_image_optimizer_install_svgcleaner_wrapper' );
|
19 |
// AJAX action hook to dismiss the exec notice May be extended to other notices in the future.
|
20 |
add_action( 'wp_ajax_ewww_dismiss_exec_notice', 'ewww_image_optimizer_dismiss_exec_notice' );
|
21 |
// Removes the binaries when the plugin is deactivated.
|
122 |
add_option( 'ewww_image_optimizer_png_level', '10' );
|
123 |
add_option( 'ewww_image_optimizer_gif_level', '10' );
|
124 |
add_option( 'ewww_image_optimizer_pdf_level', '0' );
|
125 |
+
add_option( 'ewww_image_optimizer_svg_level', '0' );
|
126 |
+
add_option( 'ewww_image_optimizer_jpg_quality', '' );
|
127 |
+
add_option( 'ewww_image_optimizer_webp_quality', '' );
|
128 |
add_option( 'ewww_image_optimizer_exactdn', false );
|
129 |
add_option( 'ewww_image_optimizer_exactdn_plan_id', 0 );
|
130 |
add_option( 'exactdn_all_the_things', true );
|
133 |
add_option( 'ewww_image_optimizer_lazy_load', false );
|
134 |
add_option( 'ewww_image_optimizer_ll_exclude', '' );
|
135 |
add_option( 'ewww_image_optimizer_disable_pngout', true );
|
136 |
+
add_option( 'ewww_image_optimizer_disable_svgcleaner', true );
|
137 |
add_option( 'ewww_image_optimizer_optipng_level', 2 );
|
138 |
add_option( 'ewww_image_optimizer_pngout_level', 2 );
|
139 |
add_option( 'ewww_image_optimizer_webp_for_cdn', false );
|
147 |
add_site_option( 'ewww_image_optimizer_png_level', '10' );
|
148 |
add_site_option( 'ewww_image_optimizer_gif_level', '10' );
|
149 |
add_site_option( 'ewww_image_optimizer_pdf_level', '0' );
|
150 |
+
add_site_option( 'ewww_image_optimizer_svg_level', '0' );
|
151 |
+
add_site_option( 'ewww_image_optimizer_jpg_quality', '' );
|
152 |
+
add_site_option( 'ewww_image_optimizer_webp_quality', '' );
|
153 |
add_site_option( 'ewww_image_optimizer_disable_pngout', true );
|
154 |
+
add_site_option( 'ewww_image_optimizer_disable_svgcleaner', true );
|
155 |
add_site_option( 'ewww_image_optimizer_optipng_level', 2 );
|
156 |
add_site_option( 'ewww_image_optimizer_pngout_level', 2 );
|
157 |
add_site_option( 'exactdn_all_the_things', true );
|
483 |
* @type bool $pngout
|
484 |
* @type bool $pngquant
|
485 |
* @type bool $webp
|
486 |
+
* @type bool $svgcleaner
|
487 |
* }
|
488 |
*/
|
489 |
function ewww_image_optimizer_skip_tools() {
|
492 |
$skip['optipng'] = false;
|
493 |
$skip['gifsicle'] = false;
|
494 |
// Except these which are off by default.
|
495 |
+
$skip['pngout'] = true;
|
496 |
+
$skip['pngquant'] = true;
|
497 |
+
$skip['webp'] = true;
|
498 |
+
$skip['svgcleaner'] = true;
|
499 |
// If the user has disabled a tool, we aren't going to bother checking to see if it is there.
|
500 |
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 || ( defined( 'EWWW_IMAGE_OPTIMIZER_NOEXEC' ) && EWWW_IMAGE_OPTIMIZER_NOEXEC ) ) {
|
501 |
$skip['jpegtran'] = true;
|
515 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) && ! ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_jpg_level' ) > 10 && ewww_image_optimizer_get_option( 'ewww_image_optimizer_png_level' ) > 10 ) ) {
|
516 |
$skip['webp'] = false;
|
517 |
}
|
518 |
+
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_disable_svgcleaner' ) && ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) ) {
|
519 |
+
$skip['svgcleaner'] = false;
|
520 |
+
}
|
521 |
foreach ( $skip as $tool => $disabled ) {
|
522 |
if ( ! $disabled ) {
|
523 |
ewwwio_debug_message( "enabled: $tool" );
|
557 |
update_option( 'ewww_image_optimizer_png_level', 0 );
|
558 |
update_option( 'ewww_image_optimizer_gif_level', 0 );
|
559 |
update_option( 'ewww_image_optimizer_pdf_level', 0 );
|
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();
|
631 |
|
632 |
$skip = ewww_image_optimizer_skip_tools();
|
633 |
// Attempt to retrieve values for utility paths, and store them in the appropriate variables.
|
634 |
+
$required = ewww_image_optimizer_path_check( ! $skip['jpegtran'], ! $skip['optipng'], ! $skip['gifsicle'], ! $skip['pngout'], ! $skip['pngquant'], ! $skip['webp'], ! $skip['svgcleaner'] );
|
635 |
$missing = array();
|
636 |
// Go through each of the required tools.
|
637 |
foreach ( $required as $key => $req ) {
|
697 |
define( 'EWWW_IMAGE_OPTIMIZER_' . $key, $req );
|
698 |
}
|
699 |
break;
|
700 |
+
case 'SVGCLEANER':
|
701 |
+
if ( ! $skip['svgcleaner'] && empty( $req ) ) {
|
702 |
+
$missing[] = 'svgcleaner';
|
703 |
+
$req = false;
|
704 |
+
}
|
705 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_' . $key ) ) {
|
706 |
+
ewwwio_debug_message( "defining EWWW_IMAGE_OPTIMIZER_$key" );
|
707 |
+
define( 'EWWW_IMAGE_OPTIMIZER_' . $key, $req );
|
708 |
+
}
|
709 |
+
break;
|
710 |
} // End switch().
|
711 |
} // End foreach().
|
712 |
// Expand the missing utilities list for use in the error message.
|
739 |
'<a href="https://docs.ewww.io/article/13-installing-pngout" data-beacon-article="5854531bc697912ffd6c1afa">' . esc_html__( 'manually', 'ewww-image-optimizer' ) . '</a>'
|
740 |
) .
|
741 |
'</p></div>';
|
742 |
+
} elseif ( 'svgcleaner' === $msg ) {
|
743 |
+
$svgcleaner_install_url = admin_url( 'admin.php?action=ewww_image_optimizer_install_svgcleaner' );
|
744 |
+
echo "<div id='ewww-image-optimizer-warning-opt-missing' class='notice notice-error'><p>" .
|
745 |
+
sprintf(
|
746 |
+
/* translators: 1: automatically (link) 2: manually (link) */
|
747 |
+
esc_html__( 'You are missing svgleaner. Install %1$s or %2$s.', 'ewww-image-optimizer' ),
|
748 |
+
"<a href='" . esc_url( $svgcleaner_install_url ) . "'>" . esc_html__( 'automatically', 'ewww-image-optimizer' ) . '</a>',
|
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 |
} else {
|
753 |
echo "<div id='ewww-image-optimizer-warning-opt-missing' class='notice notice-error'><p>" .
|
754 |
sprintf(
|
792 |
* @param bool $p True to check pngout.
|
793 |
* @param bool $q True to check pngquant.
|
794 |
* @param bool $w True to check cwebp.
|
795 |
+
* @param bool $s True to check svgcleaner.
|
796 |
+
* @return array Path for each tool (indexes JPEGTRAN, OPTIPNG, GIFSICLE, PNGOUT, PNGQUANT, CWEBP, SVGCLEANER),
|
797 |
* or false for disabled/missing tools.
|
798 |
*/
|
799 |
+
function ewww_image_optimizer_path_check( $j = true, $o = true, $g = true, $p = true, $q = true, $w = true, $s = true ) {
|
800 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
801 |
+
$jpegtran = false;
|
802 |
+
$optipng = false;
|
803 |
+
$gifsicle = false;
|
804 |
+
$pngout = false;
|
805 |
+
$pngquant = false;
|
806 |
+
$webp = false;
|
807 |
+
$svgcleaner = false;
|
808 |
ewww_image_optimizer_define_noexec();
|
809 |
if ( EWWW_IMAGE_OPTIMIZER_NOEXEC ) {
|
810 |
return array(
|
811 |
+
'JPEGTRAN' => false,
|
812 |
+
'OPTIPNG' => false,
|
813 |
+
'GIFSICLE' => false,
|
814 |
+
'PNGOUT' => false,
|
815 |
+
'PNGQUANT' => false,
|
816 |
+
'CWEBP' => false,
|
817 |
+
'SVGCLEANER' => false,
|
818 |
);
|
819 |
}
|
820 |
if ( 'WINNT' === PHP_OS ) {
|
872 |
$webp = EWWW_IMAGE_OPTIMIZER_CWEBP;
|
873 |
}
|
874 |
}
|
875 |
+
if ( $s ) {
|
876 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_SVGCLEANER' ) ) {
|
877 |
+
$svgcleaner = ewww_image_optimizer_find_win_binary( 'svgcleaner', 's' );
|
878 |
+
ewwwio_debug_message( 'defining EWWW_IMAGE_OPTIMIZER_SVGCLEANER' );
|
879 |
+
define( 'EWWW_IMAGE_OPTIMIZER_SVGCLEANER', $svgcleaner );
|
880 |
+
} else {
|
881 |
+
ewwwio_debug_message( 'using existing EWWW_IMAGE_OPTIMIZER_SVGCLEANER' );
|
882 |
+
$svgcleaner = EWWW_IMAGE_OPTIMIZER_SVGCLEANER;
|
883 |
+
}
|
884 |
+
}
|
885 |
} else {
|
886 |
if ( $j ) {
|
887 |
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_JPEGTRAN' ) ) {
|
962 |
$webp = EWWW_IMAGE_OPTIMIZER_CWEBP;
|
963 |
}
|
964 |
}
|
965 |
+
if ( $s ) {
|
966 |
+
if ( ! defined( 'EWWW_IMAGE_OPTIMIZER_SVGCLEANER' ) ) {
|
967 |
+
$svgcleaner = ewww_image_optimizer_find_nix_binary( 'svgcleaner', 's' );
|
968 |
+
ewwwio_debug_message( 'defining EWWW_IMAGE_OPTIMIZER_SVGCLEANER' );
|
969 |
+
define( 'EWWW_IMAGE_OPTIMIZER_SVGCLEANER', $svgcleaner );
|
970 |
+
} else {
|
971 |
+
ewwwio_debug_message( 'using existing EWWW_IMAGE_OPTIMIZER_SVGCLEANER' );
|
972 |
+
$svgcleaner = EWWW_IMAGE_OPTIMIZER_SVGCLEANER;
|
973 |
+
}
|
974 |
+
}
|
975 |
} // End if().
|
976 |
if ( $jpegtran ) {
|
977 |
ewwwio_debug_message( "using: $jpegtran" );
|
991 |
if ( $webp ) {
|
992 |
ewwwio_debug_message( "using: $webp" );
|
993 |
}
|
994 |
+
if ( $svgcleaner ) {
|
995 |
+
ewwwio_debug_message( "using: $svgcleaner" );
|
996 |
+
}
|
997 |
ewwwio_memory( __FUNCTION__ );
|
998 |
return array(
|
999 |
+
'JPEGTRAN' => $jpegtran,
|
1000 |
+
'OPTIPNG' => $optipng,
|
1001 |
+
'GIFSICLE' => $gifsicle,
|
1002 |
+
'PNGOUT' => $pngout,
|
1003 |
+
'PNGQUANT' => $pngquant,
|
1004 |
+
'CWEBP' => $webp,
|
1005 |
+
'SVGCLEANER' => $svgcleaner,
|
1006 |
);
|
1007 |
}
|
1008 |
|
1198 |
'66568f3b31f8f22deef38aa6ba3d2be19516514e94b7d623cd2ce2a290ccdd69', // cwebp-sol 1.0.3, EWWW 5.1.0.
|
1199 |
'e1041c5486fb4e57e31155c45d66117f8fc270e5a56a1049408a05f54bd52969', // cwebp.exe 1.0.3, EWWW 5.1.0.
|
1200 |
// end cwebp.
|
1201 |
+
'15d8b7d54b73059a9a63ab3d5ca8201cd30c2f6fc59fc068f7bd6c85e6a22420', // svgcleaner-linux 0.9.5.
|
1202 |
+
'c88c1961374b3edc93a29376ccbd447a514c1cda335fe6a868c0dac6d77c79fa', // svgcleaner-mac 0.9.5.
|
1203 |
+
'5f0b5d64e7975275cd8649f4b29bd0526ba06961aef92aa9812e26443e454fe0', // svgcleaner.exe 0.9.5.
|
1204 |
+
// end svgcleaner.
|
1205 |
);
|
1206 |
foreach ( $valid_sums as $checksum ) {
|
1207 |
if ( $checksum === $binary_sum ) {
|
1271 |
ewwwio_debug_message( "ewwwio type: $type" );
|
1272 |
return $type;
|
1273 |
}
|
1274 |
+
if ( preg_match( '/<svg/', substr( $file_contents, 0, 4096 ) ) ) {
|
1275 |
+
$type = 'image/svg+xml';
|
1276 |
+
ewwwio_debug_message( "ewwwio type: $type" );
|
1277 |
+
return $type;
|
1278 |
+
}
|
1279 |
ewwwio_debug_message( "match not found for image: $magic" );
|
1280 |
} else {
|
1281 |
ewwwio_debug_message( 'could not open for reading' );
|
1538 |
return esc_html__( 'unknown', 'ewww-image-optimizer' );
|
1539 |
}
|
1540 |
break;
|
1541 |
+
case 's': // svgcleaner.
|
1542 |
+
exec( "$path --version 2>&1", $svgcleaner_version );
|
1543 |
+
if ( ewww_image_optimizer_iterable( $svgcleaner_version ) ) {
|
1544 |
+
ewwwio_debug_message( "$path: {$svgcleaner_version[0]}" );
|
1545 |
+
} else {
|
1546 |
+
ewwwio_debug_message( "$path: invalid output" );
|
1547 |
+
break;
|
1548 |
+
}
|
1549 |
+
if ( ! empty( $svgcleaner_version ) && strpos( $svgcleaner_version[0], 'svgcleaner' ) === 0 ) {
|
1550 |
+
$svgcleaner_out = explode( ' ', $svgcleaner_version[0] );
|
1551 |
+
ewwwio_debug_message( 'optimizer found' );
|
1552 |
+
return $svgcleaner_out[1];
|
1553 |
+
}
|
1554 |
+
break;
|
1555 |
} // End switch().
|
1556 |
ewwwio_debug_message( 'tool not found' );
|
1557 |
ewwwio_memory( __FUNCTION__ );
|
1692 |
true,
|
1693 |
false,
|
1694 |
false,
|
1695 |
+
false,
|
1696 |
false
|
1697 |
);
|
1698 |
if ( empty( $tools['GIFSICLE'] ) ) {
|
1774 |
false,
|
1775 |
false,
|
1776 |
false,
|
1777 |
+
false,
|
1778 |
false
|
1779 |
);
|
1780 |
if ( empty( $tools['JPEGTRAN'] ) ) {
|
1929 |
}
|
1930 |
$skip = ewww_image_optimizer_skip_tools();
|
1931 |
if ( EWWW_IMAGE_OPTIMIZER_CLOUD ) {
|
1932 |
+
$skip['jpegtran'] = true;
|
1933 |
+
$skip['optipng'] = true;
|
1934 |
+
$skip['gifsicle'] = true;
|
1935 |
+
$skip['pngout'] = true;
|
1936 |
+
$skip['pngquant'] = true;
|
1937 |
+
$skip['webp'] = true;
|
1938 |
+
$skip['svgcleaner'] = true;
|
1939 |
}
|
1940 |
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_metadata_skip_full' ) && $fullsize ) {
|
1941 |
$keep_metadata = true;
|
2044 |
false,
|
2045 |
! $skip['pngout'],
|
2046 |
! $skip['pngquant'],
|
2047 |
+
! $skip['webp'],
|
2048 |
+
false
|
2049 |
);
|
2050 |
} else {
|
2051 |
$tools = ewww_image_optimizer_path_check(
|
2054 |
false,
|
2055 |
false,
|
2056 |
false,
|
2057 |
+
! $skip['webp'],
|
2058 |
+
false
|
2059 |
);
|
2060 |
}
|
2061 |
if ( ! empty( $ewww_webp_only ) ) {
|
2323 |
false,
|
2324 |
! $skip['pngout'],
|
2325 |
! $skip['pngquant'],
|
2326 |
+
! $skip['webp'],
|
2327 |
+
false
|
2328 |
);
|
2329 |
} else {
|
2330 |
$tools = ewww_image_optimizer_path_check(
|
2333 |
false,
|
2334 |
! $skip['pngout'],
|
2335 |
! $skip['pngquant'],
|
2336 |
+
! $skip['webp'],
|
2337 |
+
false
|
2338 |
);
|
2339 |
}
|
2340 |
// If png optimization is disabled.
|
2618 |
! $skip['gifsicle'],
|
2619 |
! $skip['pngout'],
|
2620 |
! $skip['pngquant'],
|
2621 |
+
! $skip['webp'],
|
2622 |
+
false
|
2623 |
);
|
2624 |
} else {
|
2625 |
$tools = ewww_image_optimizer_path_check(
|
2628 |
! $skip['gifsicle'],
|
2629 |
false,
|
2630 |
false,
|
2631 |
+
false,
|
2632 |
false
|
2633 |
);
|
2634 |
}
|
2757 |
list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type );
|
2758 |
}
|
2759 |
break;
|
2760 |
+
case 'image/svg+xml':
|
2761 |
+
if ( ! empty( $ewww_webp_only ) ) {
|
2762 |
+
break;
|
2763 |
+
}
|
2764 |
+
$tools = ewww_image_optimizer_path_check(
|
2765 |
+
false,
|
2766 |
+
false,
|
2767 |
+
false,
|
2768 |
+
false,
|
2769 |
+
false,
|
2770 |
+
false,
|
2771 |
+
! $skip['svgcleaner']
|
2772 |
+
);
|
2773 |
+
// If svgcleaner is disabled.
|
2774 |
+
$compression_level = 0;
|
2775 |
+
if ( ! $skip['svgcleaner'] && ! $tools['SVGCLEANER'] ) {
|
2776 |
+
/* translators: %s: name of a tool like jpegtran */
|
2777 |
+
$result = sprintf( __( '%s is missing', 'ewww-image-optimizer' ), '<em>svgcleaner</em>' );
|
2778 |
+
} else {
|
2779 |
+
// Otherwise, turn optimization ON.
|
2780 |
+
$compression_level = (int) ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' );
|
2781 |
+
if ( $compression_level ) {
|
2782 |
+
$optimize = true;
|
2783 |
+
}
|
2784 |
+
}
|
2785 |
+
// Check for previous optimization, so long as the force flag is not on and this isn't a new image that needs converting.
|
2786 |
+
if ( empty( $ewww_force ) ) {
|
2787 |
+
$results_msg = ewww_image_optimizer_check_table( $file, $orig_size );
|
2788 |
+
$smart_reopt = ! empty( $ewww_force_smart ) && ewww_image_optimizer_level_mismatch( $ewww_image->level, $compression_level ) ? true : false;
|
2789 |
+
if ( $smart_reopt ) {
|
2790 |
+
ewwwio_debug_message( "smart re-opt found level mismatch for $file, db says " . $ewww_image->level . " vs. current $compression_level" );
|
2791 |
+
// If the current compression level is less than what was previously used, and the previous level was premium (or premium plus).
|
2792 |
+
if ( $compression_level && $compression_level < $ewww_image->level && $ewww_image->level > 0 ) {
|
2793 |
+
ewwwio_debug_message( "smart re-opt triggering restoration for $file" );
|
2794 |
+
ewww_image_optimizer_cloud_restore_single_image( $ewww_image->record );
|
2795 |
+
}
|
2796 |
+
} elseif ( $results_msg ) {
|
2797 |
+
return array( $file, $results_msg, $converted, $original );
|
2798 |
+
}
|
2799 |
+
}
|
2800 |
+
$ewww_image->level = $compression_level;
|
2801 |
+
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_cloud_key' ) && $compression_level > 0 ) {
|
2802 |
+
list( $file, $converted, $result, $new_size, $backup_hash ) = ewww_image_optimizer_cloud_optimizer( $file, $type );
|
2803 |
+
break;
|
2804 |
+
}
|
2805 |
+
// If optimization is turned ON.
|
2806 |
+
if ( $optimize ) {
|
2807 |
+
$tempfile = $file . '.tmp.svg'; // temporary SVG output (must end with .svg)
|
2808 |
+
// Run svgcleaner on the SVG.
|
2809 |
+
$svgcleaner_options = array(
|
2810 |
+
'--allow-bigger-file',
|
2811 |
+
'--quiet',
|
2812 |
+
);
|
2813 |
+
if ( 1 === $compression_level ) {
|
2814 |
+
array_push(
|
2815 |
+
$svgcleaner_options,
|
2816 |
+
'--paths-to-relative=no',
|
2817 |
+
'--remove-unused-segments=no',
|
2818 |
+
'--convert-segments=no',
|
2819 |
+
'--merge-gradients=no',
|
2820 |
+
'--trim-ids=no',
|
2821 |
+
'--trim-colors=no',
|
2822 |
+
'--simplify-transforms=no',
|
2823 |
+
'--resolve-use=no'
|
2824 |
+
);
|
2825 |
+
}
|
2826 |
+
exec( "$nice " . $tools['SVGCLEANER'] . ' ' . implode( ' ', $svgcleaner_options ) . ' ' . ewww_image_optimizer_escapeshellarg( $file ) . ' ' . ewww_image_optimizer_escapeshellarg( $tempfile ) );
|
2827 |
+
// Retrieve the filesize of the temporary SVG.
|
2828 |
+
$new_size = ewww_image_optimizer_filesize( $tempfile );
|
2829 |
+
// If the new SVG is smaller.
|
2830 |
+
if ( $new_size && $orig_size > $new_size && ewww_image_optimizer_mimetype( $tempfile, 'i' ) === $type ) {
|
2831 |
+
// Replace the original with the optimized file.
|
2832 |
+
rename( $tempfile, $file );
|
2833 |
+
// Store the results of the optimization.
|
2834 |
+
$result = "$orig_size vs. $new_size";
|
2835 |
+
// If the optimization didn't produce a smaller SVG.
|
2836 |
+
} else {
|
2837 |
+
if ( ewwwio_is_file( $tempfile ) ) {
|
2838 |
+
// Delete the optimized file.
|
2839 |
+
ewwwio_delete_file( $tempfile );
|
2840 |
+
}
|
2841 |
+
// Store the results.
|
2842 |
+
$result = 'unchanged';
|
2843 |
+
$new_size = $orig_size;
|
2844 |
+
}
|
2845 |
+
}
|
2846 |
+
break;
|
2847 |
default:
|
2848 |
+
// If not a JPG, PNG, GIF, or SVG tell the user we don't work with strangers.
|
2849 |
return array( false, __( 'Unsupported file type', 'ewww-image-optimizer' ) . ": $type", $converted, $original );
|
2850 |
} // End switch().
|
2851 |
// Allow other plugins to run operations on the images after optimization.
|
2899 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
|
2900 |
return '';
|
2901 |
} elseif ( ! ewwwio_is_file( $file ) ) {
|
2902 |
+
ewwwio_debug_message( 'original file not found' );
|
2903 |
return esc_html__( 'Could not find file.', 'ewww-image-optimizer' );
|
2904 |
} elseif ( ! is_writable( $file ) ) {
|
2905 |
+
ewwwio_debug_message( 'original file not writable' );
|
2906 |
return esc_html__( 'File is not writable.', 'ewww-image-optimizer' );
|
2907 |
} elseif ( ewwwio_is_file( $webpfile ) && empty( $ewww_force ) && ! $recreate ) {
|
2908 |
ewwwio_debug_message( 'webp file exists, not forcing or recreating' );
|
2927 |
// Copy all the metadata.
|
2928 |
$copy_opt = 'all';
|
2929 |
}
|
2930 |
+
$quality = (int) apply_filters( 'webp_quality', 75, 'image/webp' );
|
2931 |
if ( $quality < 50 ) {
|
2932 |
+
$quality = 75;
|
2933 |
}
|
2934 |
if ( defined( 'EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP' ) && EWWW_IMAGE_OPTIMIZER_LOSSY_PNG2WEBP ) {
|
2935 |
$lossless = "-q $quality";
|
3115 |
return $sendback;
|
3116 |
}
|
3117 |
|
3118 |
+
/**
|
3119 |
+
* Redirects back to previous page after SVGCLEANER installation.
|
3120 |
+
*/
|
3121 |
+
function ewww_image_optimizer_install_svgcleaner_wrapper() {
|
3122 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
3123 |
+
if ( ! current_user_can( apply_filters( 'ewww_image_optimizer_admin_permissions', '' ) ) ) {
|
3124 |
+
wp_die( esc_html__( 'You do not have permission to install image optimizer utilities.', 'ewww-image-optimizer' ) );
|
3125 |
+
}
|
3126 |
+
$sendback = ewww_image_optimizer_install_svgcleaner();
|
3127 |
+
wp_safe_redirect( $sendback );
|
3128 |
+
ewwwio_memory( __FUNCTION__ );
|
3129 |
+
exit( 0 );
|
3130 |
+
}
|
3131 |
+
|
3132 |
+
/**
|
3133 |
+
* Installs svgcleaner from the official site.
|
3134 |
+
*
|
3135 |
+
* @return string The url from whence we came (settings page), with success or error parameters added.
|
3136 |
+
*/
|
3137 |
+
function ewww_image_optimizer_install_svgcleaner() {
|
3138 |
+
if ( ! extension_loaded( 'zlib' ) || ! class_exists( 'PharData' ) ) {
|
3139 |
+
$download_error = __( 'zlib or phar extension missing from PHP', 'ewww-image-optimizer' );
|
3140 |
+
}
|
3141 |
+
$os_chmod = true;
|
3142 |
+
$os_binary = 'svgcleaner';
|
3143 |
+
$os_ext = 'tar.gz';
|
3144 |
+
if ( PHP_OS === 'Linux' ) {
|
3145 |
+
$arch_type = 'x86_64';
|
3146 |
+
if ( ewww_image_optimizer_function_exists( 'php_uname' ) ) {
|
3147 |
+
$arch_type = php_uname( 'm' );
|
3148 |
+
}
|
3149 |
+
$os_string = 'linux_' . $arch_type;
|
3150 |
+
} elseif ( PHP_OS === 'Darwin' ) {
|
3151 |
+
$os_string = 'macos';
|
3152 |
+
$os_ext = 'zip';
|
3153 |
+
} elseif ( PHP_OS === 'WINNT' ) {
|
3154 |
+
$os_chmod = false;
|
3155 |
+
$os_string = 'win32';
|
3156 |
+
$os_binary = 'svgcleaner.exe';
|
3157 |
+
$os_ext = 'zip';
|
3158 |
+
}
|
3159 |
+
$latest = '0.9.5';
|
3160 |
+
$tool_path = trailingslashit( EWWW_IMAGE_OPTIMIZER_TOOL_PATH );
|
3161 |
+
if ( empty( $download_error ) ) {
|
3162 |
+
$download_result = download_url( 'https://github.com/RazrFalcon/svgcleaner/releases/download/v' . $latest . '/svgcleaner_' . $os_string . '_' . $latest . '.' . $os_ext );
|
3163 |
+
if ( is_wp_error( $download_result ) ) {
|
3164 |
+
$download_error = $download_result->get_error_message();
|
3165 |
+
} else {
|
3166 |
+
if ( ! ewwwio_check_memory_available( filesize( $download_result ) + 1000 ) ) {
|
3167 |
+
$download_error = __( 'insufficient memory available for installation', 'ewww-image-optimizer' );
|
3168 |
+
} else {
|
3169 |
+
$tmpname = current( explode( '.', $download_result ) );
|
3170 |
+
$tmpname .= '-' . uniqid() . '.' . $os_ext;
|
3171 |
+
rename( $download_result, $tmpname );
|
3172 |
+
$download_result = $tmpname;
|
3173 |
+
|
3174 |
+
if ( 'zip' === $os_ext ) {
|
3175 |
+
WP_Filesystem();
|
3176 |
+
$unzipped = unzip_file(
|
3177 |
+
$download_result,
|
3178 |
+
EWWW_IMAGE_OPTIMIZER_BINARY_PATH
|
3179 |
+
);
|
3180 |
+
if ( is_wp_error( $unzipped ) ) {
|
3181 |
+
$download_error = $unzipped->get_error_message();
|
3182 |
+
}
|
3183 |
+
} else {
|
3184 |
+
$pkg_gzipped = new PharData( $download_result );
|
3185 |
+
$pkg_tarball = $pkg_gzipped->decompress();
|
3186 |
+
$download_result = $pkg_tarball->getPath();
|
3187 |
+
$pkg_tarball->extractTo(
|
3188 |
+
EWWW_IMAGE_OPTIMIZER_BINARY_PATH,
|
3189 |
+
'svgcleaner',
|
3190 |
+
true
|
3191 |
+
);
|
3192 |
+
}
|
3193 |
+
if ( ewwwio_is_file( EWWW_IMAGE_OPTIMIZER_BINARY_PATH . $os_binary ) ) {
|
3194 |
+
if ( ! rename( EWWW_IMAGE_OPTIMIZER_BINARY_PATH . $os_binary, $tool_path . $os_binary ) ) {
|
3195 |
+
if ( empty( $download_error ) ) {
|
3196 |
+
$download_error = __( 'could not move svgcleaner', 'ewww-image-optimizer' );
|
3197 |
+
}
|
3198 |
+
}
|
3199 |
+
if ( $os_chmod && ! chmod( $tool_path . $os_binary, 0755 ) ) {
|
3200 |
+
if ( empty( $download_error ) ) {
|
3201 |
+
$download_error = __( 'could not set permissions', 'ewww-image-optimizer' );
|
3202 |
+
}
|
3203 |
+
}
|
3204 |
+
if ( PHP_OS === 'WINNT' ) {
|
3205 |
+
$pkg_version = ewww_image_optimizer_tool_found( '"' . $tool_path . $os_binary . '"', 's' );
|
3206 |
+
} else {
|
3207 |
+
$pkg_version = ewww_image_optimizer_tool_found( ewww_image_optimizer_escapeshellarg( $tool_path ) . $os_binary, 's' );
|
3208 |
+
}
|
3209 |
+
} else {
|
3210 |
+
$download_error = __( 'extraction of files failed', 'ewww-image-optimizer' );
|
3211 |
+
}
|
3212 |
+
}
|
3213 |
+
}
|
3214 |
+
}
|
3215 |
+
if ( is_string( $download_result ) && is_writable( $download_result ) ) {
|
3216 |
+
unlink( $download_result );
|
3217 |
+
}
|
3218 |
+
if ( ! empty( $pkg_version ) ) {
|
3219 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_disable_svgcleaner', false );
|
3220 |
+
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_svg_level' ) ) {
|
3221 |
+
ewww_image_optimizer_set_option( 'ewww_image_optimizer_svg_level', 10 );
|
3222 |
+
}
|
3223 |
+
$sendback = add_query_arg( 'ewww_svgcleaner', 'success', remove_query_arg( array( 'ewww_svgcleaner', 'ewww_error' ), wp_get_referer() ) );
|
3224 |
+
}
|
3225 |
+
if ( ! isset( $sendback ) ) {
|
3226 |
+
$sendback = add_query_arg(
|
3227 |
+
array(
|
3228 |
+
'ewww_svgcleaner' => 'failed',
|
3229 |
+
'ewww_error' => urlencode( $download_error ),
|
3230 |
+
),
|
3231 |
+
remove_query_arg( array( 'ewww_svgcleaner', 'ewww_error' ), wp_get_referer() )
|
3232 |
+
);
|
3233 |
+
}
|
3234 |
+
return $sendback;
|
3235 |
+
}
|
3236 |
+
|
3237 |
/**
|
3238 |
* Removes any binaries that have been installed in the wp-content/ewww/ folder.
|
3239 |
*/
|