Version Description
- security: new version of PNGOUT available on settings page (if enabled)
- added: compatibility with Phoenix Media Rename plugin
- changed: Easy IO supports img tags with SVG images
- fixed: bulk optimizer gives incorrect message about not enough credits for unlimited plans
- fixed: db install workaround for MariaDB 10.4 bug
- fixed: errors with custom db setups when DB_* constants are not defined
- fixed: error with JS WebP when a class attribute with no value is encountered
Download this release
Release Info
Developer | nosilver4u |
Plugin | EWWW Image Optimizer |
Version | 6.0.2 |
Comparing to | |
See all releases |
Code changes from version 6.0.1 to 6.0.2
- aux-optimize.php +1 -1
- changelog.txt +9 -0
- classes/class-eio-page-parser.php +2 -1
- classes/class-ewwwdb.php +0 -1
- classes/class-exactdn.php +3 -0
- common.php +233 -75
- ewww-image-optimizer.php +1 -1
- includes/lazysizes.js +9 -4
- includes/lazysizes.min.js +1 -1
- readme.txt +10 -1
- unique.php +39 -16
aux-optimize.php
CHANGED
@@ -1494,7 +1494,7 @@ function ewww_image_optimizer_aux_images_script( $hook = '' ) {
|
|
1494 |
ewwwio_memory( __FUNCTION__ );
|
1495 |
/* translators: %s: number of images */
|
1496 |
$ready_msg = sprintf( esc_html( _n( 'There is %s image ready to optimize.', 'There are %s images ready to optimize.', $image_count, 'ewww-image-optimizer' ) ), '<strong>' . number_format_i18n( $image_count ) . '</strong>' );
|
1497 |
-
if ( is_array( $usage ) && ! $usage['metered'] ) {
|
1498 |
$credits_available = $usage['licensed'] - $usage['consumed'];
|
1499 |
if ( $credits_available < $image_count ) {
|
1500 |
$ready_msg .= ' ' . esc_html__( 'You do not appear to have enough image credits to complete this operation.', 'ewww-image-optimizer' );
|
1494 |
ewwwio_memory( __FUNCTION__ );
|
1495 |
/* translators: %s: number of images */
|
1496 |
$ready_msg = sprintf( esc_html( _n( 'There is %s image ready to optimize.', 'There are %s images ready to optimize.', $image_count, 'ewww-image-optimizer' ) ), '<strong>' . number_format_i18n( $image_count ) . '</strong>' );
|
1497 |
+
if ( is_array( $usage ) && ! $usage['metered'] && ! $usage['unlimited'] ) {
|
1498 |
$credits_available = $usage['licensed'] - $usage['consumed'];
|
1499 |
if ( $credits_available < $image_count ) {
|
1500 |
$ready_msg .= ' ' . esc_html__( 'You do not appear to have enough image credits to complete this operation.', 'ewww-image-optimizer' );
|
changelog.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 6.0.1 =
|
2 |
* changed: more reliable Cloudflare detection for WebP delivery methods
|
3 |
* fixed: lazy load for external CSS breaking div elements in JS/JSON
|
1 |
+
= 6.0.2 =
|
2 |
+
* security: new version of PNGOUT available on settings page (if enabled)
|
3 |
+
* added: compatibility with Phoenix Media Rename plugin
|
4 |
+
* changed: Easy IO supports img tags with SVG images
|
5 |
+
* fixed: bulk optimizer gives incorrect message about not enough credits for unlimited plans
|
6 |
+
* fixed: db install workaround for MariaDB 10.4 bug
|
7 |
+
* fixed: errors with custom db setups when DB_* constants are not defined
|
8 |
+
* fixed: error with JS WebP when a class attribute with no value is encountered
|
9 |
+
|
10 |
= 6.0.1 =
|
11 |
* changed: more reliable Cloudflare detection for WebP delivery methods
|
12 |
* fixed: lazy load for external CSS breaking div elements in JS/JSON
|
classes/class-eio-page-parser.php
CHANGED
@@ -28,6 +28,7 @@ if ( ! class_exists( 'EIO_Page_Parser' ) ) {
|
|
28 |
'jpeg',
|
29 |
'jpe',
|
30 |
'png',
|
|
|
31 |
);
|
32 |
|
33 |
/**
|
@@ -325,7 +326,7 @@ if ( ! class_exists( 'EIO_Page_Parser' ) ) {
|
|
325 |
*/
|
326 |
function set_attribute( &$element, $name, $value, $replace = false ) {
|
327 |
if ( 'class' === $name ) {
|
328 |
-
$element = preg_replace( "#\s$name\s+[^=]#", ' ', $element );
|
329 |
}
|
330 |
$element = preg_replace( "#\s$name=\"\"#", ' ', $element );
|
331 |
$value = trim( $value );
|
28 |
'jpeg',
|
29 |
'jpe',
|
30 |
'png',
|
31 |
+
'svg',
|
32 |
);
|
33 |
|
34 |
/**
|
326 |
*/
|
327 |
function set_attribute( &$element, $name, $value, $replace = false ) {
|
328 |
if ( 'class' === $name ) {
|
329 |
+
$element = preg_replace( "#\s$name\s+([^=])#", ' $1', $element );
|
330 |
}
|
331 |
$element = preg_replace( "#\s$name=\"\"#", ' ', $element );
|
332 |
$value = trim( $value );
|
classes/class-ewwwdb.php
CHANGED
@@ -99,5 +99,4 @@ class EwwwDB extends wpdb {
|
|
99 |
$this->check_current_query = false;
|
100 |
return $this->query( $this->prepare( "INSERT INTO `$table` ($fields) VALUES $multi_formats", $values ) );
|
101 |
}
|
102 |
-
|
103 |
}
|
99 |
$this->check_current_query = false;
|
100 |
return $this->query( $this->prepare( "INSERT INTO `$table` ($fields) VALUES $multi_formats", $values ) );
|
101 |
}
|
|
|
102 |
}
|
classes/class-exactdn.php
CHANGED
@@ -2633,6 +2633,9 @@ if ( ! class_exists( 'ExactDN' ) ) {
|
|
2633 |
if ( strpos( $image_url, 'public/images/spacer.' ) ) {
|
2634 |
return array();
|
2635 |
}
|
|
|
|
|
|
|
2636 |
return $args;
|
2637 |
}
|
2638 |
|
2633 |
if ( strpos( $image_url, 'public/images/spacer.' ) ) {
|
2634 |
return array();
|
2635 |
}
|
2636 |
+
if ( '.svg' === substr( $image_url, -4, ) ) {
|
2637 |
+
return array();
|
2638 |
+
}
|
2639 |
return $args;
|
2640 |
}
|
2641 |
|
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 = '';
|
@@ -92,8 +92,6 @@ add_filter( 'plugin_action_links_' . EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL, 'ewww
|
|
92 |
add_filter( 'intermediate_image_sizes_advanced', 'ewww_image_optimizer_image_sizes_advanced' );
|
93 |
// Ditto for PDF files (or anything non-image).
|
94 |
add_filter( 'fallback_intermediate_image_sizes', 'ewww_image_optimizer_fallback_sizes' );
|
95 |
-
// Filters the settings page output when cloud settings are enabled.
|
96 |
-
add_filter( 'ewww_image_optimizer_settings', 'ewww_image_optimizer_filter_settings_page' );
|
97 |
// Processes screenshots imported with MyArcadePlugin.
|
98 |
add_filter( 'myarcade_filter_screenshot', 'ewww_image_optimizer_myarcade_thumbnail' );
|
99 |
// Processes thumbnails created by MyArcadePlugin.
|
@@ -136,6 +134,8 @@ add_action( 'admin_action_ewww_image_optimizer_manual_cloud_restore', 'ewww_imag
|
|
136 |
add_action( 'delete_attachment', 'ewww_image_optimizer_delete' );
|
137 |
// Cleanup db records when Enable Media Replace replaces a file.
|
138 |
add_action( 'wp_handle_replace', 'ewww_image_optimizer_media_replace' );
|
|
|
|
|
139 |
// Cleanup db records when Image Regenerate & Select Crop deletes a file.
|
140 |
add_action( 'sirsc_image_file_deleted', 'ewww_image_optimizer_file_deleted', 10, 2 );
|
141 |
// Adds the EWWW IO pages to the admin menu.
|
@@ -864,6 +864,15 @@ function ewww_image_optimizer_upgrade() {
|
|
864 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ) {
|
865 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_force_gif2webp', true );
|
866 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
867 |
if ( get_option( 'ewww_image_optimizer_version' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_review_time' ) ) {
|
868 |
$review_time = rand( time(), time() + 51 * DAY_IN_SECONDS );
|
869 |
add_option( 'ewww_image_optimizer_review_time', $review_time, '', false );
|
@@ -967,7 +976,6 @@ function ewww_image_optimizer_admin_init() {
|
|
967 |
ewww_image_optimizer_save_network_settings();
|
968 |
|
969 |
// Register all the common EWWW IO settings.
|
970 |
-
/* register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_cloud_key', 'ewww_image_optimizer_cloud_key_sanitize' ); */
|
971 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
|
972 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_metadata_remove', 'boolval' );
|
973 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
|
@@ -1232,6 +1240,17 @@ function ewww_image_optimizer_ajax_compat_check() {
|
|
1232 |
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1233 |
return;
|
1234 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1235 |
}
|
1236 |
|
1237 |
/**
|
@@ -1532,6 +1551,7 @@ function ewww_image_optimizer_install_table() {
|
|
1532 |
$db_collation = $wpdb->get_charset_collate();
|
1533 |
ewwwio_debug_message( "current collation: $db_collation" );
|
1534 |
|
|
|
1535 |
// See if the path column exists, and what collation it uses to determine the column index size.
|
1536 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ewwwio_images'" ) === $wpdb->ewwwio_images ) {
|
1537 |
ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
|
@@ -1540,7 +1560,10 @@ function ewww_image_optimizer_install_table() {
|
|
1540 |
$mysql_version = strtolower( $wpdb->db_server_info() );
|
1541 |
}
|
1542 |
ewwwio_debug_message( $mysql_version );
|
1543 |
-
if ( false
|
|
|
|
|
|
|
1544 |
ewwwio_debug_message( 'checking primary/unique index' );
|
1545 |
if ( ! $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'PRIMARY'", ARRAY_A ) ) {
|
1546 |
ewwwio_debug_message( 'adding primary index' );
|
@@ -1638,7 +1661,7 @@ function ewww_image_optimizer_install_table() {
|
|
1638 |
updates int unsigned,
|
1639 |
updated timestamp DEFAULT '1971-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
|
1640 |
trace blob,
|
1641 |
-
|
1642 |
KEY path (path($path_index_size)),
|
1643 |
KEY attachment_info (gallery(3),attachment_id)
|
1644 |
) $db_collation;";
|
@@ -1649,10 +1672,12 @@ function ewww_image_optimizer_install_table() {
|
|
1649 |
ewwwio_debug_message( 'images db upgrade results: ' . implode( '<br>', $updates ) );
|
1650 |
|
1651 |
/*
|
1652 |
-
* Create a table with
|
|
|
1653 |
* attachment_id: the unique id within the media library, nextgen, or flag
|
1654 |
* gallery: 'media', 'nextgen', 'nextcell', 'flag', plus -async variants.
|
1655 |
* scanned: 1 if the image is queued for optimization, 0 if it still needs scanning.
|
|
|
1656 |
*/
|
1657 |
$sql = "CREATE TABLE $wpdb->ewwwio_queue (
|
1658 |
id int unsigned NOT NULL AUTO_INCREMENT,
|
@@ -2493,6 +2518,9 @@ function ewww_image_optimizer_handle_upload( $params ) {
|
|
2493 |
clearstatcache();
|
2494 |
return $params;
|
2495 |
}
|
|
|
|
|
|
|
2496 |
ewww_image_optimizer_autorotate( $file_path );
|
2497 |
$new_image = ewww_image_optimizer_autoconvert( $file_path );
|
2498 |
if ( $new_image ) {
|
@@ -2523,6 +2551,46 @@ function ewww_image_optimizer_handle_upload( $params ) {
|
|
2523 |
}
|
2524 |
}
|
2525 |
clearstatcache();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2526 |
return $params;
|
2527 |
}
|
2528 |
|
@@ -3981,7 +4049,7 @@ function ewww_image_optimizer_delete( $id ) {
|
|
3981 |
if ( empty( $srows ) ) {
|
3982 |
ewwwio_debug_message( 'removing: ' . $base_dir . $data['orig_file'] );
|
3983 |
ewwwio_delete_file( $base_dir . $data['orig_file'] );
|
3984 |
-
$ewwwdb->delete( $ewwwdb->ewwwio_images, array( 'path' =>
|
3985 |
}
|
3986 |
}
|
3987 |
}
|
@@ -4048,11 +4116,11 @@ function ewww_image_optimizer_file_deleted( $id, $file ) {
|
|
4048 |
}
|
4049 |
|
4050 |
/**
|
4051 |
-
* Cleans records from database when an image is
|
4052 |
*
|
4053 |
-
* @param array $
|
4054 |
*/
|
4055 |
-
function ewww_image_optimizer_media_replace( $
|
4056 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4057 |
global $wpdb;
|
4058 |
if ( strpos( $wpdb->charset, 'utf8' ) === false ) {
|
@@ -4061,7 +4129,7 @@ function ewww_image_optimizer_media_replace( $image ) {
|
|
4061 |
} else {
|
4062 |
$ewwwdb = $wpdb;
|
4063 |
}
|
4064 |
-
$id = (int) $
|
4065 |
// Finds non-meta images to remove from disk, and from db, as well as converted originals.
|
4066 |
$optimized_images = $ewwwdb->get_results( "SELECT path,converted FROM $ewwwdb->ewwwio_images WHERE attachment_id = $id AND gallery = 'media'", ARRAY_A );
|
4067 |
if ( $optimized_images ) {
|
@@ -4070,7 +4138,7 @@ function ewww_image_optimizer_media_replace( $image ) {
|
|
4070 |
if ( ! empty( $image['path'] ) ) {
|
4071 |
$image['path'] = ewww_image_optimizer_absolutize_path( $image['path'] );
|
4072 |
}
|
4073 |
-
if ( strpos( $image['path'], WP_CONTENT_DIR )
|
4074 |
continue;
|
4075 |
}
|
4076 |
if ( ! empty( $image['path'] ) ) {
|
@@ -4143,12 +4211,103 @@ function ewww_image_optimizer_media_replace( $image ) {
|
|
4143 |
if ( ! empty( $data['orig_file'] ) ) {
|
4144 |
// Retrieve the filename from the metadata.
|
4145 |
$filename = $data['orig_file'];
|
4146 |
-
$ewwwdb->delete( $ewwwdb->ewwwio_images, array( 'path' =>
|
4147 |
}
|
4148 |
}
|
4149 |
}
|
4150 |
}
|
4151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4152 |
/**
|
4153 |
* Activates Easy IO via AJAX.
|
4154 |
*/
|
@@ -4191,30 +4350,18 @@ function ewww_image_optimizer_exactdn_activate_ajax() {
|
|
4191 |
}
|
4192 |
|
4193 |
/**
|
4194 |
-
* Sanitizes
|
4195 |
*
|
4196 |
* @param string $key An API key entered by the user.
|
4197 |
-
* @return string A sanitized
|
4198 |
*/
|
4199 |
function ewww_image_optimizer_cloud_key_sanitize( $key ) {
|
4200 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4201 |
$key = trim( $key );
|
4202 |
-
if ( empty( $key ) ) {
|
4203 |
-
return '';
|
4204 |
-
}
|
4205 |
-
if ( ewww_image_optimizer_cloud_verify( $key, false ) ) {
|
4206 |
-
add_settings_error( 'ewww_image_optimizer_cloud_key', 'ewwwio-cloud-key', esc_html__( 'Successfully validated API key, happy optimizing!', 'ewww-image-optimizer' ), 'updated' );
|
4207 |
-
ewwwio_debug_message( 'sanitize (verification) successful' );
|
4208 |
-
ewwwio_memory( __FUNCTION__ );
|
4209 |
return $key;
|
4210 |
-
} else {
|
4211 |
-
if ( ! empty( $key ) ) {
|
4212 |
-
add_settings_error( 'ewww_image_optimizer_cloud_key', 'ewwwio-cloud-key', esc_html__( 'Could not validate API key, please copy and paste your key to ensure it is correct.', 'ewww-image-optimizer' ) );
|
4213 |
-
}
|
4214 |
-
ewwwio_debug_message( 'sanitize (verification) failed' );
|
4215 |
-
ewwwio_memory( __FUNCTION__ );
|
4216 |
-
return '';
|
4217 |
}
|
|
|
4218 |
}
|
4219 |
|
4220 |
/**
|
@@ -4228,7 +4375,7 @@ function ewww_image_optimizer_cloud_key_verify_ajax() {
|
|
4228 |
if ( empty( $_POST['compress_api_key'] ) ) {
|
4229 |
die( wp_json_encode( array( 'error' => esc_html__( 'Please enter your API key and try again.', 'ewww-image-optimizer' ) ) ) );
|
4230 |
}
|
4231 |
-
$api_key = trim(
|
4232 |
$url = 'http://optimize.exactlywww.com/verify/';
|
4233 |
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
4234 |
$url = set_url_scheme( $url, 'https' );
|
@@ -5175,7 +5322,11 @@ function ewww_image_optimizer_db_init() {
|
|
5175 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
5176 |
global $ewwwdb, $table_prefix;
|
5177 |
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-ewwwdb.php' );
|
5178 |
-
if ( !
|
|
|
|
|
|
|
|
|
5179 |
$ewwwdb = new EwwwDB( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
|
5180 |
}
|
5181 |
|
@@ -5338,20 +5489,43 @@ function ewww_image_optimizer_find_file_by_id( $id ) {
|
|
5338 |
*
|
5339 |
* Each sub-array in $images should have the same number of items as $format.
|
5340 |
*
|
5341 |
-
* @global object $
|
|
|
5342 |
*
|
5343 |
* @param string $table The table to insert records into.
|
5344 |
-
* @param array $
|
5345 |
-
* @param array $format A list of formats for the values in each record of $
|
5346 |
*/
|
5347 |
-
function ewww_image_optimizer_mass_insert( $table, $
|
5348 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
5349 |
-
if ( empty( $table ) || ! ewww_image_optimizer_iterable( $
|
5350 |
return false;
|
5351 |
}
|
5352 |
-
|
5353 |
-
|
5354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5355 |
}
|
5356 |
|
5357 |
/**
|
@@ -6806,43 +6980,18 @@ function ewww_image_optimizer_resize_upload( $file ) {
|
|
6806 |
} else {
|
6807 |
$ewwwdb = $wpdb;
|
6808 |
}
|
6809 |
-
|
6810 |
-
|
6811 |
-
if ( empty( $
|
6812 |
-
$
|
6813 |
$ewwwdb->ewwwio_images,
|
6814 |
array(
|
6815 |
-
'
|
6816 |
-
'orig_size' => $orig_size,
|
6817 |
),
|
6818 |
array(
|
6819 |
-
'
|
6820 |
)
|
6821 |
);
|
6822 |
-
// If the tmp file didn't get optimized (and it shouldn't), then just insert a dummy record to be updated shortly.
|
6823 |
-
if ( ! $tmp_exists ) {
|
6824 |
-
$ewwwdb->insert(
|
6825 |
-
$ewwwdb->ewwwio_images,
|
6826 |
-
array(
|
6827 |
-
'path' => ewww_image_optimizer_relativize_path( $file ),
|
6828 |
-
'orig_size' => $orig_size,
|
6829 |
-
)
|
6830 |
-
);
|
6831 |
-
}
|
6832 |
-
} else {
|
6833 |
-
// Otherwise, we delete the record created from optimizing the resized file.
|
6834 |
-
$temp_optimized = ewww_image_optimizer_find_already_optimized( $new_file );
|
6835 |
-
if ( is_array( $temp_optimized ) && ! empty( $temp_optimized['id'] ) ) {
|
6836 |
-
$ewwwdb->delete(
|
6837 |
-
$ewwwdb->ewwwio_images,
|
6838 |
-
array(
|
6839 |
-
'id' => $temp_optimized['id'],
|
6840 |
-
),
|
6841 |
-
array(
|
6842 |
-
'%d',
|
6843 |
-
)
|
6844 |
-
);
|
6845 |
-
}
|
6846 |
}
|
6847 |
/* translators: 1: width in pixels 2: height in pixels */
|
6848 |
$ewwwio_resize_status = sprintf( __( 'Resized to %1$s x %2$s', 'ewww-image-optimizer' ), $newwidth . 'w', $newheight . 'h' );
|
@@ -10596,7 +10745,12 @@ function ewww_image_optimizer_intro_wizard() {
|
|
10596 |
<label for='ewww_image_optimizer_jpg_quality'><?php esc_html_e( 'JPG Quality Level', 'ewww-image-optimizer' ); ?></label>
|
10597 |
</p>
|
10598 |
<?php endif; ?>
|
10599 |
-
<?php if (
|
|
|
|
|
|
|
|
|
|
|
10600 |
<p>
|
10601 |
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' checked />
|
10602 |
<label for='ewww_image_optimizer_lazy_load'><?php esc_html_e( 'Lazy Load', 'ewww-image-optimizer' ); ?></label>
|
@@ -11116,7 +11270,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11116 |
if ( get_option( 'easyio_lazy_load' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
11117 |
$speed_score += 10;
|
11118 |
} else {
|
11119 |
-
$speed_recommendations[] = __( 'Enable Lazy Loading
|
11120 |
}
|
11121 |
if ( ! ewww_image_optimizer_easy_active() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
|
11122 |
$speed_recommendations[] = __( 'Enable WebP conversion.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' );
|
@@ -11726,11 +11880,14 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11726 |
<?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?>
|
11727 |
</th>
|
11728 |
<td>
|
|
|
|
|
|
|
11729 |
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ); ?> />
|
11730 |
<?php esc_html_e( 'Improves actual and perceived loading time as images will be loaded only as they enter (or are about to enter) the viewport.', 'ewww-image-optimizer' ); ?>
|
11731 |
-
|
11732 |
<p><strong><?php esc_html_e( 'Though you already have a lazy loader on your site, the EWWW IO lazy loader includes auto-scaling for improved responsive images.', 'ewww-image-optimizer' ); ?></strong></p>
|
11733 |
-
|
11734 |
<p class='description'>
|
11735 |
<?php esc_html_e( 'The lazy loader chooses the best available image size from existing responsive markup. When used with Easy IO, all images become responsive.', 'ewww-image-optimizer' ); ?></br>
|
11736 |
<?php esc_html_e( 'To disable auto-scaling for an image, add "skip-autoscale" to the HTML element via a class or attribute.', 'ewww-image-optimizer' ); ?>
|
@@ -11759,6 +11916,7 @@ function ewww_image_optimizer_options( $network = 'singlesite' ) {
|
|
11759 |
</p>
|
11760 |
</td>
|
11761 |
</tr>
|
|
|
11762 |
<?php if ( $free_exec ) : ?>
|
11763 |
<tr>
|
11764 |
<th> </th>
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'EWWW_IMAGE_OPTIMIZER_VERSION', '602.0' );
|
18 |
|
19 |
// Initialize a couple globals.
|
20 |
$eio_debug = '';
|
92 |
add_filter( 'intermediate_image_sizes_advanced', 'ewww_image_optimizer_image_sizes_advanced' );
|
93 |
// Ditto for PDF files (or anything non-image).
|
94 |
add_filter( 'fallback_intermediate_image_sizes', 'ewww_image_optimizer_fallback_sizes' );
|
|
|
|
|
95 |
// Processes screenshots imported with MyArcadePlugin.
|
96 |
add_filter( 'myarcade_filter_screenshot', 'ewww_image_optimizer_myarcade_thumbnail' );
|
97 |
// Processes thumbnails created by MyArcadePlugin.
|
134 |
add_action( 'delete_attachment', 'ewww_image_optimizer_delete' );
|
135 |
// Cleanup db records when Enable Media Replace replaces a file.
|
136 |
add_action( 'wp_handle_replace', 'ewww_image_optimizer_media_replace' );
|
137 |
+
// Cleanup db records when Phoenix Media Rename is finished.
|
138 |
+
add_action( 'pmr_renaming_successful', 'ewww_image_optimizer_media_rename', 10, 2 );
|
139 |
// Cleanup db records when Image Regenerate & Select Crop deletes a file.
|
140 |
add_action( 'sirsc_image_file_deleted', 'ewww_image_optimizer_file_deleted', 10, 2 );
|
141 |
// Adds the EWWW IO pages to the admin menu.
|
864 |
} elseif ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_force_gif2webp' ) ) {
|
865 |
ewww_image_optimizer_set_option( 'ewww_image_optimizer_force_gif2webp', true );
|
866 |
}
|
867 |
+
if (
|
868 |
+
get_option( 'ewww_image_optimizer_version' ) <= 601.0 &&
|
869 |
+
PHP_OS !== 'WINNT' &&
|
870 |
+
ewwwio_is_file( EWWW_IMAGE_OPTIMIZER_TOOL_PATH . '/pngout-static' ) &&
|
871 |
+
is_writable( EWWW_IMAGE_OPTIMIZER_TOOL_PATH . '/pngout-static' )
|
872 |
+
) {
|
873 |
+
ewwwio_debug_message( 'removing old version of pngout' );
|
874 |
+
ewwwio_delete_file( EWWW_IMAGE_OPTIMIZER_TOOL_PATH . '/pngout-static' );
|
875 |
+
}
|
876 |
if ( get_option( 'ewww_image_optimizer_version' ) && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_review_time' ) ) {
|
877 |
$review_time = rand( time(), time() + 51 * DAY_IN_SECONDS );
|
878 |
add_option( 'ewww_image_optimizer_review_time', $review_time, '', false );
|
976 |
ewww_image_optimizer_save_network_settings();
|
977 |
|
978 |
// Register all the common EWWW IO settings.
|
|
|
979 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_debug', 'boolval' );
|
980 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_metadata_remove', 'boolval' );
|
981 |
register_setting( 'ewww_image_optimizer_options', 'ewww_image_optimizer_jpg_level', 'intval' );
|
1240 |
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1241 |
return;
|
1242 |
}
|
1243 |
+
// Check for Phoenix Media Rename action.
|
1244 |
+
if ( class_exists( 'Phoenix_Media_Rename' ) && 'phoenix_media_rename' === $action ) {
|
1245 |
+
ewwwio_debug_message( 'Phoenix Media Rename, verifying' );
|
1246 |
+
if ( check_ajax_referer( 'phoenix_media_rename', '_wpnonce', false ) ) {
|
1247 |
+
ewwwio_debug_message( 'PMR verified' );
|
1248 |
+
remove_filter( 'wp_generate_attachment_metadata', 'ewww_image_optimizer_resize_from_meta_data', 15 );
|
1249 |
+
ewww_image_optimizer_image_sizes( false );
|
1250 |
+
add_filter( 'ewww_image_optimizer_allowed_reopt', '__return_true' );
|
1251 |
+
return;
|
1252 |
+
}
|
1253 |
+
}
|
1254 |
}
|
1255 |
|
1256 |
/**
|
1551 |
$db_collation = $wpdb->get_charset_collate();
|
1552 |
ewwwio_debug_message( "current collation: $db_collation" );
|
1553 |
|
1554 |
+
$primary_key_definition = 'PRIMARY KEY (id),';
|
1555 |
// See if the path column exists, and what collation it uses to determine the column index size.
|
1556 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ewwwio_images'" ) === $wpdb->ewwwio_images ) {
|
1557 |
ewwwio_debug_message( 'upgrading table and checking collation for path, table exists' );
|
1560 |
$mysql_version = strtolower( $wpdb->db_server_info() );
|
1561 |
}
|
1562 |
ewwwio_debug_message( $mysql_version );
|
1563 |
+
if ( false !== strpos( $mysql_version, 'maria' ) && false !== strpos( $mysql_version, '10.4.' ) ) {
|
1564 |
+
$primary_key_definition = 'UNIQUE KEY id (id),';
|
1565 |
+
}
|
1566 |
+
if ( false && false === strpos( $mysql_version, 'maria' ) || false === strpos( $mysql_version, '10.4.' ) ) {
|
1567 |
ewwwio_debug_message( 'checking primary/unique index' );
|
1568 |
if ( ! $wpdb->get_results( "SHOW INDEX FROM $wpdb->ewwwio_images WHERE Key_name = 'PRIMARY'", ARRAY_A ) ) {
|
1569 |
ewwwio_debug_message( 'adding primary index' );
|
1661 |
updates int unsigned,
|
1662 |
updated timestamp DEFAULT '1971-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
|
1663 |
trace blob,
|
1664 |
+
$primary_key_definition
|
1665 |
KEY path (path($path_index_size)),
|
1666 |
KEY attachment_info (gallery(3),attachment_id)
|
1667 |
) $db_collation;";
|
1672 |
ewwwio_debug_message( 'images db upgrade results: ' . implode( '<br>', $updates ) );
|
1673 |
|
1674 |
/*
|
1675 |
+
* Create a table with 5 columns:
|
1676 |
+
* id: unique for each record/image,
|
1677 |
* attachment_id: the unique id within the media library, nextgen, or flag
|
1678 |
* gallery: 'media', 'nextgen', 'nextcell', 'flag', plus -async variants.
|
1679 |
* scanned: 1 if the image is queued for optimization, 0 if it still needs scanning.
|
1680 |
+
* new: 1 if the image is a 'new' upload queued for optimization, 0 otherwise.
|
1681 |
*/
|
1682 |
$sql = "CREATE TABLE $wpdb->ewwwio_queue (
|
1683 |
id int unsigned NOT NULL AUTO_INCREMENT,
|
2518 |
clearstatcache();
|
2519 |
return $params;
|
2520 |
}
|
2521 |
+
|
2522 |
+
$orig_size = ewww_image_optimizer_filesize( $file_path );
|
2523 |
+
|
2524 |
ewww_image_optimizer_autorotate( $file_path );
|
2525 |
$new_image = ewww_image_optimizer_autoconvert( $file_path );
|
2526 |
if ( $new_image ) {
|
2551 |
}
|
2552 |
}
|
2553 |
clearstatcache();
|
2554 |
+
if ( ! empty( $orig_size ) && $orig_size > ewww_image_optimizer_filesize( $file_path ) ) {
|
2555 |
+
ewwwio_debug_message( "stashing $orig_size for $file_path" );
|
2556 |
+
global $wpdb;
|
2557 |
+
if ( strpos( $wpdb->charset, 'utf8' ) === false ) {
|
2558 |
+
ewww_image_optimizer_db_init();
|
2559 |
+
global $ewwwdb;
|
2560 |
+
} else {
|
2561 |
+
$ewwwdb = $wpdb;
|
2562 |
+
}
|
2563 |
+
$already_optimized = ewww_image_optimizer_find_already_optimized( $file_path );
|
2564 |
+
if ( empty( $already_optimized ) ) {
|
2565 |
+
// If the file didn't already get optimized (and it shouldn't), then just insert a dummy record to be updated shortly.
|
2566 |
+
ewwwio_debug_message( 'creating new record' );
|
2567 |
+
$dbinserted = $ewwwdb->insert(
|
2568 |
+
$ewwwdb->ewwwio_images,
|
2569 |
+
array(
|
2570 |
+
'path' => ewww_image_optimizer_relativize_path( $file_path ),
|
2571 |
+
'orig_size' => $orig_size,
|
2572 |
+
)
|
2573 |
+
);
|
2574 |
+
if ( $dbinserted ) {
|
2575 |
+
ewwwio_debug_message( 'insert success' );
|
2576 |
+
}
|
2577 |
+
} else {
|
2578 |
+
// Update the existing record.
|
2579 |
+
ewwwio_debug_message( 'updating existing record' );
|
2580 |
+
$dbupdated = $ewwwdb->update(
|
2581 |
+
$ewwwdb->ewwwio_images,
|
2582 |
+
array(
|
2583 |
+
'orig_size' => $orig_size,
|
2584 |
+
),
|
2585 |
+
array(
|
2586 |
+
'path' => ewww_image_optimizer_relativize_path( $file_path ),
|
2587 |
+
)
|
2588 |
+
);
|
2589 |
+
if ( $dbupdated ) {
|
2590 |
+
ewwwio_debug_message( 'update success' );
|
2591 |
+
}
|
2592 |
+
}
|
2593 |
+
}
|
2594 |
return $params;
|
2595 |
}
|
2596 |
|
4049 |
if ( empty( $srows ) ) {
|
4050 |
ewwwio_debug_message( 'removing: ' . $base_dir . $data['orig_file'] );
|
4051 |
ewwwio_delete_file( $base_dir . $data['orig_file'] );
|
4052 |
+
$ewwwdb->delete( $ewwwdb->ewwwio_images, array( 'path' => ewww_image_optimizer_relativize_path( $base_dir . $data['orig_file'] ) ) );
|
4053 |
}
|
4054 |
}
|
4055 |
}
|
4116 |
}
|
4117 |
|
4118 |
/**
|
4119 |
+
* Cleans records from database when an image is about to be replaced.
|
4120 |
*
|
4121 |
+
* @param array $attachment An array with the attachment/image ID.
|
4122 |
*/
|
4123 |
+
function ewww_image_optimizer_media_replace( $attachment ) {
|
4124 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4125 |
global $wpdb;
|
4126 |
if ( strpos( $wpdb->charset, 'utf8' ) === false ) {
|
4129 |
} else {
|
4130 |
$ewwwdb = $wpdb;
|
4131 |
}
|
4132 |
+
$id = (int) $attachment['post_id'];
|
4133 |
// Finds non-meta images to remove from disk, and from db, as well as converted originals.
|
4134 |
$optimized_images = $ewwwdb->get_results( "SELECT path,converted FROM $ewwwdb->ewwwio_images WHERE attachment_id = $id AND gallery = 'media'", ARRAY_A );
|
4135 |
if ( $optimized_images ) {
|
4138 |
if ( ! empty( $image['path'] ) ) {
|
4139 |
$image['path'] = ewww_image_optimizer_absolutize_path( $image['path'] );
|
4140 |
}
|
4141 |
+
if ( false === strpos( $image['path'], WP_CONTENT_DIR ) ) {
|
4142 |
continue;
|
4143 |
}
|
4144 |
if ( ! empty( $image['path'] ) ) {
|
4211 |
if ( ! empty( $data['orig_file'] ) ) {
|
4212 |
// Retrieve the filename from the metadata.
|
4213 |
$filename = $data['orig_file'];
|
4214 |
+
$ewwwdb->delete( $ewwwdb->ewwwio_images, array( 'path' => ewww_image_optimizer_relativize_path( $base_dir . $data['orig_file'] ) ) );
|
4215 |
}
|
4216 |
}
|
4217 |
}
|
4218 |
}
|
4219 |
|
4220 |
+
/**
|
4221 |
+
* Cleans records from database after an image has been renamed.
|
4222 |
+
*
|
4223 |
+
* @param string $old_name The filename of the original/old image.
|
4224 |
+
* @param string $new_name The filename of the new image.
|
4225 |
+
*/
|
4226 |
+
function ewww_image_optimizer_media_rename( $old_name, $new_name ) {
|
4227 |
+
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4228 |
+
global $wpdb;
|
4229 |
+
if ( strpos( $wpdb->charset, 'utf8' ) === false ) {
|
4230 |
+
ewww_image_optimizer_db_init();
|
4231 |
+
global $ewwwdb;
|
4232 |
+
} else {
|
4233 |
+
$ewwwdb = $wpdb;
|
4234 |
+
}
|
4235 |
+
if ( ! check_ajax_referer( 'phoenix_media_rename', '_wpnonce', false ) || empty( $_REQUEST['post_id'] ) ) {
|
4236 |
+
return;
|
4237 |
+
}
|
4238 |
+
$id = (int) $_REQUEST['post_id'];
|
4239 |
+
ewwwio_debug_message( "image renamed from $old_name to $new_name, looking for old records (id $id)" );
|
4240 |
+
// Finds images to remove from disk, and from db, as well as converted originals.
|
4241 |
+
$optimized_images = $ewwwdb->get_results( "SELECT id,path,resize,converted FROM $ewwwdb->ewwwio_images WHERE attachment_id = $id AND gallery = 'media'", ARRAY_A );
|
4242 |
+
if ( ewww_image_optimizer_iterable( $optimized_images ) ) {
|
4243 |
+
foreach ( $optimized_images as $image ) {
|
4244 |
+
if ( ! empty( $image['path'] ) ) {
|
4245 |
+
$image['path'] = ewww_image_optimizer_absolutize_path( $image['path'] );
|
4246 |
+
}
|
4247 |
+
ewwwio_debug_message( "checking to see if {$image['path']} is stale" );
|
4248 |
+
if ( false === strpos( $image['path'], WP_CONTENT_DIR ) ) {
|
4249 |
+
ewwwio_debug_message( 'not in ' . WP_CONTENT_DIR );
|
4250 |
+
continue;
|
4251 |
+
}
|
4252 |
+
if ( ewwwio_is_file( $image['path'] ) ) {
|
4253 |
+
ewwwio_debug_message( 'file still exists, skipping' );
|
4254 |
+
continue;
|
4255 |
+
}
|
4256 |
+
if ( ! empty( $image['path'] ) && ewwwio_is_file( $image['path'] . '.webp' ) ) {
|
4257 |
+
ewwwio_debug_message( 'removing WebP version' );
|
4258 |
+
ewwwio_delete_file( $image['path'] . '.webp' );
|
4259 |
+
}
|
4260 |
+
if ( ! empty( $image['converted'] ) ) {
|
4261 |
+
$image['converted'] = ewww_image_optimizer_absolutize_path( $image['converted'] );
|
4262 |
+
}
|
4263 |
+
if ( ! empty( $image['converted'] ) && ewwwio_is_file( $image['converted'] ) ) {
|
4264 |
+
ewwwio_debug_message( 'removing "converted" file' );
|
4265 |
+
ewwwio_delete_file( $image['converted'] );
|
4266 |
+
if ( ewwwio_is_file( $image['converted'] . '.webp' ) ) {
|
4267 |
+
ewwwio_debug_message( 'and WebP derivative' );
|
4268 |
+
ewwwio_delete_file( $image['converted'] . '.webp' );
|
4269 |
+
}
|
4270 |
+
}
|
4271 |
+
if ( 'full' === $image['resize'] ) {
|
4272 |
+
ewwwio_debug_message( "updating path for $id (full)" );
|
4273 |
+
$new_path = str_replace( wp_basename( $old_name ), wp_basename( $new_name ), $image['path'] );
|
4274 |
+
if ( ewwwio_is_file( $new_path ) ) {
|
4275 |
+
$new_path = ewww_image_optimizer_relativize_path( $new_path );
|
4276 |
+
$ewwwdb->update(
|
4277 |
+
$ewwwdb->ewwwio_images,
|
4278 |
+
array(
|
4279 |
+
'path' => $new_path,
|
4280 |
+
),
|
4281 |
+
array(
|
4282 |
+
'id' => $image['id'],
|
4283 |
+
)
|
4284 |
+
);
|
4285 |
+
continue;
|
4286 |
+
}
|
4287 |
+
}
|
4288 |
+
$ewwwdb->delete( $ewwwdb->ewwwio_images, array( 'id' => $image['id'] ) );
|
4289 |
+
}
|
4290 |
+
}
|
4291 |
+
// Retrieve the image metadata.
|
4292 |
+
$meta = wp_get_attachment_metadata( $id );
|
4293 |
+
// If the attachment has an original file set.
|
4294 |
+
if ( ! empty( $meta['orig_file'] ) && ! ewwwio_is_file( $meta['orig_file'] ) ) {
|
4295 |
+
// Get the filepath from the metadata.
|
4296 |
+
$file_path = $meta['orig_file'];
|
4297 |
+
|
4298 |
+
$webpfile = $file_path . '.webp';
|
4299 |
+
$webpfileold = preg_replace( '/\.\w+$/', '.webp', $file_path );
|
4300 |
+
if ( ewwwio_is_file( $webpfile ) ) {
|
4301 |
+
ewwwio_delete_file( $webpfile );
|
4302 |
+
}
|
4303 |
+
if ( ewwwio_is_file( $webpfileold ) ) {
|
4304 |
+
ewwwio_delete_file( $webpfileold );
|
4305 |
+
}
|
4306 |
+
$ewwwdb->delete( $ewwwdb->ewwwio_images, array( 'path' => ewww_image_optimizer_relativize_path( $file_path ) ) );
|
4307 |
+
}
|
4308 |
+
ewww_image_optimizer_resize_from_meta_data( $meta, $id );
|
4309 |
+
}
|
4310 |
+
|
4311 |
/**
|
4312 |
* Activates Easy IO via AJAX.
|
4313 |
*/
|
4350 |
}
|
4351 |
|
4352 |
/**
|
4353 |
+
* Sanitizes an API key for the cloud service.
|
4354 |
*
|
4355 |
* @param string $key An API key entered by the user.
|
4356 |
+
* @return string A sanitized API key.
|
4357 |
*/
|
4358 |
function ewww_image_optimizer_cloud_key_sanitize( $key ) {
|
4359 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
4360 |
$key = trim( $key );
|
4361 |
+
if ( ! empty( $key ) && strlen( $key ) < 200 && preg_match( '/^[a-zA-Z0-9]+$/', $key ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
4362 |
return $key;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4363 |
}
|
4364 |
+
return '';
|
4365 |
}
|
4366 |
|
4367 |
/**
|
4375 |
if ( empty( $_POST['compress_api_key'] ) ) {
|
4376 |
die( wp_json_encode( array( 'error' => esc_html__( 'Please enter your API key and try again.', 'ewww-image-optimizer' ) ) ) );
|
4377 |
}
|
4378 |
+
$api_key = trim( ewww_image_optimizer_cloud_key_sanitize( wp_unslash( $_POST['compress_api_key'] ) ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
4379 |
$url = 'http://optimize.exactlywww.com/verify/';
|
4380 |
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
4381 |
$url = set_url_scheme( $url, 'https' );
|
5322 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
5323 |
global $ewwwdb, $table_prefix;
|
5324 |
require_once( EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'classes/class-ewwwdb.php' );
|
5325 |
+
if ( ! defined( 'DB_USER' ) || ! defined( 'DB_PASSWORD' ) || ! defined( 'DB_NAME' ) || ! defined( 'DB_HOST' ) ) {
|
5326 |
+
global $wpdb;
|
5327 |
+
$ewwwdb = $wpdb;
|
5328 |
+
return;
|
5329 |
+
} elseif ( ! isset( $ewwwdb ) ) {
|
5330 |
$ewwwdb = new EwwwDB( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
|
5331 |
}
|
5332 |
|
5489 |
*
|
5490 |
* Each sub-array in $images should have the same number of items as $format.
|
5491 |
*
|
5492 |
+
* @global object $wpdb
|
5493 |
+
* @global object $ewwwdb A clone of $wpdb unless it is lacking utf8 connectivity.
|
5494 |
*
|
5495 |
* @param string $table The table to insert records into.
|
5496 |
+
* @param array $data Can be any multi-dimensional array with records to insert.
|
5497 |
+
* @param array $format A list of formats for the values in each record of $data.
|
5498 |
*/
|
5499 |
+
function ewww_image_optimizer_mass_insert( $table, $data, $format ) {
|
5500 |
ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' );
|
5501 |
+
if ( empty( $table ) || ! ewww_image_optimizer_iterable( $data ) || ! ewww_image_optimizer_iterable( $format ) ) {
|
5502 |
return false;
|
5503 |
}
|
5504 |
+
global $wpdb;
|
5505 |
+
if ( strpos( $wpdb->charset, 'utf8' ) === false ) {
|
5506 |
+
ewww_image_optimizer_db_init();
|
5507 |
+
global $ewwwdb;
|
5508 |
+
} else {
|
5509 |
+
$ewwwdb = $wpdb;
|
5510 |
+
}
|
5511 |
+
|
5512 |
+
$multi_formats = array();
|
5513 |
+
$values = array();
|
5514 |
+
foreach ( $data as $record ) {
|
5515 |
+
if ( ! ewww_image_optimizer_iterable( $record ) ) {
|
5516 |
+
continue;
|
5517 |
+
}
|
5518 |
+
|
5519 |
+
foreach ( $record as $value ) {
|
5520 |
+
$values[] = $value;
|
5521 |
+
}
|
5522 |
+
$multi_formats[] = '(' . implode( ',', $format ) . ')';
|
5523 |
+
}
|
5524 |
+
$first = reset( $data );
|
5525 |
+
$fields = '`' . implode( '`, `', array_keys( $first ) ) . '`';
|
5526 |
+
$multi_formats = implode( ',', $multi_formats );
|
5527 |
+
|
5528 |
+
return $ewwwdb->query( $ewwwdb->prepare( "INSERT INTO `$table` ($fields) VALUES $multi_formats", $values ) );
|
5529 |
}
|
5530 |
|
5531 |
/**
|
6980 |
} else {
|
6981 |
$ewwwdb = $wpdb;
|
6982 |
}
|
6983 |
+
// Delete the record created from optimizing the resized file (if it exists, which it shouldn't).
|
6984 |
+
$temp_optimized = ewww_image_optimizer_find_already_optimized( $new_file );
|
6985 |
+
if ( is_array( $temp_optimized ) && ! empty( $temp_optimized['id'] ) ) {
|
6986 |
+
$ewwwdb->delete(
|
6987 |
$ewwwdb->ewwwio_images,
|
6988 |
array(
|
6989 |
+
'id' => $temp_optimized['id'],
|
|
|
6990 |
),
|
6991 |
array(
|
6992 |
+
'%d',
|
6993 |
)
|
6994 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6995 |
}
|
6996 |
/* translators: 1: width in pixels 2: height in pixels */
|
6997 |
$ewwwio_resize_status = sprintf( __( 'Resized to %1$s x %2$s', 'ewww-image-optimizer' ), $newwidth . 'w', $newheight . 'h' );
|
10745 |
<label for='ewww_image_optimizer_jpg_quality'><?php esc_html_e( 'JPG Quality Level', 'ewww-image-optimizer' ); ?></label>
|
10746 |
</p>
|
10747 |
<?php endif; ?>
|
10748 |
+
<?php if ( function_exists( 'easyio_get_option' ) && easyio_get_option( 'easyio_lazy_load' ) ) : ?>
|
10749 |
+
<p>
|
10750 |
+
<input type='checkbox' id='ewww_image_optimizer_easy_lazy' name='ewww_image_optimizer_easy_lazy' value='true' checked disabled />
|
10751 |
+
<label for='ewww_image_optimizer_easy_lazy'><?php esc_html_e( 'Lazy Load (enabled in Easy IO)', 'ewww-image-optimizer' ); ?></label><br>
|
10752 |
+
</p>
|
10753 |
+
<?php elseif ( ! ewwwio_other_lazy_detected() ) : ?>
|
10754 |
<p>
|
10755 |
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' checked />
|
10756 |
<label for='ewww_image_optimizer_lazy_load'><?php esc_html_e( 'Lazy Load', 'ewww-image-optimizer' ); ?></label>
|
11270 |
if ( get_option( 'easyio_lazy_load' ) || ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ) {
|
11271 |
$speed_score += 10;
|
11272 |
} else {
|
11273 |
+
$speed_recommendations[] = __( 'Enable Lazy Loading.', 'ewww-image-optimizer' );
|
11274 |
}
|
11275 |
if ( ! ewww_image_optimizer_easy_active() && ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' ) ) {
|
11276 |
$speed_recommendations[] = __( 'Enable WebP conversion.', 'ewww-image-optimizer' ) . ewwwio_get_help_link( 'https://docs.ewww.io/article/16-ewww-io-and-webp-images', '5854745ac697912ffd6c1c89' );
|
11880 |
<?php ewwwio_help_link( 'https://docs.ewww.io/article/74-lazy-load', '5c6c36ed042863543ccd2d9b' ); ?>
|
11881 |
</th>
|
11882 |
<td>
|
11883 |
+
<?php if ( function_exists( 'easyio_get_option' ) && easyio_get_option( 'easyio_lazy_load' ) ) : ?>
|
11884 |
+
<p class='description'><?php esc_html_e( 'Lazy Load enabled in Easy Image Optimizer.', 'ewww-image-optimizer' ); ?></p>
|
11885 |
+
<?php else : ?>
|
11886 |
<input type='checkbox' id='ewww_image_optimizer_lazy_load' name='ewww_image_optimizer_lazy_load' value='true' <?php checked( ewww_image_optimizer_get_option( 'ewww_image_optimizer_lazy_load' ) ); ?> />
|
11887 |
<?php esc_html_e( 'Improves actual and perceived loading time as images will be loaded only as they enter (or are about to enter) the viewport.', 'ewww-image-optimizer' ); ?>
|
11888 |
+
<?php if ( ewwwio_other_lazy_detected() ) : ?>
|
11889 |
<p><strong><?php esc_html_e( 'Though you already have a lazy loader on your site, the EWWW IO lazy loader includes auto-scaling for improved responsive images.', 'ewww-image-optimizer' ); ?></strong></p>
|
11890 |
+
<?php endif; ?>
|
11891 |
<p class='description'>
|
11892 |
<?php esc_html_e( 'The lazy loader chooses the best available image size from existing responsive markup. When used with Easy IO, all images become responsive.', 'ewww-image-optimizer' ); ?></br>
|
11893 |
<?php esc_html_e( 'To disable auto-scaling for an image, add "skip-autoscale" to the HTML element via a class or attribute.', 'ewww-image-optimizer' ); ?>
|
11916 |
</p>
|
11917 |
</td>
|
11918 |
</tr>
|
11919 |
+
<?php endif; ?>
|
11920 |
<?php if ( $free_exec ) : ?>
|
11921 |
<tr>
|
11922 |
<th> </th>
|
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: 6.0.
|
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: 6.0.2
|
17 |
Author URI: https://ewww.io/
|
18 |
License: GPLv3
|
19 |
*/
|
includes/lazysizes.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
// version 5.
|
2 |
(function(window, factory) {
|
3 |
var lazySizes = factory(window, window.document, Date);
|
4 |
window.lazySizes = lazySizes;
|
@@ -23,6 +23,8 @@
|
|
23 |
errorClass: 'lazyerror',
|
24 |
//strictClass: 'lazystrict',
|
25 |
autosizesClass: 'lazyautosizes',
|
|
|
|
|
26 |
srcAttr: 'data-src',
|
27 |
srcsetAttr: 'data-srcset',
|
28 |
sizesAttr: 'data-sizes',
|
@@ -442,9 +444,12 @@
|
|
442 |
};
|
443 |
|
444 |
var changeIframeSrc = function(elem, src){
|
445 |
-
|
|
|
|
|
|
|
446 |
elem.contentWindow.location.replace(src);
|
447 |
-
}
|
448 |
elem.src = src;
|
449 |
}
|
450 |
};
|
@@ -526,7 +531,7 @@
|
|
526 |
|
527 |
if( !firesLoad || isLoaded){
|
528 |
if (isLoaded) {
|
529 |
-
addClass(elem,
|
530 |
}
|
531 |
switchLoadingClass(event);
|
532 |
elem._lazyCache = true;
|
1 |
+
// version 5.3.0
|
2 |
(function(window, factory) {
|
3 |
var lazySizes = factory(window, window.document, Date);
|
4 |
window.lazySizes = lazySizes;
|
23 |
errorClass: 'lazyerror',
|
24 |
//strictClass: 'lazystrict',
|
25 |
autosizesClass: 'lazyautosizes',
|
26 |
+
fastLoadedClass: 'ls-is-cached',
|
27 |
+
iframeLoadMode: 0,
|
28 |
srcAttr: 'data-src',
|
29 |
srcsetAttr: 'data-srcset',
|
30 |
sizesAttr: 'data-sizes',
|
444 |
};
|
445 |
|
446 |
var changeIframeSrc = function(elem, src){
|
447 |
+
var loadMode = elem.getAttribute('data-load-mode') || lazySizesCfg.iframeLoadMode;
|
448 |
+
|
449 |
+
// loadMode can be also a string!
|
450 |
+
if (loadMode == 0) {
|
451 |
elem.contentWindow.location.replace(src);
|
452 |
+
} else if (loadMode == 1) {
|
453 |
elem.src = src;
|
454 |
}
|
455 |
};
|
531 |
|
532 |
if( !firesLoad || isLoaded){
|
533 |
if (isLoaded) {
|
534 |
+
addClass(elem, lazySizesCfg.fastLoadedClass);
|
535 |
}
|
536 |
switchLoadingClass(event);
|
537 |
elem._lazyCache = true;
|
includes/lazysizes.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var ewww_webp_supported=!1;function lazysizesWebP(e,t){var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t()},a.onerror=function(){t()},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function shouldAutoScale(e){if(1==eio_lazy_vars.skip_autoscale)return!1;if(e.hasAttributes())for(var t=e.attributes,a=/skip-autoscale/,i=t.length-1;0<=i;i--){if(a.test(t[i].name))return!1;if(a.test(t[i].value))return!1}return!0}function constrainSrc(e,t,a,i){if(null===e)return e;var r=/w=(\d+)/,n=/fit=(\d+),(\d+)/,o=/resize=(\d+),(\d+)/,s=decodeURIComponent(e);if("undefined"==typeof eio_lazy_vars&&(eio_lazy_vars={exactdn_domain:".exactdn.com"}),0<e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)){var l=o.exec(s);if(l&&t<l[1])return s.replace(o,"resize="+t+","+a);var c=r.exec(e);if(c&&t<=c[1]){if("bg-cover"!==i&&"img-crop"!==i)return e.replace(r,"w="+t);var d=c[1]-t;return 20<d||a<1080?e.replace(r,"resize="+t+","+a):e}var u=n.exec(s);if(u&&t<u[1]){if("bg-cover"!==i&&"img-crop"!==i)return s.replace(n,"fit="+t+","+a);var f=u[1]-t,A=u[2]-a;return 20<f||20<A?e.replace(r,"resize="+t+","+a):e}if(!c&&!u&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"&h="+a:e+"&w="+t}return-1==e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)?"img"===i?e+"?fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"?h="+a:e+"?w="+t:e}window.lazySizesConfig=window.lazySizesConfig||{},window.lazySizesConfig.init=!1,function(e,t){var a=function(i,A,n){"use strict";var g,h;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in h=i.lazySizesConfig||i.lazysizesConfig||{},t)e in h||(h[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:h,noSupport:!0};var z=A.documentElement,r=i.HTMLPictureElement,o="addEventListener",v="getAttribute",e=i[o].bind(i),u=i.setTimeout,a=i.requestAnimationFrame||u,s=i.requestIdleCallback,f=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],c={},p=Array.prototype.forEach,d=function(e,t){return c[t]||(c[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),c[t].test(e[v]("class")||"")&&c[t]},m=function(e,t){d(e,t)||e.setAttribute("class",(e[v]("class")||"").trim()+" "+t)},y=function(e,t){var a;(a=d(e,t))&&e.setAttribute("class",(e[v]("class")||"").replace(a," "))},b=function(t,a,e){var i=e?o:"removeEventListener";e&&b(t,a),l.forEach(function(e){t[i](e,a)})},w=function(e,t,a,i,r){var n=A.createEvent("Event");return a||(a={}),a.instance=g,n.initEvent(t,!i,!r),n.detail=a,e.dispatchEvent(n),n},_=function(e,t){var a;!r&&(a=i.picturefill||h.pf)?(t&&t.src&&!e[v]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},C=function(e,t){return(getComputedStyle(e,null)||{})[t]},E=function(e,t,a){for(a=a||e.offsetWidth;a<h.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],_e=[],Ce=we,Ee=function(){var e=Ce;for(Ce=we.length?_e:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(Ce.push(e),be||(be=!0,(A.hidden?u:a)(Ee)))},Se._lsFlush=Ee,Se),t=function(a,e){return e?function(){S(a)}:function(){var e=this,t=arguments;S(function(){a.apply(e,t)})}},W=function(e){var t,a,i=function(){t=null,e()},r=function(){var e=n.now()-a;e<99?u(r,99-e):(s||i)(i)};return function(){a=n.now(),t||(t=u(r,99))}},x=(ee=/^img$/i,te=/^iframe$/i,ae="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ie=0,re=0,ne=-1,oe=function(e){re--,(!e||re<0||!e.target)&&(re=0)},se=function(e){return null==$&&($="hidden"==C(A.body,"visibility")),$||!("hidden"==C(e.parentNode,"visibility")&&"hidden"==C(e,"visibility"))},le=function(e,t){var a,i=e,r=se(e);for(I-=t,G+=t,J-=t,O+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=z;)(r=0<(C(i,"opacity")||1))&&"visible"!=C(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},ce=function(){var e,t,a,i,r,n,o,s,l,c,d,u,f=g.elements;if((H=h.loadMode)&&re<8&&(e=f.length)){for(t=0,ne++;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(!ae||g.prematureUnveil&&g.prematureUnveil(f[t]))ze(f[t]);else if((s=f[t][v]("data-expand"))&&(n=1*s)||(n=ie),c||(c=!h.expand||h.expand<1?500<z.clientHeight&&500<z.clientWidth?500:370:h.expand,g._defEx=c,d=c*h.expFactor,u=h.hFac,$=null,ie<d&&re<1&&2<ne&&2<H&&!A.hidden?(ie=d,ne=0):ie=1<H&&1<ne&&re<6?c:0),l!==n&&(U=innerWidth+n*u,F=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(G=a.bottom)>=o&&(I=a.top)<=F&&(O=a.right)>=o*u&&(J=a.left)<=U&&(G||O||J||I)&&(h.loadHidden||se(f[t]))&&(P&&re<3&&!s&&(H<3||ne<4)||le(f[t],n))){if(ze(f[t]),r=!0,9<re)break}else!r&&P&&!i&&re<4&&ne<4&&2<H&&(k[0]||h.preloadAfterLoad)&&(k[0]||!s&&(G||O||J||I||"auto"!=f[t][v](h.sizesAttr)))&&(i=k[0]||f[t]);i&&!r&&ze(i)}},q=ce,V=0,X=h.throttleDelay,Y=h.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==h.ricTimeout&&(Y=h.ricTimeout)}:t(function(){u(K)},!0),de=function(e){var t;(e=!0===e)&&(Y=33),j||(j=!0,(t=X-(n.now()-V))<0&&(t=0),e||t<9?Z():u(Z,t))},ue=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(oe(e),m(t,h.loadedClass),y(t,h.loadingClass),b(t,Ae),w(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[v](h.srcsetAttr);(t=h.customMedia[e[v]("data-media")||e[v]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},he=t(function(t,e,a,i,r){var n,o,s,l,c,d;(c=w(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?m(t,h.autosizesClass):t.setAttribute("sizes",i)),o=t[v](h.srcsetAttr),n=t[v](h.srcAttr),r&&(s=t.parentNode,l=s&&f.test(s.nodeName||"")),d=e.firesLoad||"src"in t&&(o||n||l),c={target:t},m(t,h.loadingClass),d&&(clearTimeout(D),D=u(oe,2500),b(t,Ae,!0)),l&&p.call(s.getElementsByTagName("source"),ge),o?t.setAttribute("srcset",o):n&&!l&&(te.test(t.nodeName)?function(t,a){try{t.contentWindow.location.replace(a)}catch(e){t.src=a}}(t,n):t.src=n),r&&(o||l)&&_(t,{src:n})),t._lazyRace&&delete t._lazyRace,y(t,h.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;d&&!e||(e&&m(t,"ls-is-cached"),ue(c),t._lazyCache=!0,u(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ze=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[v](h.sizesAttr)||e[v]("sizes")),r="auto"==i;(!r&&P||!a||!e[v]("src")&&!e.srcset||e.complete||d(e,h.errorClass)||!d(e,h.lazyClass))&&(t=w(e,"lazyunveilread").detail,r&&M.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,he(e,t,r,i,a))}},ve=W(function(){h.loadMode=3,de()}),pe=function(){3==h.loadMode&&(h.loadMode=2),ve()},me=function(){P||(n.now()-T<999?u(me,999):(P=!0,h.loadMode=3,de(),e("scroll",pe,!0)))},{_:function(){T=n.now(),g.elements=A.getElementsByClassName(h.lazyClass),k=A.getElementsByClassName(h.lazyClass+" "+h.preloadClass),e("scroll",de,!0),e("resize",de,!0),e("pageshow",function(e){if(e.persisted){var t=A.querySelectorAll("."+h.loadingClass);t.length&&t.forEach&&a(function(){t.forEach(function(e){e.complete&&ze(e)})})}}),i.MutationObserver?new MutationObserver(de).observe(z,{childList:!0,subtree:!0,attributes:!0}):(z[o]("DOMNodeInserted",de,!0),z[o]("DOMAttrModified",de,!0),setInterval(de,999)),e("hashchange",de,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,de,!0)}),/d$|^c/.test(A.readyState)?me():(e("load",me),A[o]("DOMContentLoaded",de),u(me,2e4)),g.elements.length?(ce(),S._lsFlush()):de()},checkElems:de,unveil:ze,_aLSL:pe}),M=(R=t(function(e,t,a,i){var r,n,o;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),f.test(t.nodeName||""))for(r=t.getElementsByTagName("source"),n=0,o=r.length;n<o;n++)r[n].setAttribute("sizes",i);a.detail.dataAttr||_(e,a.detail)}),L=function(e,t,a){var i,r=e.parentNode;r&&(a=E(e,r,a),(i=w(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=i.detail.width)&&a!==e._lazysizesWidth&&R(e,r,i,a))},Q=W(function(){var e,t=N.length;if(t)for(e=0;e<t;e++)L(N[e])}),{_:function(){N=A.getElementsByClassName(h.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:L}),B=function(){!B.i&&A.getElementsByClassName&&(B.i=!0,M._(),x._())};var N,R,L,Q;var k,P,D,H,T,U,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,ce,de,ue,fe,Ae,ge,he,ze,ve,pe,me;var ye,be,we,_e,Ce,Ee,Se;return u(function(){h.init&&B()}),g={cfg:h,autoSizer:M,loader:x,init:B,uP:_,aC:m,rC:y,hC:d,fire:w,gW:E,rAF:S}}(e,e.document,Date);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforesizes",function(e){void 0!==e.target._lazysizesWidth&&e.detail.width<e.target._lazysizesWidth&&(e.detail.width=e.target._lazysizesWidth)}),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=t.clientWidth&&1.25*t.clientWidth<t.naturalWidth,n=t.clientHeight&&1.25*t.clientHeight<t.naturalHeight;if(r||n){var o=Math.round(t.offsetWidth*i),s=Math.round(t.offsetHeight*i),l=t.getAttribute("data-src"),c=t.getAttribute("data-src-webp");if(ewww_webp_supported&&c&&-1==l.search("webp=1")&&(l=c),shouldAutoScale(t)&&shouldAutoScale(t.parentNode))if(window.lazySizes.hC(t,"et_pb_jt_filterable_grid_item_image")||window.lazySizes.hC(t,"ss-foreground-image"))d=constrainSrc(l,o,s,"img-crop");else d=constrainSrc(l,o,s,"img");else var d=!1;d&&l!=d&&t.setAttribute("data-src",d)}}if(ewww_webp_supported){if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if(!(c=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",c)}}),function(e,t){var a=function(){t(e.lazySizes),e.removeEventListener("lazyunveilread",a,!0)};t=t.bind(null,e,e.document),"object"==typeof module&&module.exports?t(require("lazysizes")):e.lazySizes?a():e.addEventListener("lazyunveilread",a,!0)}(window,function(o,e,s){"use strict";var l;e.addEventListener&&(l=/\(|\)|\s|'/,addEventListener("lazybeforeunveil",function(e){var t,a;if(e.detail.instance==s&&(!e.defaultPrevented&&("none"==e.target.preload&&(e.target.preload="auto"),t=e.target.getAttribute("data-bg")))){ewww_webp_supported&&(a=e.target.getAttribute("data-bg-webp"))&&(t=a);var i=o.devicePixelRatio||1,r=Math.round(e.target.offsetWidth*i),n=Math.round(e.target.offsetHeight*i);shouldAutoScale(e.target)&&shouldAutoScale(e.target.parentNode)&&(t=o.lazySizes.hC(e.target,"wp-block-cover")?(o.lazySizes.hC(e.target,"has-parallax")&&(r=Math.round(o.screen.width*i),n=Math.round(o.screen.height*i)),constrainSrc(t,r,n,"bg-cover")):o.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,r,n,"bg-cover"):constrainSrc(t,r,n,"bg")),e.target.style.backgroundImage="url("+(l.test(t)?JSON.stringify(t):t)+")"}},!1))});
|
1 |
+
var ewww_webp_supported=!1;function lazysizesWebP(e,t){var a=new Image;a.onload=function(){ewww_webp_supported=0<a.width&&0<a.height,t()},a.onerror=function(){t()},a.src="data:image/webp;base64,"+{alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"}[e]}function shouldAutoScale(e){if(1==eio_lazy_vars.skip_autoscale)return!1;if(e.hasAttributes())for(var t=e.attributes,a=/skip-autoscale/,i=t.length-1;0<=i;i--){if(a.test(t[i].name))return!1;if(a.test(t[i].value))return!1}return!0}function constrainSrc(e,t,a,i){if(null===e)return e;var r=/w=(\d+)/,n=/fit=(\d+),(\d+)/,o=/resize=(\d+),(\d+)/,s=decodeURIComponent(e);if("undefined"==typeof eio_lazy_vars&&(eio_lazy_vars={exactdn_domain:".exactdn.com"}),0<e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)){var l=o.exec(s);if(l&&t<l[1])return s.replace(o,"resize="+t+","+a);var d=r.exec(e);if(d&&t<=d[1]){if("bg-cover"!==i&&"img-crop"!==i)return e.replace(r,"w="+t);var c=d[1]-t;return 20<c||a<1080?e.replace(r,"resize="+t+","+a):e}var u=n.exec(s);if(u&&t<u[1]){if("bg-cover"!==i&&"img-crop"!==i)return s.replace(n,"fit="+t+","+a);var f=u[1]-t,A=u[2]-a;return 20<f||20<A?e.replace(r,"resize="+t+","+a):e}if(!d&&!u&&!l)return"img"===i?e+"&fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"&h="+a:e+"&w="+t}return-1==e.search("\\?")&&0<e.search(eio_lazy_vars.exactdn_domain)?"img"===i?e+"?fit="+t+","+a:"bg-cover"===i||"img-crop"===i?e+"?resize="+t+","+a:t<a?e+"?h="+a:e+"?w="+t:e}window.lazySizesConfig=window.lazySizesConfig||{},window.lazySizesConfig.init=!1,function(e,t){var a=function(i,A,n){"use strict";var g,h;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",fastLoadedClass:"ls-is-cached",iframeLoadMode:0,srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in h=i.lazySizesConfig||i.lazysizesConfig||{},t)e in h||(h[e]=t[e])}(),!A||!A.getElementsByClassName)return{init:function(){},cfg:h,noSupport:!0};var z=A.documentElement,r=i.HTMLPictureElement,o="addEventListener",v="getAttribute",e=i[o].bind(i),m=i.setTimeout,a=i.requestAnimationFrame||m,s=i.requestIdleCallback,p=/^picture$/i,l=["load","error","lazyincluded","_lazyloaded"],d={},y=Array.prototype.forEach,c=function(e,t){return d[t]||(d[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),d[t].test(e[v]("class")||"")&&d[t]},b=function(e,t){c(e,t)||e.setAttribute("class",(e[v]("class")||"").trim()+" "+t)},w=function(e,t){var a;(a=c(e,t))&&e.setAttribute("class",(e[v]("class")||"").replace(a," "))},_=function(t,a,e){var i=e?o:"removeEventListener";e&&_(t,a),l.forEach(function(e){t[i](e,a)})},C=function(e,t,a,i,r){var n=A.createEvent("Event");return a||(a={}),a.instance=g,n.initEvent(t,!i,!r),n.detail=a,e.dispatchEvent(n),n},E=function(e,t){var a;!r&&(a=i.picturefill||h.pf)?(t&&t.src&&!e[v]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)},u=function(e,t){return(getComputedStyle(e,null)||{})[t]},f=function(e,t,a){for(a=a||e.offsetWidth;a<h.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a},S=(we=[],_e=[],Ce=we,Ee=function(){var e=Ce;for(Ce=we.length?_e:we,be=!(ye=!0);e.length;)e.shift()();ye=!1},Se=function(e,t){ye&&!t?e.apply(this,arguments):(Ce.push(e),be||(be=!0,(A.hidden?m:a)(Ee)))},Se._lsFlush=Ee,Se),t=function(a,e){return e?function(){S(a)}:function(){var e=this,t=arguments;S(function(){a.apply(e,t)})}},W=function(e){var t,a,i=function(){t=null,e()},r=function(){var e=n.now()-a;e<99?m(r,99-e):(s||i)(i)};return function(){a=n.now(),t||(t=m(r,99))}},x=(ee=/^img$/i,te=/^iframe$/i,ae="onscroll"in i&&!/(gle|ing)bot/.test(navigator.userAgent),ie=0,re=0,ne=-1,oe=function(e){re--,(!e||re<0||!e.target)&&(re=0)},se=function(e){return null==$&&($="hidden"==u(A.body,"visibility")),$||!("hidden"==u(e.parentNode,"visibility")&&"hidden"==u(e,"visibility"))},le=function(e,t){var a,i=e,r=se(e);for(I-=t,G+=t,J-=t,O+=t;r&&(i=i.offsetParent)&&i!=A.body&&i!=z;)(r=0<(u(i,"opacity")||1))&&"visible"!=u(i,"overflow")&&(a=i.getBoundingClientRect(),r=O>a.left&&J<a.right&&G>a.top-1&&I<a.bottom+1);return r},de=function(){var e,t,a,i,r,n,o,s,l,d,c,u,f=g.elements;if((H=h.loadMode)&&re<8&&(e=f.length)){for(t=0,ne++;t<e;t++)if(f[t]&&!f[t]._lazyRace)if(!ae||g.prematureUnveil&&g.prematureUnveil(f[t]))ze(f[t]);else if((s=f[t][v]("data-expand"))&&(n=1*s)||(n=ie),d||(d=!h.expand||h.expand<1?500<z.clientHeight&&500<z.clientWidth?500:370:h.expand,g._defEx=d,c=d*h.expFactor,u=h.hFac,$=null,ie<c&&re<1&&2<ne&&2<H&&!A.hidden?(ie=c,ne=0):ie=1<H&&1<ne&&re<6?d:0),l!==n&&(U=innerWidth+n*u,F=innerHeight+n,o=-1*n,l=n),a=f[t].getBoundingClientRect(),(G=a.bottom)>=o&&(I=a.top)<=F&&(O=a.right)>=o*u&&(J=a.left)<=U&&(G||O||J||I)&&(h.loadHidden||se(f[t]))&&(P&&re<3&&!s&&(H<3||ne<4)||le(f[t],n))){if(ze(f[t]),r=!0,9<re)break}else!r&&P&&!i&&re<4&&ne<4&&2<H&&(k[0]||h.preloadAfterLoad)&&(k[0]||!s&&(G||O||J||I||"auto"!=f[t][v](h.sizesAttr)))&&(i=k[0]||f[t]);i&&!r&&ze(i)}},q=de,V=0,X=h.throttleDelay,Y=h.ricTimeout,K=function(){j=!1,V=n.now(),q()},Z=s&&49<Y?function(){s(K,{timeout:Y}),Y!==h.ricTimeout&&(Y=h.ricTimeout)}:t(function(){m(K)},!0),ce=function(e){var t;(e=!0===e)&&(Y=33),j||(j=!0,(t=X-(n.now()-V))<0&&(t=0),e||t<9?Z():m(Z,t))},ue=function(e){var t=e.target;t._lazyCache?delete t._lazyCache:(oe(e),b(t,h.loadedClass),w(t,h.loadingClass),_(t,Ae),C(t,"lazyloaded"))},fe=t(ue),Ae=function(e){fe({target:e.target})},ge=function(e){var t,a=e[v](h.srcsetAttr);(t=h.customMedia[e[v]("data-media")||e[v]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)},he=t(function(t,e,a,i,r){var n,o,s,l,d,c,u,f,A;(d=C(t,"lazybeforeunveil",e)).defaultPrevented||(i&&(a?b(t,h.autosizesClass):t.setAttribute("sizes",i)),o=t[v](h.srcsetAttr),n=t[v](h.srcAttr),r&&(s=t.parentNode,l=s&&p.test(s.nodeName||"")),c=e.firesLoad||"src"in t&&(o||n||l),d={target:t},b(t,h.loadingClass),c&&(clearTimeout(D),D=m(oe,2500),_(t,Ae,!0)),l&&y.call(s.getElementsByTagName("source"),ge),o?t.setAttribute("srcset",o):n&&!l&&(te.test(t.nodeName)?(f=n,0==(A=(u=t).getAttribute("data-load-mode")||h.iframeLoadMode)?u.contentWindow.location.replace(f):1==A&&(u.src=f)):t.src=n),r&&(o||l)&&E(t,{src:n})),t._lazyRace&&delete t._lazyRace,w(t,h.lazyClass),S(function(){var e=t.complete&&1<t.naturalWidth;c&&!e||(e&&b(t,h.fastLoadedClass),ue(d),t._lazyCache=!0,m(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&re--},!0)}),ze=function(e){if(!e._lazyRace){var t,a=ee.test(e.nodeName),i=a&&(e[v](h.sizesAttr)||e[v]("sizes")),r="auto"==i;(!r&&P||!a||!e[v]("src")&&!e.srcset||e.complete||c(e,h.errorClass)||!c(e,h.lazyClass))&&(t=C(e,"lazyunveilread").detail,r&&M.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,re++,he(e,t,r,i,a))}},ve=W(function(){h.loadMode=3,ce()}),me=function(){3==h.loadMode&&(h.loadMode=2),ve()},pe=function(){P||(n.now()-T<999?m(pe,999):(P=!0,h.loadMode=3,ce(),e("scroll",me,!0)))},{_:function(){T=n.now(),g.elements=A.getElementsByClassName(h.lazyClass),k=A.getElementsByClassName(h.lazyClass+" "+h.preloadClass),e("scroll",ce,!0),e("resize",ce,!0),e("pageshow",function(e){if(e.persisted){var t=A.querySelectorAll("."+h.loadingClass);t.length&&t.forEach&&a(function(){t.forEach(function(e){e.complete&&ze(e)})})}}),i.MutationObserver?new MutationObserver(ce).observe(z,{childList:!0,subtree:!0,attributes:!0}):(z[o]("DOMNodeInserted",ce,!0),z[o]("DOMAttrModified",ce,!0),setInterval(ce,999)),e("hashchange",ce,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){A[o](e,ce,!0)}),/d$|^c/.test(A.readyState)?pe():(e("load",pe),A[o]("DOMContentLoaded",ce),m(pe,2e4)),g.elements.length?(de(),S._lsFlush()):ce()},checkElems:ce,unveil:ze,_aLSL:me}),M=(N=t(function(e,t,a,i){var r,n,o;if(e._lazysizesWidth=i,i+="px",e.setAttribute("sizes",i),p.test(t.nodeName||""))for(r=t.getElementsByTagName("source"),n=0,o=r.length;n<o;n++)r[n].setAttribute("sizes",i);a.detail.dataAttr||E(e,a.detail)}),R=function(e,t,a){var i,r=e.parentNode;r&&(a=f(e,r,a),(i=C(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=i.detail.width)&&a!==e._lazysizesWidth&&N(e,r,i,a))},Q=W(function(){var e,t=L.length;if(t)for(e=0;e<t;e++)R(L[e])}),{_:function(){L=A.getElementsByClassName(h.autosizesClass),e("resize",Q)},checkElems:Q,updateElem:R}),B=function(){!B.i&&A.getElementsByClassName&&(B.i=!0,M._(),x._())};var L,N,R,Q;var k,P,D,H,T,U,F,I,J,O,G,$,q,j,V,X,Y,K,Z,ee,te,ae,ie,re,ne,oe,se,le,de,ce,ue,fe,Ae,ge,he,ze,ve,me,pe;var ye,be,we,_e,Ce,Ee,Se;return m(function(){h.init&&B()}),g={cfg:h,autoSizer:M,loader:x,init:B,uP:E,aC:b,rC:w,hC:c,fire:C,gW:f,rAF:S}}(e,e.document,Date);e.lazySizes=a,"object"==typeof module&&module.exports&&(module.exports=a)}("undefined"!=typeof window?window:{}),lazysizesWebP("alpha",lazySizes.init),document.addEventListener("lazybeforesizes",function(e){void 0!==e.target._lazysizesWidth&&e.detail.width<e.target._lazysizesWidth&&(e.detail.width=e.target._lazysizesWidth)}),document.addEventListener("lazybeforeunveil",function(e){var t=e.target,a=t.getAttribute("data-srcset");if(t.naturalWidth&&1<t.naturalWidth&&1<t.naturalHeight){var i=window.devicePixelRatio||1,r=t.clientWidth&&1.25*t.clientWidth<t.naturalWidth,n=t.clientHeight&&1.25*t.clientHeight<t.naturalHeight;if(r||n){var o=Math.round(t.offsetWidth*i),s=Math.round(t.offsetHeight*i),l=t.getAttribute("data-src"),d=t.getAttribute("data-src-webp");if(ewww_webp_supported&&d&&-1==l.search("webp=1")&&(l=d),shouldAutoScale(t)&&shouldAutoScale(t.parentNode))if(window.lazySizes.hC(t,"et_pb_jt_filterable_grid_item_image")||window.lazySizes.hC(t,"ss-foreground-image"))c=constrainSrc(l,o,s,"img-crop");else c=constrainSrc(l,o,s,"img");else var c=!1;c&&l!=c&&t.setAttribute("data-src",c)}}if(ewww_webp_supported){if(a){var u=t.getAttribute("data-srcset-webp");u&&t.setAttribute("data-srcset",u)}if(!(d=t.getAttribute("data-src-webp")))return;t.setAttribute("data-src",d)}}),function(e,t){var a=function(){t(e.lazySizes),e.removeEventListener("lazyunveilread",a,!0)};t=t.bind(null,e,e.document),"object"==typeof module&&module.exports?t(require("lazysizes")):e.lazySizes?a():e.addEventListener("lazyunveilread",a,!0)}(window,function(o,e,s){"use strict";var l;e.addEventListener&&(l=/\(|\)|\s|'/,addEventListener("lazybeforeunveil",function(e){var t,a;if(e.detail.instance==s&&(!e.defaultPrevented&&("none"==e.target.preload&&(e.target.preload="auto"),t=e.target.getAttribute("data-bg")))){ewww_webp_supported&&(a=e.target.getAttribute("data-bg-webp"))&&(t=a);var i=o.devicePixelRatio||1,r=Math.round(e.target.offsetWidth*i),n=Math.round(e.target.offsetHeight*i);shouldAutoScale(e.target)&&shouldAutoScale(e.target.parentNode)&&(t=o.lazySizes.hC(e.target,"wp-block-cover")?(o.lazySizes.hC(e.target,"has-parallax")&&(r=Math.round(o.screen.width*i),n=Math.round(o.screen.height*i)),constrainSrc(t,r,n,"bg-cover")):o.lazySizes.hC(e.target,"elementor-bg")?constrainSrc(t,r,n,"bg-cover"):constrainSrc(t,r,n,"bg")),e.target.style.backgroundImage="url("+(l.test(t)?JSON.stringify(t):t)+")"}},!1))});
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: optimize, image, convert, webp, resize, compress, lazy load, optimization,
|
|
5 |
Requires at least: 5.3
|
6 |
Tested up to: 5.6
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 6.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,6 +132,15 @@ 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 |
= 6.0.1 =
|
136 |
* changed: more reliable Cloudflare detection for WebP delivery methods
|
137 |
* fixed: lazy load for external CSS breaking div elements in JS/JSON
|
5 |
Requires at least: 5.3
|
6 |
Tested up to: 5.6
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 6.0.2
|
9 |
License: GPLv3
|
10 |
|
11 |
Smaller Images, Faster Sites, Happier Visitors. Comprehensive image optimization that doesn't require a degree in rocket science.
|
132 |
* Feature requests can be viewed and submitted on our [feedback portal](https://feedback.ewww.io)
|
133 |
* If you would like to help translate this plugin in your language, [join the team](https://translate.wordpress.org/projects/wp-plugins/ewww-image-optimizer/)
|
134 |
|
135 |
+
= 6.0.2 =
|
136 |
+
* security: new version of PNGOUT available on settings page (if enabled)
|
137 |
+
* added: compatibility with Phoenix Media Rename plugin
|
138 |
+
* changed: Easy IO supports img tags with SVG images
|
139 |
+
* fixed: bulk optimizer gives incorrect message about not enough credits for unlimited plans
|
140 |
+
* fixed: db install workaround for MariaDB 10.4 bug
|
141 |
+
* fixed: errors with custom db setups when DB_* constants are not defined
|
142 |
+
* fixed: error with JS WebP when a class attribute with no value is encountered
|
143 |
+
|
144 |
= 6.0.1 =
|
145 |
* changed: more reliable Cloudflare detection for WebP delivery methods
|
146 |
* fixed: lazy load for external CSS breaking div elements in JS/JSON
|
unique.php
CHANGED
@@ -1139,6 +1139,15 @@ function ewww_image_optimizer_md5check( $path ) {
|
|
1139 |
'12afd90e04387d4c3be985042c1eada89e0c4504f84c0b4739c459c7b3831774', // 20150319-mac/pngout.
|
1140 |
'843f0be42e86680c1663c4ef58eb0677ace15fc29ab23897c83f4b7e5af3ef36', // 20150319-windows/pngout.exe 20150319.
|
1141 |
'aa3993937455094c0f66ac77d60bf53be441fdf8f14618520c2af68f2253085d', // 20150920-mac/pngout.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1142 |
// end pngout.
|
1143 |
'8417d5d60bc66442ecc666e31ec7b9e1b7c55f48291e74b4b81f35703e2aef2e', // pngquant-fbsd 2.0.2, EWWW 1.8.3.
|
1144 |
'78668c38d0be70764b18f3f4e0ea2b647df2ae87cedb2216d0ef69c8c55b688a', // pngquant-linux 2.0.2, EWWW 1.8.3.
|
@@ -3022,7 +3031,7 @@ function ewww_image_optimizer_install_pngout() {
|
|
3022 |
if ( PHP_OS === 'FreeBSD' ) {
|
3023 |
$os_string = 'bsd';
|
3024 |
}
|
3025 |
-
$latest = '
|
3026 |
$tool_path = trailingslashit( EWWW_IMAGE_OPTIMIZER_TOOL_PATH );
|
3027 |
if ( empty( $pngout_error ) ) {
|
3028 |
if ( PHP_OS === 'Linux' || PHP_OS === 'FreeBSD' ) {
|
@@ -3036,6 +3045,9 @@ function ewww_image_optimizer_install_pngout() {
|
|
3036 |
$arch_type = 'i686';
|
3037 |
if ( ewww_image_optimizer_function_exists( 'php_uname' ) ) {
|
3038 |
$arch_type = php_uname( 'm' );
|
|
|
|
|
|
|
3039 |
}
|
3040 |
|
3041 |
$tmpname = current( explode( '.', $download_result ) );
|
@@ -3069,10 +3081,11 @@ function ewww_image_optimizer_install_pngout() {
|
|
3069 |
}
|
3070 |
}
|
3071 |
}
|
3072 |
-
}
|
3073 |
-
|
3074 |
-
$
|
3075 |
-
$
|
|
|
3076 |
if ( is_wp_error( $download_result ) ) {
|
3077 |
$pngout_error = $download_result->get_error_message();
|
3078 |
} else {
|
@@ -3080,20 +3093,28 @@ function ewww_image_optimizer_install_pngout() {
|
|
3080 |
$pngout_error = __( 'insufficient memory available for installation', 'ewww-image-optimizer' );
|
3081 |
} else {
|
3082 |
$tmpname = current( explode( '.', $download_result ) );
|
3083 |
-
$tmpname .= '-' . uniqid() . '.
|
3084 |
rename( $download_result, $tmpname );
|
3085 |
$download_result = $tmpname;
|
3086 |
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3097 |
if ( empty( $pngout_error ) ) {
|
3098 |
$pngout_error = __( 'could not move pngout', 'ewww-image-optimizer' );
|
3099 |
}
|
@@ -3104,6 +3125,8 @@ function ewww_image_optimizer_install_pngout() {
|
|
3104 |
}
|
3105 |
}
|
3106 |
$pngout_version = ewww_image_optimizer_tool_found( ewww_image_optimizer_escapeshellarg( $tool_path ) . 'pngout-static', 'p' );
|
|
|
|
|
3107 |
} else {
|
3108 |
$pngout_error = __( 'extraction of files failed', 'ewww-image-optimizer' );
|
3109 |
}
|
1139 |
'12afd90e04387d4c3be985042c1eada89e0c4504f84c0b4739c459c7b3831774', // 20150319-mac/pngout.
|
1140 |
'843f0be42e86680c1663c4ef58eb0677ace15fc29ab23897c83f4b7e5af3ef36', // 20150319-windows/pngout.exe 20150319.
|
1141 |
'aa3993937455094c0f66ac77d60bf53be441fdf8f14618520c2af68f2253085d', // 20150920-mac/pngout.
|
1142 |
+
'0b1483c00f495d6341bb3d5941d14184c8c3be68d140470828b6bc1183d815a6', // 20200115-bsd/i686/pngout
|
1143 |
+
'42af74a2a2ea71234d9098d1e405ed7b0e402e6b3334c86bb2d25c733143e53b', // 20200115-bsd/amd64/pngout
|
1144 |
+
'6d6c3b9d821e5562e68511e8daeaf7a239afdfb2587e520df47f5dfa673a8008', // 20200115-bsd-static/i686/pngout-static
|
1145 |
+
'30c8043dbcff879a060c463d7ea1aa253344eedaafbf62687956f589f94bdcb0', // 20200115-bsd-static/amd64/pngout-static
|
1146 |
+
'8b9eb97b000592844725def8ede4e45c15cad83c5accd672dad76cf9c47e52cd', // 20200115-linux/i686/pngout
|
1147 |
+
'c509286fccedd7529b32dfdee2b39906f06d35350034df6dfbf75a4c7dc9a0b5', // 20200115-linux/amd64/pngout
|
1148 |
+
'fcac0af92eca59a87ed8d446ab707cdf39d8c7961e0feab27b5bec862d1b11d5', // 20200115-linux-static/i686/pngout-static
|
1149 |
+
'9339c71b57dc71cf4d7c1d027383b76c1f426305ae8b7557d0d68f1ca396a06c', // 20200115-linux-static/amd64/pngout-static
|
1150 |
+
'020c15f908f26aac59988eff77296e57b546cc0e784746efb9ec84e4316edca1', // 20200115-macos/pngout
|
1151 |
// end pngout.
|
1152 |
'8417d5d60bc66442ecc666e31ec7b9e1b7c55f48291e74b4b81f35703e2aef2e', // pngquant-fbsd 2.0.2, EWWW 1.8.3.
|
1153 |
'78668c38d0be70764b18f3f4e0ea2b647df2ae87cedb2216d0ef69c8c55b688a', // pngquant-linux 2.0.2, EWWW 1.8.3.
|
3031 |
if ( PHP_OS === 'FreeBSD' ) {
|
3032 |
$os_string = 'bsd';
|
3033 |
}
|
3034 |
+
$latest = '20200115';
|
3035 |
$tool_path = trailingslashit( EWWW_IMAGE_OPTIMIZER_TOOL_PATH );
|
3036 |
if ( empty( $pngout_error ) ) {
|
3037 |
if ( PHP_OS === 'Linux' || PHP_OS === 'FreeBSD' ) {
|
3045 |
$arch_type = 'i686';
|
3046 |
if ( ewww_image_optimizer_function_exists( 'php_uname' ) ) {
|
3047 |
$arch_type = php_uname( 'm' );
|
3048 |
+
if ( 'x86_64' === $arch_type ) {
|
3049 |
+
$arch_type = 'amd64';
|
3050 |
+
}
|
3051 |
}
|
3052 |
|
3053 |
$tmpname = current( explode( '.', $download_result ) );
|
3081 |
}
|
3082 |
}
|
3083 |
}
|
3084 |
+
} elseif ( PHP_OS === 'Darwin' ) {
|
3085 |
+
$latest = '20200115';
|
3086 |
+
$os_ext = 'tar.gz';
|
3087 |
+
$os_ext = 'zip';
|
3088 |
+
$download_result = download_url( 'http://static.jonof.id.au/dl/kenutils/pngout-' . $latest . '-macos.' . $os_ext );
|
3089 |
if ( is_wp_error( $download_result ) ) {
|
3090 |
$pngout_error = $download_result->get_error_message();
|
3091 |
} else {
|
3093 |
$pngout_error = __( 'insufficient memory available for installation', 'ewww-image-optimizer' );
|
3094 |
} else {
|
3095 |
$tmpname = current( explode( '.', $download_result ) );
|
3096 |
+
$tmpname .= '-' . uniqid() . '.' . $os_ext;
|
3097 |
rename( $download_result, $tmpname );
|
3098 |
$download_result = $tmpname;
|
3099 |
|
3100 |
+
if ( 'zip' === $os_ext ) {
|
3101 |
+
WP_Filesystem();
|
3102 |
+
$unzipped = unzip_file(
|
3103 |
+
$download_result,
|
3104 |
+
EWWW_IMAGE_OPTIMIZER_BINARY_PATH
|
3105 |
+
);
|
3106 |
+
} else {
|
3107 |
+
$pngout_gzipped = new PharData( $download_result );
|
3108 |
+
$pngout_tarball = $pngout_gzipped->decompress();
|
3109 |
+
$download_result = $pngout_tarball->getPath();
|
3110 |
+
$pngout_tarball->extractTo(
|
3111 |
+
EWWW_IMAGE_OPTIMIZER_BINARY_PATH,
|
3112 |
+
'pngout-' . $latest . '-darwin/pngout',
|
3113 |
+
true
|
3114 |
+
);
|
3115 |
+
}
|
3116 |
+
if ( ewwwio_is_file( EWWW_IMAGE_OPTIMIZER_BINARY_PATH . 'pngout-' . $latest . '-macos/pngout' ) ) {
|
3117 |
+
if ( ! rename( EWWW_IMAGE_OPTIMIZER_BINARY_PATH . 'pngout-' . $latest . '-macos/pngout', $tool_path . 'pngout-static' ) ) {
|
3118 |
if ( empty( $pngout_error ) ) {
|
3119 |
$pngout_error = __( 'could not move pngout', 'ewww-image-optimizer' );
|
3120 |
}
|
3125 |
}
|
3126 |
}
|
3127 |
$pngout_version = ewww_image_optimizer_tool_found( ewww_image_optimizer_escapeshellarg( $tool_path ) . 'pngout-static', 'p' );
|
3128 |
+
} elseif ( ! empty( $unzipped ) && is_wp_error( $unzipped ) ) {
|
3129 |
+
$pngout_error = $unzipped->get_error_message();
|
3130 |
} else {
|
3131 |
$pngout_error = __( 'extraction of files failed', 'ewww-image-optimizer' );
|
3132 |
}
|