Smush Image Compression and Optimization - Version 3.0.1

Version Description

  • Security: Remove support for Upfront theme functions
Download this release

Release Info

Developer vanyukov
Plugin Icon 128x128 Smush Image Compression and Optimization
Version 3.0.1
Comparing to
See all releases

Code changes from version 3.0.0 to 3.0.1

core/class-wp-smush-core.php CHANGED
@@ -1091,36 +1091,4 @@ class WP_Smush_Core {
1091
  }
1092
  }
1093
 
1094
- /**
1095
- * Checks if upfront images needs to be resmushed
1096
- *
1097
- * @param array $resmush_list Resmush list.
1098
- *
1099
- * @return array Returns the list of image ids that needs to be re-smushed
1100
- */
1101
- public function get_upfront_resmush_list( $resmush_list ) {
1102
- $upfront_attachments = WP_Smush::get_instance()->core()->mod->db->get_upfront_images( $resmush_list );
1103
- if ( ! empty( $upfront_attachments ) && is_array( $upfront_attachments ) ) {
1104
- foreach ( $upfront_attachments as $u_attachment_id ) {
1105
- if ( ! in_array( $u_attachment_id, $resmush_list ) ) {
1106
- // Check if not smushed.
1107
- $upfront_images = get_post_meta( $u_attachment_id, 'upfront_used_image_sizes', true );
1108
- if ( ! empty( $upfront_images ) && is_array( $upfront_images ) ) {
1109
- // Iterate over all the images.
1110
- foreach ( $upfront_images as $image ) {
1111
- // If any of the element image is not smushed, add the id to resmush list
1112
- // and skip to next image.
1113
- if ( empty( $image['is_smushed'] ) || 1 != $image['is_smushed'] ) {
1114
- $resmush_list[] = $u_attachment_id;
1115
- break;
1116
- }
1117
- }
1118
- }
1119
- }
1120
- }
1121
- }
1122
-
1123
- return $resmush_list;
1124
- }
1125
-
1126
  }
1091
  }
1092
  }
1093
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1094
  }
