Skip to content

Commit

Permalink
Release version 1.0.2 (#14)
Browse files Browse the repository at this point in the history
Merge pull request #14 from resmushit/updates
  • Loading branch information
pdobrescu authored Mar 29, 2024
2 parents 0f509e8 + be3dfc7 commit 968335c
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 35 deletions.
4 changes: 2 additions & 2 deletions build/shortpixel/filesystem/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"license": "MIT",
"authors": [
{
"name": "Bas",
"email": "bas@weblogmechanic.com"
"name": "ShortPixel",
"email": "help@shortpixel.com"
}
],
"minimum-stability": "dev",
Expand Down
4 changes: 2 additions & 2 deletions build/shortpixel/log/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"license": "MIT",
"authors": [
{
"name": "Bas",
"email": "bas@weblogmechanic.com"
"name": "ShortPixel",
"email": "help@shortpixel.com"
}
],
"minimum-stability": "dev",
Expand Down
4 changes: 2 additions & 2 deletions build/shortpixel/notices/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"license": "MIT",
"authors": [
{
"name": "Bas",
"email": "bas@weblogmechanic.com"
"name": "ShortPixel",
"email": "help@shortpixel.com"
}
],
"minimum-stability": "dev",
Expand Down
16 changes: 14 additions & 2 deletions classes/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ public function settings_page() {
<span class='text'><?php _e('Support Us', 'resmushit-image-optimizer'); ?></span>
</a>
</span>
</li>
<li>
<span class="kofi-support">
<a href="https://wordpress.org/support/plugin/resmushit-image-optimizer/reviews/#new-post" target="_blank">
<img width="22" height="15" src="<?php echo plugins_url('images/star.png', RESMUSH_PLUGIN_FILE); ?>">
<span class="text">Rate Us</span>
</a>
</span>
</li>
</ul>

</div>
Expand Down Expand Up @@ -281,10 +290,13 @@ public function settings_page() {
<li>$9.99 / month</li>
</ul>
<div class='button-wrapper'>
<a class='button' href=" https://shortpixel.com/ms/af/C34DUIL28044" target="_blank">Buy now</a>
</div>
<a class='button' href="https://shortpixel.com/compare/resmushit-vs-shortpixel" target="_blank">Buy now</a>
</div>
<div class='link-under'>
<a href="https://shortpixel.com/compare/resmushit-vs-shortpixel" target="_blank"><?php _e('Why is premium optimization better?', 'resmushit-image-optimizer'); ?></a>
</div>
</div>
</div>

</div> <!-- // ui -->
<?php
Expand Down
2 changes: 1 addition & 1 deletion classes/Controller/CronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function cron_process() {
// required if launch through wp-cron.php
include_once( ABSPATH . 'wp-admin/includes/image.php' );

add_filter('wp_generate_attachment_metadata', array(\Resmush()->process(), 'process_images') );
add_filter('wp_generate_attachment_metadata', array(\Resmush()->process(), 'process_images'), 10, 2);
Log::addDebug('Gathering unoptimized pictures from CRON');
$unoptimized_pictures = json_decode(reSmushit::getNonOptimizedPictures(TRUE));
Log::addDebug('Found ' . count($unoptimized_pictures->nonoptimized) . ' attachments');
Expand Down
23 changes: 15 additions & 8 deletions classes/Controller/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ protected function initHooks()
//Automatically optimize images if option is checked
if(get_option('resmushit_on_upload') OR ( isset($_POST['action']) AND ($_POST['action'] === "resmushit_bulk_process_image" OR $_POST['action'] === "resmushit_optimize_single_attachment" )) OR (defined( 'WP_CLI' ) && WP_CLI ) OR ($doing_cron) )
{
Log::addTemp('Gen Attachment metadta filter set');
add_filter('wp_generate_attachment_metadata', array($this,'process_images') );
add_filter('wp_generate_attachment_metadata', array($this,'process_images'), 10, 2);
}
}

public function unHookProcessor()
{
Log::addTemp('Unhooking Process Filter');
remove_filter('wp_generate_attachment_metadata', array($this,'process_images') );
remove_filter('wp_generate_attachment_metadata', array($this,'process_images'), 10, 2 );

}

Expand Down Expand Up @@ -88,8 +87,7 @@ public function get_meta_id($result){
* @param boolean preserve original file
* @return attachment object
*/
public function process_images($attachments, $force_keep_original = TRUE) {
global $attachment_id;
public function process_images($attachments, $attachment_id) {
$cumulated_original_sizes = 0;
$cumulated_optimized_sizes = 0;
$error = FALSE;
Expand Down Expand Up @@ -121,14 +119,22 @@ public function process_images($attachments, $force_keep_original = TRUE) {
}
$basefile = basename($attachments[ 'file' ]);

$statistics[] = reSmushit::optimize($basepath . $basefile, $force_keep_original );
$statsObj = reSmushit::optimize($basepath . $basefile,true );
$attachments['filesize'] = $statsObj->dest_size;
$statistics[] = $statsObj;

if(!isset($attachments[ 'sizes' ])) {
Log::addError("Error! Unable to find image sizes." . print_r($attachments, TRUE), 'WARNING');
return $attachments;
}
foreach($attachments['sizes'] as $image_style) {
$statistics[] = reSmushit::optimize($basepath . $image_style['file'], FALSE );
foreach($attachments['sizes'] as $thumbnail_name => $image_style) {
$statsObj = reSmushit::optimize($basepath . $image_style['file'], FALSE );
// Update Filesize in the WP metadata
if (isset($attachments['sizes'][$thumbnail_name]))
{
$attachments['sizes'][$thumbnail_name]['filesize'] = $statsObj->dest_size;
}
$statistics[] = $statsObj;
}

$count = 0;
Expand All @@ -148,6 +154,7 @@ public function process_images($attachments, $force_keep_original = TRUE) {
update_post_meta($attachment_id,'resmushed_cumulated_original_sizes', $cumulated_original_sizes);
update_post_meta($attachment_id,'resmushed_cumulated_optimized_sizes', $cumulated_optimized_sizes);
}
update_post_meta( $attachment_id, '_wp_attachment_metadata', $attachments );
return $attachments;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function checkLogger()
$uploaddir = wp_upload_dir(null, false, false);
if (isset($uploaddir['basedir']))
{
$log->setLogPath($uploaddir['basedir'] . "/resmush_log");
$log->setLogPath($uploaddir['basedir'] . "/resmushit.log");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions classes/resmushit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public static function getPictureQualitySetting() {
* Optimize an image according to a filepath.
*
* @param string $file_path the path to the file on the server
* @param boolean The is_original param doesn't make any sense, since it's always true. Also before it was hooked to regenerate attachment metadata, hoping it wouldnt send a second param. This whole thing can probl. go
*
* @return bool TRUE if the resmush operation worked
*/
public static function optimize($file_path = NULL, $is_original = TRUE) {
Expand Down
21 changes: 15 additions & 6 deletions classes/resmushitUI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ public static function settingsPanel() {

echo '<table class="form-table">'
. self::addSetting("number", __("Image quality", 'resmushit-image-optimizer'), __("A lower value means a smaller image size, a higher value means better image quality. A value between 50 and 85 is normally recommended.", 'resmushit-image-optimizer'), "resmushit_qlty")

. self::addSetting("checkbox", __("Optimize on upload", 'resmushit-image-optimizer'), __("Once activated, newly uploaded images are automatically optimized.", 'resmushit-image-optimizer'), "resmushit_on_upload")
. self::addSetting("checkbox", __("Preserve EXIF", 'resmushit-image-optimizer'), __("Activate this option to retain the original EXIF data in the images.", 'resmushit-image-optimizer'), "resmushit_preserve_exif")
. self::addSetting("checkbox", __("Deactivate backup", 'resmushit-image-optimizer'), sprintf(__("If you select this option, you choose not to keep the original version of the images. This is helpful to save disk space, but we strongly recommend having a backup of the entire website on hand. <a href='%s' title='Should I remove backups?' target='_blank'>More information</a>.", "resmushit-image-optimizer"), "https://resmush.it/why-preserving-backup-files/"), "resmushit_remove_unsmushed")
. self::addSetting("checkbox", __("Optimize images using CRON", 'resmushit-image-optimizer'), sprintf(__("Image optimization is performed automatically via CRON tasks. <a href='%s' title='How to configure Cronjobs?' target='_blank'>More information</a>", 'resmushit-image-optimizer'), 'https://resmush.it/how-to-configure-cronjobs/'), "resmushit_cron")
. self::addSetting("checkbox", __("Activate logs", 'resmushit-image-optimizer'), sprintf(__("Activate logging in a file. Useful for debugging/developers. <a href='%s' title='Details about logs' target='_blank'>More information</a>", 'resmushit-image-optimizer'), 'https://resmush.it/features/'), "resmushit_logs")

. self::addSetting("checkbox", __("Generate WebP/AVIF", 'resmushit-image-optimizer'), sprintf(__("Create WebP/AVIF versions of the images. %s Request access %s ", 'resmushit-image-optimizer'), '<a href="https://resmush.it/contact/" target="_blank">', '</a>'), "resmushit_webpavif")


. self::addSetting("checkbox", __("Activate statistics", 'resmushit-image-optimizer'), __("Generates statistics about optimized images.", 'resmushit-image-optimizer'), "resmushit_statistics")
. '</table>';
submit_button();
Expand Down Expand Up @@ -166,8 +170,6 @@ public static function bulkPanel() {
$limitReached = true;
}



echo wp_kses_post("<div class='rsmt-bulk' data-csrf='" . wp_create_nonce( 'bulk_process_image' ) . "'><div class='non-optimized-wrapper $additionnalClassNeedOptimization'><h3 class='icon_message warning'>");

if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
Expand Down Expand Up @@ -204,7 +206,6 @@ public static function bulkPanel() {
echo wp_kses_post(__('Optimize all images', 'resmushit-image-optimizer'));
}


echo ("</button></p><div id='bulk_resize_image_list'></div></div>"
. "<div class='optimized-wrapper $additionnalClassNoNeedOptimization'><h3 class='icon_message ok'>"
. __('Congratulations! All your images are optimized correctly!', 'resmushit-image-optimizer')
Expand Down Expand Up @@ -339,6 +340,9 @@ public static function feedbackPanel()
<li>
<a href="https://resmush.it/how-to-configure-cronjobs/" target="_blank"><?php _e('How to configure CRON jobs','resmushit-image-optimizer'); ?></a>
</li>
<li>
<a href="https://shortpixel.com/knowledge-base/article/582-an-error-occured-during-the-optimization-self-debugging" target="_blank"><?php _e('"An error occured during the optimization" - Self debugging','resmushit-image-optimizer'); ?></a>
</li>
<p>&nbsp;</p>

<?php
Expand Down Expand Up @@ -555,17 +559,22 @@ public static function addSetting($type, $name, $extra, $machine_name) {
";
$label = "<label for='$machine_name'>$name<p>$extra</p></label>";



switch($type){
case 'text':
$output .= $label . "<input type='text' name='$machine_name' id='$machine_name' value='". get_option( $machine_name ) ."'/>";
break;
case 'number':
$output .= $label . "<span><input type='number' class='number-small' name='$machine_name' id='$machine_name' value='". get_option( $machine_name ) ."'/></span>";
$more = ($machine_name == 'resmushit_qlty') ? '&nbsp;&nbsp;<a href="https://shortpixel.com/compare/resmushit-vs-shortpixel" target="_blank">' . __('What is the best way to optimize images?', 'resmushit-image-optimizer') . '</a></p></div>' : '';

$output .= $label . "<span><input type='number' class='number-small' name='$machine_name' id='$machine_name' value='". get_option( $machine_name ) ."'/>$more</span>";
break;
case 'checkbox':
$additionnal = null;
if ( 1 == get_option( $machine_name ) ) $additionnal = 'checked="checked"';
$output .= "<input type='checkbox' name='$machine_name' id='$machine_name' value='1' ". $additionnal ."/>";
$disabled = ($machine_name == 'resmushit_webpavif') ? 'disabled' : '';
$output .= "<input type='checkbox' name='$machine_name' id='$machine_name' ' $disabled . ' value='1' ". $additionnal ."/>";
$output .= $label;
break;
default:
Expand Down
9 changes: 8 additions & 1 deletion css/resmush_admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/resmush_admin.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added images/star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: ShortPixel, resmushit
Donate link: https://ko-fi.com/resmushit
Tags: image, optimizer, image optimization, smush, free image optimization
Requires at least: 4.0.0
Tested up to: 6.4
Tested up to: 6.5
Requires PHP: 5.6
Stable tag: 1.0.1
Stable tag: 1.0.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -85,14 +85,18 @@ Yes ! Absolutely free, the only restriction is that the images must not be large

= Where do I report security bugs found in this plugin? =

Please report security bugs found in the source code of the reSmush.it Image Optimizer plugin through the [Patchstack Vulnerability Disclosure Program](https://patchs
tack.com/database/vdp/resmushit-image-optimizer). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
Please report security bugs found in the source code of the reSmush.it Image Optimizer plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/resmushit-image-optimizer). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.

== Screenshots ==

1. The simple interface

== Changelog ==
= 1.0.2 =
Release date March 29, 2024
* Fix: The new image size after compressing/restoring the image is now saved correctly in WordPress;
* Tweak: Updated the settings page and added more support links and a "Rate Us" button;

= 1.0.1 =
Release date March 12, 2024
* Fix: A PHP Notice was displayed in the logs for certain settings;
Expand Down
6 changes: 3 additions & 3 deletions resmushit.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* Plugin Name: reSmush.it Image Optimizer
* Plugin URI: https://wordpress.org/plugins/resmushit-image-optimizer/
* Description: 100% Free Image Optimizer and Compressor plugin. Fast JPEG/PNG and GIF compression.
* Version: 1.0.1
* Timestamp: 2024.03.12
* Version: 1.0.2
* Timestamp: 2024.03.29
* Author: reSmush.it
* Author URI: https://resmush.it
* Author: Charles Bourgeaux, ShortPixel
Expand All @@ -24,7 +24,7 @@

require('resmushit.inc.php');

define( 'RESMUSH_PLUGIN_VERSION', '1.0.1');
define( 'RESMUSH_PLUGIN_VERSION', '1.0.2');
define( 'RESMUSH_PLUGIN_FILE', __FILE__ );
define( 'RESMUSH_PLUGIN_PATH', plugin_dir_path(__FILE__) );

Expand Down
2 changes: 1 addition & 1 deletion resmushit.settings.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
define('RESMUSHIT_VERSION', '1.0.1');
define('RESMUSHIT_VERSION', '1.0.2');
define('RESMUSHIT_DEFAULT_QLTY', '82');
define('RESMUSHIT_TIMEOUT', '10');
define('RESMUSHIT_NEWSFEED', 'https://feed.resmush.it/');
Expand Down
10 changes: 9 additions & 1 deletion scss/resmush_admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
.button-wrapper
{
text-align: center;
margin: 36px 0 26px;
margin: 36px 0 10px;
a {
font-size: 20px;
padding: 8px 8px;
Expand All @@ -193,6 +193,14 @@
}
}
}
.link-under {
text-align: center;
a {
color: #1ABDCA;
}

margin-bottom: 16px;
}
@include breakpoint (0, 1100px)
{
max-width: 500px;
Expand Down

0 comments on commit 968335c

Please sign in to comment.