Version Description
- Security fixes : protection in a WP's way
Download this release
Release Info
Developer | resmushit |
Plugin | reSmush.it Image Optimizer |
Version | 0.4.6 |
Comparing to | |
See all releases |
Code changes from version 0.4.5 to 0.4.6
- classes/resmushit.class.php +4 -1
- classes/resmushitUI.class.php +158 -94
- readme.txt +4 -1
- resmushit.inc.php +1 -1
- resmushit.php +15 -15
- resmushit.settings.php +1 -1
classes/resmushit.class.php
CHANGED
@@ -59,7 +59,10 @@ Class reSmushit {
|
|
59 |
rlog('Error! Picture ' . str_replace(ABSPATH, '/', $file_path) . ' cannot be optimized, file size is above 5MB ('. reSmushitUI::sizeFormat(filesize($file_path)) .')', 'WARNING');
|
60 |
return false;
|
61 |
}
|
62 |
-
|
|
|
|
|
|
|
63 |
$ch = curl_init();
|
64 |
curl_setopt($ch, CURLOPT_URL, RESMUSHIT_ENDPOINT);
|
65 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
59 |
rlog('Error! Picture ' . str_replace(ABSPATH, '/', $file_path) . ' cannot be optimized, file size is above 5MB ('. reSmushitUI::sizeFormat(filesize($file_path)) .')', 'WARNING');
|
60 |
return false;
|
61 |
}
|
62 |
+
if(! in_array('curl', get_loaded_extensions())){
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
$ch = curl_init();
|
67 |
curl_setopt($ch, CURLOPT_URL, RESMUSHIT_ENDPOINT);
|
68 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
classes/resmushitUI.class.php
CHANGED
@@ -21,7 +21,7 @@ Class reSmushitUI {
|
|
21 |
*/
|
22 |
public static function fullWidthPanel($title = null, $html = null, $border = null) {
|
23 |
self::fullWidthPanelWrapper($title, $html, $border);
|
24 |
-
echo $html;
|
25 |
self::fullWidthPanelEndWrapper();
|
26 |
}
|
27 |
|
@@ -43,7 +43,7 @@ Class reSmushitUI {
|
|
43 |
if($border) {
|
44 |
$borderClass = 'brdr-'.$border;
|
45 |
}
|
46 |
-
echo "<div class='rsmt-panel w100 $borderClass'><h2>$title</h2>";
|
47 |
}
|
48 |
|
49 |
|
@@ -57,7 +57,7 @@ Class reSmushitUI {
|
|
57 |
* @return none
|
58 |
*/
|
59 |
public static function fullWidthPanelEndWrapper() {
|
60 |
-
echo "</div>";
|
61 |
}
|
62 |
|
63 |
|
@@ -87,14 +87,45 @@ Class reSmushitUI {
|
|
87 |
* @return none
|
88 |
*/
|
89 |
public static function settingsPanel() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
self::fullWidthPanelWrapper(__('Settings', 'resmushit-image-optimizer'), null, 'orange');
|
91 |
$new_label = "<span class='new'>" . __("New!", 'resmushit-image-optimizer') . "</span>";
|
92 |
-
echo '<div class="rsmt-settings">
|
93 |
-
<form method="post" action="options.php" id="rsmt-options-form">';
|
94 |
settings_fields( 'resmushit-settings' );
|
95 |
do_settings_sections( 'resmushit-settings' );
|
96 |
|
97 |
-
|
|
|
|
|
98 |
. self::addSetting("text", __("Image quality", 'resmushit-image-optimizer'), __("Default value is 92. The quality factor must be between 0 (very weak) and 100 (best quality)", 'resmushit-image-optimizer'), "resmushit_qlty")
|
99 |
. self::addSetting("checkbox", __("Optimize on upload", 'resmushit-image-optimizer'), __("All future images uploaded will be automatically optimized", 'resmushit-image-optimizer'), "resmushit_on_upload")
|
100 |
. self::addSetting("checkbox", __("Enable statistics", 'resmushit-image-optimizer'), __("Generates statistics about optimized pictures", 'resmushit-image-optimizer'), "resmushit_statistics")
|
@@ -102,9 +133,9 @@ Class reSmushitUI {
|
|
102 |
. self::addSetting("checkbox", $new_label . __("Process optimize on CRON", 'resmushit-image-optimizer'), __("Will perform image optimization process through CRON tasks", 'resmushit-image-optimizer'), "resmushit_cron")
|
103 |
. self::addSetting("checkbox", $new_label . __("Preserve EXIF", 'resmushit-image-optimizer'), __("Will preserve EXIF data during optimization", 'resmushit-image-optimizer'), "resmushit_preserve_exif")
|
104 |
. self::addSetting("checkbox", $new_label . __("Do not preserve backups", 'resmushit-image-optimizer'), sprintf(__("Will not preserve a backup of the original file (save space). <a href='%s' title='Should I remove backups?' target='_blank'>Read instructions</a> carefully before enabling.", 'resmushit-image-optimizer'), 'https://resmush.it/wordpress/why-keeping-backup-files'), "resmushit_remove_unsmushed")
|
105 |
-
. '</table>';
|
106 |
submit_button();
|
107 |
-
echo '</form></div>';
|
108 |
self::fullWidthPanelEndWrapper();
|
109 |
}
|
110 |
|
@@ -131,35 +162,41 @@ Class reSmushitUI {
|
|
131 |
$countNonOptimizedPictures .= '+';
|
132 |
}
|
133 |
|
134 |
-
echo "<div class='rsmt-bulk'><div class='non-optimized-wrapper $additionnalClassNeedOptimization'><h3 class='icon_message warning'>";
|
135 |
|
136 |
if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
|
137 |
-
echo "<em>$countNonOptimizedPictures "
|
138 |
. __('non optimized pictures will be automatically optimized', 'resmushit-image-optimizer')
|
139 |
. "</em>.</h3><p>"
|
140 |
. __('These pictures will be automatically optimized using schedule tasks (cronjobs).', 'resmushit-image-optimizer')
|
141 |
. " "
|
142 |
-
. __('Image optimization process can be launched <b>manually</b> by clicking on the button below :', 'resmushit-image-optimizer');
|
143 |
} else {
|
144 |
-
echo __('There is currently', 'resmushit-image-optimizer')
|
145 |
. " <em>$countNonOptimizedPictures "
|
146 |
. __('non optimized pictures', 'resmushit-image-optimizer')
|
147 |
. "</em>.</h3><p>"
|
148 |
-
. __('This action will resmush all pictures which have not been optimized to the good Image Quality Rate.', 'resmushit-image-optimizer');
|
149 |
}
|
150 |
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
|
154 |
-
echo __('Optimize all pictures manually', 'resmushit-image-optimizer');
|
155 |
} else {
|
156 |
-
echo __('Optimize all pictures', 'resmushit-image-optimizer');
|
157 |
}
|
158 |
|
159 |
-
echo "</button></p><div id='bulk_resize_image_list'></div></div>"
|
160 |
. "<div class='optimized-wrapper $additionnalClassNoNeedOptimization'><h3 class='icon_message ok'>"
|
161 |
. __('Congrats ! All your pictures are correctly optimized', 'resmushit-image-optimizer')
|
162 |
-
. "</h3></div></div>";
|
163 |
self::fullWidthPanelEndWrapper();
|
164 |
}
|
165 |
|
@@ -185,30 +222,30 @@ Class reSmushitUI {
|
|
185 |
$additionnalClass = 'disabled';
|
186 |
}
|
187 |
|
188 |
-
echo "<div class='rsmt-bigfiles'><div class='optimized-wrapper $additionnalClass'>
|
189 |
-
<h3 class='icon_message info'>";
|
190 |
|
191 |
if($countfilesTooBigPictures > 1) {
|
192 |
-
echo
|
193 |
} else {
|
194 |
-
echo
|
195 |
}
|
196 |
-
echo "</h3><div class='list-accordion'><h4>"
|
197 |
. __('List of files above 5MB', 'resmushit-image-optimizer')
|
198 |
-
. "</h4><ul>";
|
199 |
|
200 |
foreach($getNonOptimizedPictures->filestoobig as $file){
|
201 |
$fileInfo = pathinfo(get_attached_file( $file->ID ));
|
202 |
$filesize = reSmushitUI::sizeFormat(filesize(get_attached_file( $file->ID )));
|
203 |
|
204 |
-
echo "<li><a href='"
|
205 |
-
.
|
206 |
. "' target='_blank'>"
|
207 |
. wp_get_attachment_image($file->ID, 'thumbnail')
|
208 |
. "<span>"
|
209 |
-
.
|
210 |
}
|
211 |
-
echo '</ul></div></div></div>';
|
212 |
|
213 |
self::fullWidthPanelEndWrapper();
|
214 |
}
|
@@ -229,10 +266,10 @@ Class reSmushitUI {
|
|
229 |
self::fullWidthPanelWrapper(__('Statistics', 'resmushit-image-optimizer'), null, 'green');
|
230 |
$resmushit_stat = reSmushit::getStatistics();
|
231 |
|
232 |
-
echo "<div class='rsmt-statistics'>";
|
233 |
|
234 |
if($resmushit_stat['files_optimized'] != 0) {
|
235 |
-
echo "<p><strong>"
|
236 |
. __('Space saved :', 'resmushit-image-optimizer')
|
237 |
. "</strong> <span id='rsmt-statistics-space-saved'>"
|
238 |
. self::sizeFormat($resmushit_stat['total_saved_size'])
|
@@ -256,11 +293,11 @@ Class reSmushitUI {
|
|
256 |
. __('Total images optimized :', 'resmushit-image-optimizer')
|
257 |
. "</strong> <span id='rsmt-statistics-total-optimizations'>"
|
258 |
. $resmushit_stat['total_optimizations']
|
259 |
-
. "</span></p>";
|
260 |
} else {
|
261 |
-
echo "<p>" . __('No picture has been optimized yet ! Add pictures to your Wordpress Media Library.', 'resmushit-image-optimizer') . "</p>";
|
262 |
}
|
263 |
-
echo "</div>";
|
264 |
self::fullWidthPanelEndWrapper();
|
265 |
}
|
266 |
|
@@ -277,15 +314,20 @@ Class reSmushitUI {
|
|
277 |
return FALSE;
|
278 |
}
|
279 |
self::fullWidthPanelWrapper(__('Restore Media Library', 'resmushit-image-optimizer'), null, 'black');
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
'
|
|
|
|
|
|
|
|
|
|
|
285 |
. __('Warning! By clicking the button below, you will restore all the original pictures, as before reSmush.it Image Optimizer installation. You will not have your pictures optimized! We strongly advice to be sure to have a complete backup of your website before performing this action', 'resmushit-image-optimizer')
|
286 |
. '</strong></p><p>'
|
287 |
-
. '<input type="button" value="'. __('Restore ALL my original pictures', 'resmushit-image-optimizer') .'" class="rsmt-trigger--restore-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />'
|
288 |
-
|
289 |
self::fullWidthPanelEndWrapper();
|
290 |
}
|
291 |
|
@@ -299,46 +341,49 @@ Class reSmushitUI {
|
|
299 |
public static function newsPanel() {
|
300 |
global $wp_version;
|
301 |
|
302 |
-
echo "<div class='rsmt-news'>";
|
303 |
|
304 |
self::fullWidthPanelWrapper(__('News', 'resmushit-image-optimizer'), null, 'red');
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
315 |
if($data) {
|
316 |
foreach($data as $i=>$news) {
|
317 |
if($i > 2){
|
318 |
break;
|
319 |
}
|
320 |
|
321 |
-
echo "<div class='news-item'><span class='news-date'>"
|
322 |
. date('d/m/Y', $news->date)
|
323 |
-
. "</span>";
|
324 |
if($news->picture) {
|
325 |
-
echo "<div class='news-img'><a href='"
|
326 |
-
.
|
327 |
. "' target='_blank'><img src='"
|
328 |
-
.
|
329 |
-
. "' /></a></div>";
|
330 |
}
|
331 |
-
echo "<h3><a href='"
|
332 |
-
.
|
333 |
. "' target='_blank'>"
|
334 |
-
.
|
335 |
. "</a></h3><div class='news-content'>"
|
336 |
-
.
|
337 |
-
. "</div>";
|
338 |
}
|
339 |
}
|
340 |
|
341 |
-
echo "<div class='social'>"
|
342 |
. "<p class='datainformation'>"
|
343 |
. __('No user data nor any information is collected while requesting this news feed.', 'resmushit-image-optimizer')
|
344 |
. "<p>"
|
@@ -351,7 +396,7 @@ Class reSmushitUI {
|
|
351 |
. __('Follow reSmush.it on Twitter', 'resmushit-image-optimizer')
|
352 |
. "' href='https://www.twitter.com/resmushit' target='_blank'>"
|
353 |
. "<img src='"
|
354 |
-
. RESMUSHIT_BASE_URL . "images/twitter.png' /></a></div></div>";
|
355 |
|
356 |
self::fullWidthPanelEndWrapper();
|
357 |
}
|
@@ -376,49 +421,52 @@ Class reSmushitUI {
|
|
376 |
|
377 |
if(resmushit_get_cron_status() != 'DISABLED' && resmushit_get_cron_status() != 'OK') {
|
378 |
|
379 |
-
echo "<div class='rsmt-alert'>"
|
380 |
-
|
381 |
. __('Cronjobs seems incorrectly configured', 'resmushit-image-optimizer')
|
382 |
-
. "</h3>";
|
383 |
|
384 |
if (resmushit_get_cron_status() == 'MISCONFIGURED') {
|
385 |
-
echo "<p>"
|
386 |
. __('Cronjobs are not correctly configured. The variable <em>DISABLE_WP_CRON</em> must be set to <em>TRUE</em> in <em>wp-config.php</em>. Please install them by reading the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a>.', 'resmushit-image-optimizer')
|
387 |
. "</p><p>"
|
388 |
. __('We advice to disable Remush.it option "Process optimize on CRON" as long as Cron jobs are incorrectly set up.', 'resmushit-image-optimizer')
|
389 |
-
. "</p>";
|
390 |
} else if (resmushit_get_cron_status() == 'NEVER_RUN') {
|
391 |
-
echo "<p>"
|
392 |
. __('Cronjobs seems to have never been launched. Please install them by reading the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a>.', 'resmushit-image-optimizer')
|
393 |
-
. "</p>";
|
394 |
} else if (resmushit_get_cron_status() == 'NO_LATELY_RUN') {
|
395 |
-
echo "<p>"
|
396 |
. __('Cronjobs seems not to have run lately. Please read the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a> to install them correctly.', 'resmushit-image-optimizer')
|
397 |
. "<ul><li><em>" . __('Expected Frequency :', 'resmushit-image-optimizer') . "</em> " . __('Every', 'resmushit-image-optimizer') . " " . time_elapsed_string(RESMUSHIT_CRON_FREQUENCY) . "</li>"
|
398 |
. "<li><em>" . __('Last run :', 'resmushit-image-optimizer') . "</em> " . time_elapsed_string(time() - get_option('resmushit_cron_lastrun')) . " " . __('ago', 'resmushit-image-optimizer') . "</li></ul>"
|
399 |
-
. "</p>";
|
400 |
}
|
401 |
-
echo "</div>";
|
402 |
}
|
403 |
if(get_option('resmushit_remove_unsmushed') == 1 && get_option('resmushit_has_no_backup_files') == 0) {
|
404 |
$files_to_delete = count(detect_unsmushed_files());
|
405 |
|
406 |
if($files_to_delete) {
|
407 |
-
|
408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
. __('Backup files can be removed.', 'resmushit-image-optimizer')
|
410 |
-
. "</h3>"
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
. '</p><p>'
|
419 |
-
. '<input type="button" value="'. __('Remove backup files', 'resmushit-image-optimizer') .'" class="rsmt-trigger--remove-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />';
|
420 |
-
|
421 |
-
echo "</div>";
|
422 |
}
|
423 |
}
|
424 |
|
@@ -482,11 +530,18 @@ Class reSmushitUI {
|
|
482 |
if($wpdb->get_results($query))
|
483 |
$attachment_resmushit_disabled = 'checked';
|
484 |
|
485 |
-
$output = '<input type="checkbox" data-attachment-id="'.
|
486 |
|
487 |
if($return)
|
488 |
return $output;
|
489 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
}
|
491 |
|
492 |
|
@@ -505,16 +560,25 @@ Class reSmushitUI {
|
|
505 |
$output = '-';
|
506 |
}
|
507 |
else if(reSmushit::getAttachmentQuality($attachment_id) != reSmushit::getPictureQualitySetting())
|
508 |
-
$output = '<input type="button" value="'. __('Optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'.
|
509 |
else{
|
510 |
$statistics = reSmushit::getStatistics($attachment_id);
|
511 |
-
$output = __('Reduced by', 'resmushit-image-optimizer') . " ".
|
512 |
-
$output .= '<input type="button" value="'. __('Force re-optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'.
|
513 |
}
|
514 |
|
515 |
if($return)
|
516 |
return $output;
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
}
|
519 |
|
520 |
|
21 |
*/
|
22 |
public static function fullWidthPanel($title = null, $html = null, $border = null) {
|
23 |
self::fullWidthPanelWrapper($title, $html, $border);
|
24 |
+
echo wp_kses_post($html);
|
25 |
self::fullWidthPanelEndWrapper();
|
26 |
}
|
27 |
|
43 |
if($border) {
|
44 |
$borderClass = 'brdr-'.$border;
|
45 |
}
|
46 |
+
echo wp_kses_post("<div class='rsmt-panel w100 $borderClass'><h2>$title</h2>");
|
47 |
}
|
48 |
|
49 |
|
57 |
* @return none
|
58 |
*/
|
59 |
public static function fullWidthPanelEndWrapper() {
|
60 |
+
echo wp_kses_post("</div>");
|
61 |
}
|
62 |
|
63 |
|
87 |
* @return none
|
88 |
*/
|
89 |
public static function settingsPanel() {
|
90 |
+
$allowed_html = array(
|
91 |
+
'input' => array(
|
92 |
+
'type' => array(),
|
93 |
+
'name' => array(),
|
94 |
+
'value' => array(),
|
95 |
+
'checked' => array(),
|
96 |
+
'class' => array(),
|
97 |
+
'id' => array()
|
98 |
+
),
|
99 |
+
'form' => array(
|
100 |
+
'method' => array(),
|
101 |
+
'action' => array(),
|
102 |
+
'id' => array()
|
103 |
+
),
|
104 |
+
'div' => array(
|
105 |
+
'class' => array(),
|
106 |
+
),
|
107 |
+
'span' => array(
|
108 |
+
'class' => array(),
|
109 |
+
),
|
110 |
+
'table' => array(
|
111 |
+
'class' => array(),
|
112 |
+
),
|
113 |
+
'label' => array(
|
114 |
+
'class' => array(),
|
115 |
+
),
|
116 |
+
'p' => array()
|
117 |
+
);
|
118 |
+
|
119 |
self::fullWidthPanelWrapper(__('Settings', 'resmushit-image-optimizer'), null, 'orange');
|
120 |
$new_label = "<span class='new'>" . __("New!", 'resmushit-image-optimizer') . "</span>";
|
121 |
+
echo wp_kses('<div class="rsmt-settings">
|
122 |
+
<form method="post" action="options.php" id="rsmt-options-form">', $allowed_html);
|
123 |
settings_fields( 'resmushit-settings' );
|
124 |
do_settings_sections( 'resmushit-settings' );
|
125 |
|
126 |
+
|
127 |
+
|
128 |
+
echo wp_kses('<table class="form-table">'
|
129 |
. self::addSetting("text", __("Image quality", 'resmushit-image-optimizer'), __("Default value is 92. The quality factor must be between 0 (very weak) and 100 (best quality)", 'resmushit-image-optimizer'), "resmushit_qlty")
|
130 |
. self::addSetting("checkbox", __("Optimize on upload", 'resmushit-image-optimizer'), __("All future images uploaded will be automatically optimized", 'resmushit-image-optimizer'), "resmushit_on_upload")
|
131 |
. self::addSetting("checkbox", __("Enable statistics", 'resmushit-image-optimizer'), __("Generates statistics about optimized pictures", 'resmushit-image-optimizer'), "resmushit_statistics")
|
133 |
. self::addSetting("checkbox", $new_label . __("Process optimize on CRON", 'resmushit-image-optimizer'), __("Will perform image optimization process through CRON tasks", 'resmushit-image-optimizer'), "resmushit_cron")
|
134 |
. self::addSetting("checkbox", $new_label . __("Preserve EXIF", 'resmushit-image-optimizer'), __("Will preserve EXIF data during optimization", 'resmushit-image-optimizer'), "resmushit_preserve_exif")
|
135 |
. self::addSetting("checkbox", $new_label . __("Do not preserve backups", 'resmushit-image-optimizer'), sprintf(__("Will not preserve a backup of the original file (save space). <a href='%s' title='Should I remove backups?' target='_blank'>Read instructions</a> carefully before enabling.", 'resmushit-image-optimizer'), 'https://resmush.it/wordpress/why-keeping-backup-files'), "resmushit_remove_unsmushed")
|
136 |
+
. '</table>', $allowed_html);
|
137 |
submit_button();
|
138 |
+
echo wp_kses('</form></div>', $allowed_html);
|
139 |
self::fullWidthPanelEndWrapper();
|
140 |
}
|
141 |
|
162 |
$countNonOptimizedPictures .= '+';
|
163 |
}
|
164 |
|
165 |
+
echo wp_kses_post("<div class='rsmt-bulk'><div class='non-optimized-wrapper $additionnalClassNeedOptimization'><h3 class='icon_message warning'>");
|
166 |
|
167 |
if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
|
168 |
+
echo wp_kses_post("<em>$countNonOptimizedPictures "
|
169 |
. __('non optimized pictures will be automatically optimized', 'resmushit-image-optimizer')
|
170 |
. "</em>.</h3><p>"
|
171 |
. __('These pictures will be automatically optimized using schedule tasks (cronjobs).', 'resmushit-image-optimizer')
|
172 |
. " "
|
173 |
+
. __('Image optimization process can be launched <b>manually</b> by clicking on the button below :', 'resmushit-image-optimizer'));
|
174 |
} else {
|
175 |
+
echo wp_kses_post(__('There is currently', 'resmushit-image-optimizer')
|
176 |
. " <em>$countNonOptimizedPictures "
|
177 |
. __('non optimized pictures', 'resmushit-image-optimizer')
|
178 |
. "</em>.</h3><p>"
|
179 |
+
. __('This action will resmush all pictures which have not been optimized to the good Image Quality Rate.', 'resmushit-image-optimizer'));
|
180 |
}
|
181 |
|
182 |
+
$allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array(
|
183 |
+
'button' => array(
|
184 |
+
'class' => array(),
|
185 |
+
'onclick' => array()
|
186 |
+
)));
|
187 |
+
|
188 |
+
echo wp_kses("</p><p class='submit' id='bulk-resize-examine-button'><button class='button-primary' onclick='resmushit_bulk_resize(\"bulk_resize_image_list\");'>", $allowed_html);
|
189 |
|
190 |
if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
|
191 |
+
echo wp_kses_post(__('Optimize all pictures manually', 'resmushit-image-optimizer'));
|
192 |
} else {
|
193 |
+
echo wp_kses_post(__('Optimize all pictures', 'resmushit-image-optimizer'));
|
194 |
}
|
195 |
|
196 |
+
echo wp_kses_post("</button></p><div id='bulk_resize_image_list'></div></div>"
|
197 |
. "<div class='optimized-wrapper $additionnalClassNoNeedOptimization'><h3 class='icon_message ok'>"
|
198 |
. __('Congrats ! All your pictures are correctly optimized', 'resmushit-image-optimizer')
|
199 |
+
. "</h3></div></div>");
|
200 |
self::fullWidthPanelEndWrapper();
|
201 |
}
|
202 |
|
222 |
$additionnalClass = 'disabled';
|
223 |
}
|
224 |
|
225 |
+
echo wp_kses_post("<div class='rsmt-bigfiles'><div class='optimized-wrapper $additionnalClass'>
|
226 |
+
<h3 class='icon_message info'>");
|
227 |
|
228 |
if($countfilesTooBigPictures > 1) {
|
229 |
+
echo esc_html($countfilesTooBigPictures . ' ' . __('pictures are too big (> 5MB) for the optimizer', 'resmushit-image-optimizer'));
|
230 |
} else {
|
231 |
+
echo esc_html($countfilesTooBigPictures . ' ' . __('picture is too big (> 5MB) for the optimizer', 'resmushit-image-optimizer'));
|
232 |
}
|
233 |
+
echo wp_kses_post("</h3><div class='list-accordion'><h4>"
|
234 |
. __('List of files above 5MB', 'resmushit-image-optimizer')
|
235 |
+
. "</h4><ul>");
|
236 |
|
237 |
foreach($getNonOptimizedPictures->filestoobig as $file){
|
238 |
$fileInfo = pathinfo(get_attached_file( $file->ID ));
|
239 |
$filesize = reSmushitUI::sizeFormat(filesize(get_attached_file( $file->ID )));
|
240 |
|
241 |
+
echo wp_kses_post("<li><a href='"
|
242 |
+
. esc_url(wp_get_attachment_url( $file->ID ))
|
243 |
. "' target='_blank'>"
|
244 |
. wp_get_attachment_image($file->ID, 'thumbnail')
|
245 |
. "<span>"
|
246 |
+
. $fileInfo['basename'] . ' (' . $filesize . ').</span></a></li>');
|
247 |
}
|
248 |
+
echo wp_kses_post('</ul></div></div></div>');
|
249 |
|
250 |
self::fullWidthPanelEndWrapper();
|
251 |
}
|
266 |
self::fullWidthPanelWrapper(__('Statistics', 'resmushit-image-optimizer'), null, 'green');
|
267 |
$resmushit_stat = reSmushit::getStatistics();
|
268 |
|
269 |
+
echo wp_kses_post("<div class='rsmt-statistics'>");
|
270 |
|
271 |
if($resmushit_stat['files_optimized'] != 0) {
|
272 |
+
echo wp_kses_post("<p><strong>"
|
273 |
. __('Space saved :', 'resmushit-image-optimizer')
|
274 |
. "</strong> <span id='rsmt-statistics-space-saved'>"
|
275 |
. self::sizeFormat($resmushit_stat['total_saved_size'])
|
293 |
. __('Total images optimized :', 'resmushit-image-optimizer')
|
294 |
. "</strong> <span id='rsmt-statistics-total-optimizations'>"
|
295 |
. $resmushit_stat['total_optimizations']
|
296 |
+
. "</span></p>");
|
297 |
} else {
|
298 |
+
echo wp_kses_post("<p>" . __('No picture has been optimized yet ! Add pictures to your Wordpress Media Library.', 'resmushit-image-optimizer') . "</p>");
|
299 |
}
|
300 |
+
echo wp_kses_post("</div>");
|
301 |
self::fullWidthPanelEndWrapper();
|
302 |
}
|
303 |
|
314 |
return FALSE;
|
315 |
}
|
316 |
self::fullWidthPanelWrapper(__('Restore Media Library', 'resmushit-image-optimizer'), null, 'black');
|
317 |
+
$allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array(
|
318 |
+
'input' => array(
|
319 |
+
'type' => array(),
|
320 |
+
'value' => array(),
|
321 |
+
'class' => array(),
|
322 |
+
'name' => array()
|
323 |
+
)));
|
324 |
+
|
325 |
+
echo wp_kses("<div class='rsmt-restore'>"
|
326 |
+
. '<p><strong>'
|
327 |
. __('Warning! By clicking the button below, you will restore all the original pictures, as before reSmush.it Image Optimizer installation. You will not have your pictures optimized! We strongly advice to be sure to have a complete backup of your website before performing this action', 'resmushit-image-optimizer')
|
328 |
. '</strong></p><p>'
|
329 |
+
. '<input type="button" value="'. __('Restore ALL my original pictures', 'resmushit-image-optimizer') .'" class="rsmt-trigger--restore-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />'
|
330 |
+
. '</div>', $allowed_html);
|
331 |
self::fullWidthPanelEndWrapper();
|
332 |
}
|
333 |
|
341 |
public static function newsPanel() {
|
342 |
global $wp_version;
|
343 |
|
344 |
+
echo wp_kses_post("<div class='rsmt-news'>");
|
345 |
|
346 |
self::fullWidthPanelWrapper(__('News', 'resmushit-image-optimizer'), null, 'red');
|
347 |
+
if(in_array('curl', get_loaded_extensions())){
|
348 |
+
$ch = curl_init();
|
349 |
+
curl_setopt($ch, CURLOPT_URL, RESMUSHIT_NEWSFEED);
|
350 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
351 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
352 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
353 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
354 |
+
$data_raw = curl_exec($ch);
|
355 |
+
curl_close($ch);
|
356 |
+
$data = json_decode($data_raw);
|
357 |
+
} else {
|
358 |
+
$data = [];
|
359 |
+
}
|
360 |
if($data) {
|
361 |
foreach($data as $i=>$news) {
|
362 |
if($i > 2){
|
363 |
break;
|
364 |
}
|
365 |
|
366 |
+
echo wp_kses_post("<div class='news-item'><span class='news-date'>"
|
367 |
. date('d/m/Y', $news->date)
|
368 |
+
. "</span>");
|
369 |
if($news->picture) {
|
370 |
+
echo wp_kses_post("<div class='news-img'><a href='"
|
371 |
+
. esc_url($news->link)
|
372 |
. "' target='_blank'><img src='"
|
373 |
+
. esc_url($news->picture)
|
374 |
+
. "' /></a></div>");
|
375 |
}
|
376 |
+
echo wp_kses_post("<h3><a href='"
|
377 |
+
. esc_url($news->link)
|
378 |
. "' target='_blank'>"
|
379 |
+
. $news->title
|
380 |
. "</a></h3><div class='news-content'>"
|
381 |
+
. $news->content
|
382 |
+
. "</div>");
|
383 |
}
|
384 |
}
|
385 |
|
386 |
+
echo wp_kses_post("<div class='social'>"
|
387 |
. "<p class='datainformation'>"
|
388 |
. __('No user data nor any information is collected while requesting this news feed.', 'resmushit-image-optimizer')
|
389 |
. "<p>"
|
396 |
. __('Follow reSmush.it on Twitter', 'resmushit-image-optimizer')
|
397 |
. "' href='https://www.twitter.com/resmushit' target='_blank'>"
|
398 |
. "<img src='"
|
399 |
+
. RESMUSHIT_BASE_URL . "images/twitter.png' /></a></div></div>");
|
400 |
|
401 |
self::fullWidthPanelEndWrapper();
|
402 |
}
|
421 |
|
422 |
if(resmushit_get_cron_status() != 'DISABLED' && resmushit_get_cron_status() != 'OK') {
|
423 |
|
424 |
+
echo wp_kses_post("<div class='rsmt-alert'>"
|
425 |
+
. "<h3 class='icon_message warning'>"
|
426 |
. __('Cronjobs seems incorrectly configured', 'resmushit-image-optimizer')
|
427 |
+
. "</h3>");
|
428 |
|
429 |
if (resmushit_get_cron_status() == 'MISCONFIGURED') {
|
430 |
+
echo wp_kses_post("<p>"
|
431 |
. __('Cronjobs are not correctly configured. The variable <em>DISABLE_WP_CRON</em> must be set to <em>TRUE</em> in <em>wp-config.php</em>. Please install them by reading the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a>.', 'resmushit-image-optimizer')
|
432 |
. "</p><p>"
|
433 |
. __('We advice to disable Remush.it option "Process optimize on CRON" as long as Cron jobs are incorrectly set up.', 'resmushit-image-optimizer')
|
434 |
+
. "</p>");
|
435 |
} else if (resmushit_get_cron_status() == 'NEVER_RUN') {
|
436 |
+
echo wp_kses_post("<p>"
|
437 |
. __('Cronjobs seems to have never been launched. Please install them by reading the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a>.', 'resmushit-image-optimizer')
|
438 |
+
. "</p>");
|
439 |
} else if (resmushit_get_cron_status() == 'NO_LATELY_RUN') {
|
440 |
+
echo wp_kses_post("<p>"
|
441 |
. __('Cronjobs seems not to have run lately. Please read the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a> to install them correctly.', 'resmushit-image-optimizer')
|
442 |
. "<ul><li><em>" . __('Expected Frequency :', 'resmushit-image-optimizer') . "</em> " . __('Every', 'resmushit-image-optimizer') . " " . time_elapsed_string(RESMUSHIT_CRON_FREQUENCY) . "</li>"
|
443 |
. "<li><em>" . __('Last run :', 'resmushit-image-optimizer') . "</em> " . time_elapsed_string(time() - get_option('resmushit_cron_lastrun')) . " " . __('ago', 'resmushit-image-optimizer') . "</li></ul>"
|
444 |
+
. "</p>");
|
445 |
}
|
446 |
+
echo wp_kses_post("</div>");
|
447 |
}
|
448 |
if(get_option('resmushit_remove_unsmushed') == 1 && get_option('resmushit_has_no_backup_files') == 0) {
|
449 |
$files_to_delete = count(detect_unsmushed_files());
|
450 |
|
451 |
if($files_to_delete) {
|
452 |
+
$allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array(
|
453 |
+
'input' => array(
|
454 |
+
'type' => array(),
|
455 |
+
'value' => array(),
|
456 |
+
'class' => array(),
|
457 |
+
'name' => array(),
|
458 |
+
)));
|
459 |
+
echo wp_kses("<div class='rsmt-alert'>"
|
460 |
+
. "<h3 class='icon_message warning'>"
|
461 |
. __('Backup files can be removed.', 'resmushit-image-optimizer')
|
462 |
+
. "</h3>"
|
463 |
+
. '<p>'
|
464 |
+
. sprintf(__('Keep these files and turn off "Do not preserve backups" option if you want to restore your unoptimized files in the future. Please <a href="%s" title="Should I remove backups? target="_blank">read instructions</a> before clicking.', 'resmushit-image-optimizer'), 'https://resmush.it/wordpress/why-keeping-backup-files')
|
465 |
+
. '</p><p>'
|
466 |
+
. sprintf( __( 'We have found %s files ready to be removed', 'resmushit-image-optimizer' ), count(detect_unsmushed_files()) )
|
467 |
+
. '</p><p>'
|
468 |
+
. '<input type="button" value="'. __('Remove backup files', 'resmushit-image-optimizer') .'" class="rsmt-trigger--remove-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />'
|
469 |
+
. "</div>", $allowed_html);
|
|
|
|
|
|
|
|
|
470 |
}
|
471 |
}
|
472 |
|
530 |
if($wpdb->get_results($query))
|
531 |
$attachment_resmushit_disabled = 'checked';
|
532 |
|
533 |
+
$output = '<input type="checkbox" data-attachment-id="'. $id .'"" class="rsmt-trigger--disabled-checkbox" '. $attachment_resmushit_disabled .' />';
|
534 |
|
535 |
if($return)
|
536 |
return $output;
|
537 |
+
|
538 |
+
$allowed_html = array(
|
539 |
+
'input' => array(
|
540 |
+
'type' => array(),
|
541 |
+
'data-attachment-id' => array(),
|
542 |
+
'checked' => array(),
|
543 |
+
));
|
544 |
+
echo wp_kses($output, $allowed_html);
|
545 |
}
|
546 |
|
547 |
|
560 |
$output = '-';
|
561 |
}
|
562 |
else if(reSmushit::getAttachmentQuality($attachment_id) != reSmushit::getPictureQualitySetting())
|
563 |
+
$output = '<input type="button" value="'. __('Optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'. $attachment_id .'" class="button wp-smush-send" />';
|
564 |
else{
|
565 |
$statistics = reSmushit::getStatistics($attachment_id);
|
566 |
+
$output = __('Reduced by', 'resmushit-image-optimizer') . " ". $statistics['total_saved_size_nice'] ." (". $statistics['percent_reduction'] . ' ' . __('saved', 'resmushit-image-optimizer') . ")";
|
567 |
+
$output .= '<input type="button" value="'. __('Force re-optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'. $attachment_id .'" class="button wp-smush-send" />';
|
568 |
}
|
569 |
|
570 |
if($return)
|
571 |
return $output;
|
572 |
+
$allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array(
|
573 |
+
'input' => array(
|
574 |
+
'type' => array(),
|
575 |
+
'value' => array(),
|
576 |
+
'class' => array(),
|
577 |
+
'name' => array(),
|
578 |
+
'data-attachment-id' => array(),
|
579 |
+
'checked' => array(),
|
580 |
+
)));
|
581 |
+
echo wp_kses($output, $allowed_html);
|
582 |
}
|
583 |
|
584 |
|
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.0.2
|
6 |
-
Stable tag: 0.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -75,6 +75,9 @@ Yes ! Absolutely free, the only restriction is to send images below 5MB.
|
|
75 |
== Changelog ==
|
76 |
|
77 |
|
|
|
|
|
|
|
78 |
= 0.4.5 =
|
79 |
* Security fixes : prevent XSS breachs
|
80 |
|
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.0.2
|
6 |
+
Stable tag: 0.4.6
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
75 |
== Changelog ==
|
76 |
|
77 |
|
78 |
+
= 0.4.6 =
|
79 |
+
* Security fixes : protection in a WP's way
|
80 |
+
|
81 |
= 0.4.5 =
|
82 |
* Security fixes : prevent XSS breachs
|
83 |
|
resmushit.inc.php
CHANGED
@@ -30,7 +30,7 @@ function rlog($str, $level = 'SUCCESS') {
|
|
30 |
case 'SUCCESS':
|
31 |
$prefix = "[\033[32m+\033[0m]"; break;
|
32 |
}
|
33 |
-
echo "$prefix $str\n";
|
34 |
}
|
35 |
|
36 |
if(get_option('resmushit_logs') == 0)
|
30 |
case 'SUCCESS':
|
31 |
$prefix = "[\033[32m+\033[0m]"; break;
|
32 |
}
|
33 |
+
echo esc_html("$prefix $str\n");
|
34 |
}
|
35 |
|
36 |
if(get_option('resmushit_logs') == 0)
|
resmushit.php
CHANGED
@@ -10,7 +10,7 @@
|
|
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.09.13
|
15 |
* Author: reSmush.it
|
16 |
* Author URI: https://resmush.it
|
@@ -194,10 +194,10 @@ if(get_option('resmushit_on_upload'))
|
|
194 |
*/
|
195 |
function resmushit_bulk_get_images() {
|
196 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
197 |
-
|
198 |
die();
|
199 |
}
|
200 |
-
|
201 |
die();
|
202 |
}
|
203 |
add_action( 'wp_ajax_resmushit_bulk_get_images', 'resmushit_bulk_get_images' );
|
@@ -214,11 +214,11 @@ add_action( 'wp_ajax_resmushit_bulk_get_images', 'resmushit_bulk_get_images' );
|
|
214 |
*/
|
215 |
function resmushit_update_disabled_state() {
|
216 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
217 |
-
|
218 |
die();
|
219 |
}
|
220 |
if(isset($_POST['data']['id']) && $_POST['data']['id'] != null && isset($_POST['data']['disabled'])){
|
221 |
-
echo
|
222 |
}
|
223 |
die();
|
224 |
}
|
@@ -237,12 +237,12 @@ add_action( 'wp_ajax_resmushit_update_disabled_state', 'resmushit_update_disable
|
|
237 |
*/
|
238 |
function resmushit_optimize_single_attachment() {
|
239 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
240 |
-
|
241 |
die();
|
242 |
}
|
243 |
if(isset($_POST['data']['id']) && $_POST['data']['id'] != null){
|
244 |
reSmushit::revert(sanitize_text_field((int)$_POST['data']['id']));
|
245 |
-
|
246 |
}
|
247 |
die();
|
248 |
}
|
@@ -261,11 +261,11 @@ add_action( 'wp_ajax_resmushit_optimize_single_attachment', 'resmushit_optimize_
|
|
261 |
*/
|
262 |
function resmushit_bulk_process_image() {
|
263 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
264 |
-
|
265 |
die();
|
266 |
}
|
267 |
rlog('Bulk optimization launched for file : ' . get_attached_file( sanitize_text_field((int)$_POST['data']['ID']) ));
|
268 |
-
echo
|
269 |
die();
|
270 |
}
|
271 |
add_action( 'wp_ajax_resmushit_bulk_process_image', 'resmushit_bulk_process_image' );
|
@@ -283,12 +283,12 @@ add_action( 'wp_ajax_resmushit_bulk_process_image', 'resmushit_bulk_process_imag
|
|
283 |
*/
|
284 |
function resmushit_update_statistics() {
|
285 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
286 |
-
|
287 |
die();
|
288 |
}
|
289 |
$output = reSmushit::getStatistics();
|
290 |
$output['total_saved_size_formatted'] = reSmushitUI::sizeFormat($output['total_saved_size']);
|
291 |
-
|
292 |
die();
|
293 |
}
|
294 |
add_action( 'wp_ajax_resmushit_update_statistics', 'resmushit_update_statistics' );
|
@@ -453,7 +453,7 @@ add_action('update_option_resmushit_remove_unsmushed', 'resmushit_on_remove_unsm
|
|
453 |
function resmushit_remove_backup_files() {
|
454 |
$return = array('success' => 0);
|
455 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
456 |
-
|
457 |
die();
|
458 |
}
|
459 |
|
@@ -464,8 +464,8 @@ function resmushit_remove_backup_files() {
|
|
464 |
$return['success']++;
|
465 |
}
|
466 |
}
|
467 |
-
echo json_encode($return);
|
468 |
update_option( 'resmushit_has_no_backup_files', 1);
|
|
|
469 |
|
470 |
die();
|
471 |
}
|
@@ -495,7 +495,7 @@ function resmushit_get_image_id($image_url) {
|
|
495 |
*/
|
496 |
function resmushit_restore_backup_files() {
|
497 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
498 |
-
|
499 |
die();
|
500 |
}
|
501 |
$files=detect_unsmushed_files();
|
@@ -513,7 +513,7 @@ function resmushit_restore_backup_files() {
|
|
513 |
}
|
514 |
}
|
515 |
}
|
516 |
-
|
517 |
die();
|
518 |
}
|
519 |
add_action( 'wp_ajax_resmushit_restore_backup_files', 'resmushit_restore_backup_files' );
|
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.6
|
14 |
* Timestamp: 2022.09.13
|
15 |
* Author: reSmush.it
|
16 |
* Author URI: https://resmush.it
|
194 |
*/
|
195 |
function resmushit_bulk_get_images() {
|
196 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
197 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
198 |
die();
|
199 |
}
|
200 |
+
wp_send_json(reSmushit::getNonOptimizedPictures());
|
201 |
die();
|
202 |
}
|
203 |
add_action( 'wp_ajax_resmushit_bulk_get_images', 'resmushit_bulk_get_images' );
|
214 |
*/
|
215 |
function resmushit_update_disabled_state() {
|
216 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
217 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
218 |
die();
|
219 |
}
|
220 |
if(isset($_POST['data']['id']) && $_POST['data']['id'] != null && isset($_POST['data']['disabled'])){
|
221 |
+
echo wp_kses_post(reSmushit::updateDisabledState(sanitize_text_field((int)$_POST['data']['id']), sanitize_text_field($_POST['data']['disabled'])));
|
222 |
}
|
223 |
die();
|
224 |
}
|
237 |
*/
|
238 |
function resmushit_optimize_single_attachment() {
|
239 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
240 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
241 |
die();
|
242 |
}
|
243 |
if(isset($_POST['data']['id']) && $_POST['data']['id'] != null){
|
244 |
reSmushit::revert(sanitize_text_field((int)$_POST['data']['id']));
|
245 |
+
wp_send_json(json_encode(reSmushit::getStatistics(sanitize_text_field((int)$_POST['data']['id']))));
|
246 |
}
|
247 |
die();
|
248 |
}
|
261 |
*/
|
262 |
function resmushit_bulk_process_image() {
|
263 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
264 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
265 |
die();
|
266 |
}
|
267 |
rlog('Bulk optimization launched for file : ' . get_attached_file( sanitize_text_field((int)$_POST['data']['ID']) ));
|
268 |
+
echo esc_html(reSmushit::revert(sanitize_text_field((int)$_POST['data']['ID'])));
|
269 |
die();
|
270 |
}
|
271 |
add_action( 'wp_ajax_resmushit_bulk_process_image', 'resmushit_bulk_process_image' );
|
283 |
*/
|
284 |
function resmushit_update_statistics() {
|
285 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
286 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
287 |
die();
|
288 |
}
|
289 |
$output = reSmushit::getStatistics();
|
290 |
$output['total_saved_size_formatted'] = reSmushitUI::sizeFormat($output['total_saved_size']);
|
291 |
+
wp_send_json(json_encode($output));
|
292 |
die();
|
293 |
}
|
294 |
add_action( 'wp_ajax_resmushit_update_statistics', 'resmushit_update_statistics' );
|
453 |
function resmushit_remove_backup_files() {
|
454 |
$return = array('success' => 0);
|
455 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
456 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
457 |
die();
|
458 |
}
|
459 |
|
464 |
$return['success']++;
|
465 |
}
|
466 |
}
|
|
|
467 |
update_option( 'resmushit_has_no_backup_files', 1);
|
468 |
+
wp_send_json(json_encode($return));
|
469 |
|
470 |
die();
|
471 |
}
|
495 |
*/
|
496 |
function resmushit_restore_backup_files() {
|
497 |
if(!is_super_admin() && !current_user_can('administrator')) {
|
498 |
+
wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));
|
499 |
die();
|
500 |
}
|
501 |
$files=detect_unsmushed_files();
|
513 |
}
|
514 |
}
|
515 |
}
|
516 |
+
wp_send_json(json_encode($return));
|
517 |
die();
|
518 |
}
|
519 |
add_action( 'wp_ajax_resmushit_restore_backup_files', 'resmushit_restore_backup_files' );
|
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.6');
|
5 |
define('RESMUSHIT_DEFAULT_QLTY', '92');
|
6 |
define('RESMUSHIT_TIMEOUT', '10');
|
7 |
define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
|