reSmush.it Image Optimizer - Version 0.2.2

Version Description

  • Fix settings automatically reinitialized.
Download this release

Release Info

Developer resmushit
Plugin Icon 128x128 reSmush.it Image Optimizer
Version 0.2.2
Comparing to
See all releases

Code changes from version 0.2.1 to 0.2.2

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: 5.3.2
6
- Stable tag: 0.2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -70,6 +70,9 @@ Yes ! Absolutely free, the only restriction is to send images below 5MB.
70
 
71
  == Changelog ==
72
 
 
 
 
73
  = 0.2.1 =
74
  * Complete French translation
75
  * Plugin translation fix
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: 5.3.2
6
+ Stable tag: 0.2.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
70
 
71
  == Changelog ==
72
 
73
+ = 0.2.2 =
74
+ * Fix settings automatically reinitialized.
75
+
76
  = 0.2.1 =
77
  * Complete French translation
78
  * Plugin translation fix
resmushit.php CHANGED
@@ -49,19 +49,19 @@ add_action( 'plugins_loaded', 'resmushit_load_plugin_textdomain' );
49
  */
50
  function resmushit_activate() {
51
  if ( is_super_admin() ) {
52
- if(!get_option('resmushit_qlty'))
53
  update_option( 'resmushit_qlty', RESMUSHIT_DEFAULT_QLTY );
54
- if(!get_option('resmushit_on_upload'))
55
  update_option( 'resmushit_on_upload', '1' );
56
- if(!get_option('resmushit_statistics'))
57
  update_option( 'resmushit_statistics', '1' );
58
- if(!get_option('resmushit_total_optimized'))
59
  update_option( 'resmushit_total_optimized', '0' );
60
- if(!get_option('resmushit_cron'))
61
  update_option( 'resmushit_cron', 0 );
62
- if(!get_option('resmushit_cron_lastrun'))
63
  update_option( 'resmushit_cron_lastrun', 0 );
64
- if(!get_option('resmushit_cron_firstactivation'))
65
  update_option( 'resmushit_cron_firstactivation', 0 );
66
  }
67
  }
49
  */
50
  function resmushit_activate() {
51
  if ( is_super_admin() ) {
52
+ if(get_option('resmushit_qlty') === null)
53
  update_option( 'resmushit_qlty', RESMUSHIT_DEFAULT_QLTY );
54
+ if(get_option('resmushit_on_upload') === null)
55
  update_option( 'resmushit_on_upload', '1' );
56
+ if(get_option('resmushit_statistics') === null)
57
  update_option( 'resmushit_statistics', '1' );
58
+ if(get_option('resmushit_total_optimized') === null)
59
  update_option( 'resmushit_total_optimized', '0' );
60
+ if(get_option('resmushit_cron') === null)
61
  update_option( 'resmushit_cron', 0 );
62
+ if(get_option('resmushit_cron_lastrun') === null)
63
  update_option( 'resmushit_cron_lastrun', 0 );
64
+ if(get_option('resmushit_cron_firstactivation') === null)
65
  update_option( 'resmushit_cron_firstactivation', 0 );
66
  }
67
  }
resmushit.settings.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
4
- define('RESMUSHIT_VERSION', '0.2.1');
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.2.2');
5
  define('RESMUSHIT_DEFAULT_QLTY', '92');
6
  define('RESMUSHIT_TIMEOUT', '10');
7
  define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
