SG Optimizer - Version 5.4.2

Version Description

Download this release

Release Info

Developer sstoqnov
Plugin Icon 128x128 SG Optimizer
Version 5.4.2
Comparing to
See all releases

Code changes from version 5.4.1 to 5.4.2

core/Images_Optimizer/Images_Optimizer_Webp.php CHANGED
@@ -35,15 +35,13 @@ class Images_Optimizer_Webp {
35
  add_action( 'wp_ajax_siteground_optimizer_start_webp_conversion', array( $this, 'start_conversion' ) );
36
  add_action( 'siteground_optimizer_start_webp_conversion_cron', array( $this, 'start_conversion' ) );
37
 
38
- add_action( 'delete_attachment', array( $this, 'delete_webp_copy' ) );
39
- add_action( 'edit_attachment', array( $this, 'regenerate_webp_copy' ) );
40
-
41
-
42
  // Optimize newly uploaded images.
43
  if (
44
  Options::is_enabled( 'siteground_optimizer_webp_support' ) &&
45
  0 === Helper::is_cron_disabled()
46
  ) {
 
 
47
  add_action( 'wp_generate_attachment_metadata', array( $this, 'optimize_new_image' ), 10, 2 );
48
  } else {
49
  add_action( 'wp_generate_attachment_metadata', array( $this, 'maybe_update_total_non_converted_images' ) );
@@ -437,12 +435,14 @@ class Images_Optimizer_Webp {
437
  $files = array( $main_image . '.webp' );
438
  $basename = basename( $main_image );
439
 
440
- // Loop through all image sizes and optimize them as well.
441
- foreach ( $metadata['sizes'] as $size ) {
442
- $sizes[] = str_replace( $basename, $size['file'], $main_image ) . '.webp';
 
 
443
  }
444
 
445
- exec( 'rm ' . implode( ' ', $sizes ) );
446
  }
447
 
448
  /**
35
  add_action( 'wp_ajax_siteground_optimizer_start_webp_conversion', array( $this, 'start_conversion' ) );
36
  add_action( 'siteground_optimizer_start_webp_conversion_cron', array( $this, 'start_conversion' ) );
37
 
 
 
 
 
38
  // Optimize newly uploaded images.
39
  if (
40
  Options::is_enabled( 'siteground_optimizer_webp_support' ) &&
41
  0 === Helper::is_cron_disabled()
42
  ) {
43
+ add_action( 'delete_attachment', array( $this, 'delete_webp_copy' ) );
44
+ add_action( 'edit_attachment', array( $this, 'regenerate_webp_copy' ) );
45
  add_action( 'wp_generate_attachment_metadata', array( $this, 'optimize_new_image' ), 10, 2 );
46
  } else {
47
  add_action( 'wp_generate_attachment_metadata', array( $this, 'maybe_update_total_non_converted_images' ) );
435
  $files = array( $main_image . '.webp' );
436
  $basename = basename( $main_image );
437
 
438
+ if ( ! empty( $metadata['sizes'] ) ) {
439
+ // Loop through all image sizes and optimize them as well.
440
+ foreach ( $metadata['sizes'] as $size ) {
441
+ $files[] = str_replace( $basename, $size['file'], $main_image ) . '.webp';
442
+ }
443
  }
444
 
445
+ exec( 'rm ' . implode( ' ', $files ) );
446
  }
447
 
448
  /**
readme.txt CHANGED
@@ -171,6 +171,9 @@ Our plugin uses a cookie in order to function properly. It does not store person
171
 
172
  == Changelog ==
173
 
 
 
 
174
  = Version 5.4.1 =
175
  * Added PHP 7.4 support for PHP Compatibility Checker
176
  * Improved WebP Conversion
171
 
172
  == Changelog ==
173
 
174
+ = Version 5.4.2 =
175
+ * Fixed bug with WebP image regeneration on image delete
176
+
177
  = Version 5.4.1 =
178
  * Added PHP 7.4 support for PHP Compatibility Checker
179
  * Improved WebP Conversion
sg-cachepress.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: SG Optimizer
11
  * Plugin URI: https://siteground.com
12
  * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
13
- * Version: 5.4.1
14
  * Author: SiteGround
15
  * Author URI: https://www.siteground.com
16
  * Text Domain: sg-cachepress
@@ -31,7 +31,7 @@ if ( ! defined( 'WPINC' ) ) {
31
 
32
  // Define version constant.
33
  if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
34
- define( __NAMESPACE__ . '\VERSION', '5.4.1' );
35
  }
36
 
37
  // Define slug constant.
10
  * Plugin Name: SG Optimizer
11
  * Plugin URI: https://siteground.com
12
  * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
13
+ * Version: 5.4.2
14
  * Author: SiteGround
15
  * Author URI: https://www.siteground.com
16
  * Text Domain: sg-cachepress
31
 
32
  // Define version constant.
33
  if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
34
+ define( __NAMESPACE__ . '\VERSION', '5.4.2' );
35
  }
36
 
37
  // Define slug constant.