Version Description
- Partnership with Shortpixel
- fix crash bug when uploading non Image document in library (while log enabled)
Download this release
Release Info
Developer | resmushit |
Plugin | reSmush.it Image Optimizer |
Version | 0.4.10 |
Comparing to | |
See all releases |
Code changes from version 0.4.9 to 0.4.10
- css/resmushit.css +35 -1
- js/script.js +18 -0
- readme.txt +4 -1
- resmushit.admin.php +4 -0
- resmushit.php +80 -9
- resmushit.settings.php +1 -1
css/resmushit.css
CHANGED
@@ -40,24 +40,58 @@
|
|
40 |
.rsmt-panels .brdr-black{
|
41 |
border-left: 4px solid #222222
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
.rsmt-panels h2{
|
44 |
text-transform: uppercase;
|
45 |
font-family: 'Roboto Slab', serif;
|
46 |
font-size: 1.5em;
|
47 |
color:#4B4B4B;
|
48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
.rsmt-panels img{
|
50 |
max-width: 100%;
|
51 |
}
|
|
|
|
|
|
|
|
|
52 |
.rsmt-panels em{
|
53 |
font-weight: bold;
|
54 |
font-style: normal;
|
55 |
}
|
|
|
56 |
.rsmt-panels ul {
|
57 |
list-style-type: disc;
|
58 |
list-style-position: inside;
|
59 |
}
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
.rsmt-settings .setting-row{
|
63 |
margin-bottom: 20px;
|
40 |
.rsmt-panels .brdr-black{
|
41 |
border-left: 4px solid #222222
|
42 |
}
|
43 |
+
.rsmt-panels .brdr-dashed{
|
44 |
+
border: 2px dashed #7cd7e5;
|
45 |
+
padding: 5px 10px;
|
46 |
+
}
|
47 |
+
.rsmt-notice .no-uppercase,
|
48 |
+
.rsmt-panels .no-uppercase {
|
49 |
+
text-transform: none;
|
50 |
+
}
|
51 |
+
.rsmt-notice h4,
|
52 |
.rsmt-panels h2{
|
53 |
text-transform: uppercase;
|
54 |
font-family: 'Roboto Slab', serif;
|
55 |
font-size: 1.5em;
|
56 |
color:#4B4B4B;
|
57 |
}
|
58 |
+
.rsmt-notice h4{
|
59 |
+
text-transform: uppercase;
|
60 |
+
font-family: 'Roboto Slab', serif;
|
61 |
+
font-size: 1.5em;
|
62 |
+
color:#4B4B4B;
|
63 |
+
}
|
64 |
+
|
65 |
+
.rsmt-notice img {
|
66 |
+
max-width: 400px;
|
67 |
+
}
|
68 |
.rsmt-panels img{
|
69 |
max-width: 100%;
|
70 |
}
|
71 |
+
.rsmt-notice {
|
72 |
+
padding: 10px;
|
73 |
+
}
|
74 |
+
.rsmt-notice em,
|
75 |
.rsmt-panels em{
|
76 |
font-weight: bold;
|
77 |
font-style: normal;
|
78 |
}
|
79 |
+
.rsmt-notice ul,
|
80 |
.rsmt-panels ul {
|
81 |
list-style-type: disc;
|
82 |
list-style-position: inside;
|
83 |
}
|
84 |
+
.rsmt-notice .txt-through,
|
85 |
+
.rsmt-panels .txt-through{
|
86 |
+
text-decoration:line-through;
|
87 |
+
}
|
88 |
+
.rsmt-panels .extra-padding{
|
89 |
+
padding: 2px 5px;
|
90 |
+
}
|
91 |
+
.rsmt-notice .txt-center,
|
92 |
+
.rsmt-panels .txt-center{
|
93 |
+
text-align: center
|
94 |
+
}
|
95 |
|
96 |
.rsmt-settings .setting-row{
|
97 |
margin-bottom: 20px;
|
js/script.js
CHANGED
@@ -8,6 +8,24 @@ var next_index = 0;
|
|
8 |
var file_too_big_count = 0;
|
9 |
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Form Validators
|
13 |
*/
|
8 |
var file_too_big_count = 0;
|
9 |
|
10 |
|
11 |
+
/**
|
12 |
+
* Notice
|
13 |
+
*/
|
14 |
+
jQuery(document).delegate(".rsmt-notice button.notice-dismiss","mouseup",function(e){
|
15 |
+
var current = this;
|
16 |
+
var csrf_token = jQuery(current).parent().attr('data-csrf');
|
17 |
+
jQuery.post(
|
18 |
+
ajaxurl, {
|
19 |
+
action: 'resmushit_notice_close',
|
20 |
+
csrf: csrf_token
|
21 |
+
},
|
22 |
+
function(response) {
|
23 |
+
var data = jQuery.parseJSON(response);
|
24 |
+
}
|
25 |
+
);
|
26 |
+
});
|
27 |
+
|
28 |
+
|
29 |
/**
|
30 |
* Form Validators
|
31 |
*/
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: resmushit
|
|
3 |
Tags: image, optimizer, image optimization, resmush.it, smush, jpg, png, gif, optimization, compression, Compress, Images, Pictures, Reduce Image Size, Smush, Smush.it
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 6.1.0
|
6 |
-
Stable tag: 0.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -74,6 +74,9 @@ Yes ! Absolutely free, the only restriction is to send images below 5MB.
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
|
|
|
|
|
|
77 |
|
78 |
= 0.4.9 =
|
79 |
* Compatibility with WP 6.1.0
|
3 |
Tags: image, optimizer, image optimization, resmush.it, smush, jpg, png, gif, optimization, compression, Compress, Images, Pictures, Reduce Image Size, Smush, Smush.it
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 6.1.0
|
6 |
+
Stable tag: 0.4.10
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 0.4.10 =
|
78 |
+
* Partnership with Shortpixel
|
79 |
+
* fix crash bug when uploading non Image document in library (while log enabled)
|
80 |
|
81 |
= 0.4.9 =
|
82 |
* Compatibility with WP 6.1.0
|
resmushit.admin.php
CHANGED
@@ -29,6 +29,7 @@ function resmushit_settings_declare() {
|
|
29 |
register_setting( 'resmushit-settings', 'resmushit_cron' );
|
30 |
register_setting( 'resmushit-settings', 'resmushit_preserve_exif' );
|
31 |
register_setting( 'resmushit-settings', 'resmushit_remove_unsmushed' );
|
|
|
32 |
}
|
33 |
add_action( 'admin_init', 'resmushit_settings_declare' );
|
34 |
|
@@ -154,6 +155,9 @@ function resmushit_register_plugin_assets(){
|
|
154 |
$allowed_pages = array( 'media_page_resmushit_options',
|
155 |
'upload',
|
156 |
'post',
|
|
|
|
|
|
|
157 |
'attachment');
|
158 |
|
159 |
if ( function_exists( 'get_current_screen' ) ) {
|
29 |
register_setting( 'resmushit-settings', 'resmushit_cron' );
|
30 |
register_setting( 'resmushit-settings', 'resmushit_preserve_exif' );
|
31 |
register_setting( 'resmushit-settings', 'resmushit_remove_unsmushed' );
|
32 |
+
register_setting( 'resmushit-settings', 'resmushit_notice_close' );
|
33 |
}
|
34 |
add_action( 'admin_init', 'resmushit_settings_declare' );
|
35 |
|
155 |
$allowed_pages = array( 'media_page_resmushit_options',
|
156 |
'upload',
|
157 |
'post',
|
158 |
+
'plugins',
|
159 |
+
'edit-post',
|
160 |
+
'media',
|
161 |
'attachment');
|
162 |
|
163 |
if ( function_exists( 'get_current_screen' ) ) {
|
resmushit.php
CHANGED
@@ -10,8 +10,8 @@
|
|
10 |
* Plugin Name: reSmush.it Image Optimizer
|
11 |
* Plugin URI: https://wordpress.org/plugins/resmushit-image-optimizer/
|
12 |
* Description: Image Optimization API. Provides image size optimization
|
13 |
-
* Version: 0.4.
|
14 |
-
* Timestamp: 2022.11.
|
15 |
* Author: reSmush.it
|
16 |
* Author URI: https://resmush.it
|
17 |
* Author: Charles Bourgeaux
|
@@ -69,6 +69,8 @@ function resmushit_activate() {
|
|
69 |
update_option( 'resmushit_remove_unsmushed', 0 );
|
70 |
if(get_option('resmushit_has_no_backup_files') === false || get_option('resmushit_has_no_backup_files') == "")
|
71 |
update_option( 'resmushit_has_no_backup_files', 0 );
|
|
|
|
|
72 |
}
|
73 |
}
|
74 |
register_activation_hook( __FILE__, 'resmushit_activate' );
|
@@ -108,27 +110,29 @@ function resmushit_process_images($attachments, $force_keep_original = TRUE) {
|
|
108 |
|
109 |
$fileInfo = pathinfo(get_attached_file( $attachment_id ));
|
110 |
if(!isset($fileInfo['dirname'])) {
|
111 |
-
rlog("Error! Incorrect file provided." . print_r($fileInfo), 'WARNING');
|
112 |
return $attachments;
|
113 |
}
|
114 |
$basepath = $fileInfo['dirname'] . '/';
|
115 |
$extension = isset($fileInfo['extension']) ? $fileInfo['extension'] : NULL;
|
116 |
|
|
|
|
|
|
|
|
|
|
|
117 |
if(!isset($attachments[ 'file' ])) {
|
118 |
-
rlog("Error! Incorrect attachment
|
119 |
return $attachments;
|
120 |
}
|
121 |
$basefile = basename($attachments[ 'file' ]);
|
122 |
|
123 |
-
|
124 |
-
if( !in_array(strtolower($extension), resmushit::authorizedExtensions()) ) {
|
125 |
-
return $attachments;
|
126 |
-
}
|
127 |
|
128 |
$statistics[] = reSmushit::optimize($basepath . $basefile, $force_keep_original );
|
129 |
|
130 |
if(!isset($attachments[ 'sizes' ])) {
|
131 |
-
rlog("Error! Unable to find attachments sizes." . print_r($attachments), 'WARNING');
|
132 |
return $attachments;
|
133 |
}
|
134 |
foreach($attachments['sizes'] as $image_style) {
|
@@ -560,6 +564,73 @@ function resmushit_restore_backup_files() {
|
|
560 |
add_action( 'wp_ajax_resmushit_restore_backup_files', 'resmushit_restore_backup_files' );
|
561 |
|
562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
|
564 |
/**
|
565 |
*
|
10 |
* Plugin Name: reSmush.it Image Optimizer
|
11 |
* Plugin URI: https://wordpress.org/plugins/resmushit-image-optimizer/
|
12 |
* Description: Image Optimization API. Provides image size optimization
|
13 |
+
* Version: 0.4.10
|
14 |
+
* Timestamp: 2022.11.08
|
15 |
* Author: reSmush.it
|
16 |
* Author URI: https://resmush.it
|
17 |
* Author: Charles Bourgeaux
|
69 |
update_option( 'resmushit_remove_unsmushed', 0 );
|
70 |
if(get_option('resmushit_has_no_backup_files') === false || get_option('resmushit_has_no_backup_files') == "")
|
71 |
update_option( 'resmushit_has_no_backup_files', 0 );
|
72 |
+
if(get_option('resmushit_notice_close') === false || get_option('resmushit_notice_close') == "")
|
73 |
+
update_option( 'resmushit_notice_close', 0 );
|
74 |
}
|
75 |
}
|
76 |
register_activation_hook( __FILE__, 'resmushit_activate' );
|
110 |
|
111 |
$fileInfo = pathinfo(get_attached_file( $attachment_id ));
|
112 |
if(!isset($fileInfo['dirname'])) {
|
113 |
+
rlog("Error! Incorrect file provided." . print_r($fileInfo, TRUE), 'WARNING');
|
114 |
return $attachments;
|
115 |
}
|
116 |
$basepath = $fileInfo['dirname'] . '/';
|
117 |
$extension = isset($fileInfo['extension']) ? $fileInfo['extension'] : NULL;
|
118 |
|
119 |
+
// Optimize only pictures/files accepted by the API
|
120 |
+
if( !in_array(strtolower($extension), resmushit::authorizedExtensions()) ) {
|
121 |
+
return $attachments;
|
122 |
+
}
|
123 |
+
|
124 |
if(!isset($attachments[ 'file' ])) {
|
125 |
+
rlog("Error! Incorrect attachment " . print_r($attachments, TRUE), 'WARNING');
|
126 |
return $attachments;
|
127 |
}
|
128 |
$basefile = basename($attachments[ 'file' ]);
|
129 |
|
130 |
+
|
|
|
|
|
|
|
131 |
|
132 |
$statistics[] = reSmushit::optimize($basepath . $basefile, $force_keep_original );
|
133 |
|
134 |
if(!isset($attachments[ 'sizes' ])) {
|
135 |
+
rlog("Error! Unable to find attachments sizes." . print_r($attachments, TRUE), 'WARNING');
|
136 |
return $attachments;
|
137 |
}
|
138 |
foreach($attachments['sizes'] as $image_style) {
|
564 |
add_action( 'wp_ajax_resmushit_restore_backup_files', 'resmushit_restore_backup_files' );
|
565 |
|
566 |
|
567 |
+
/**
|
568 |
+
*
|
569 |
+
* add Ajax action to close permanently notice
|
570 |
+
*
|
571 |
+
* @param none
|
572 |
+
* @return json object
|
573 |
+
*/
|
574 |
+
function resmushit_notice_close() {
|
575 |
+
$return = FALSE;
|
576 |
+
if ( !isset($_REQUEST['csrf']) || ! wp_verify_nonce( $_REQUEST['csrf'], 'notice_close' ) ) {
|
577 |
+
wp_send_json(json_encode(array('error' => 'Invalid CSRF token')));
|
578 |
+
die();
|
579 |
+
}
|
580 |
+
if(!is_super_admin() && !current_user_can('administrator')) {
|
581 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
582 |
+
die();
|
583 |
+
}
|
584 |
+
if(update_option( 'resmushit_notice_close', 1 )) {
|
585 |
+
$return = TRUE;
|
586 |
+
}
|
587 |
+
wp_send_json(json_encode(array('status' => $return)));
|
588 |
+
die();
|
589 |
+
}
|
590 |
+
add_action( 'wp_ajax_resmushit_notice_close', 'resmushit_notice_close' );
|
591 |
+
|
592 |
+
|
593 |
+
/**
|
594 |
+
*
|
595 |
+
* add Notice information for Shortpixel offer
|
596 |
+
*
|
597 |
+
* @param none
|
598 |
+
* @return json object
|
599 |
+
*/
|
600 |
+
function resmushit_general_admin_notice(){
|
601 |
+
// Expired offer
|
602 |
+
if(time() > strtotime("21 November 2022")) {
|
603 |
+
return FALSE;
|
604 |
+
}
|
605 |
+
// Already seen notice
|
606 |
+
if(get_option('resmushit_notice_close') == 1) {
|
607 |
+
return FALSE;
|
608 |
+
}
|
609 |
+
$allowed_pages = array(
|
610 |
+
'media_page_resmushit_options',
|
611 |
+
'upload',
|
612 |
+
'plugins',
|
613 |
+
'edit-post',
|
614 |
+
'media',
|
615 |
+
'attachment');
|
616 |
+
|
617 |
+
if ( function_exists( 'get_current_screen' ) ) {
|
618 |
+
$current_page = get_current_screen();
|
619 |
+
}
|
620 |
+
|
621 |
+
if ( isset( $current_page->id ) && in_array( $current_page->id, $allowed_pages ) ) {
|
622 |
+
echo "
|
623 |
+
<div class='notice notice-success is-dismissible rsmt-notice' data-csrf='" . wp_create_nonce( 'notice_close' ) . "' data-dismissible='disable-done-notice-forever' data-notice='resmushit-notice-shortpixel'>
|
624 |
+
<div class='txt-center'><img src='". RESMUSHIT_BASE_URL . "images/shortpixel-resmushit.png' /></div>
|
625 |
+
<div class='extra-padding'><h4 class='no-uppercase'>Limited time, unique offer in partnership with <a target='_blank' href='https://www.shortpixel.com' title='Shortpixel'>ShortPixel</a></h4> <ul><li><em>Unlimited</em> monthly credits</li><li>Optimize All your website's JPEG, PNG, (animated)GIF and PDFs with ShortPixel's SmartCompress algorithms.</li><li>Generate <em>next-gen image</em> <a href='https://shortpixel.com/blog/how-webp-images-can-speed-up-your-site/' title='How WebP can speed up your website' target='_blank'>format WebP</a> for ALL your images.</li><li>No size limit</li><li><em><a href='https://status.shortpixel.com/' target='_blank' title='Status page of Shortpixel'>99.9%</a></em> service availability</li></ul> </div>
|
626 |
+
<div class='txt-center'><a class='button button-primary' target='_blank' href='https://unlimited.shortpixel.com' title='Subscribe to the premium offer'>Subscribe for <span class='txt-through'>$41.66</span> $9.99/mo until Nov 20th</a></div>
|
627 |
+
|
628 |
+
</div>";
|
629 |
+
}
|
630 |
+
|
631 |
+
}
|
632 |
+
add_action('admin_notices', 'resmushit_general_admin_notice');
|
633 |
+
|
634 |
|
635 |
/**
|
636 |
*
|
resmushit.settings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
|
4 |
-
define('RESMUSHIT_VERSION', '0.4.
|
5 |
define('RESMUSHIT_DEFAULT_QLTY', '92');
|
6 |
define('RESMUSHIT_TIMEOUT', '10');
|
7 |
define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
|
1 |
<?php
|
2 |
|
3 |
define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
|
4 |
+
define('RESMUSHIT_VERSION', '0.4.10');
|
5 |
define('RESMUSHIT_DEFAULT_QLTY', '92');
|
6 |
define('RESMUSHIT_TIMEOUT', '10');
|
7 |
define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
|