trunk/classes/resmushit.class.php ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ReSmushit
5
+ *
6
+ *
7
+ * @package Resmush.it
8
+ * @subpackage Controller
9
+ * @author Charles Bourgeaux <contact@resmush.it>
10
+ */
11
+ Class reSmushit {
12
+
13
+ const MAX_FILESIZE = 5242880;
14
+ const MAX_ATTACHMENTS_REQ = 1000;
15
+
16
+ /**
17
+ *
18
+ * returns the list of supported extensions by the API
19
+ *
20
+ * @return array List of extensions
21
+ */
22
+ public static function authorizedExtensions() {
23
+ return array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff');
24
+ }
25
+
26
+
27
+ /**
28
+ *
29
+ * Optimize a picture according to a filepath.
30
+ *
31
+ * @param string $file_path the path to the file on the server
32
+ * @return bool TRUE if the resmush operation worked
33
+ */
34
+ public static function getPictureQualitySetting() {
35
+ if(get_option( 'resmushit_qlty' )) {
36
+ return get_option( 'resmushit_qlty' );
37
+ } else {
38
+ if (!defined('RESMUSHIT_QLTY')) {
39
+ return RESMUSHIT_DEFAULT_QLTY;
40
+ }
41
+ return RESMUSHIT_QLTY;
42
+ }
43
+ }
44
+
45
+ /**
46
+ *
47
+ * Optimize a picture according to a filepath.
48
+ *
49
+ * @param string $file_path the path to the file on the server
50
+ * @return bool TRUE if the resmush operation worked
51
+ */
52
+ public static function optimize($file_path = NULL, $is_original = TRUE) {
53
+ global $wp_version;
54
+
55
+ if(filesize($file_path) > self::MAX_FILESIZE){
56
+ rlog('Error! Picture ' . str_replace(ABSPATH, '/', $file_path) . ' cannot be optimized, file size is above 5MB ('. reSmushitUI::sizeFormat(filesize($file_path)) .')', 'WARNING');
57
+ return false;
58
+ }
59
+
60
+ $ch = curl_init();
61
+ curl_setopt($ch, CURLOPT_URL, RESMUSHIT_ENDPOINT);
62
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
63
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, RESMUSHIT_TIMEOUT);
64
+ curl_setopt($ch, CURLOPT_POST, true);
65
+ curl_setopt($ch, CURLOPT_USERAGENT, "Wordpress $wp_version/Resmush.it " . RESMUSHIT_VERSION . ' - ' . get_bloginfo('wpurl') );
66
+
67
+ if (!class_exists('CURLFile')) {
68
+ $arg = array('files' => '@' . $file_path);
69
+ } else {
70
+ $cfile = new CURLFile($file_path);
71
+ $arg = array(
72
+ 'files' => $cfile,
73
+ );
74
+ }
75
+
76
+ $arg['qlty'] = self::getPictureQualitySetting();
77
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $arg);
78
+
79
+ $data = curl_exec($ch);
80
+ curl_close($ch);
81
+
82
+ $json = json_decode($data);
83
+ if($json){
84
+ if (!isset($json->error)) {
85
+ if (ini_get('allow_url_fopen')) {
86
+ $data = file_get_contents($json->dest);
87
+ } else {
88
+ $ch = curl_init();
89
+ curl_setopt($ch, CURLOPT_URL, $json->dest);
90
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
91
+ $data = curl_exec($ch);
92
+ curl_close($ch);
93
+ }
94
+ if ($data) {
95
+ if($is_original){
96
+ $originalFile = pathinfo($file_path);
97
+ $newPath = $originalFile['dirname'] . '/' . $originalFile['filename'] . '-unsmushed.' . $originalFile['extension'];
98
+ copy($file_path, $newPath);
99
+ }
100
+ file_put_contents($file_path, $data);
101
+ rlog("Optimized file " . str_replace(ABSPATH, '/', $file_path) . " from " . reSmushitUI::sizeFormat($json->src_size) . " to " . reSmushitUI::sizeFormat($json->dest_size));
102
+ return $json;
103
+ }
104
+ } else {
105
+ rlog("Webservice returned the following error while optimizing $file_path : Code #" . $json->error . " - " . $json->error_long, 'ERROR');
106
+ }
107
+ } else {
108
+ rlog("Cannot establish connection with reSmush.it webservice while optimizing $file_path (timeout of " . RESMUSHIT_TIMEOUT . "sec.)", 'ERROR');
109
+ }
110
+ return false;
111
+ }
112
+
113
+
114
+
115
+
116
+ /**
117
+ *
118
+ * Revert original file and regenerates attachment thumbnails
119
+ *
120
+ * @param int $attachment_id ID of the attachment to revert
121
+ * @return none
122
+ */
123
+ public static function revert($id) {
124
+ global $wp_version;
125
+ global $attachment_id;
126
+ $attachment_id = $id;
127
+
128
+ delete_post_meta($attachment_id, 'resmushed_quality');
129
+ delete_post_meta($attachment_id, 'resmushed_cumulated_original_sizes');
130
+ delete_post_meta($attachment_id, 'resmushed_cumulated_optimized_sizes');
131
+
132
+ $basepath = dirname(get_attached_file( $attachment_id )) . '/';
133
+ $fileInfo = pathinfo(get_attached_file( $attachment_id ));
134
+
135
+ $originalFile = $basepath . $fileInfo['filename'] . '-unsmushed.' . $fileInfo['extension'];
136
+ rlog('Revert original image for : ' . str_replace(ABSPATH, '/', get_attached_file( $attachment_id )));
137
+
138
+ if(file_exists($originalFile))
139
+ copy($originalFile, get_attached_file( $attachment_id ));
140
+
141
+ //Regenerate thumbnails
142
+ wp_generate_attachment_metadata($attachment_id, get_attached_file( $attachment_id ));
143
+
144
+ return self::wasSuccessfullyUpdated( $attachment_id );
145
+ }
146
+
147
+
148
+
149
+ /**
150
+ *
151
+ * Delete Original file (-unsmushed)
152
+ *
153
+ * @param int $attachment_id ID of the attachment
154
+ * @return none
155
+ */
156
+ public static function deleteOriginalFile($attachment_id) {
157
+ $basepath = dirname(get_attached_file( $attachment_id )) . '/';
158
+ $fileInfo = pathinfo(get_attached_file( $attachment_id ));
159
+
160
+ $originalFile = $basepath . $fileInfo['filename'] . '-unsmushed.' . $fileInfo['extension'];
161
+ rlog('Delete original image for : ' . get_attached_file( $attachment_id ));
162
+ if(file_exists($originalFile))
163
+ unlink($originalFile);
164
+ }
165
+
166
+
167
+ /**
168
+ *
169
+ * Return optimization statistics
170
+ *
171
+ * @param int $attachment_id (optional)
172
+ * @return array of statistics
173
+ */
174
+ public static function getStatistics($attachment_id = null){
175
+ global $wpdb;
176
+ $output = array();
177
+ $extraSQL = null;
178
+ if($attachment_id)
179
+ $extraSQL = "where $wpdb->postmeta.post_id = ". $attachment_id;
180
+
181
+ $query = $wpdb->prepare(
182
+ "select
183
+ $wpdb->posts.ID as ID, $wpdb->postmeta.meta_value
184
+ from $wpdb->posts
185
+ inner join $wpdb->postmeta on $wpdb->posts.ID = $wpdb->postmeta.post_id and $wpdb->postmeta.meta_key = %s $extraSQL",
186
+ array('resmushed_cumulated_original_sizes')
187
+ );
188
+ $original_sizes = $wpdb->get_results($query);
189
+ $total_original_size = 0;
190
+ foreach($original_sizes as $s){
191
+ $total_original_size += $s->meta_value;
192
+ }
193
+
194
+ $query = $wpdb->prepare(
195
+ "select
196
+ $wpdb->posts.ID as ID, $wpdb->postmeta.meta_value
197
+ from $wpdb->posts
198
+ inner join $wpdb->postmeta on $wpdb->posts.ID = $wpdb->postmeta.post_id and $wpdb->postmeta.meta_key = %s $extraSQL",
199
+ array('resmushed_cumulated_optimized_sizes')
200
+ );
201
+ $optimized_sizes = $wpdb->get_results($query);
202
+ $total_optimized_size = 0;
203
+ foreach($optimized_sizes as $s){
204
+ $total_optimized_size += $s->meta_value;
205
+ }
206
+
207
+
208
+ $output['total_original_size'] = $total_original_size;
209
+ $output['total_optimized_size'] = $total_optimized_size;
210
+ $output['total_saved_size'] = $total_original_size - $total_optimized_size;
211
+
212
+ $output['total_original_size_nice'] = reSmushitUI::sizeFormat($total_original_size);
213
+ $output['total_optimized_size_nice'] = reSmushitUI::sizeFormat($total_optimized_size);
214
+ $output['total_saved_size_nice'] = reSmushitUI::sizeFormat($total_original_size - $total_optimized_size);
215
+ if($total_original_size == 0)
216
+ $output['percent_reduction'] = 0;
217
+ else
218
+ $output['percent_reduction'] = 100*round(($total_original_size - $total_optimized_size)/$total_original_size,4) . ' %';
219
+ //number of thumbnails + original picture
220
+ $output['files_optimized'] = sizeof($optimized_sizes);
221
+ $output['files_optimized_with_thumbnails'] = sizeof($optimized_sizes) * (sizeof(get_intermediate_image_sizes()) + 1);
222
+
223
+ if(!$attachment_id){
224
+ $output['total_optimizations'] = get_option('resmushit_total_optimized');
225
+ $output['total_pictures'] = self::getCountAllPictures();
226
+ $output['total_pictures_with_thumbnails'] = self::getCountAllPictures() * (sizeof(get_intermediate_image_sizes()) + 1);
227
+ }
228
+ return $output;
229
+ }
230
+
231
+
232
+
233
+ /**
234
+ *
235
+ * Get the count of all pictures
236
+ *
237
+ * @param none
238
+ * @return json of unsmushed pictures attachments ID
239
+ */
240
+ public static function getCountAllPictures(){
241
+ global $wpdb;
242
+
243
+ $queryAllPictures = $wpdb->prepare(
244
+ "select
245
+ Count($wpdb->posts.ID) as count
246
+ from $wpdb->posts
247
+ inner join $wpdb->postmeta on $wpdb->posts.ID = $wpdb->postmeta.post_id and $wpdb->postmeta.meta_key = %s
248
+ where $wpdb->posts.post_type = %s
249
+ and $wpdb->posts.post_mime_type like %s
250
+ and ($wpdb->posts.post_mime_type = 'image/jpeg' OR $wpdb->posts.post_mime_type = 'image/gif' OR $wpdb->posts.post_mime_type = 'image/png')",
251
+ array('_wp_attachment_metadata','attachment', 'image%')
252
+ );
253
+ $data = $wpdb->get_results($queryAllPictures);
254
+ if(isset($data[0]))
255
+ $data = $data[0];
256
+
257
+ if(!isset($data->count))
258
+ return 0;
259
+ return $data->count;
260
+ }
261
+
262
+
263
+
264
+ /**
265
+ *
266
+ * Get a list of non optimized pictures
267
+ *
268
+ * @param none
269
+ * @return json of unsmushed pictures attachments ID
270
+ */
271
+ public static function getNonOptimizedPictures($id_only = FALSE){
272
+ global $wpdb;
273
+ $tmp = array();
274
+ $unsmushed_images = array();
275
+ $files_too_big = array();
276
+ $already_optimized_images_array = array();
277
+ $disabled_images_array = array();
278
+ $files_not_found = array();
279
+ $extra_select = "";
280
+ if($id_only == FALSE) {
281
+ $extra_select = ",POSTS.guid as guid, METAATTACH.meta_value as file_meta";
282
+ }
283
+
284
+ $queryUnoptimizedPicture = $wpdb->prepare(
285
+ "SELECT ATTACHMENTS.* FROM (
286
+ select
287
+ POSTS.ID as ID, METAQLTY.meta_value as qlty, METADISABLED.meta_value as disabled
288
+ $extra_select
289
+ from wp_posts as POSTS
290
+ inner join
291
+ wp_postmeta as METAATTACH on POSTS.ID = METAATTACH.post_id
292
+ and METAATTACH.meta_key = %s
293
+ left join
294
+ wp_postmeta as METAQLTY on POSTS.ID = METAQLTY.post_id
295
+ and METAQLTY.meta_key = %s
296
+ left join
297
+ wp_postmeta as METADISABLED on POSTS.ID = METADISABLED.post_id
298
+ and METADISABLED.meta_key = %s
299
+ where
300
+ POSTS.post_type = %s
301
+ and (POSTS.post_mime_type = 'image/jpeg' OR POSTS.post_mime_type = 'image/gif' OR POSTS.post_mime_type = 'image/png')
302
+ ) as ATTACHMENTS
303
+ WHERE
304
+ (ATTACHMENTS.qlty != '%s' OR ATTACHMENTS.qlty IS NULL)
305
+ AND ATTACHMENTS.disabled IS NULL
306
+ LIMIT %d",
307
+ array('_wp_attachment_metadata','resmushed_quality','resmushed_disabled','attachment', self::getPictureQualitySetting(), self::MAX_ATTACHMENTS_REQ)
308
+ );
309
+ // Get the images in the attachement table
310
+ $all_images = $wpdb->get_results($queryUnoptimizedPicture);
311
+
312
+ foreach($all_images as $image){
313
+ $tmp = array();
314
+ $tmp['ID'] = $image->ID;
315
+ $tmp['attachment_metadata'] = unserialize($image->file_meta);
316
+
317
+ if( !file_exists(get_attached_file( $image->ID )) ) {
318
+ $files_not_found[] = $tmp;
319
+ continue;
320
+ }
321
+ //If filesize > 5MB, we do not optimize this picture
322
+ if( filesize(get_attached_file( $image->ID )) > self::MAX_FILESIZE ){
323
+ $files_too_big[] = $tmp;
324
+ continue;
325
+ }
326
+
327
+ $unsmushed_images[] = $tmp;
328
+ }
329
+ return json_encode(array('nonoptimized' => $unsmushed_images, 'filestoobig' => $files_too_big, 'filesnotfound' => $files_not_found));
330
+ }
331
+
332
+
333
+ /**
334
+ *
335
+ * Return the number of non optimized pictures
336
+ *
337
+ * @param none
338
+ * @return number of non optimized pictures to the current quality factor
339
+ */
340
+ public static function getCountNonOptimizedPictures(){
341
+ $data = json_decode(self::getNonOptimizedPictures());
342
+ $output = array();
343
+ $output['nonoptimized'] = is_array($data->nonoptimized) ? sizeof($data->nonoptimized) : 0;
344
+ $output['filesnotfound'] = is_array($data->filesnotfound) ? sizeof($data->filesnotfound) : 0;
345
+ $output['filestoobig'] = is_array($data->filestoobig) ? sizeof($data->filestoobig) : 0;
346
+ return $output;
347
+ }
348
+
349
+
350
+ /**
351
+ *
352
+ * Record in DB new status for optimization disabled state
353
+ *
354
+ * @param int $id ID of postID
355
+ * @param string $state state of disable
356
+ * @return none
357
+ */
358
+ public static function updateDisabledState($id, $state){
359
+ //if we do not want this attachment to be resmushed.
360
+ if($state == "true"){
361
+ update_post_meta($id, 'resmushed_disabled', 'disabled');
362
+ self::revert($id);
363
+ return 'true';
364
+ } else {
365
+ delete_post_meta($id, 'resmushed_disabled');
366
+ return 'false';
367
+ }
368
+ }
369
+
370
+
371
+
372
+ /**
373
+ *
374
+ * Get Disabled State
375
+ *
376
+ * @param int $attachment_id Post ID
377
+ * @return boolean true if attachment is disabled
378
+ */
379
+ public static function getDisabledState($attachment_id){
380
+ if(get_post_meta($attachment_id, 'resmushed_disabled'))
381
+ return true;
382
+ return false;
383
+ }
384
+
385
+
386
+
387
+ /**
388
+ *
389
+ * Get Last Quality Factor attached to a picture
390
+ *
391
+ * @param int $attachment_id Post ID
392
+ * @return int quality setting for this attachment
393
+ */
394
+ public static function getAttachmentQuality($attachment_id){
395
+ $attachmentQuality = get_post_meta($attachment_id, 'resmushed_quality');
396
+ if(isset($attachmentQuality[0]))
397
+ return $attachmentQuality[0];
398
+ return null;
399
+ }
400
+
401
+
402
+
403
+ /**
404
+ *
405
+ * Check if this Attachment was successfully optimized
406
+ *
407
+ * @param int $attachment_id Post ID
408
+ * @return string $status
409
+ */
410
+ public static function wasSuccessfullyUpdated($attachment_id){
411
+ if( self::getDisabledState( $attachment_id ))
412
+ return 'disabled';
413
+
414
+ if( filesize(get_attached_file( $attachment_id )) > self::MAX_FILESIZE){
415
+ return 'file_too_big';
416
+ }
417
+
418
+ if( self::getPictureQualitySetting() != self::getAttachmentQuality( $attachment_id ))
419
+ return 'failed';
420
+ return 'success';
421
+ }
422
+ }
trunk/classes/resmushitUI.class.php ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ReSmushit Admin UI class
5
+ *
6
+ *
7
+ * @package Resmush.it
8
+ * @subpackage UI
9
+ * @author Charles Bourgeaux <contact@resmush.it>
10
+ */
11
+ Class reSmushitUI {
12
+
13
+ /**
14
+ *
15
+ * Create a new panel
16
+ *
17
+ * @param string $title Title of the pane
18
+ * @param string $html HTML content
19
+ * @param string $border Color of the border
20
+ * @return none
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
+
28
+
29
+
30
+
31
+ /**
32
+ *
33
+ * Create a new panel wrapper (start)
34
+ *
35
+ * @param string $title Title of the pane
36
+ * @param string $html HTML content
37
+ * @param string $border Color of the border
38
+ * @return none
39
+ */
40
+ public static function fullWidthPanelWrapper($title = null, $html = null, $border = null) {
41
+ $borderClass = NULL;
42
+
43
+ if($border) {
44
+ $borderClass = 'brdr-'.$border;
45
+ }
46
+ echo "<div class='rsmt-panel w100 $borderClass'><h2>$title</h2>";
47
+ }
48
+
49
+
50
+
51
+
52
+ /**
53
+ *
54
+ * Create a new panel wrapper (end)
55
+ *
56
+ * @param none
57
+ * @return none
58
+ */
59
+ public static function fullWidthPanelEndWrapper() {
60
+ echo "</div>";
61
+ }
62
+
63
+
64
+
65
+
66
+ /**
67
+ *
68
+ * Generate Header panel
69
+ *
70
+ * @param none
71
+ * @return none
72
+ */
73
+ public static function headerPanel() {
74
+ $html = "<img src='". RESMUSHIT_BASE_URL . "images/header.jpg' />";
75
+ self::fullWidthPanel($html);
76
+ }
77
+
78
+
79
+
80
+
81
+
82
+ /**
83
+ *
84
+ * Generate Settings panel
85
+ *
86
+ * @param none
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
+ echo '<table class="form-table">'
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")
101
+ . self::addSetting("checkbox", __("Enable logs", 'resmushit-image-optimizer'), __("Enable file logging (for developers)", 'resmushit-image-optimizer'), "resmushit_logs")
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
+ . '</table>';
104
+ submit_button();
105
+ echo '</form></div>';
106
+ self::fullWidthPanelEndWrapper();
107
+ }
108
+
109
+
110
+
111
+ /**
112
+ *
113
+ * Generate Bulk panel
114
+ *
115
+ * @param none
116
+ * @return none
117
+ */
118
+ public static function bulkPanel() {
119
+ $dataCountNonOptimizedPictures = reSmushit::getCountNonOptimizedPictures();
120
+ $countNonOptimizedPictures = $dataCountNonOptimizedPictures['nonoptimized'];
121
+ self::fullWidthPanelWrapper(__('Optimize unsmushed pictures', 'resmushit-image-optimizer'), null, 'blue');
122
+
123
+ $additionnalClassNeedOptimization = NULL;
124
+ $additionnalClassNoNeedOptimization = 'disabled';
125
+ if(!$countNonOptimizedPictures) {
126
+ $additionnalClassNeedOptimization = 'disabled';
127
+ $additionnalClassNoNeedOptimization = NULL;
128
+ } else if ($countNonOptimizedPictures == reSmushit::MAX_ATTACHMENTS_REQ) {
129
+ $countNonOptimizedPictures .= '+';
130
+ }
131
+
132
+ echo "<div class='rsmt-bulk'><div class='non-optimized-wrapper $additionnalClassNeedOptimization'><h3 class='icon_message warning'>";
133
+
134
+ if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
135
+ echo "<em>$countNonOptimizedPictures "
136
+ . __('non optimized pictures will be automatically optimized', 'resmushit-image-optimizer')
137
+ . "</em>.</h3><p>"
138
+ . __('These pictures will be automatically optimized using schedule tasks (cronjobs).', 'resmushit-image-optimizer')
139
+ . " "
140
+ . __('Image optimization process can be launched <b>manually</b> by clicking on the button below :', 'resmushit-image-optimizer');
141
+ } else {
142
+ echo __('There is currently', 'resmushit-image-optimizer')
143
+ . " <em>$countNonOptimizedPictures "
144
+ . __('non optimized pictures', 'resmushit-image-optimizer')
145
+ . "</em>.</h3><p>"
146
+ . __('This action will resmush all pictures which have not been optimized to the good Image Quality Rate.', 'resmushit-image-optimizer');
147
+ }
148
+
149
+ echo "</p><p class='submit' id='bulk-resize-examine-button'><button class='button-primary' onclick='resmushit_bulk_resize(\"bulk_resize_image_list\");'>";
150
+
151
+ if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) {
152
+ echo __('Optimize all pictures manually', 'resmushit-image-optimizer');
153
+ } else {
154
+ echo __('Optimize all pictures', 'resmushit-image-optimizer');
155
+ }
156
+
157
+ echo "</button></p><div id='bulk_resize_image_list'></div></div>"
158
+ . "<div class='optimized-wrapper $additionnalClassNoNeedOptimization'><h3 class='icon_message ok'>"
159
+ . __('Congrats ! All your pictures are correctly optimized', 'resmushit-image-optimizer')
160
+ . "</h3></div></div>";
161
+ self::fullWidthPanelEndWrapper();
162
+ }
163
+
164
+
165
+ /**
166
+ *
167
+ * Generate Bulk panel
168
+ *
169
+ * @param none
170
+ * @return none
171
+ */
172
+ public static function bigFilesPanel() {
173
+ $getNonOptimizedPictures = json_decode(reSmushit::getNonOptimizedPictures());
174
+ $countfilesTooBigPictures = is_array($getNonOptimizedPictures->filestoobig) ? sizeof($getNonOptimizedPictures->filestoobig) : 0;
175
+
176
+ if(!$countfilesTooBigPictures)
177
+ return false;
178
+
179
+ self::fullWidthPanelWrapper(__('Files non optimized', 'resmushit-image-optimizer'), null, 'grey');
180
+
181
+ $additionnalClass = NULL;
182
+ if(!$countfilesTooBigPictures) {
183
+ $additionnalClass = 'disabled';
184
+ }
185
+
186
+ echo "<div class='rsmt-bigfiles'><div class='optimized-wrapper $additionnalClass'>
187
+ <h3 class='icon_message info'>";
188
+
189
+ if($countfilesTooBigPictures > 1) {
190
+ echo $countfilesTooBigPictures . ' ' . __('pictures are too big (> 5MB) for the optimizer', 'resmushit-image-optimizer');
191
+ } else {
192
+ echo $countfilesTooBigPictures . ' ' . __('picture is too big (> 5MB) for the optimizer', 'resmushit-image-optimizer');
193
+ }
194
+ echo "</h3><div class='list-accordion'><h4>"
195
+ . __('List of files above 5MB', 'resmushit-image-optimizer')
196
+ . "</h4><ul>";
197
+
198
+ foreach($getNonOptimizedPictures->filestoobig as $file){
199
+ $fileInfo = pathinfo(get_attached_file( $file->ID ));
200
+ $filesize = reSmushitUI::sizeFormat(filesize(get_attached_file( $file->ID )));
201
+
202
+ echo "<li><a href='"
203
+ . wp_get_attachment_url( $file->ID )
204
+ . "' target='_blank'>"
205
+ . wp_get_attachment_image($file->ID, 'thumbnail')
206
+ . "<span>"
207
+ . $fileInfo['basename'] . ' (' . $filesize . ').</span></a></li>';
208
+ }
209
+ echo '</ul></div></div></div>';
210
+
211
+ self::fullWidthPanelEndWrapper();
212
+ }
213
+
214
+
215
+
216
+
217
+ /**
218
+ *
219
+ * Generate Statistics panel
220
+ *
221
+ * @param none
222
+ * @return none
223
+ */
224
+ public static function statisticsPanel() {
225
+ if(!get_option('resmushit_statistics'))
226
+ return false;
227
+ self::fullWidthPanelWrapper(__('Statistics', 'resmushit-image-optimizer'), null, 'green');
228
+ $resmushit_stat = reSmushit::getStatistics();
229
+
230
+ echo "<div class='rsmt-statistics'>";
231
+
232
+ if($resmushit_stat['files_optimized'] != 0) {
233
+ echo "<p><strong>"
234
+ . __('Space saved :', 'resmushit-image-optimizer')
235
+ . "</strong> <span id='rsmt-statistics-space-saved'>"
236
+ . self::sizeFormat($resmushit_stat['total_saved_size'])
237
+ . "</span></p><p><strong>"
238
+ . __('Total reduction :', 'resmushit-image-optimizer')
239
+ . "</strong> <span id='rsmt-statistics-percent-reduction'>"
240
+ . $resmushit_stat['percent_reduction']
241
+ . "</span></p><p><strong>"
242
+ . __('Attachments optimized :', 'resmushit-image-optimizer')
243
+ . "</strong> <span id='rsmt-statistics-files-optimized'>"
244
+ . $resmushit_stat['files_optimized']
245
+ . "</span>/<span id='rsmt-statistics-total-picture'>"
246
+ . $resmushit_stat['total_pictures']
247
+ . "</span></p><p><strong>"
248
+ . __('Image optimized (including thumbnails) :', 'resmushit-image-optimizer')
249
+ . "</strong> <span id='rsmt-statistics-files-optimized'>"
250
+ . $resmushit_stat['files_optimized_with_thumbnails']
251
+ . "</span>/<span id='rsmt-statistics-total-pictures'>"
252
+ . $resmushit_stat['total_pictures_with_thumbnails']
253
+ . "</span></p><p><strong>"
254
+ . __('Total images optimized :', 'resmushit-image-optimizer')
255
+ . "</strong> <span id='rsmt-statistics-total-optimizations'>"
256
+ . $resmushit_stat['total_optimizations']
257
+ . "</span></p>";
258
+ } else {
259
+ echo "<p>" . __('No picture has been optimized yet ! Add pictures to your Wordpress Media Library.', 'resmushit-image-optimizer') . "</p>";
260
+ }
261
+ echo "</div>";
262
+ self::fullWidthPanelEndWrapper();
263
+ }
264
+
265
+
266
+
267
+ /**
268
+ *
269
+ * Generate News panel
270
+ *
271
+ * @param none
272
+ * @return none
273
+ */
274
+ public static function newsPanel() {
275
+ global $wp_version;
276
+
277
+ echo "<div class='rsmt-news'>";
278
+
279
+ self::fullWidthPanelWrapper(__('News', 'resmushit-image-optimizer'), null, 'red');
280
+ $ch = curl_init();
281
+ curl_setopt($ch, CURLOPT_URL, RESMUSHIT_NEWSFEED);
282
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
283
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
284
+ $data_raw = curl_exec($ch);
285
+ curl_close($ch);
286
+ $data = json_decode($data_raw);
287
+
288
+ if($data) {
289
+ foreach($data as $i=>$news) {
290
+ if($i > 2){
291
+ break;
292
+ }
293
+
294
+ echo "<div class='news-item'><span class='news-date'>"
295
+ . date('d/m/Y', $news->date)
296
+ . "</span>";
297
+ if($news->picture) {
298
+ echo "<div class='news-img'><a href='"
299
+ . $news->link
300
+ . "' target='_blank'><img src='"
301
+ . $news->picture
302
+ . "' /></a></div>";
303
+ }
304
+ echo "<h3><a href='"
305
+ . $news->link
306
+ . "' target='_blank'>"
307
+ . $news->title
308
+ . "</a></h3><div class='news-content'>"
309
+ . $news->content
310
+ . "</div>";
311
+ }
312
+ }
313
+
314
+ echo "<div class='social'>"
315
+ . "<a class='social-maecia' title='"
316
+ . __('Maecia Agency - Paris France', 'resmushit-image-optimizer')
317
+ . "' href='https://www.maecia.com' target='_blank'>"
318
+ . "<img src='"
319
+ . RESMUSHIT_BASE_URL . "images/maecia.png' /></a>"
320
+ . "<a class='social-resmushit' title='"
321
+ . __('Visit resmush.it for more informations', 'resmushit-image-optimizer')
322
+ . "' href='https://resmush.it' target='_blank'>"
323
+ . "<img src='"
324
+ . RESMUSHIT_BASE_URL . "images/logo.png' /></a>"
325
+ . "<a class='social-twitter' title='"
326
+ . __('Follow reSmush.it on Twitter', 'resmushit-image-optimizer')
327
+ . "' href='https://www.twitter.com/resmushit' target='_blank'>"
328
+ . "<img src='"
329
+ . RESMUSHIT_BASE_URL . "images/twitter.png' /></a></div></div>";
330
+
331
+ self::fullWidthPanelEndWrapper();
332
+ }
333
+
334
+
335
+ /**
336
+ *
337
+ * Generate ALERT panel
338
+ *
339
+ * @param none
340
+ * @return none
341
+ */
342
+ public static function alertPanel() {
343
+ if (resmushit_get_cron_status() == 'DISABLED' || resmushit_get_cron_status() == 'OK') {
344
+ return TRUE;
345
+ }
346
+
347
+ self::fullWidthPanelWrapper(__('Important informations', 'resmushit-image-optimizer'), null, 'red');
348
+ echo "<div class='rsmt-alert'>";
349
+
350
+
351
+ echo "<h3 class='icon_message warning'>"
352
+ . __('Cronjobs seems incorrectly configured', 'resmushit-image-optimizer')
353
+ . "</h3>";
354
+
355
+ if (resmushit_get_cron_status() == 'MISCONFIGURED') {
356
+ echo "<p>"
357
+ . __('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')
358
+ . "</p><p>"
359
+ . __('We advice to disable Remush.it option "Process optimize on CRON" as long as Cron jobs are incorrectly set up.', 'resmushit-image-optimizer')
360
+ . "</p>";
361
+ } else if (resmushit_get_cron_status() == 'NEVER_RUN') {
362
+ echo "<p>"
363
+ . __('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')
364
+ . "</p>";
365
+ } else if (resmushit_get_cron_status() == 'NO_LATELY_RUN') {
366
+ echo "<p>"
367
+ . __('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')
368
+ . "<ul><li><em>" . __('Expected Frequency :', 'resmushit-image-optimizer') . "</em> " . __('Every', 'resmushit-image-optimizer') . " " . time_elapsed_string(RESMUSHIT_CRON_FREQUENCY) . "</li>"
369
+ . "<ul><li><em>" . __('Last run :', 'resmushit-image-optimizer') . "</em> " . time_elapsed_string(time() - get_option('resmushit_cron_lastrun')) . " " . __('ago', 'resmushit-image-optimizer') . "</li>"
370
+ . "</p>";
371
+ }
372
+ echo "</div>";
373
+
374
+ self::fullWidthPanelEndWrapper();
375
+ }
376
+
377
+
378
+
379
+
380
+ /**
381
+ *
382
+ * Helper to generate multiple settings fields
383
+ *
384
+ * @param string $type type of the setting
385
+ * @param string $name displayed name of the setting
386
+ * @param string $extra additionnal informations about the setting
387
+ * @param string $machine_name setting machine name
388
+ * @return none
389
+ */
390
+ public static function addSetting($type, $name, $extra, $machine_name) {
391
+ $output = " <div class='setting-row type-$type'>
392
+ <label for='$machine_name'>$name<p>$extra</p></label>";
393
+ switch($type){
394
+ case 'text':
395
+ $output .= "<input type='text' name='$machine_name' id='$machine_name' value='". get_option( $machine_name ) ."'/>";
396
+ break;
397
+ case 'checkbox':
398
+ $additionnal = null;
399
+ if ( 1 == get_option( $machine_name ) ) $additionnal = 'checked="checked"';
400
+ $output .= "<input type='checkbox' name='$machine_name' id='$machine_name' value='1' ". $additionnal ."/>";
401
+ break;
402
+ }
403
+ $output .= '</div>';
404
+ return $output;
405
+ }
406
+
407
+
408
+
409
+
410
+
411
+ /**
412
+ *
413
+ * Generate checkbox "disabled" on media list
414
+ *
415
+ * @param int $id Post ID associated to postmetas
416
+ * @return none
417
+ */
418
+ public static function mediaListCustomValuesDisable($id, $return = false) {
419
+ global $wpdb;
420
+ $query = $wpdb->prepare(
421
+ "select
422
+ $wpdb->posts.ID as ID, $wpdb->postmeta.meta_value
423
+ from $wpdb->posts
424
+ inner join $wpdb->postmeta on $wpdb->posts.ID = $wpdb->postmeta.post_id and $wpdb->postmeta.meta_key = %s and $wpdb->postmeta.post_id = %s",
425
+ array('resmushed_disabled', $id)
426
+ );
427
+ $attachment_resmushit_disabled = null;
428
+ if($wpdb->get_results($query))
429
+ $attachment_resmushit_disabled = 'checked';
430
+
431
+ $output = '<input type="checkbox" data-attachment-id="'. $id .'"" class="rsmt-trigger--disabled-checkbox" '. $attachment_resmushit_disabled .' />';
432
+
433
+ if($return)
434
+ return $output;
435
+ echo $output;
436
+ }
437
+
438
+
439
+
440
+
441
+
442
+ /**
443
+ *
444
+ * Generate status info OR button on media list
445
+ *
446
+ * @param int $attachment_id Post ID associated to postmetas
447
+ * @return none
448
+ */
449
+ public static function mediaListCustomValuesStatus($attachment_id, $return = false) {
450
+ if(reSmushit::getDisabledState($attachment_id)){
451
+ $output = '-';
452
+ }
453
+ else if(reSmushit::getAttachmentQuality($attachment_id) != reSmushit::getPictureQualitySetting())
454
+ $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" />';
455
+ else{
456
+ $statistics = reSmushit::getStatistics($attachment_id);
457
+ $output = __('Reduced by', 'resmushit-image-optimizer') . " ". $statistics['total_saved_size_nice'] ." (". $statistics['percent_reduction'] . ' ' . __('saved', 'resmushit-image-optimizer') . ")";
458
+ $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" />';
459
+ }
460
+
461
+ if($return)
462
+ return $output;
463
+ echo $output;
464
+ }
465
+
466
+
467
+
468
+
469
+ /**
470
+ *
471
+ * Helper to format size in bytes
472
+ *
473
+ * @param int $bytes filesize in bytes
474
+ * @return string rendered filesize
475
+ */
476
+ public static function sizeFormat($bytes) {
477
+ if ($bytes > 0)
478
+ {
479
+ $unit = intval(log($bytes, 1024));
480
+ $units = array('B', 'KB', 'MB', 'GB');
481
+
482
+ if (array_key_exists($unit, $units) === true)
483
+ {
484
+ return sprintf('%d %s', $bytes / pow(1024, $unit), $units[$unit]);
485
+ }
486
+ }
487
+ return $bytes;
488
+ }
489
+ }
trunk/css/resmushit.css ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .rsmt-panels{
2
+ display: flex;
3
+ flex-direction:row;
4
+ justify-content:space-between;
5
+ margin-right: 20px;
6
+ }
7
+ .rsmt-panels .rsmt-panel{
8
+ background-color: #FFF;
9
+ box-shadow: 0 2px 0 #EAEAEA;
10
+ padding: 15px;
11
+ margin: 0 0 15px;
12
+ -webkit-box-sizing: border-box;
13
+ -moz-box-sizing: border-box;
14
+ box-sizing: border-box;
15
+ }
16
+ .rsmt-panels .w100{
17
+ width: 100%;
18
+ }
19
+ .rsmt-panels .w66{
20
+ flex-basis: 66%;
21
+ }
22
+ .rsmt-panels .w33{
23
+ flex-basis: 33%;
24
+ }
25
+ .rsmt-panels .brdr-green{
26
+ border-left: 4px solid #277F72
27
+ }
28
+ .rsmt-panels .brdr-blue{
29
+ border-left: 4px solid #5A8BA8
30
+ }
31
+ .rsmt-panels .brdr-orange{
32
+ border-left: 4px solid #DFC02A
33
+ }
34
+ .rsmt-panels .brdr-red{
35
+ border-left: 4px solid #9E2F29
36
+ }
37
+ .rsmt-panels .brdr-grey{
38
+ border-left: 4px solid #a2a2a2
39
+ }
40
+ .rsmt-panels h2{
41
+ text-transform: uppercase;
42
+ font-family: 'Roboto Slab', serif;
43
+ font-size: 1.5em;
44
+ color:#4B4B4B;
45
+ }
46
+ .rsmt-panels img{
47
+ max-width: 100%;
48
+ }
49
+ .rsmt-panels em{
50
+ font-weight: bold;
51
+ font-style: normal;
52
+ }
53
+ .rsmt-panels ul {
54
+ list-style-type: disc;
55
+ list-style-position: inside;
56
+ }
57
+
58
+
59
+ .rsmt-settings .setting-row{
60
+ margin-bottom: 20px;
61
+ }
62
+ .rsmt-settings .new {
63
+ background-color: #c30000;
64
+ color: white;
65
+ padding: 1px 3px;
66
+ margin-right: 5px;
67
+ }
68
+ .rsmt-settings .setting-row.type-checkbox{
69
+ display: flex;
70
+ }
71
+ .rsmt-settings .setting-row label{
72
+ display: inline-block;
73
+ font-weight: bold;
74
+ width: 100%
75
+ }
76
+ .rsmt-settings .setting-row label p{
77
+ margin:0;
78
+ font-size: 0.8em;
79
+ font-weight: normal;
80
+ }
81
+ .rsmt-settings .setting-row input[type='text']{
82
+ width: 100%;
83
+ }
84
+ .rsmt-settings .setting-row input[type='checkbox']{
85
+ margin-top: 2px;
86
+ }
87
+ .rsmt-settings .setting-row input.form-error{
88
+ border: 1px solid #D54E21;
89
+ color: #D54E21;
90
+ }
91
+
92
+
93
+ .rsmt-bulk .loader{
94
+ height: 50px;
95
+ width: 50px;
96
+ display: inline-block;
97
+ background-image: url(../images/clock.gif);
98
+ background-repeat: no-repeat;
99
+ }
100
+ .rsmt-bulk .disabled{
101
+ display: none;
102
+ }
103
+ .rsmt-bigfiles .icon_message,
104
+ .rsmt-alert .icon_message,
105
+ .rsmt-bulk .icon_message{
106
+ background-repeat: no-repeat;
107
+ padding: 13px 0 0 60px;
108
+ min-height: 48px;
109
+ -webkit-box-sizing: border-box;
110
+ -moz-box-sizing: border-box;
111
+ box-sizing: border-box;
112
+ }
113
+ .rsmt-bulk .warning,
114
+ .rsmt-alert .warning{
115
+ background-image: url(../images/warning.png);
116
+ }
117
+ .rsmt-bulk .ok,
118
+ .rsmt-alert .ok{
119
+ background-image: url(../images/ok.png);
120
+ }
121
+ .rsmt-bulk .bulk--back-progressionbar{
122
+ background: #F1F1F1;
123
+ box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.1);
124
+ width: 100%;
125
+ height: 25px;
126
+ position: relative;
127
+ text-align: center;
128
+ }
129
+ .rsmt-bulk .resmushit--progress--bar p{
130
+ font-size: 15px;
131
+ line-height: 1.5;
132
+ color: white;
133
+ position: absolute;
134
+ left: 50%;
135
+ top: -13px;
136
+ z-index: 1;
137
+ transform: translate(-50%,0%);
138
+ }
139
+ .rsmt-bulk .resmushit--progress--bar{
140
+ background: #234C71;
141
+ position:absolute;
142
+ transition: all 1s ease-out;
143
+ height:100%;
144
+ }
145
+ .rsmt-bulk .resmushit--progress--bar:after{
146
+ content: "";
147
+ width: 100%;
148
+ position: absolute;
149
+ bottom: 0;
150
+ height: 50%;
151
+ background: rgb(0,0,0);
152
+ background: rgba(0,0,0,0.2);
153
+ left: 0;
154
+ color: white;
155
+ }
156
+ .rsmt-bulk .resmush--complete{
157
+ padding: 10px;
158
+ background-color: #4862A3;
159
+ text-align: center;
160
+ color: white;
161
+ width: 200px;
162
+ margin: 20px auto;
163
+ }
164
+ .rsmt-bulk .loading--bulk{
165
+ text-align: center;
166
+ }
167
+ .rsmt-bulk #bulk_resize_target{
168
+ overflow: auto;
169
+ padding: 20px 10px;
170
+ height: 100% !important;
171
+ background: white;
172
+ }
173
+ .rsmt-bulk .file--treated{
174
+ display: none;
175
+ }
176
+
177
+ .rsmt-bigfiles .info{
178
+ background-image: url(../images/info.png);
179
+
180
+ }
181
+ .rsmt-bigfiles h4{
182
+ cursor: pointer;
183
+ background-image: url(../images/toggle.png);
184
+ background-repeat: no-repeat;
185
+ padding-left: 20px;
186
+ background-position: 0 1px;
187
+ }
188
+ .rsmt-bigfiles .opened h4{
189
+ background-position: 0 -13px;
190
+ }
191
+ .rsmt-bigfiles ul{
192
+ display: none;
193
+ }
194
+ .rsmt-bigfiles ul{
195
+ margin-left:10px;
196
+ }
197
+
198
+ .rsmt-bigfiles ul li *{
199
+ display: inline-block;
200
+ vertical-align: middle;
201
+ }
202
+ .rsmt-bigfiles ul li img{
203
+ height: auto;
204
+ width: 50px;
205
+ border: 1px solid #666;
206
+ margin-right: 15px;
207
+ }
208
+
209
+ .rsmt-news .news-item{
210
+ margin-bottom: 25px;
211
+ }
212
+ .rsmt-news .news-date{
213
+ background: #bbb;
214
+ color:#fff;
215
+ padding: 2px 5px;
216
+ font-size: 0.8em;
217
+ }
218
+ .rsmt-news .news-content{
219
+ font-style: italic;
220
+ }
221
+ .rsmt-news .news-img img{
222
+ width: 100%;
223
+ box-shadow: 0 2px 0 #EAEAEA;
224
+ padding: 10px 10px;
225
+ -webkit-box-sizing: border-box;
226
+ -moz-box-sizing: border-box;
227
+ box-sizing: border-box;
228
+ background: #F4F4F4;
229
+ }
230
+ .rsmt-news h3{
231
+ margin: 5px 0 3px;
232
+ font-size: 1.2em;
233
+ }
234
+ .rsmt-news h3 a{
235
+ text-decoration: none;
236
+ }
237
+ .rsmt-news .social{
238
+ text-align: right;
239
+ }
240
+ .rsmt-news .social a{
241
+ margin-left: 10px;
242
+ }
243
+ .rsmt-news .social .social-twitter{
244
+ width: 16px;
245
+ height: 16px;
246
+ display: inline-block;
247
+ }
248
+ .rsmt-news .social a{
249
+ opacity: 0.5;
250
+ text-decoration: none;
251
+ }
252
+ .rsmt-news .social a:hover{
253
+ opacity: 0.8;
254
+ }
255
+
256
+ input[type=checkbox].rsmt-disable-loader{
257
+ border:none;
258
+ height: 16px;
259
+ width: 16px;
260
+ display: inline-block;
261
+ background-image: url(../images/loading.gif);
262
+ background-repeat: no-repeat;
263
+ }
264
+ input[type=checkbox].rsmt-disable-loader:checked:before{
265
+ content: "";
266
+ }
267
+
268
+
269
+ @media screen and (max-width: 1100px) {
270
+ .rsmt-panels{
271
+ flex-direction:column;
272
+ }
273
+ }
trunk/images/clock.gif ADDED
Binary file
trunk/images/header.jpg ADDED
Binary file
trunk/images/info.png ADDED
Binary file
trunk/images/loading.gif ADDED
Binary file
trunk/images/logo.png ADDED
Binary file
trunk/images/maecia.png ADDED
Binary file
trunk/images/ok.png ADDED
Binary file
trunk/images/toggle.png ADDED
Binary file
trunk/images/twitter.png ADDED
Binary file
trunk/images/warning.png ADDED
Binary file
trunk/js/script.js ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ * Bulk Resize admin javascript functions
4
+ */
5
+ var bulkCounter = 0;
6
+ var bulkTotalimages = 0;
7
+ var next_index = 0;
8
+ var file_too_big_count = 0;
9
+
10
+
11
+ /**
12
+ * Form Validators
13
+ */
14
+ jQuery("#rsmt-options-form").submit(function(){
15
+ jQuery("#resmushit_qlty").removeClass('form-error');
16
+ var qlty = jQuery("#resmushit_qlty").val();
17
+ if(!jQuery.isNumeric(qlty) || qlty > 100 || qlty < 0){
18
+ jQuery("#resmushit_qlty").addClass('form-error');
19
+ return false;
20
+ }
21
+ });
22
+
23
+
24
+ jQuery( ".list-accordion h4" ).on('click', function(){
25
+ if(jQuery(this).parent().hasClass('opened')){
26
+ jQuery(".list-accordion ul").slideUp();
27
+ jQuery('.list-accordion').removeClass('opened');
28
+
29
+ } else {
30
+ jQuery(".list-accordion ul").slideDown();
31
+ jQuery('.list-accordion').addClass('opened');
32
+ }
33
+ });
34
+
35
+ updateDisabledState();
36
+ optimizeSingleAttachment();
37
+
38
+
39
+
40
+ /**
41
+ * recursive function for resizing images
42
+ */
43
+ function resmushit_bulk_process(bulk, item){
44
+ var error_occured = false;
45
+ jQuery.post(
46
+ ajaxurl, {
47
+ action: 'resmushit_bulk_process_image',
48
+ data: bulk[item]
49
+ },
50
+ function(response) {
51
+ if(response == 'failed')
52
+ error_occured = true;
53
+ else if(response == 'file_too_big')
54
+ file_too_big_count++;
55
+
56
+ if(!flag_removed){
57
+ jQuery('#bulk_resize_target').remove();
58
+ container.append('<div id="smush_results" style="padding: 20px 5px; overflow: auto;" />');
59
+ var results_target = jQuery('#smush_results');
60
+ results_target.html('<div class="bulk--back-progressionbar"><div <div class="resmushit--progress--bar"</div></div>');
61
+ flag_removed = true;
62
+ }
63
+
64
+ bulkCounter++;
65
+ jQuery('.resmushit--progress--bar').html('<p>'+ Math.round((bulkCounter*100/bulkTotalimages)) +'%</p>');
66
+ jQuery('.resmushit--progress--bar').animate({'width': Math.round((bulkCounter*100/bulkTotalimages))+'%'}, 0);
67
+
68
+ if(item < bulk.length - 1)
69
+ resmushit_bulk_process(bulk, item + 1);
70
+ else{
71
+ if(error_occured){
72
+ jQuery('.non-optimized-wrapper h3').text('An error occured when contacting webservice. Please try again later.');
73
+ jQuery('.non-optimized-wrapper > p').remove();
74
+ jQuery('.non-optimized-wrapper > div').remove();
75
+ } else if(file_too_big_count){
76
+
77
+ var message = file_too_big_count + ' picture cannot be optimized (> 5MB). All others have been optimized';
78
+ if(file_too_big_count > 1)
79
+ var message = file_too_big_count + ' pictures cannot be optimized (> 5MB). All others have been optimized';
80
+
81
+ jQuery('.non-optimized-wrapper h3').text(message);
82
+ jQuery('.non-optimized-wrapper > p').remove();
83
+ jQuery('.non-optimized-wrapper > div').remove();
84
+ } else{
85
+ jQuery('.non-optimized-wrapper').addClass('disabled');
86
+ jQuery('.optimized-wrapper').removeClass('disabled');
87
+ updateStatistics();
88
+ }
89
+ }
90
+ }
91
+ );
92
+ }
93
+
94
+
95
+ /**
96
+ * ajax post to return all images that are candidates for resizing
97
+ * @param string the id of the html element into which results will be appended
98
+ */
99
+ function resmushit_bulk_resize(container_id) {
100
+ container = jQuery('#'+container_id);
101
+ container.html('<div id="bulk_resize_target">');
102
+ jQuery('#bulk-resize-examine-button').fadeOut(200);
103
+ var target = jQuery('#bulk_resize_target');
104
+
105
+ target.html('<div class="loading--bulk"><span class="loader"></span><br />Examining existing attachments. This may take a few moments...</div>');
106
+
107
+ target.animate(
108
+ { height: [100,'swing'] },
109
+ 500,
110
+ function() {
111
+ jQuery.post(
112
+ ajaxurl,
113
+ { action: 'resmushit_bulk_get_images' },
114
+ function(response) {
115
+ var images = JSON.parse(response);
116
+ if (images.nonoptimized.length > 0) {
117
+ bulkTotalimages = images.nonoptimized.length;
118
+ target.html('<div class="loading--bulk"><span class="loader"></span><br />' + bulkTotalimages + ' attachment(s) found, starting optimization...</div>');
119
+ flag_removed = false;
120
+ //start treating all pictures
121
+ resmushit_bulk_process(images.nonoptimized, 0);
122
+ } else {
123
+ target.html('<div>There are no existing attachments that requires optimization.</div>');
124
+ }
125
+ }
126
+ );
127
+ });
128
+ }
129
+
130
+
131
+ /**
132
+ * ajax post to update statistics
133
+ */
134
+ function updateStatistics() {
135
+ jQuery.post(
136
+ ajaxurl, {
137
+ action: 'resmushit_update_statistics'
138
+ },
139
+ function(response) {
140
+ statistics = JSON.parse(response);
141
+ jQuery('#rsmt-statistics-space-saved').text(statistics.total_saved_size_formatted);
142
+ jQuery('#rsmt-statistics-files-optimized').text(statistics.files_optimized);
143
+ jQuery('#rsmt-statistics-percent-reduction').text(statistics.percent_reduction);
144
+ jQuery('#rsmt-statistics-total-optimizations').text(statistics.total_optimizations);
145
+ }
146
+ );
147
+ }
148
+
149
+
150
+ /**
151
+ * ajax post to disabled status (or remove)
152
+ */
153
+ function updateDisabledState() {
154
+ jQuery(document).delegate(".rsmt-trigger--disabled-checkbox","change",function(e){
155
+ e.preventDefault();
156
+ var current = this;
157
+ jQuery(current).addClass('rsmt-disable-loader');
158
+ jQuery(current).prop('disabled', true);
159
+ var disabledState = jQuery(current).is(':checked');
160
+ var postID = jQuery(current).attr('data-attachment-id');
161
+
162
+ jQuery.post(
163
+ ajaxurl, {
164
+ action: 'resmushit_update_disabled_state',
165
+ data: {id: postID, disabled: disabledState}
166
+ },
167
+ function(response) {
168
+ jQuery(current).removeClass('rsmt-disable-loader');
169
+ jQuery(current).prop('disabled', false);
170
+
171
+ if(jQuery(current).parent().hasClass('field')){
172
+ var selector = jQuery(current).parent().parent().next('tr').find('td.field');
173
+ } else {
174
+ var selector = jQuery(current).parent().next('td');
175
+ }
176
+
177
+ if(disabledState == true){
178
+ selector.empty().append('-');
179
+ } else {
180
+ selector.empty().append('<input type="button" value="Optimize" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="' + postID + '" class="button wp-smush-send" />');
181
+ }
182
+ optimizeSingleAttachment();
183
+ }
184
+ );
185
+ });
186
+ }
187
+
188
+
189
+
190
+ /**
191
+ * ajax to Optimize a single picture
192
+ */
193
+ function optimizeSingleAttachment() {
194
+ jQuery(document).delegate(".rsmt-trigger--optimize-attachment","mouseup",function(e){
195
+ e.preventDefault();
196
+ var current = this;
197
+ jQuery(current).val('Optimizing...');
198
+ jQuery(current).prop('disabled', true);
199
+ var disabledState = jQuery(current).is(':checked');
200
+ var postID = jQuery(current).attr('data-attachment-id');
201
+ jQuery.post(
202
+ ajaxurl, {
203
+ action: 'resmushit_optimize_single_attachment',
204
+ data: {id: postID}
205
+ },
206
+ function(response) {
207
+ var statistics = jQuery.parseJSON(response);
208
+ jQuery(current).parent().empty().append('Reduced by ' + statistics.total_saved_size_nice + ' (' + statistics.percent_reduction + ' saved)');
209
+ }
210
+ );
211
+ });
212
+ }
trunk/languages/resmushit-image-optimizer-fr_FR.mo ADDED
Binary file
trunk/languages/resmushit-image-optimizer-fr_FR.po ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: \n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2019-12-22 08:03+0100\n"
11
+ "PO-Revision-Date: 2019-12-22 11:14+0100\n"
12
+ "Last-Translator: \n"
13
+ "Language-Team: \n"
14
+ "Language: fr\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 2.2.4\n"
19
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
20
+
21
+ #: classes/resmushitUI.class.php:90 resmushit.php:269
22
+ msgid "Settings"
23
+ msgstr "Paramètres"
24
+
25
+ #: classes/resmushitUI.class.php:91
26
+ msgid "New!"
27
+ msgstr "Nouveau!"
28
+
29
+ #: classes/resmushitUI.class.php:98
30
+ msgid "Image quality"
31
+ msgstr "Qualité d’image"
32
+
33
+ #: classes/resmushitUI.class.php:98
34
+ msgid ""
35
+ "Default value is 92. The quality factor must be between 0 (very weak) and "
36
+ "100 (best quality)"
37
+ msgstr ""
38
+ "La valeur par défaut est de 92. Le facteur de qualité doit être comprise "
39
+ "entre 0 (mauvaise) et 100 (meilleure qualité)"
40
+
41
+ #: classes/resmushitUI.class.php:99
42
+ msgid "Optimize on upload"
43
+ msgstr "Optimiser à l'upload"
44
+
45
+ #: classes/resmushitUI.class.php:99
46
+ msgid "All future images uploaded will be automatically optimized"
47
+ msgstr ""
48
+ "Toutes les futures images téléchargées seront automatiquement optimisées"
49
+
50
+ #: classes/resmushitUI.class.php:100
51
+ msgid "Enable statistics"
52
+ msgstr "Activer les statistiques"
53
+
54
+ #: classes/resmushitUI.class.php:100
55
+ msgid "Generates statistics about optimized pictures"
56
+ msgstr "Génère des statistiques à partir des images optimisées via reSmush.it"
57
+
58
+ #: classes/resmushitUI.class.php:101
59
+ msgid "Enable logs"
60
+ msgstr "Activer les journaux"
61
+
62
+ #: classes/resmushitUI.class.php:101
63
+ msgid "Enable file logging (for developers)"
64
+ msgstr "Activation de la journalisation d'erreurs (pour développeurs)"
65
+
66
+ #: classes/resmushitUI.class.php:102
67
+ msgid "Process optimize on CRON"
68
+ msgstr "Optimiser les images via les cronjobs"
69
+
70
+ #: classes/resmushitUI.class.php:102
71
+ msgid "Will perform image optimization process through CRON tasks"
72
+ msgstr "Optimisera les images lors de l’exécution des tâches planifiées (CRON)"
73
+
74
+ #: classes/resmushitUI.class.php:121
75
+ msgid "Optimize unsmushed pictures"
76
+ msgstr "Optimiser les images via reSmush.it"
77
+
78
+ #: classes/resmushitUI.class.php:136
79
+ msgid "non optimized pictures will be automatically optimized"
80
+ msgstr "les images non optimisées le seront automatiquement"
81
+
82
+ #: classes/resmushitUI.class.php:138
83
+ msgid ""
84
+ "These pictures will be automatically optimized using schedule tasks "
85
+ "(cronjobs)."
86
+ msgstr ""
87
+ "Ces images seront automatiquement optimisées lors de l’exécution des tâches "
88
+ "planifiées (cronjobs)"
89
+
90
+ #: classes/resmushitUI.class.php:140
91
+ msgid ""
92
+ "Image optimization process can be launched <b>manually</b> by clicking on "
93
+ "the button below :"
94
+ msgstr ""
95
+ "L’optimisation des images peut être lancé <b>manuellement </b> en cliquant "
96
+ "sur le bouton suivant :"
97
+
98
+ #: classes/resmushitUI.class.php:142
99
+ msgid "There is currently"
100
+ msgstr "Il y a actuellement"
101
+
102
+ #: classes/resmushitUI.class.php:144
103
+ msgid "non optimized pictures"
104
+ msgstr "images non optimisées"
105
+
106
+ #: classes/resmushitUI.class.php:146
107
+ msgid ""
108
+ "This action will resmush all pictures which have not been optimized to the "
109
+ "good Image Quality Rate."
110
+ msgstr ""
111
+ "Cette action va optimiser toutes les images qui ne l'ont pas été avec le "
112
+ "nouveau facteur de qualité."
113
+
114
+ #: classes/resmushitUI.class.php:152
115
+ msgid "Optimize all pictures manually"
116
+ msgstr "Optimiser toutes les images manuellement"
117
+
118
+ #: classes/resmushitUI.class.php:154
119
+ msgid "Optimize all pictures"
120
+ msgstr "Optimiser toutes les images"
121
+
122
+ #: classes/resmushitUI.class.php:159
123
+ msgid "Congrats ! All your pictures are correctly optimized"
124
+ msgstr "Félicitations ! Toutes les images ont été correctement optimisées"
125
+
126
+ #: classes/resmushitUI.class.php:179
127
+ msgid "Files non optimized"
128
+ msgstr "Fichiers non optimisés"
129
+
130
+ #: classes/resmushitUI.class.php:190
131
+ msgid "pictures are too big (> 5MB) for the optimizer"
132
+ msgstr "images sont trop lourdes (> 5 Mo) pour reSmush.it"
133
+
134
+ #: classes/resmushitUI.class.php:192
135
+ msgid "picture is too big (> 5MB) for the optimizer"
136
+ msgstr "image est trop lourde (> 5 Mo) pour reSmush.it"
137
+
138
+ #: classes/resmushitUI.class.php:195
139
+ msgid "List of files above 5MB"
140
+ msgstr "Liste des fichiers de plus de 5 Mo"
141
+
142
+ #: classes/resmushitUI.class.php:227
143
+ msgid "Statistics"
144
+ msgstr "Statistiques"
145
+
146
+ #: classes/resmushitUI.class.php:234
147
+ msgid "Space saved :"
148
+ msgstr "Poids gagné :"
149
+
150
+ #: classes/resmushitUI.class.php:238
151
+ msgid "Total reduction :"
152
+ msgstr "Total réduit :"
153
+
154
+ #: classes/resmushitUI.class.php:242
155
+ msgid "Attachments optimized :"
156
+ msgstr "Nombre d'attachements optimisés :"
157
+
158
+ #: classes/resmushitUI.class.php:248
159
+ msgid "Image optimized (including thumbnails) :"
160
+ msgstr "Images optimisées (incluant les vignettes) :"
161
+
162
+ #: classes/resmushitUI.class.php:254
163
+ msgid "Total images optimized :"
164
+ msgstr "Nombre total de fichiers optimisés :"
165
+
166
+ #: classes/resmushitUI.class.php:259
167
+ msgid ""
168
+ "No picture has been optimized yet ! Add pictures to your Wordpress Media "
169
+ "Library."
170
+ msgstr ""
171
+ "Aucune image n'a été optimisée pour le moment ! Ajoutez des images à votre "
172
+ "médiathèque Wordpress."
173
+
174
+ #: classes/resmushitUI.class.php:279
175
+ msgid "News"
176
+ msgstr "Actualités"
177
+
178
+ #: classes/resmushitUI.class.php:316
179
+ msgid "Maecia Agency - Paris France"
180
+ msgstr "Agence Maecia - Paris, France"
181
+
182
+ #: classes/resmushitUI.class.php:321
183
+ msgid "Visit resmush.it for more informations"
184
+ msgstr "Visitez resmush.it pour plus d'informations"
185
+
186
+ #: classes/resmushitUI.class.php:326
187
+ msgid "Follow reSmush.it on Twitter"
188
+ msgstr "Suivez reSmush.it sur Twitter"
189
+
190
+ #: classes/resmushitUI.class.php:347
191
+ msgid "Important informations"
192
+ msgstr "Important"
193
+
194
+ #: classes/resmushitUI.class.php:352
195
+ msgid "Cronjobs seems incorrectly configured"
196
+ msgstr "Les tâches planifiées semblent configurées incorrectement"
197
+
198
+ #: classes/resmushitUI.class.php:357
199
+ msgid ""
200
+ "Cronjobs are not correctly configured. The variable <em>DISABLE_WP_CRON</em> "
201
+ "must be set to <em>TRUE</em> in <em>wp-config.php</em>. Please install them "
202
+ "by reading the following <a href=\"https://resmush.it/wordpress/howto-"
203
+ "configure-cronjobs\" target=\"_blank\">instruction page</a>."
204
+ msgstr ""
205
+ "Les cronjobs semblent mal configurés. La variable <em>DISABLE_WP_CRON</em> "
206
+ "doit être définie à la valeur <em>TRUE</em> dans le fichier <em>wp-config."
207
+ "php</em>. Se référer à <a href=\"https://resmush.it/wordpress/howto-"
208
+ "configure-cronjobs\" target=\" _blank\">la documentation</a> pour installer "
209
+ "les cronjobs correctement."
210
+
211
+ #: classes/resmushitUI.class.php:359
212
+ msgid ""
213
+ "We advice to disable Remush.it option \"Process optimize on CRON\" as long "
214
+ "as Cron jobs are incorrectly set up."
215
+ msgstr ""
216
+ "Il est recommandé de désactiver l’option \"Optimiser les images via les "
217
+ "cronjobs\" tant que ces derniers sont incorrectement configurés."
218
+
219
+ #: classes/resmushitUI.class.php:363
220
+ msgid ""
221
+ "Cronjobs seems to have never been launched. Please install them by reading "
222
+ "the following <a href=\"https://resmush.it/wordpress/howto-configure-cronjobs"
223
+ "\" target=\"_blank\">instruction page</a>."
224
+ msgstr ""
225
+ "Les tâches planifiées semblent ne s’être jamais exécutées. Installez les en "
226
+ "suivant <a href=\"https://resmush.it/wordpress/howto-configure-cronjobs\" "
227
+ "target=\" _blank\">la documentation</a>."
228
+
229
+ #: classes/resmushitUI.class.php:367
230
+ msgid ""
231
+ "Cronjobs seems not to have run lately. Please read the following <a href="
232
+ "\"https://resmush.it/wordpress/howto-configure-cronjobs\" target=\"_blank"
233
+ "\">instruction page</a> to install them correctly."
234
+ msgstr ""
235
+ "Les tâches planifiées semblent ne pas s’être lancées récemment. Suivez les "
236
+ "instructions de la <a href=\"https://resmush.it/wordpress/howto-configure-"
237
+ "cronjobs\" target=\" _blank\">la documentation</a> pour les installer "
238
+ "correctement."
239
+
240
+ #: classes/resmushitUI.class.php:368
241
+ msgid "Expected Frequency :"
242
+ msgstr "Fréquence :"
243
+
244
+ #: classes/resmushitUI.class.php:368 resmushit.php:299
245
+ msgid "Every"
246
+ msgstr "Toutes les"
247
+
248
+ #: classes/resmushitUI.class.php:369
249
+ msgid "Last run :"
250
+ msgstr "Dernière exécution :"
251
+
252
+ #: classes/resmushitUI.class.php:369
253
+ msgid "ago"
254
+ msgstr ""
255
+
256
+ #: classes/resmushitUI.class.php:454
257
+ msgid "Optimize"
258
+ msgstr "Optimiser"
259
+
260
+ #: classes/resmushitUI.class.php:457
261
+ msgid "Reduced by"
262
+ msgstr "Réduction de"
263
+
264
+ #: classes/resmushitUI.class.php:457
265
+ msgid "saved"
266
+ msgstr "gagné"
267
+
268
+ #: classes/resmushitUI.class.php:458
269
+ msgid "Force re-optimize"
270
+ msgstr "Forcer la ré-optimisation"
271
+
272
+ #: resmushit.admin.php:43 resmushit.admin.php:98
273
+ msgid "Disable of reSmush.it"
274
+ msgstr "Désactiver l'optimisation reSmush.it"
275
+
276
+ #: resmushit.admin.php:44 resmushit.admin.php:105
277
+ msgid "reSmush.it status"
278
+ msgstr "Statut de reSmush.it"
279
+
280
+ #: resmushit.inc.php:119
281
+ msgid "year"
282
+ msgstr "année"
283
+
284
+ #: resmushit.inc.php:120
285
+ msgid "month"
286
+ msgstr "mois"
287
+
288
+ #: resmushit.inc.php:121
289
+ msgid "week"
290
+ msgstr "semaine"
291
+
292
+ #: resmushit.inc.php:122
293
+ msgid "day"
294
+ msgstr "jour"
295
+
296
+ #: resmushit.inc.php:123
297
+ msgid "hour"
298
+ msgstr "heure"
299
+
300
+ #: resmushit.inc.php:124
301
+ msgid "minute"
302
+ msgstr "minute"
303
+
304
+ #: resmushit.inc.php:125
305
+ msgid "second"
306
+ msgstr "seconde"
307
+
308
+ #: resmushit.inc.php:136
309
+ msgid "just now"
310
+ msgstr "à l’instant"
311
+
312
+ #: resmushit.php:299
313
+ msgid " "
314
+ msgstr ""
315
+
316
+ #. Plugin Name of the plugin/theme
317
+ msgid "reSmush.it Image Optimizer"
318
+ msgstr "reSmush.it Image Optimizer"
319
+
320
+ #. Plugin URI of the plugin/theme
321
+ #. Author URI of the plugin/theme
322
+ msgid "https://resmush.it"
323
+ msgstr "https://resmush.it"
324
+
325
+ #. Description of the plugin/theme
326
+ msgid "Image Optimization API. Provides image size optimization"
327
+ msgstr "Image Optimization API. Optimisation de la taille des images"
328
+
329
+ #. Author of the plugin/theme
330
+ msgid "reSmush.it"
331
+ msgstr "reSmush.it"
332
+
333
+ #~ msgid "Maecia"
334
+ #~ msgstr "Maecia"
335
+
336
+ #~ msgid "https://www.maecia.com"
337
+ #~ msgstr "https://www.maecia.com"
trunk/languages/resmushit-image-optimizer-it_IT.mo ADDED
Binary file
trunk/languages/resmushit-image-optimizer-it_IT.po ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: \n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2018-04-04 13:44+0200\n"
11
+ "PO-Revision-Date: 2018-04-04 13:45+0200\n"
12
+ "Last-Translator: \n"
13
+ "Language-Team: \n"
14
+ "Language: it\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 2.0.2\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+
21
+ #: classes/resmushitUI.class.php:90
22
+ msgid "Settings"
23
+ msgstr "Configurazioni"
24
+
25
+ #: classes/resmushitUI.class.php:97
26
+ msgid "Image quality"
27
+ msgstr "Qualità dell'immagine"
28
+
29
+ #: classes/resmushitUI.class.php:97
30
+ msgid ""
31
+ "Default value is 92. The quality factor must be between 0 (very weak) and "
32
+ "100 (best quality)"
33
+ msgstr ""
34
+ "Il valore di Default è 92. Il fattore qualità deve essere tra 0 (qualità "
35
+ "pessima) e 100 (massima qualità)"
36
+
37
+ #: classes/resmushitUI.class.php:98
38
+ msgid "Optimize on upload"
39
+ msgstr "Ottimizza nella fase di upload"
40
+
41
+ #: classes/resmushitUI.class.php:98
42
+ msgid "All future images uploaded will be automatically optimized"
43
+ msgstr ""
44
+ "Tutte le immagini che in futuro verranno caricate verranno automaticamente "
45
+ "ottimizzate"
46
+
47
+ #: classes/resmushitUI.class.php:99
48
+ msgid "Enable statistics"
49
+ msgstr "Abilita le statistiche"
50
+
51
+ #: classes/resmushitUI.class.php:99
52
+ msgid "Generates statistics about optimized pictures"
53
+ msgstr "Genera le statistiche in merito alle immagini ottimizzate"
54
+
55
+ #: classes/resmushitUI.class.php:100
56
+ msgid "Enable logs"
57
+ msgstr "Abilita i logs"
58
+
59
+ #: classes/resmushitUI.class.php:100
60
+ msgid "Enable file logging (for developers)"
61
+ msgstr "Abilita i file di log (per gli sviluppatori)"
62
+
63
+ #: classes/resmushitUI.class.php:120
64
+ msgid "Optimize unsmushed pictures"
65
+ msgstr "Ottimizza le immagini"
66
+
67
+ #: classes/resmushitUI.class.php:125
68
+ msgid "There is currently"
69
+ msgstr "Vi è attualmente"
70
+
71
+ #: classes/resmushitUI.class.php:125
72
+ msgid "non optimized pictures"
73
+ msgstr "immagini non ottiizzate"
74
+
75
+ #: classes/resmushitUI.class.php:126
76
+ msgid ""
77
+ "This action will resmush all pictures which have not been optimized to the "
78
+ "good Image Quality Rate."
79
+ msgstr ""
80
+ "Questa azione ottimizzerà tutte le immagini che non sono state "
81
+ "precedentemente ottimizzate secondo i Parametri di Qualità d'immagine "
82
+ "definiti."
83
+
84
+ #: classes/resmushitUI.class.php:128
85
+ msgid "Optimize all pictures"
86
+ msgstr "Ottimizza tutte le immagini"
87
+
88
+ #: classes/resmushitUI.class.php:134
89
+ msgid "Congrats ! All your pictures are correctly optimized"
90
+ msgstr ""
91
+ "Congratulazioni ! Tutte le immagini sono state ottimizzate correttamente"
92
+
93
+ #: classes/resmushitUI.class.php:155
94
+ msgid "Files non optimized"
95
+ msgstr "Files non ottimizzati"
96
+
97
+ #: classes/resmushitUI.class.php:162
98
+ msgid "pictures are too big (> 5MB) for the optimizer"
99
+ msgstr "immagini troppo grandi (> 5MB) per l'ottimizzatore"
100
+
101
+ #: classes/resmushitUI.class.php:164
102
+ msgid "picture is too big (> 5MB) for the optimizer"
103
+ msgstr "immagine troppo grande (> 5MB) per l'ottimizzatore"
104
+
105
+ #: classes/resmushitUI.class.php:168
106
+ msgid "List of files above 5MB"
107
+ msgstr "Elenco dei file che superano i 5MB"
108
+
109
+ #: classes/resmushitUI.class.php:197
110
+ msgid "Statistics"
111
+ msgstr "Statistiche"
112
+
113
+ #: classes/resmushitUI.class.php:204
114
+ msgid "Space saved :"
115
+ msgstr "Spazio risparmiato:"
116
+
117
+ #: classes/resmushitUI.class.php:205
118
+ msgid "Total reduction :"
119
+ msgstr "Riduzione totale"
120
+
121
+ #: classes/resmushitUI.class.php:206
122
+ msgid "Attachments optimized :"
123
+ msgstr "Allegati ottimizzati:"
124
+
125
+ #: classes/resmushitUI.class.php:207
126
+ msgid "Image optimized (including thumbnails) :"
127
+ msgstr "Immagine ottimizzata (thumbnails inclusi)"
128
+
129
+ #: classes/resmushitUI.class.php:208
130
+ msgid "Total images optimized :"
131
+ msgstr "Totale immagini ottimizzate:"
132
+
133
+ #: classes/resmushitUI.class.php:210
134
+ msgid ""
135
+ "No picture has been optimized yet ! Add pictures to your Wordpress Media "
136
+ "Library."
137
+ msgstr ""
138
+ "Nessuna immagine è stata ancora ottimizzata! Aggiungi immagini alla tua "
139
+ "Libreria Media di Wordpress"
140
+
141
+ #: classes/resmushitUI.class.php:231
142
+ msgid "News"
143
+ msgstr "Novità"
144
+
145
+ #: classes/resmushitUI.class.php:262
146
+ msgid "Maecia Agency - Paris France"
147
+ msgstr "Maecia Agency - Parigi Francia"
148
+
149
+ #: classes/resmushitUI.class.php:265
150
+ msgid "Visit resmush.it for more informations"
151
+ msgstr "Visita resmush.it per ottenere più informazioni"
152
+
153
+ #: classes/resmushitUI.class.php:268
154
+ msgid "Follow reSmush.it on Twitter"
155
+ msgstr "Segui reSmush.it su Twitter"
156
+
157
+ #: classes/resmushitUI.class.php:352
158
+ msgid "Optimize"
159
+ msgstr "Ottimizza"
160
+
161
+ #: classes/resmushitUI.class.php:355
162
+ msgid "Reduced by"
163
+ msgstr "Ridotto di"
164
+
165
+ #: classes/resmushitUI.class.php:355
166
+ msgid "saved"
167
+ msgstr "risparmiati"
168
+
169
+ #: resmushit.admin.php:37 resmushit.admin.php:64
170
+ msgid "Disable of reSmush.it"
171
+ msgstr "Disabilita reSmush.it"
172
+
173
+ #: resmushit.admin.php:38 resmushit.admin.php:71
174
+ msgid "reSmush.it status"
175
+ msgstr "stato di reSmush.it"
176
+
177
+ #. Plugin Name of the plugin/theme
178
+ msgid "reSmush.it Image Optimizer"
179
+ msgstr "reSmush.it Image Optimizer"
180
+
181
+ #. Plugin URI of the plugin/theme
182
+ msgid "http://www.resmush.it"
183
+ msgstr "https://resmush.it"
184
+
185
+ #. Description of the plugin/theme
186
+ msgid "Image Optimization API. Provides image size optimization"
187
+ msgstr ""
188
+ "Image Optimization API. Fornisce l'ottimizzazione della dimensione "
189
+ "dell'immagine"
190
+
191
+ #. Author of the plugin/theme
192
+ msgid "Maecia"
193
+ msgstr "Maecia"
194
+
195
+ #. Author URI of the plugin/theme
196
+ msgid "https://www.maecia.com"
197
+ msgstr "https://www.maecia.com"
trunk/languages/resmushit-image-optimizer-sk_SK.mo ADDED
Binary file
trunk/languages/resmushit-image-optimizer-sk_SK.po ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: \n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2018-04-04 13:46+0200\n"
11
+ "PO-Revision-Date: 2018-04-04 13:47+0200\n"
12
+ "Last-Translator: Martin Šturcel <martin@sturcel.sk>\n"
13
+ "Language-Team: Martin Šturcel <martin@sturcel.sk>\n"
14
+ "Language: sk\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 2.0.2\n"
19
+ "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
20
+
21
+ #: classes/resmushitUI.class.php:90
22
+ msgid "Settings"
23
+ msgstr "Nastavenia"
24
+
25
+ #: classes/resmushitUI.class.php:97
26
+ msgid "Image quality"
27
+ msgstr "Kvalita obrázkov"
28
+
29
+ #: classes/resmushitUI.class.php:97
30
+ msgid ""
31
+ "Default value is 92. The quality factor must be between 0 (very weak) and "
32
+ "100 (best quality)"
33
+ msgstr ""
34
+ "Prednastavená hodnota je 92. Hodnota kvality musí byť v rozmedzí od 0 (veľmi "
35
+ "slabá) a 100 (najlepšia kvalita)"
36
+
37
+ #: classes/resmushitUI.class.php:98
38
+ msgid "Optimize on upload"
39
+ msgstr "Optimalizovať pri nahrávaní"
40
+
41
+ #: classes/resmushitUI.class.php:98
42
+ msgid "All future images uploaded will be automatically optimized"
43
+ msgstr "Všetky vaše novo pridané obrázky budú automaticky optimalizované"
44
+
45
+ #: classes/resmushitUI.class.php:99
46
+ msgid "Enable statistics"
47
+ msgstr "Zapnúť štatistiku"
48
+
49
+ #: classes/resmushitUI.class.php:99
50
+ msgid "Generates statistics about optimized pictures"
51
+ msgstr "Generuje štatistiky o optimalizovaných súboroch"
52
+
53
+ #: classes/resmushitUI.class.php:100
54
+ msgid "Enable logs"
55
+ msgstr "Zapnúť logovanie"
56
+
57
+ #: classes/resmushitUI.class.php:100
58
+ msgid "Enable file logging (for developers)"
59
+ msgstr "Zapnúť logovanie do súboru (pre vývojárov)"
60
+
61
+ #: classes/resmushitUI.class.php:120
62
+ msgid "Optimize unsmushed pictures"
63
+ msgstr "Optimalizácia obrázkov"
64
+
65
+ #: classes/resmushitUI.class.php:125
66
+ msgid "There is currently"
67
+ msgstr "V súčastnosti"
68
+
69
+ #: classes/resmushitUI.class.php:125
70
+ msgid "non optimized pictures"
71
+ msgstr "neoptimalizovaných obrázkov"
72
+
73
+ #: classes/resmushitUI.class.php:126
74
+ msgid ""
75
+ "This action will resmush all pictures which have not been optimized to the "
76
+ "good Image Quality Rate."
77
+ msgstr ""
78
+ "Týmto tlačidlom budú spracované všetky obrázky, ktoré neboli ešte "
79
+ "optimalizované nastavenej kvalite."
80
+
81
+ #: classes/resmushitUI.class.php:128
82
+ msgid "Optimize all pictures"
83
+ msgstr "Optimalizovať všetky obrázky"
84
+
85
+ #: classes/resmushitUI.class.php:134
86
+ msgid "Congrats ! All your pictures are correctly optimized"
87
+ msgstr ""
88
+ "Blahoželáme! Všetky vaše obrázky sú optimalizované podľa aktuáneho "
89
+ "nastavenia kvality"
90
+
91
+ #: classes/resmushitUI.class.php:155
92
+ msgid "Files non optimized"
93
+ msgstr "Súbory ktoré neboli optimalizované"
94
+
95
+ #: classes/resmushitUI.class.php:162
96
+ msgid "pictures are too big (> 5MB) for the optimizer"
97
+ msgstr "obrázky sú príliš veľké pre optimalizáciu, majú viac ako 5MB"
98
+
99
+ #: classes/resmushitUI.class.php:164
100
+ msgid "picture is too big (> 5MB) for the optimizer"
101
+ msgstr "obrázok je príliš veľký pre optimalizáciu, má viac ako 5MB"
102
+
103
+ #: classes/resmushitUI.class.php:168
104
+ msgid "List of files above 5MB"
105
+ msgstr "Zoznam súborov väčších ako 5MB"
106
+
107
+ #: classes/resmushitUI.class.php:197
108
+ msgid "Statistics"
109
+ msgstr "Štatistika"
110
+
111
+ #: classes/resmushitUI.class.php:204
112
+ msgid "Space saved :"
113
+ msgstr "Ušetrené miesto:"
114
+
115
+ #: classes/resmushitUI.class.php:205
116
+ msgid "Total reduction :"
117
+ msgstr "Celkovo ušetrené :"
118
+
119
+ #: classes/resmushitUI.class.php:206
120
+ msgid "Attachments optimized :"
121
+ msgstr "Optimalizované prílohy:"
122
+
123
+ #: classes/resmushitUI.class.php:207
124
+ msgid "Image optimized (including thumbnails) :"
125
+ msgstr "Optimalizované obrázky (vrátane náhľadov):"
126
+
127
+ #: classes/resmushitUI.class.php:208
128
+ msgid "Total images optimized :"
129
+ msgstr "Celkom optimalizvaných obrázkov :"
130
+
131
+ #: classes/resmushitUI.class.php:210
132
+ msgid ""
133
+ "No picture has been optimized yet ! Add pictures to your Wordpress Media "
134
+ "Library."
135
+ msgstr ""
136
+ "Žiadne obrázky zatiaľ neboli optimalizované. Pridajte obrázky do "
137
+ "multimediálnej knižnice alebo optimalizujte obrázky."
138
+
139
+ #: classes/resmushitUI.class.php:231
140
+ msgid "News"
141
+ msgstr "Novinky"
142
+
143
+ #: classes/resmushitUI.class.php:262
144
+ msgid "Maecia Agency - Paris France"
145
+ msgstr "Maecia Agency - Paris France"
146
+
147
+ #: classes/resmushitUI.class.php:265
148
+ msgid "Visit resmush.it for more informations"
149
+ msgstr "Navštívte resmush.it pre viac informácii"
150
+
151
+ #: classes/resmushitUI.class.php:268
152
+ msgid "Follow reSmush.it on Twitter"
153
+ msgstr "Sledovať reSmush.it na Twitteri"
154
+
155
+ #: classes/resmushitUI.class.php:352
156
+ msgid "Optimize"
157
+ msgstr "Optimalizovať"
158
+
159
+ #: classes/resmushitUI.class.php:355
160
+ msgid "Reduced by"
161
+ msgstr "Znížená veľkosť o"
162
+
163
+ #: classes/resmushitUI.class.php:355
164
+ msgid "saved"
165
+ msgstr "ušetrené"
166
+
167
+ #: resmushit.admin.php:37 resmushit.admin.php:64
168
+ msgid "Disable of reSmush.it"
169
+ msgstr "Vypnúť reSmush.it"
170
+
171
+ #: resmushit.admin.php:38 resmushit.admin.php:71
172
+ msgid "reSmush.it status"
173
+ msgstr "Stav reSmush.it"
174
+
175
+ #. Plugin Name of the plugin/theme
176
+ msgid "reSmush.it Image Optimizer"
177
+ msgstr "reSmush.it Image Optimizer"
178
+
179
+ #. Plugin URI of the plugin/theme
180
+ msgid "http://www.resmush.it"
181
+ msgstr "https://resmush.it"
182
+
183
+ #. Description of the plugin/theme
184
+ msgid "Image Optimization API. Provides image size optimization"
185
+ msgstr "Image Optimization API. Poskytuje optimalizáciu veľkosti obrázka"
186
+
187
+ #. Author of the plugin/theme
188
+ msgid "Maecia"
189
+ msgstr "Maecia"
190
+
191
+ #. Author URI of the plugin/theme
192
+ msgid "https://www.maecia.com"
193
+ msgstr "https://www.maecia.com"
trunk/languages/resmushit-image-optimizer.pot ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #, fuzzy
2
+ msgid ""
3
+ msgstr ""
4
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
+ "Project-Id-Version: reSmush.it Image Optimizer\n"
6
+ "POT-Creation-Date: 2019-12-22 08:03+0100\n"
7
+ "PO-Revision-Date: 2018-04-04 13:39+0200\n"
8
+ "Last-Translator: \n"
9
+ "Language-Team: https://resmush.it\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.2.4\n"
14
+ "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-Flags-xgettext: --add-comments=translators:\n"
16
+ "X-Poedit-WPHeader: resmushit.php\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
19
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
20
+ "_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
21
+ "X-Poedit-SearchPath-0: .\n"
22
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
23
+
24
+ #: classes/resmushitUI.class.php:90 resmushit.php:269
25
+ msgid "Settings"
26
+ msgstr ""
27
+
28
+ #: classes/resmushitUI.class.php:91
29
+ msgid "New!"
30
+ msgstr ""
31
+
32
+ #: classes/resmushitUI.class.php:98
33
+ msgid "Image quality"
34
+ msgstr ""
35
+
36
+ #: classes/resmushitUI.class.php:98
37
+ msgid ""
38
+ "Default value is 92. The quality factor must be between 0 (very weak) and "
39
+ "100 (best quality)"
40
+ msgstr ""
41
+
42
+ #: classes/resmushitUI.class.php:99
43
+ msgid "Optimize on upload"
44
+ msgstr ""
45
+
46
+ #: classes/resmushitUI.class.php:99
47
+ msgid "All future images uploaded will be automatically optimized"
48
+ msgstr ""
49
+
50
+ #: classes/resmushitUI.class.php:100
51
+ msgid "Enable statistics"
52
+ msgstr ""
53
+
54
+ #: classes/resmushitUI.class.php:100
55
+ msgid "Generates statistics about optimized pictures"
56
+ msgstr ""
57
+
58
+ #: classes/resmushitUI.class.php:101
59
+ msgid "Enable logs"
60
+ msgstr ""
61
+
62
+ #: classes/resmushitUI.class.php:101
63
+ msgid "Enable file logging (for developers)"
64
+ msgstr ""
65
+
66
+ #: classes/resmushitUI.class.php:102
67
+ msgid "Process optimize on CRON"
68
+ msgstr ""
69
+
70
+ #: classes/resmushitUI.class.php:102
71
+ msgid "Will perform image optimization process through CRON tasks"
72
+ msgstr ""
73
+
74
+ #: classes/resmushitUI.class.php:121
75
+ msgid "Optimize unsmushed pictures"
76
+ msgstr ""
77
+
78
+ #: classes/resmushitUI.class.php:136
79
+ msgid "non optimized pictures will be automatically optimized"
80
+ msgstr ""
81
+
82
+ #: classes/resmushitUI.class.php:138
83
+ msgid ""
84
+ "These pictures will be automatically optimized using schedule tasks "
85
+ "(cronjobs)."
86
+ msgstr ""
87
+
88
+ #: classes/resmushitUI.class.php:140
89
+ msgid ""
90
+ "Image optimization process can be launched <b>manually</b> by clicking on "
91
+ "the button below :"
92
+ msgstr ""
93
+
94
+ #: classes/resmushitUI.class.php:142
95
+ msgid "There is currently"
96
+ msgstr ""
97
+
98
+ #: classes/resmushitUI.class.php:144
99
+ msgid "non optimized pictures"
100
+ msgstr ""
101
+
102
+ #: classes/resmushitUI.class.php:146
103
+ msgid ""
104
+ "This action will resmush all pictures which have not been optimized to the "
105
+ "good Image Quality Rate."
106
+ msgstr ""
107
+
108
+ #: classes/resmushitUI.class.php:152
109
+ msgid "Optimize all pictures manually"
110
+ msgstr ""
111
+
112
+ #: classes/resmushitUI.class.php:154
113
+ msgid "Optimize all pictures"
114
+ msgstr ""
115
+
116
+ #: classes/resmushitUI.class.php:159
117
+ msgid "Congrats ! All your pictures are correctly optimized"
118
+ msgstr ""
119
+
120
+ #: classes/resmushitUI.class.php:179
121
+ msgid "Files non optimized"
122
+ msgstr ""
123
+
124
+ #: classes/resmushitUI.class.php:190
125
+ msgid "pictures are too big (> 5MB) for the optimizer"
126
+ msgstr ""
127
+
128
+ #: classes/resmushitUI.class.php:192
129
+ msgid "picture is too big (> 5MB) for the optimizer"
130
+ msgstr ""
131
+
132
+ #: classes/resmushitUI.class.php:195
133
+ msgid "List of files above 5MB"
134
+ msgstr ""
135
+
136
+ #: classes/resmushitUI.class.php:227
137
+ msgid "Statistics"
138
+ msgstr ""
139
+
140
+ #: classes/resmushitUI.class.php:234
141
+ msgid "Space saved :"
142
+ msgstr ""
143
+
144
+ #: classes/resmushitUI.class.php:238
145
+ msgid "Total reduction :"
146
+ msgstr ""
147
+
148
+ #: classes/resmushitUI.class.php:242
149
+ msgid "Attachments optimized :"
150
+ msgstr ""
151
+
152
+ #: classes/resmushitUI.class.php:248
153
+ msgid "Image optimized (including thumbnails) :"
154
+ msgstr ""
155
+
156
+ #: classes/resmushitUI.class.php:254
157
+ msgid "Total images optimized :"
158
+ msgstr ""
159
+
160
+ #: classes/resmushitUI.class.php:259
161
+ msgid ""
162
+ "No picture has been optimized yet ! Add pictures to your Wordpress Media "
163
+ "Library."
164
+ msgstr ""
165
+
166
+ #: classes/resmushitUI.class.php:279
167
+ msgid "News"
168
+ msgstr ""
169
+
170
+ #: classes/resmushitUI.class.php:316
171
+ msgid "Maecia Agency - Paris France"
172
+ msgstr ""
173
+
174
+ #: classes/resmushitUI.class.php:321
175
+ msgid "Visit resmush.it for more informations"
176
+ msgstr ""
177
+
178
+ #: classes/resmushitUI.class.php:326
179
+ msgid "Follow reSmush.it on Twitter"
180
+ msgstr ""
181
+
182
+ #: classes/resmushitUI.class.php:347
183
+ msgid "Important informations"
184
+ msgstr ""
185
+
186
+ #: classes/resmushitUI.class.php:352
187
+ msgid "Cronjobs seems incorrectly configured"
188
+ msgstr ""
189
+
190
+ #: classes/resmushitUI.class.php:357
191
+ msgid ""
192
+ "Cronjobs are not correctly configured. The variable <em>DISABLE_WP_CRON</"
193
+ "em> must be set to <em>TRUE</em> in <em>wp-config.php</em>. Please install "
194
+ "them by reading the following <a href=\"https://resmush.it/wordpress/howto-"
195
+ "configure-cronjobs\" target=\"_blank\">instruction page</a>."
196
+ msgstr ""
197
+
198
+ #: classes/resmushitUI.class.php:359
199
+ msgid ""
200
+ "We advice to disable Remush.it option \"Process optimize on CRON\" as long "
201
+ "as Cron jobs are incorrectly set up."
202
+ msgstr ""
203
+
204
+ #: classes/resmushitUI.class.php:363
205
+ msgid ""
206
+ "Cronjobs seems to have never been launched. Please install them by reading "
207
+ "the following <a href=\"https://resmush.it/wordpress/howto-configure-"
208
+ "cronjobs\" target=\"_blank\">instruction page</a>."
209
+ msgstr ""
210
+
211
+ #: classes/resmushitUI.class.php:367
212
+ msgid ""
213
+ "Cronjobs seems not to have run lately. Please read the following <a href="
214
+ "\"https://resmush.it/wordpress/howto-configure-cronjobs\" target=\"_blank"
215
+ "\">instruction page</a> to install them correctly."
216
+ msgstr ""
217
+
218
+ #: classes/resmushitUI.class.php:368
219
+ msgid "Expected Frequency :"
220
+ msgstr ""
221
+
222
+ #: classes/resmushitUI.class.php:368 resmushit.php:299
223
+ msgid "Every"
224
+ msgstr ""
225
+
226
+ #: classes/resmushitUI.class.php:369
227
+ msgid "Last run :"
228
+ msgstr ""
229
+
230
+ #: classes/resmushitUI.class.php:369
231
+ msgid "ago"
232
+ msgstr ""
233
+
234
+ #: classes/resmushitUI.class.php:454
235
+ msgid "Optimize"
236
+ msgstr ""
237
+
238
+ #: classes/resmushitUI.class.php:457
239
+ msgid "Reduced by"
240
+ msgstr ""
241
+
242
+ #: classes/resmushitUI.class.php:457
243
+ msgid "saved"
244
+ msgstr ""
245
+
246
+ #: classes/resmushitUI.class.php:458
247
+ msgid "Force re-optimize"
248
+ msgstr ""
249
+
250
+ #: resmushit.admin.php:43 resmushit.admin.php:98
251
+ msgid "Disable of reSmush.it"
252
+ msgstr ""
253
+
254
+ #: resmushit.admin.php:44 resmushit.admin.php:105
255
+ msgid "reSmush.it status"
256
+ msgstr ""
257
+
258
+ #: resmushit.inc.php:119
259
+ msgid "year"
260
+ msgstr ""
261
+
262
+ #: resmushit.inc.php:120
263
+ msgid "month"
264
+ msgstr ""
265
+
266
+ #: resmushit.inc.php:121
267
+ msgid "week"
268
+ msgstr ""
269
+
270
+ #: resmushit.inc.php:122
271
+ msgid "day"
272
+ msgstr ""
273
+
274
+ #: resmushit.inc.php:123
275
+ msgid "hour"
276
+ msgstr ""
277
+
278
+ #: resmushit.inc.php:124
279
+ msgid "minute"
280
+ msgstr ""
281
+
282
+ #: resmushit.inc.php:125
283
+ msgid "second"
284
+ msgstr ""
285
+
286
+ #: resmushit.inc.php:136
287
+ msgid "just now"
288
+ msgstr ""
289
+
290
+ #: resmushit.php:299
291
+ msgid " "
292
+ msgstr ""
293
+
294
+ #. Plugin Name of the plugin/theme
295
+ msgid "reSmush.it Image Optimizer"
296
+ msgstr ""
297
+
298
+ #. Plugin URI of the plugin/theme
299
+ #. Author URI of the plugin/theme
300
+ msgid "https://resmush.it"
301
+ msgstr ""
302
+
303
+ #. Description of the plugin/theme
304
+ msgid "Image Optimization API. Provides image size optimization"
305
+ msgstr ""
306
+
307
+ #. Author of the plugin/theme
308
+ msgid "reSmush.it"
309
+ msgstr ""
trunk/readme.txt ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === reSmush.it Image Optimizer ===
2
+ 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: 5.3.2
6
+ Stable tag: 0.2.2
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Use reSmush.it Image Optimizer for FREE to optimize your pictures file sizes. Improve your performances by using reSmush.it, the 7 billion images API optimizer.
11
+
12
+ == Description ==
13
+
14
+ reSmush.it Image Optimizer allow to use **free Image optimization** based on [reSmush.it API](http://www.resmush.it/ "Image Optimization API, developped by Charles Bourgeaux"). reSmush.it provides image size reduction based on several advanced algorithms. The API accept JPG, PNG and GIF files up to **5MB**.
15
+
16
+ This plugin includes a bulk operation to optimize all your pictures in 2 clicks ! Change your image optimization level to fit your needs !
17
+ This service is used by more than **400,000** websites on different CMS (Wordpress, Drupal, Joomla, Magento, Prestashop...).
18
+
19
+ The plugin includes an option to exclude some pictures of the optimizer.
20
+
21
+ Since Aug. 2016, reSmush.it allows to optimize pictures up to 5MB, for free !
22
+
23
+ This plugin has initially been developped by [Maecia Agency](http://www.maecia.com/ "Maecia Drupal & Wordpress Agency"), Paris.
24
+
25
+ == Installation ==
26
+
27
+ 1. Upload `resmushit-image-optimizer` to the `/wp-content/plugins/` directory.
28
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
29
+ 3. All your new pictures will be automatically optimized !
30
+
31
+
32
+ == Frequently Asked Questions ==
33
+
34
+
35
+ = How great is reSmush.it ? =
36
+
37
+ Since we've optimized more than 7,000,000,000 pictures, we've risen new skills. Our service is still in development to bring you new crazy functionalities.
38
+
39
+ = Is there an "Optimize on upload" feature ? =
40
+
41
+ Absolutely, this feature is enabled for all new pictures to be added, and can be disabled on will.
42
+
43
+ = Is there a CRON feature ? =
44
+
45
+ Yes, for big (and even for small) media Libraries, you can optimize your pictures using Cronjobs.
46
+
47
+ = Can I choose an optimisation level ? =
48
+
49
+ Yes, by default the optimization level is set at 92. But you can optimize more your pictures by reducing this optimization level.
50
+
51
+ = Can I go back to my original pictures ? =
52
+
53
+ Yes, by excluding/reverting this asset you'll have your original image available.
54
+
55
+ = Is it possible to exclude some pictures from the optimizer ? =
56
+
57
+ Yes, since version 0.1.2, you can easily exclude an asset from the optimizer.
58
+
59
+ = Have I a risk to lose my existing pictures ? =
60
+
61
+ Nope ! reSmush.it Image Optimizer creates a copy of the original pictures, and will perform optimizations only on copies.
62
+
63
+ = Is it free ? =
64
+
65
+ Yes ! Absolutely free, the only restriction is to send images below 5MB.
66
+
67
+ == Screenshots ==
68
+
69
+ 1. The simple interface
70
+
71
+ == Changelog ==
72
+
73
+ = 0.2.2 =
74
+ * Fix settings automatically reinitialized.
75
+
76
+ = 0.2.1 =
77
+ * Complete French translation
78
+ * Plugin translation fix
79
+
80
+ = 0.2.0 =
81
+ * Add CRON feature
82
+ * Code refactoring
83
+ * Fix issue for big Media library, with a limitation while fetching attachments
84
+ * Fix log path issues
85
+
86
+ = 0.1.23 =
87
+ * Add Settings link to Plugin page
88
+ * Limit reSmush.it options to image attachments only
89
+ * Fix `RESMUSHIT_QLTY is not defined`
90
+
91
+ = 0.1.22 =
92
+ * Fix on attachment metadata incorrectly returned (will fix issues with other media libraries)
93
+
94
+ = 0.1.21 =
95
+ * Wordpress 5.0 compatibility
96
+
97
+ = 0.1.20 =
98
+ * Fix PHP errors with PHP 7.2
99
+ * Code refacto
100
+
101
+ = 0.1.19 =
102
+ * Fix JS on "Optimize" button for a single picture
103
+ * Provide a new "Force Optimization" for a single picture
104
+
105
+ = 0.1.18 =
106
+ * Avoid `filesize () : stat failed` errors if a picture file is missing
107
+ * Log check file permissions
108
+ * Check extensions on upload (avoid using reSmush.it API if it's not a picture)
109
+ * Increase API Timeout for big pictures (10 secs)
110
+
111
+ = 0.1.17 =
112
+ * Fix bug (non-working optimization) on bulk upload when "Optimize on upload" isn't selected
113
+ * New header banner for 4 billionth images optimized
114
+
115
+ = 0.1.16 =
116
+ * Add correction for allow_url_fopen support
117
+ * News feed loaded from a SSL URL
118
+
119
+ = 0.1.15 =
120
+ * Log rotate if file too big
121
+
122
+ = 0.1.14 =
123
+ * Tested up to Wordpress 4.9.5
124
+ * New contributor (resmushit)
125
+ * Translation completion
126
+
127
+ = 0.1.13 =
128
+ * Tested up to Wordpress 4.9.1
129
+ * New header banner for 3 billionth images optimized :)
130
+
131
+ = 0.1.12 =
132
+ * Tested up to Wordpress 4.8.1
133
+
134
+ = 0.1.11 =
135
+ * New header banner for 2 billionth images optimized :)
136
+
137
+ = 0.1.10 =
138
+ * Slovak translation fix
139
+
140
+ = 0.1.9 =
141
+ * Slovak translation fix
142
+
143
+ = 0.1.8 =
144
+ * Italian translation added (thanks to Cristian R.)
145
+ * Description minor correction
146
+
147
+ = 0.1.7 =
148
+ * Slovak translation added (thanks to Martin S.)
149
+
150
+ = 0.1.6 =
151
+ * Bug fix when images uploaded > 5MB
152
+ * List of files above 5MB
153
+ * Translation minor corrections
154
+
155
+ = 0.1.5 =
156
+ * Error management if webservice not reachable
157
+ * Filesize limitation increased from 2MB to 5MB
158
+
159
+ = 0.1.4 =
160
+ * CSS Fixes
161
+
162
+ = 0.1.3 =
163
+ * Translation correction
164
+ * News feed images correction
165
+
166
+ = 0.1.2 =
167
+ * Delete also original file when deleting an attachment
168
+ * Exclusion of an attachment of the reSmush.it optimization (checkboxes)
169
+ * Adding french translation
170
+ * Code optimizations
171
+ * 4.6.x check
172
+ * Minor bugs corrections
173
+
174
+ = 0.1.1 =
175
+ * Optimize on upload
176
+ * Statistics
177
+ * Log services
178
+ * Interface rebuild
179
+ * News feed from feed.resmush.it
180
+
181
+ = 0.1.0 =
182
+ * plugin base
183
+ * bulk optimizer
trunk/resmushit.admin.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Create menu entries and routing
5
+ *
6
+ * @param none
7
+ * @return none
8
+ */
9
+ function resmushit_create_menu() {
10
+ if ( is_super_admin() )
11
+ add_media_page( 'reSmush.it', 'reSmush.it', 'manage_options', 'resmushit_options', 'resmushit_settings_page');
12
+ }
13
+ add_action( 'admin_menu','resmushit_create_menu');
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * Declares settings entries
20
+ *
21
+ * @param none
22
+ * @return none
23
+ */
24
+ function resmushit_settings_declare() {
25
+ register_setting( 'resmushit-settings', 'resmushit_on_upload' );
26
+ register_setting( 'resmushit-settings', 'resmushit_qlty' );
27
+ register_setting( 'resmushit-settings', 'resmushit_statistics' );
28
+ register_setting( 'resmushit-settings', 'resmushit_logs' );
29
+ register_setting( 'resmushit-settings', 'resmushit_cron' );
30
+ }
31
+ add_action( 'admin_init', 'resmushit_settings_declare' );
32
+
33
+
34
+
35
+ /**
36
+ *
37
+ * Add Columns to the media panel
38
+ *
39
+ * @param array $columns
40
+ * @return $columns
41
+ */
42
+ function resmushit_media_list_add_column( $columns ) {
43
+ $columns["resmushit_disable"] = __('Disable of reSmush.it', 'resmushit-image-optimizer');
44
+ $columns["resmushit_status"] = __('reSmush.it status', 'resmushit-image-optimizer');
45
+ return $columns;
46
+ }
47
+ add_filter( 'manage_media_columns', 'resmushit_media_list_add_column' );
48
+
49
+
50
+
51
+ /**
52
+ *
53
+ * Sort Columns to the media panel
54
+ *
55
+ * @param array $columns
56
+ * @return $columns
57
+ */
58
+ function resmushit_media_list_sort_column( $columns ) {
59
+ $columns["resmushit_disable"] = "resmushit_disable";
60
+ $columns["resmushit_status"] = "resmushit_status";
61
+ return $columns;
62
+ }
63
+ add_filter( 'manage_upload_sortable_columns', 'resmushit_media_list_sort_column' );
64
+
65
+
66
+
67
+ /**
68
+ *
69
+ * Add Value to Columns of the media panel
70
+ *
71
+ * @param string $column_name
72
+ * @param string $identifier of the column
73
+ * @return none
74
+ */
75
+ function resmushit_media_list_add_column_value( $column_name, $id ) {
76
+ if ( $column_name == "resmushit_disable" )
77
+ reSmushitUI::mediaListCustomValuesDisable($id);
78
+ else if ( $column_name == "resmushit_status" )
79
+ reSmushitUI::mediaListCustomValuesStatus($id);
80
+ }
81
+ add_action( 'manage_media_custom_column', 'resmushit_media_list_add_column_value', 10, 2 );
82
+
83
+
84
+
85
+ /**
86
+ *
87
+ * Add custom field to attachment
88
+ *
89
+ * @param array $form_fields
90
+ * @param object $post
91
+ * @return array
92
+ */
93
+ function resmushit_image_attachment_add_status_button($form_fields, $post) {
94
+ if ( !preg_match("/image.*/", $post->post_mime_type) )
95
+ return $form_fields;
96
+
97
+ $form_fields["rsmt-disabled-checkbox"] = array(
98
+ "label" => __("Disable of reSmush.it", "resmushit-image-optimizer"),
99
+ "input" => "html",
100
+ "value" => '',
101
+ "html" => reSmushitUI::mediaListCustomValuesDisable($post->ID, true)
102
+ );
103
+
104
+ $form_fields["rsmt-status-button"] = array(
105
+ "label" => __("reSmush.it status", "resmushit-image-optimizer"),
106
+ "input" => "html",
107
+ "value" => '',
108
+ "html" => reSmushitUI::mediaListCustomValuesStatus($post->ID, true)
109
+ );
110
+ return $form_fields;
111
+ }
112
+ add_filter("attachment_fields_to_edit", "resmushit_image_attachment_add_status_button", null, 2);
113
+
114
+
115
+
116
+ /**
117
+ *
118
+ * Settings page builder
119
+ *
120
+ * @param none
121
+ * @return none
122
+ */
123
+ function resmushit_settings_page() {
124
+ ?>
125
+ <div class='rsmt-panels'>
126
+ <div class="rsmt-cols w66 iln-block">
127
+ <?php reSmushitUI::headerPanel();?>
128
+ <?php reSmushitUI::alertPanel();?>
129
+ <?php reSmushitUI::bulkPanel();?>
130
+ <?php reSmushitUI::bigFilesPanel();?>
131
+ <?php reSmushitUI::statisticsPanel();?>
132
+ </div>
133
+ <div class="rsmt-cols w33 iln-block">
134
+ <?php reSmushitUI::settingsPanel();?>
135
+ <?php reSmushitUI::newsPanel();?>
136
+ </div>
137
+ </div>
138
+ <?php
139
+ }
140
+
141
+
142
+
143
+ /**
144
+ *
145
+ * Assets declaration
146
+ *
147
+ * @param none
148
+ * @return none
149
+ */
150
+ function resmushit_register_plugin_assets(){
151
+
152
+ wp_register_style( 'resmushit-css', plugins_url( 'css/resmushit.css', __FILE__ ) );
153
+ wp_enqueue_style( 'resmushit-css' );
154
+ wp_enqueue_style( 'prefix-style', esc_url_raw( 'https://fonts.googleapis.com/css?family=Roboto+Slab:700' ), array(), null );
155
+
156
+ wp_register_script( 'resmushit-js', plugins_url( 'js/script.js', __FILE__ ) );
157
+ wp_enqueue_script( 'resmushit-js' );
158
+ }
159
+ add_action( 'admin_head', 'resmushit_register_plugin_assets' );
trunk/resmushit.inc.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require('resmushit.settings.php');
4
+ require('classes/resmushit.class.php');
5
+ require('classes/resmushitUI.class.php');
6
+ require('resmushit.admin.php');
7
+
8
+
9
+
10
+ /**
11
+ *
12
+ * Embedded file log function
13
+ *
14
+ * @param string $str text to log in file
15
+ * @return none
16
+ */
17
+ function rlog($str, $level = 'SUCCESS') {
18
+ global $is_cron;
19
+
20
+ if(isset($is_cron) && $is_cron) {
21
+ switch ($level) {
22
+ case 'WARNING':
23
+ $prefix = "[\033[33m!\033[0m]"; break;
24
+ case 'ERROR':
25
+ $prefix = "[\033[31m!\033[0m]"; break;
26
+ default:
27
+ case 'SUCCESS':
28
+ $prefix = "[\033[32m+\033[0m]"; break;
29
+ }
30
+ echo "$prefix $str\n";
31
+ }
32
+
33
+ if(get_option('resmushit_logs') == 0)
34
+ return FALSE;
35
+
36
+ if( !is_writable(ABSPATH . RESMUSHIT_LOGS_PATH) ) {
37
+ return FALSE;
38
+ }
39
+ // Preserve file size under a reasonable value
40
+ if(file_exists(ABSPATH . RESMUSHIT_LOGS_PATH)){
41
+ if(filesize(ABSPATH . RESMUSHIT_LOGS_PATH) > RESMUSHIT_LOGS_MAX_FILESIZE) {
42
+ $logtailed = logtail(ABSPATH . RESMUSHIT_LOGS_PATH, 20);
43
+ $fp = fopen(ABSPATH . RESMUSHIT_LOGS_PATH, 'w');
44
+ fwrite($fp, $logtailed);
45
+ fclose($fp);
46
+ }
47
+ }
48
+
49
+ $str = "[".date('d-m-Y H:i:s')."] " . $str;
50
+ $str = print_r($str, true) . "\n";
51
+ $fp = fopen(ABSPATH . RESMUSHIT_LOGS_PATH, 'a+');
52
+ fwrite($fp, $str);
53
+ fclose($fp);
54
+ }
55
+
56
+
57
+ /**
58
+ *
59
+ * Tail function for files
60
+ *
61
+ * @param string $filepath path of the file to tail
62
+ * @param string $lines number of lines to keep
63
+ * @param string $adaptative will preserve line memory
64
+ * @return tailed file
65
+ * @author Torleif Berger, Lorenzo Stanco
66
+ * @link http://stackoverflow.com/a/15025877/995958
67
+ * @license http://creativecommons.org/licenses/by/3.0/
68
+ */
69
+ function logtail($filepath, $lines = 1, $adaptive = true) {
70
+
71
+ $f = @fopen($filepath, "rb");
72
+ if ($f === false) return false;
73
+ if (!$adaptive) $buffer = 4096;
74
+ else $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096));
75
+ fseek($f, -1, SEEK_END);
76
+ if (fread($f, 1) != "\n") $lines -= 1;
77
+
78
+ $output = '';
79
+ $chunk = '';
80
+
81
+ while (ftell($f) > 0 && $lines >= 0) {
82
+ $seek = min(ftell($f), $buffer);
83
+ fseek($f, -$seek, SEEK_CUR);
84
+ $output = ($chunk = fread($f, $seek)) . $output;
85
+ fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
86
+ $lines -= substr_count($chunk, "\n");
87
+ }
88
+
89
+ while ($lines++ < 0) {
90
+ $output = substr($output, strpos($output, "\n") + 1);
91
+ }
92
+ fclose($f);
93
+ return trim($output);
94
+ }
95
+
96
+
97
+ /**
98
+ *
99
+ * Calculates time ago
100
+ *
101
+ * @param string $datetime time input
102
+ * @param boolean $full number of lines to keep
103
+ * @param string $adaptative will preserve line memory
104
+ * @return string
105
+ * @author Glavić
106
+ * @link https://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago
107
+ */
108
+ function time_elapsed_string($duration, $full = false) {
109
+ $datetime = "@" . (time() - $duration);
110
+
111
+ $now = new DateTime;
112
+ $ago = new DateTime($datetime);
113
+ $diff = $now->diff($ago);
114
+
115
+ $diff->w = floor($diff->d / 7);
116
+ $diff->d -= $diff->w * 7;
117
+
118
+ $string = array(
119
+ 'y' => __('year', 'resmushit-image-optimizer'),
120
+ 'm' => __('month', 'resmushit-image-optimizer'),
121
+ 'w' => __('week', 'resmushit-image-optimizer'),
122
+ 'd' => __('day', 'resmushit-image-optimizer'),
123
+ 'h' => __('hour', 'resmushit-image-optimizer'),
124
+ 'i' => __('minute', 'resmushit-image-optimizer'),
125
+ 's' => __('second', 'resmushit-image-optimizer'),
126
+ );
127
+ foreach ($string as $k => &$v) {
128
+ if ($diff->$k) {
129
+ $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
130
+ } else {
131
+ unset($string[$k]);
132
+ }
133
+ }
134
+
135
+ if (!$full) $string = array_slice($string, 0, 1);
136
+ return $string ? implode(', ', $string) : __('just now', 'resmushit-image-optimizer');
137
+ }
trunk/resmushit.php ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package resmushit
4
+ * @author Charles Bourgeaux <hello@resmush.it>
5
+ * @license GPL-2.0+
6
+ * @link http://www.resmush.it
7
+ * @copyright 2019 Resmush.it
8
+ *
9
+ * @wordpress-plugin
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.2.2
14
+ * Timestamp: 2019.12.23
15
+ * Author: reSmush.it
16
+ * Author URI: https://resmush.it
17
+ * Author: Charles Bourgeaux
18
+ * License: GPL-2.0+
19
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
20
+ * Domain Path: /languages
21
+ * Text Domain: resmushit-image-optimizer
22
+ */
23
+
24
+ require('resmushit.inc.php');
25
+
26
+
27
+ /**
28
+ *
29
+ * Registering language plugin
30
+ *
31
+ * @param none
32
+ * @return none
33
+ */
34
+ function resmushit_load_plugin_textdomain() {
35
+ load_plugin_textdomain( 'resmushit', FALSE, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
36
+ }
37
+ add_action( 'plugins_loaded', 'resmushit_load_plugin_textdomain' );
38
+
39
+
40
+
41
+
42
+
43
+ /**
44
+ *
45
+ * Registering settings on plugin installation
46
+ *
47
+ * @param none
48
+ * @return none
49
+ */
50
+ function resmushit_activate() {
51
+ if ( is_super_admin() ) {
52
+ if(get_option('resmushit_qlty') === null)
53
+ update_option( 'resmushit_qlty', RESMUSHIT_DEFAULT_QLTY );
54
+ if(get_option('resmushit_on_upload') === null)
55
+ update_option( 'resmushit_on_upload', '1' );
56
+ if(get_option('resmushit_statistics') === null)
57
+ update_option( 'resmushit_statistics', '1' );
58
+ if(get_option('resmushit_total_optimized') === null)
59
+ update_option( 'resmushit_total_optimized', '0' );
60
+ if(get_option('resmushit_cron') === null)
61
+ update_option( 'resmushit_cron', 0 );
62
+ if(get_option('resmushit_cron_lastrun') === null)
63
+ update_option( 'resmushit_cron_lastrun', 0 );
64
+ if(get_option('resmushit_cron_firstactivation') === null)
65
+ update_option( 'resmushit_cron_firstactivation', 0 );
66
+ }
67
+ }
68
+ register_activation_hook( __FILE__, 'resmushit_activate' );
69
+ add_action( 'admin_init', 'resmushit_activate' );
70
+
71
+
72
+ /**
73
+ * Run using the 'init' action.
74
+ */
75
+ function resmushit_init() {
76
+ load_plugin_textdomain( 'resmushit-image-optimizer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
77
+ }
78
+ add_action( 'admin_init', 'resmushit_init' );
79
+
80
+
81
+ /**
82
+ *
83
+ * Call resmush.it optimization for attachments
84
+ *
85
+ * @param attachment object
86
+ * @param boolean preserve original file
87
+ * @return attachment object
88
+ */
89
+ function resmushit_process_images($attachments, $force_keep_original = TRUE) {
90
+ global $attachment_id;
91
+ $cumulated_original_sizes = 0;
92
+ $cumulated_optimized_sizes = 0;
93
+ $error = FALSE;
94
+
95
+ if(reSmushit::getDisabledState($attachment_id))
96
+ return $attachments;
97
+
98
+ $fileInfo = pathinfo(get_attached_file( $attachment_id ));
99
+ $basepath = $fileInfo['dirname'] . '/';
100
+ $extension = isset($fileInfo['extension']) ? $fileInfo['extension'] : NULL;
101
+ $basefile = basename($attachments[ 'file' ]);
102
+
103
+ // Optimize only pictures/files accepted by the API
104
+ if( !in_array($extension, resmushit::authorizedExtensions()) ) {
105
+ return $attachments;
106
+ }
107
+
108
+ $statistics[] = reSmushit::optimize($basepath . $basefile, $force_keep_original );
109
+
110
+ foreach($attachments['sizes'] as $image_style)
111
+ $statistics[] = reSmushit::optimize($basepath . $image_style['file'], FALSE );
112
+
113
+ $count = 0;
114
+ foreach($statistics as $stat){
115
+ if($stat && !isset($stat->error)){
116
+ $cumulated_original_sizes += $stat->src_size;
117
+ $cumulated_optimized_sizes += $stat->dest_size;
118
+ $count++;
119
+ } else
120
+ $error = TRUE;
121
+ }
122
+ if(!$error) {
123
+ $optimizations_successful_count = get_option('resmushit_total_optimized');
124
+ update_option( 'resmushit_total_optimized', $optimizations_successful_count + $count );
125
+
126
+ update_post_meta($attachment_id,'resmushed_quality', resmushit::getPictureQualitySetting());
127
+ if(get_option('resmushit_statistics')){
128
+ update_post_meta($attachment_id,'resmushed_cumulated_original_sizes', $cumulated_original_sizes);
129
+ update_post_meta($attachment_id,'resmushed_cumulated_optimized_sizes', $cumulated_optimized_sizes);
130
+ }
131
+ }
132
+ return $attachments;
133
+ }
134
+ //Automatically optimize images if option is checked
135
+ if(get_option('resmushit_on_upload') OR ( isset($_POST['action']) AND $_POST['action'] === "resmushit_bulk_process_image" ))
136
+ add_filter('wp_generate_attachment_metadata', 'resmushit_process_images');
137
+
138
+
139
+
140
+
141
+
142
+
143
+ /**
144
+ *
145
+ * Delete also -unsmushed file (ie. Original file) when deleting an attachment
146
+ *
147
+ * @param int postID
148
+ * @return none
149
+ */
150
+ function resmushit_delete_attachment($postid) {
151
+ reSmushit::deleteOriginalFile($postid);
152
+ }
153
+ add_action( 'delete_attachment', 'resmushit_delete_attachment' );
154
+
155
+
156
+
157
+
158
+
159
+ /**
160
+ *
161
+ * Make current attachment available
162
+ *
163
+ * @param attachment object
164
+ * @return attachment object
165
+ */
166
+ function resmushit_get_meta_id($result){
167
+ global $attachment_id;
168
+ $attachment_id = $result;
169
+ }
170
+ //Automatically retrieve image attachment ID if option is checked
171
+ if(get_option('resmushit_on_upload'))
172
+ add_filter('add_attachment', 'resmushit_get_meta_id');
173
+
174
+
175
+
176
+
177
+
178
+ /**
179
+ *
180
+ * add Ajax action to fetch all unsmushed pictures
181
+ *
182
+ * @param none
183
+ * @return json object
184
+ */
185
+ function resmushit_bulk_get_images() {
186
+ echo reSmushit::getNonOptimizedPictures();
187
+ die();
188
+ }
189
+ add_action( 'wp_ajax_resmushit_bulk_get_images', 'resmushit_bulk_get_images' );
190
+
191
+
192
+
193
+
194
+ /**
195
+ *
196
+ * add Ajax action to change disabled state for an attachment
197
+ *
198
+ * @param none
199
+ * @return json object
200
+ */
201
+ function resmushit_update_disabled_state() {
202
+ if(isset($_POST['data']['id']) && $_POST['data']['id'] != null && isset($_POST['data']['disabled'])){
203
+ echo reSmushit::updateDisabledState(sanitize_text_field($_POST['data']['id']), sanitize_text_field($_POST['data']['disabled']));
204
+ }
205
+ die();
206
+ }
207
+ add_action( 'wp_ajax_resmushit_update_disabled_state', 'resmushit_update_disabled_state' );
208
+
209
+
210
+
211
+
212
+
213
+ /**
214
+ *
215
+ * add Ajax action to optimize a single attachment in the library
216
+ *
217
+ * @param none
218
+ * @return json object
219
+ */
220
+ function resmushit_optimize_single_attachment() {
221
+ if(isset($_POST['data']['id']) && $_POST['data']['id'] != null){
222
+ reSmushit::revert(sanitize_text_field($_POST['data']['id']));
223
+ echo json_encode(reSmushit::getStatistics($_POST['data']['id']));
224
+ }
225
+ die();
226
+ }
227
+ add_action( 'wp_ajax_resmushit_optimize_single_attachment', 'resmushit_optimize_single_attachment' );
228
+
229
+
230
+
231
+
232
+
233
+ /**
234
+ *
235
+ * add Ajax action to optimize a picture according to attachment ID
236
+ *
237
+ * @param none
238
+ * @return boolean
239
+ */
240
+ function resmushit_bulk_process_image() {
241
+ rlog('Bulk optimization launched for file : ' . get_attached_file( sanitize_text_field($_POST['data']['ID']) ));
242
+ echo reSmushit::revert(sanitize_text_field($_POST['data']['ID']));
243
+ die();
244
+ }
245
+ add_action( 'wp_ajax_resmushit_bulk_process_image', 'resmushit_bulk_process_image' );
246
+
247
+
248
+
249
+
250
+
251
+ /**
252
+ *
253
+ * add Ajax action to update statistics
254
+ *
255
+ * @param none
256
+ * @return json object
257
+ */
258
+ function resmushit_update_statistics() {
259
+ $output = reSmushit::getStatistics();
260
+ $output['total_saved_size_formatted'] = reSmushitUI::sizeFormat($output['total_saved_size']);
261
+ echo json_encode($output);
262
+ die();
263
+ }
264
+ add_action( 'wp_ajax_resmushit_update_statistics', 'resmushit_update_statistics' );
265
+
266
+
267
+
268
+
269
+
270
+ /**
271
+ * add 'Settings' link to options page from Plugins
272
+ * @param array $links
273
+ * @return string
274
+ */
275
+ function resmushit_add_plugin_page_settings_link($links) {
276
+ $links[] = '<a href="' . admin_url( 'upload.php?page=resmushit_options' ) . '">' . __('Settings', "resmushit-image-optimizer") . '</a>';
277
+ return $links;
278
+ }
279
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'resmushit_add_plugin_page_settings_link');
280
+
281
+
282
+
283
+ /**
284
+ * Trigger when the cron are activated for the first time
285
+ * @param mixed old value for cron_activation option
286
+ * @param mixed new value for cron_activation option
287
+ */
288
+
289
+ function resmushit_on_cron_activation($old_value, $value) {
290
+ if($value == 1 && (!get_option('resmushit_cron_firstactivation') || get_option('resmushit_cron_firstactivation') === 0)) {
291
+ update_option( 'resmushit_cron_firstactivation', time() );
292
+ }
293
+ }
294
+ add_action('update_option_resmushit_cron', 'resmushit_on_cron_activation', 100, 2);
295
+
296
+
297
+
298
+ /**
299
+ * Declare a new time interval to run Cron
300
+ * @param array $schedules
301
+ * @return array
302
+ */
303
+ function resmushit_add_cron_interval( $schedules ) {
304
+ $schedules['resmushit_interval'] = array(
305
+ 'interval' => RESMUSHIT_CRON_FREQUENCY,
306
+ 'display' => esc_html__( __('Every', 'resmushit-image-optimizer') . ' ' . time_elapsed_string(RESMUSHIT_CRON_FREQUENCY) ),
307
+ );
308
+ return $schedules;
309
+ }
310
+ add_filter( 'cron_schedules', 'resmushit_add_cron_interval' );
311
+
312
+ if(!get_option('resmushit_cron') || get_option('resmushit_cron') === 0) {
313
+ if (wp_next_scheduled ( 'resmushit_optimize' )) {
314
+ wp_clear_scheduled_hook('resmushit_optimize');
315
+ }
316
+ } else {
317
+ if (! wp_next_scheduled ( 'resmushit_optimize' )) {
318
+ wp_schedule_event(time(), 'resmushit_interval', 'resmushit_optimize');
319
+ }
320
+ }
321
+
322
+
323
+
324
+ /**
325
+ * Declare a new crontask for optimization bulk
326
+ */
327
+ function resmushit_cron_process() {
328
+ global $is_cron;
329
+ $is_cron = TRUE;
330
+ update_option( 'resmushit_cron_lastrun', time() );
331
+
332
+ // required if launch through wp-cron.php
333
+ include_once( ABSPATH . 'wp-admin/includes/image.php' );
334
+
335
+ add_filter('wp_generate_attachment_metadata', 'resmushit_process_images');
336
+ rlog('Gathering unoptimized pictures from CRON');
337
+ $unoptimized_pictures = json_decode(reSmushit::getNonOptimizedPictures(TRUE));
338
+ rlog('Found ' . count($unoptimized_pictures->nonoptimized) . ' attachments');
339
+ foreach($unoptimized_pictures->nonoptimized as $el) {
340
+ if (wp_next_scheduled ( 'resmushit_optimize' )) {
341
+ //avoid to collapse two crons
342
+ wp_unschedule_event(wp_next_scheduled('resmushit_optimize'), 'resmushit_optimize');
343
+ }
344
+ rlog('CRON Processing attachments #' . $el->ID);
345
+ reSmushit::revert($el->ID);
346
+ }
347
+ }
348
+ add_action('resmushit_optimize', 'resmushit_cron_process');
349
+
350
+
351
+
352
+ /**
353
+ * Return the RESMUSHIT CRON status according to last_execution variables
354
+ * @return string
355
+ */
356
+ function resmushit_get_cron_status() {
357
+ if(get_option('resmushit_cron') == 0) {
358
+ return 'DISABLED';
359
+ }
360
+ if(!defined('DISABLE_WP_CRON') OR DISABLE_WP_CRON == false) {
361
+ return 'MISCONFIGURED';
362
+ }
363
+
364
+ if(get_option('resmushit_cron_lastrun') == 0 && (time() - get_option('resmushit_cron_firstactivation') > 2*RESMUSHIT_CRON_FREQUENCY)) {
365
+ return 'NEVER_RUN';
366
+ }
367
+ if(get_option('resmushit_cron_lastrun') != 0 && (time() - get_option('resmushit_cron_lastrun') > 2*RESMUSHIT_CRON_FREQUENCY)) {
368
+ return 'NO_LATELY_RUN';
369
+ }
370
+ return 'OK';
371
+ }
trunk/resmushit.settings.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/');
4
+ define('RESMUSHIT_VERSION', '0.2.2');
5
+ define('RESMUSHIT_DEFAULT_QLTY', '92');
6
+ define('RESMUSHIT_TIMEOUT', '10');
7
+ define('RESMUSHIT_LOGS_PATH', 'resmushit.log');
8
+ define('RESMUSHIT_LOGS_MAX_FILESIZE', '102400');
9
+ define('RESMUSHIT_NEWSFEED', 'https://feed.resmush.it/');
10
+ define('RESMUSHIT_BASE_URL', plugin_dir_url( __FILE__ ));
11
+ define('RESMUSHIT_CRON_FREQUENCY', 600);
12
+
13
+ global $is_cron;