core/modules/class-wp-smush-ajax.php CHANGED
@@ -391,8 +391,6 @@ class WP_Smush_Ajax extends WP_Smush_Module {
391
 
392
  // Logic: If none of the required settings is on, don't need to resmush any of the images
393
  // We need at least one of these settings to be on, to check if any of the image needs resmush
394
- // Allow to smush Upfront images as well.
395
- $upfront_active = class_exists( 'Upfront' );
396
 
397
  // Initialize Media Library Stats.
398
  if ( 'nextgen' !== $type && empty( $core->remaining_count ) ) {
@@ -408,7 +406,7 @@ class WP_Smush_Ajax extends WP_Smush_Module {
408
 
409
  $remaining_count = 'nextgen' === $type ? $core->nextgen->ng_admin->remaining_count : $core->remaining_count;
410
 
411
- if ( 0 == $remaining_count && ! $core->mod->smush->lossy_enabled && ! $core->mod->smush->smush_original && $core->mod->smush->keep_exif && ! $upfront_active ) {
412
  delete_option( $key );
413
  delete_site_option( WP_SMUSH_PREFIX . 'run_recheck' );
414
  wp_send_json_success( array( 'notice' => $resp ) );
@@ -518,11 +516,6 @@ class WP_Smush_Ajax extends WP_Smush_Module {
518
  }
519
  }// End of Foreach Loop
520
 
521
- // Check for Upfront images that needs to be smushed.
522
- if ( $upfront_active && 'nextgen' !== $type ) {
523
- $resmush_list = $core->get_upfront_resmush_list( $resmush_list );
524
- }//End Of Upfront loop
525
-
526
  // Store the resmush list in Options table.
527
  update_option( $key, $resmush_list, false );
528
  }
391
 
392
  // Logic: If none of the required settings is on, don't need to resmush any of the images
393
  // We need at least one of these settings to be on, to check if any of the image needs resmush
 
 
394
 
395
  // Initialize Media Library Stats.
396
  if ( 'nextgen' !== $type && empty( $core->remaining_count ) ) {
406
 
407
  $remaining_count = 'nextgen' === $type ? $core->nextgen->ng_admin->remaining_count : $core->remaining_count;
408
 
409
+ if ( 0 == $remaining_count && ! $core->mod->smush->lossy_enabled && ! $core->mod->smush->smush_original && $core->mod->smush->keep_exif ) {
410
  delete_option( $key );
411
  delete_site_option( WP_SMUSH_PREFIX . 'run_recheck' );
412
  wp_send_json_success( array( 'notice' => $resp ) );
516
  }
517
  }// End of Foreach Loop
518
 
 
 
 
 
 
519
  // Store the resmush list in Options table.
520
  update_option( $key, $resmush_list, false );
521
  }
core/modules/class-wp-smush-db.php CHANGED
@@ -810,38 +810,6 @@ class WP_Smush_DB {
810
  return $lossy_attachments;
811
  }
812
 
813
- /**
814
- * Get the attachment IDs with Upfront images
815
- *
816
- * @param array $skip_ids Skip IDs.
817
- *
818
- * @return array|bool
819
- */
820
- public function get_upfront_images( $skip_ids = array() ) {
821
- $query = array(
822
- 'fields' => array( 'ids', 'post_mime_type' ),
823
- 'post_type' => 'attachment',
824
- 'post_status' => 'any',
825
- 'order' => 'ASC',
826
- 'posts_per_page' => - 1,
827
- 'meta_key' => 'upfront_used_image_sizes',
828
- 'no_found_rows' => true,
829
- );
830
-
831
- // Skip all the ids which are already in resmush list.
832
- if ( ! empty( $skip_ids ) && is_array( $skip_ids ) ) {
833
- $query['post__not_in'] = $skip_ids;
834
- }
835
-
836
- $results = new WP_Query( $query );
837
-
838
- if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
839
- return $this->filter_by_mime( $results->posts );
840
- }
841
-
842
- return false;
843
- }
844
-
845
  /**
846
  * Get the savings for the given set of attachments
847
  *
810
  return $lossy_attachments;
811
  }
812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  /**
814
  * Get the savings for the given set of attachments
815
  *
core/modules/class-wp-smushit.php CHANGED
@@ -1376,8 +1376,6 @@ class WP_Smushit extends WP_Smush_Module {
1376
  $stats['stats']['keep_exif'] = ! empty( $response['data']->keep_exif ) ? $response['data']->keep_exif : 0;
1377
  }
1378
  }
1379
- // Upfront Integration.
1380
- $stats = $this->smush_upfront_images( $id, $stats );
1381
  } else {
1382
  $smush_full = true;
1383
  }
@@ -1482,71 +1480,6 @@ class WP_Smushit extends WP_Smush_Module {
1482
  return $meta;
1483
  }
1484
 
1485
- /**
1486
- * Smushes the upfront images and Updates the respective stats.
1487
- *
1488
- * @param int $attachment_id Attachment ID.
1489
- * @param array $stats Stats array.
1490
- *
1491
- * @return mixed
1492
- */
1493
- private function smush_upfront_images( $attachment_id, $stats ) {
1494
- // Check if upfront is active or not.
1495
- if ( empty( $attachment_id ) || ! class_exists( 'Upfront' ) ) {
1496
- return $stats;
1497
- }
1498
-
1499
- // Set attachment id and Media type.
1500
- $this->attachment_id = $attachment_id;
1501
- $this->media_type = 'upfront';
1502
-
1503
- // Get post meta to check for Upfront images.
1504
- $upfront_images = get_post_meta( $attachment_id, 'upfront_used_image_sizes', true );
1505
-
1506
- // If there is no upfront meta for the image.
1507
- if ( ! $upfront_images || empty( $upfront_images ) || ! is_array( $upfront_images ) ) {
1508
- return $stats;
1509
- }
1510
- // Loop over all the images in upfront meta.
1511
- foreach ( $upfront_images as $element_id => $image ) {
1512
- if ( isset( $image['is_smushed'] ) && 1 == $image['is_smushed'] ) {
1513
- continue;
1514
- }
1515
-
1516
- /**
1517
- * Skip phar files. Potential phar vulnerability.
1518
- */
1519
- $ext = substr( $image['path'], 0,4 );
1520
- if ( 'phar' === strtolower( $ext ) ) {
1521
- continue;
1522
- }
1523
-
1524
- // Get the image path and smush it.
1525
- if ( isset( $image['path'] ) && file_exists( $image['path'] ) ) {
1526
- $res = $this->do_smushit( $image['path'] );
1527
- // If sizes key is not yet initialised.
1528
- if ( empty( $stats['sizes'] ) ) {
1529
- $stats['sizes'] = array();
1530
- }
1531
-
1532
- // If the smushing was successful.
1533
- if ( ! is_wp_error( $res ) && ! empty( $res['data'] ) ) {
1534
- if ( $res['data']->bytes_saved > 0 ) {
1535
- // Update attachment stats.
1536
- $stats['sizes'][ $element_id ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $res['data'] );
1537
- }
1538
-
1539
- // Update upfront stats for the element id.
1540
- $upfront_images[ $element_id ]['is_smushed'] = 1;
1541
- }
1542
- }
1543
- }
1544
- // Finally Update the upfront meta key.
1545
- update_post_meta( $attachment_id, 'upfront_used_image_sizes', $upfront_images );
1546
-
1547
- return $stats;
1548
- }
1549
-
1550
  /**
1551
  * Calculate saving percentage from existing and current stats
1552
  *
1376
  $stats['stats']['keep_exif'] = ! empty( $response['data']->keep_exif ) ? $response['data']->keep_exif : 0;
1377
  }
1378
  }
 
 
1379
  } else {
1380
  $smush_full = true;
1381
  }
1480
  return $meta;
1481
  }
1482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1483
  /**
1484
  * Calculate saving percentage from existing and current stats
1485
  *
languages/wp-smushit.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Smush 3.0.0\n"
6
  "Report-Msgid-Bugs-To: https://wpmudev.org\n"
7
- "POT-Creation-Date: 2018-12-10 04:53:31+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -49,7 +49,7 @@ msgstr ""
49
  #: core/integrations/class-wp-smush-s3.php:242
50
  #: core/modules/class-wp-smush-ajax.php:361
51
  #: core/modules/class-wp-smush-ajax.php:382
52
- #: core/modules/class-wp-smush-ajax.php:570
53
  msgid "Dismiss"
54
  msgstr ""
55
 
@@ -1373,7 +1373,7 @@ msgid "NextGen Gallery"
1373
  msgstr ""
1374
 
1375
  #: core/integrations/class-wp-smush-nextgen.php:146
1376
- #: core/modules/class-wp-smush-ajax.php:716
1377
  msgid "No attachment ID was received"
1378
  msgstr ""
1379
 
@@ -1537,30 +1537,30 @@ msgstr ""
1537
  msgid "Yay! All images are optimized as per your current settings."
1538
  msgstr ""
1539
 
1540
- #: core/modules/class-wp-smush-ajax.php:564
1541
  msgid ""
1542
  "Image check complete, you have %1$d images that need smushing. %2$sBulk "
1543
  "smush now!%3$s"
1544
  msgstr ""
1545
 
1546
- #: core/modules/class-wp-smush-ajax.php:728
1547
  msgid ""
1548
  "You've reached the %1$d attachment limit for bulk smushing in the free "
1549
  "version. Upgrade to Pro to smush unlimited images, or click resume to smush "
1550
  "another %2$d attachments."
1551
  msgstr ""
1552
 
1553
- #: core/modules/class-wp-smush-ajax.php:758
1554
  msgid "Skipped with wp_smush_image filter"
1555
  msgstr ""
1556
 
1557
- #: core/modules/class-wp-smush-ajax.php:824
1558
  msgid ""
1559
  "Timeout error. You can increase the request timeout to make sure Smush has "
1560
  "enough time to process larger files. `define('WP_SMUSH_API_TIMEOUT', 150);`"
1561
  msgstr ""
1562
 
1563
- #: core/modules/class-wp-smush-ajax.php:914
1564
  msgid "User can not modify options"
1565
  msgstr ""
1566
 
@@ -1795,7 +1795,7 @@ msgstr ""
1795
  msgid "Image couldn't be smushed"
1796
  msgstr ""
1797
 
1798
- #: core/modules/class-wp-smushit.php:1807
1799
  #. translators: %s: number of thumbnails
1800
  msgid ""
1801
  "When you upload an image to WordPress it automatically creates %s thumbnail "
@@ -1807,13 +1807,13 @@ msgid ""
1807
  "\t\t\toverride this."
1808
  msgstr ""
1809
 
1810
- #: core/modules/class-wp-smushit.php:1819
1811
  msgid ""
1812
  "Image couldn't be smushed as it exceeded the 1Mb size limit,\n"
1813
  "\t\t\tPro users can smush images with size up to 32Mb."
1814
  msgstr ""
1815
 
1816
- #: core/modules/class-wp-smushit.php:1826
1817
  msgid " Skipped"
1818
  msgstr ""
1819
 
2
  # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Smush 3.0.1\n"
6
  "Report-Msgid-Bugs-To: https://wpmudev.org\n"
7
+ "POT-Creation-Date: 2018-12-10 14:24:10+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
49
  #: core/integrations/class-wp-smush-s3.php:242
50
  #: core/modules/class-wp-smush-ajax.php:361
51
  #: core/modules/class-wp-smush-ajax.php:382
52
+ #: core/modules/class-wp-smush-ajax.php:563
53
  msgid "Dismiss"
54
  msgstr ""
55
 
1373
  msgstr ""
1374
 
1375
  #: core/integrations/class-wp-smush-nextgen.php:146
1376
+ #: core/modules/class-wp-smush-ajax.php:709
1377
  msgid "No attachment ID was received"
1378
  msgstr ""
1379
 
1537
  msgid "Yay! All images are optimized as per your current settings."
1538
  msgstr ""
1539
 
1540
+ #: core/modules/class-wp-smush-ajax.php:557
1541
  msgid ""
1542
  "Image check complete, you have %1$d images that need smushing. %2$sBulk "
1543
  "smush now!%3$s"
1544
  msgstr ""
1545
 
1546
+ #: core/modules/class-wp-smush-ajax.php:721
1547
  msgid ""
1548
  "You've reached the %1$d attachment limit for bulk smushing in the free "
1549
  "version. Upgrade to Pro to smush unlimited images, or click resume to smush "
1550
  "another %2$d attachments."
1551
  msgstr ""
1552
 
1553
+ #: core/modules/class-wp-smush-ajax.php:751
1554
  msgid "Skipped with wp_smush_image filter"
1555
  msgstr ""
1556
 
1557
+ #: core/modules/class-wp-smush-ajax.php:817
1558
  msgid ""
1559
  "Timeout error. You can increase the request timeout to make sure Smush has "
1560
  "enough time to process larger files. `define('WP_SMUSH_API_TIMEOUT', 150);`"
1561
  msgstr ""
1562
 
1563
+ #: core/modules/class-wp-smush-ajax.php:907
1564
  msgid "User can not modify options"
1565
  msgstr ""
1566
 
1795
  msgid "Image couldn't be smushed"
1796
  msgstr ""
1797
 
1798
+ #: core/modules/class-wp-smushit.php:1740
1799
  #. translators: %s: number of thumbnails
1800
  msgid ""
1801
  "When you upload an image to WordPress it automatically creates %s thumbnail "
1807
  "\t\t\toverride this."
1808
  msgstr ""
1809
 
1810
+ #: core/modules/class-wp-smushit.php:1752
1811
  msgid ""
1812
  "Image couldn't be smushed as it exceeded the 1Mb size limit,\n"
1813
  "\t\t\tPro users can smush images with size up to 32Mb."
1814
  msgstr ""
1815
 
1816
+ #: core/modules/class-wp-smushit.php:1759
1817
  msgid " Skipped"
1818
  msgstr ""
1819
 
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === Smush Image Compression and Optimization ===
2
  Plugin Name: Smush Image Compression and Optimization
3
- Version: 3.0.0
4
  Author: WPMU DEV
5
  Author URI: https://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: image, resize, optimize, optimise, compress, performance, optimisation, optimise JPG, photo, pictures, optimizer, Smush WordPress Compression, Smush.it
8
  Requires at least: 4.6
9
  Tested up to: 5.0.0
10
- Stable tag: 3.0.0
11
  Requires PHP: 5.2.4
12
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
13
 
@@ -153,6 +153,10 @@ It depends what side of the pond you live on...but whether you say optimize, opt
153
 
154
  == Changelog ==
155
 
 
 
 
 
156
  = 3.0.0 =
157
 
158
  * New: Smush CDN
@@ -652,6 +656,7 @@ Fix: Compatibility issues with latest WP Offload Media (WP Offload S3) update
652
  ----------------------------------------------------------------------
653
  - First release
654
 
 
655
  == About Us ==
656
  WPMU DEV is a premium supplier of quality WordPress plugins, services and support. Learn more here:
657
  [https://premium.wpmudev.org/](https://premium.wpmudev.org/?utm_source=wordpress.org&utm_medium=readme)
1
  === Smush Image Compression and Optimization ===
2
  Plugin Name: Smush Image Compression and Optimization
3
+ Version: 3.0.1
4
  Author: WPMU DEV
5
  Author URI: https://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: image, resize, optimize, optimise, compress, performance, optimisation, optimise JPG, photo, pictures, optimizer, Smush WordPress Compression, Smush.it
8
  Requires at least: 4.6
9
  Tested up to: 5.0.0
10
+ Stable tag: 3.0.1
11
  Requires PHP: 5.2.4
12
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
13
 
153
 
154
  == Changelog ==
155
 
156
+ = 3.0.1 =
157
+
158
+ * Security: Remove support for Upfront theme functions
159
+
160
  = 3.0.0 =
161
 
162
  * New: Smush CDN
656
  ----------------------------------------------------------------------
657
  - First release
658
 
659
+
660
  == About Us ==
661
  WPMU DEV is a premium supplier of quality WordPress plugins, services and support. Learn more here:
662
  [https://premium.wpmudev.org/](https://premium.wpmudev.org/?utm_source=wordpress.org&utm_medium=readme)
wp-smush.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: Smush
14
  * Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
15
  * Description: Reduce image file sizes, improve performance and boost your SEO using the free free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
16
- * Version: 3.0.0
17
  * Author: WPMU DEV
18
  * Author URI: https://premium.wpmudev.org/
19
  * License: GPLv2
@@ -47,7 +47,7 @@ if ( ! defined( 'WPINC' ) ) {
47
  }
48
 
49
  if ( ! defined( 'WP_SMUSH_VERSION' ) ) {
50
- define( 'WP_SMUSH_VERSION', '3.0.0' );
51
  }
52
  // Used to define body class.
53
  if ( ! defined( 'WP_SHARED_UI_VERSION' ) ) {
13
  * Plugin Name: Smush
14
  * Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
15
  * Description: Reduce image file sizes, improve performance and boost your SEO using the free free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
16
+ * Version: 3.0.1
17
  * Author: WPMU DEV
18
  * Author URI: https://premium.wpmudev.org/
19
  * License: GPLv2
47
  }
48
 
49
  if ( ! defined( 'WP_SMUSH_VERSION' ) ) {
50
+ define( 'WP_SMUSH_VERSION', '3.0.1' );
51
  }
52
  // Used to define body class.
53
  if ( ! defined( 'WP_SHARED_UI_VERSION' ) ) {