Smush Image Compression and Optimization - Version 1.6.5.1

Version Description

  • Correct Settings > Media issue causing settings to report warnings and not save.
  • Corrected some processing logic to better handling or image path. Images still need to be within ABSPATH of site
  • Correct image URL passed to Smush.it API to convert https:// urls to http:// since the API does not allow https:// images
Download this release

Release Info

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

Code changes from version 1.6.5 to 1.6.5.1

languages/wp_smushit-default.mo ADDED
Binary file
languages/wp_smushit-default.po ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the WordPress plugin WP Smush.it 1.6.5.1 by WPMU DEV.
2
+ # Copyright (C) 2013 WPMU DEV
3
+ # This file is distributed under the same license as the WP Smush.it package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: WP Smush.it 1.6.5.1\n"
9
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-smushit\n"
10
+ "POT-Creation-Date: 2013-08-20 07:59-0500\n"
11
+ "PO-Revision-Date: 2013-08-20 09:02-0500\n"
12
+ "Last-Translator: Paul Menard <paul@codehooligans.com>\n"
13
+ "Language-Team: \n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=UTF-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "X-Poedit-Language: English\n"
18
+
19
+ #: wp-smushit.php:104
20
+ msgid "Use Smush.it on upload?"
21
+ msgstr ""
22
+
23
+ #: wp-smushit.php:106
24
+ msgid "How many seconds should we wait for a response from Smush.it?"
25
+ msgstr ""
26
+
27
+ #: wp-smushit.php:120
28
+ msgid "Automatically process on upload"
29
+ msgstr ""
30
+
31
+ #: wp-smushit.php:121
32
+ msgid "Do not process on upload"
33
+ msgstr ""
34
+
35
+ #: wp-smushit.php:125
36
+ #, php-format
37
+ msgid "Temporarily disabled until %s"
38
+ msgstr ""
39
+
40
+ #: wp-smushit.php:178
41
+ msgid "Bulk WP Smush.it"
42
+ msgstr ""
43
+
44
+ #: wp-smushit.php:182
45
+ msgid "<p>You don't appear to have uploaded any images yet.</p>"
46
+ msgstr ""
47
+
48
+ #: wp-smushit.php:186
49
+ msgid "<p>This tool will run all of the images in your media library through the WP Smush.it web service. It won't re-smush images that were successfully smushed before. It will retry images that were not successfully smushed.</p>"
50
+ msgstr ""
51
+
52
+ #: wp-smushit.php:188
53
+ msgid "<p>It uploads each and every file to Yahoo! and then downloads the resulting file. Note: the Yahoo! Smush.it service does not support https:// urls. So the image MUST be accessible via the public internet over a non-SSL URL. It can take a long time.</p>"
54
+ msgstr ""
55
+
56
+ #: wp-smushit.php:190
57
+ #, php-format
58
+ msgid "<p>We found %d images in your media library. Be forewarned, <strong>it will take <em>at least</em> %d minutes</strong> to process all these images if they have never been smushed before.</p>"
59
+ msgstr ""
60
+
61
+ #: wp-smushit.php:192
62
+ msgid "<p><em>N.B. If your server <tt>gzip</tt>s content you may not see the progress updates as your files are processed.</em></p>"
63
+ msgstr ""
64
+
65
+ #: wp-smushit.php:194
66
+ #, php-format
67
+ msgid "<p><strong>This is an experimental feature.</strong> Please post any feedback to the %s.</p>"
68
+ msgstr ""
69
+
70
+ #: wp-smushit.php:194
71
+ msgid "WordPress WP Smush.it forums"
72
+ msgstr ""
73
+
74
+ #: wp-smushit.php:198
75
+ msgid "Run all my images through WP Smush.it right now"
76
+ msgstr ""
77
+
78
+ #: wp-smushit.php:205
79
+ msgid "Cheatin&#8217; uh?"
80
+ msgstr ""
81
+
82
+ #: wp-smushit.php:212
83
+ #, php-format
84
+ msgid "<p>Processing <strong>%s</strong>&hellip;<br />"
85
+ msgstr ""
86
+
87
+ #: wp-smushit.php:227
88
+ #: wp-smushit.php:382
89
+ msgid "No savings"
90
+ msgstr ""
91
+
92
+ #: wp-smushit.php:228
93
+ #: wp-smushit.php:240
94
+ msgid "<strong>already smushed</strong>"
95
+ msgstr ""
96
+
97
+ #: wp-smushit.php:256
98
+ msgid "<hr /></p>Smush.it finished processing.</p>"
99
+ msgstr ""
100
+
101
+ #: wp-smushit.php:269
102
+ msgid "You don't have permission to work with uploaded files."
103
+ msgstr ""
104
+
105
+ #: wp-smushit.php:273
106
+ msgid "No attachment ID was provided."
107
+ msgstr ""
108
+
109
+ #: wp-smushit.php:307
110
+ msgid "File path is empty"
111
+ msgstr ""
112
+
113
+ #: wp-smushit.php:311
114
+ msgid "File URL is empty"
115
+ msgstr ""
116
+
117
+ #: wp-smushit.php:317
118
+ msgid "Did not smush due to previous errors"
119
+ msgstr ""
120
+
121
+ #: wp-smushit.php:322
122
+ #, php-format
123
+ msgid "Could not find <span class='code'>%s</span>"
124
+ msgstr ""
125
+
126
+ #: wp-smushit.php:327
127
+ #, php-format
128
+ msgid "<span class='code'>%s</span> is not writable"
129
+ msgstr ""
130
+
131
+ #: wp-smushit.php:333
132
+ #, php-format
133
+ msgid "<span style=\"color:#FF0000;\">Skipped (%s) Unable to Smush due to Yahoo 1mb size limits. See <a href=\"http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict\">FAQ</a></span>"
134
+ msgstr ""
135
+
136
+ #: wp-smushit.php:338
137
+ #, php-format
138
+ msgid "<span class='code'>%s</span> must be within the website directory (<span class='code'>%s</span>)"
139
+ msgstr ""
140
+
141
+ #: wp-smushit.php:349
142
+ #, php-format
143
+ msgid "<span class='code'>%s</span> must be within the website home URL (<span class='code'>%s</span>)"
144
+ msgstr ""
145
+
146
+ #: wp-smushit.php:359
147
+ msgid "Error posting to Smush.it"
148
+ msgstr ""
149
+
150
+ #: wp-smushit.php:365
151
+ #: wp-smushit.php:379
152
+ msgid "Bad response from Smush.it"
153
+ msgstr ""
154
+
155
+ #: wp-smushit.php:385
156
+ msgid "Smush.it error: "
157
+ msgstr ""
158
+
159
+ #: wp-smushit.php:385
160
+ msgid "unknown error"
161
+ msgstr ""
162
+
163
+ #: wp-smushit.php:386
164
+ #, php-format
165
+ msgid " while processing <span class='code'>%s</span> (<span class='code'>%s</span>)"
166
+ msgstr ""
167
+
168
+ #: wp-smushit.php:402
169
+ #, php-format
170
+ msgid "Error downloading file (%s)"
171
+ msgstr ""
172
+
173
+ #: wp-smushit.php:406
174
+ #, php-format
175
+ msgid "Unable to locate Smuch.it downloaded file (%s)"
176
+ msgstr ""
177
+
178
+ #: wp-smushit.php:420
179
+ #, php-format
180
+ msgid "Reduced by %01.1f%% (%s)"
181
+ msgstr ""
182
+
183
+ #: wp-smushit.php:527
184
+ msgid "WP Smush.it requires WordPress 2.8 or greater"
185
+ msgstr ""
186
+
187
+ #: wp-smushit.php:567
188
+ msgid "Re-smush"
189
+ msgstr ""
190
+
191
+ #: wp-smushit.php:570
192
+ msgid "Not processed"
193
+ msgstr ""
194
+
195
+ #: wp-smushit.php:573
196
+ msgid "Smush.it now!"
197
+ msgstr ""
198
+
199
+ #. Plugin Name of the plugin/theme
200
+ msgid "WP Smush.it"
201
+ msgstr ""
202
+
203
+ #. Plugin URI of the plugin/theme
204
+ msgid "http://wordpress.org/extend/plugins/wp-smushit/"
205
+ msgstr ""
206
+
207
+ #. Description of the plugin/theme
208
+ msgid "Reduce image file sizes and improve performance using the <a href=\"http://smush.it/\">Smush.it</a> API within WordPress."
209
+ msgstr ""
210
+
211
+ #. Author of the plugin/theme
212
+ msgid "WPMU DEV"
213
+ msgstr ""
214
+
215
+ #. Author URI of the plugin/theme
216
+ msgid "http://premium.wpmudev.org/"
217
+ msgstr ""
218
+
languages/wp_smushit-default.pot ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the WordPress plugin WP Smush.it 1.6.5.1 by WPMU DEV.
2
+ # Copyright (C) 2013 WPMU DEV
3
+ # This file is distributed under the same license as the WP Smush.it package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: WP Smush.it 1.6.5.1\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-smushit\n"
11
+ "POT-Creation-Date: 2013-08-20 07:59-0500\n"
12
+ "PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=utf-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+
19
+ #: wp-smushit.php:104
20
+ msgid "Use Smush.it on upload?"
21
+ msgstr ""
22
+
23
+ #: wp-smushit.php:106
24
+ msgid "How many seconds should we wait for a response from Smush.it?"
25
+ msgstr ""
26
+
27
+ #: wp-smushit.php:120
28
+ msgid "Automatically process on upload"
29
+ msgstr ""
30
+
31
+ #: wp-smushit.php:121
32
+ msgid "Do not process on upload"
33
+ msgstr ""
34
+
35
+ #: wp-smushit.php:125
36
+ #, php-format
37
+ msgid "Temporarily disabled until %s"
38
+ msgstr ""
39
+
40
+ #: wp-smushit.php:178
41
+ msgid "Bulk WP Smush.it"
42
+ msgstr ""
43
+
44
+ #: wp-smushit.php:182
45
+ msgid "<p>You don't appear to have uploaded any images yet.</p>"
46
+ msgstr ""
47
+
48
+ #: wp-smushit.php:186
49
+ msgid ""
50
+ "<p>This tool will run all of the images in your media library through the WP "
51
+ "Smush.it web service. It won't re-smush images that were successfully "
52
+ "smushed before. It will retry images that were not successfully smushed.</p>"
53
+ msgstr ""
54
+
55
+ #: wp-smushit.php:188
56
+ msgid ""
57
+ "<p>It uploads each and every file to Yahoo! and then downloads the resulting "
58
+ "file. Note: the Yahoo! Smush.it service does not support https:// urls. So "
59
+ "the image MUST be accessible via the public internet over a non-SSL URL. It "
60
+ "can take a long time.</p>"
61
+ msgstr ""
62
+
63
+ #: wp-smushit.php:190
64
+ #, php-format
65
+ msgid ""
66
+ "<p>We found %d images in your media library. Be forewarned, <strong>it will "
67
+ "take <em>at least</em> %d minutes</strong> to process all these images if "
68
+ "they have never been smushed before.</p>"
69
+ msgstr ""
70
+
71
+ #: wp-smushit.php:192
72
+ msgid ""
73
+ "<p><em>N.B. If your server <tt>gzip</tt>s content you may not see the "
74
+ "progress updates as your files are processed.</em></p>"
75
+ msgstr ""
76
+
77
+ #: wp-smushit.php:194
78
+ #, php-format
79
+ msgid ""
80
+ "<p><strong>This is an experimental feature.</strong> Please post any "
81
+ "feedback to the %s.</p>"
82
+ msgstr ""
83
+
84
+ #: wp-smushit.php:194
85
+ msgid "WordPress WP Smush.it forums"
86
+ msgstr ""
87
+
88
+ #: wp-smushit.php:198
89
+ msgid "Run all my images through WP Smush.it right now"
90
+ msgstr ""
91
+
92
+ #: wp-smushit.php:205
93
+ msgid "Cheatin&#8217; uh?"
94
+ msgstr ""
95
+
96
+ #: wp-smushit.php:212
97
+ #, php-format
98
+ msgid "<p>Processing <strong>%s</strong>&hellip;<br />"
99
+ msgstr ""
100
+
101
+ #: wp-smushit.php:227 wp-smushit.php:382
102
+ msgid "No savings"
103
+ msgstr ""
104
+
105
+ #: wp-smushit.php:228 wp-smushit.php:240
106
+ msgid "<strong>already smushed</strong>"
107
+ msgstr ""
108
+
109
+ #: wp-smushit.php:256
110
+ msgid "<hr /></p>Smush.it finished processing.</p>"
111
+ msgstr ""
112
+
113
+ #: wp-smushit.php:269
114
+ msgid "You don't have permission to work with uploaded files."
115
+ msgstr ""
116
+
117
+ #: wp-smushit.php:273
118
+ msgid "No attachment ID was provided."
119
+ msgstr ""
120
+
121
+ #: wp-smushit.php:307
122
+ msgid "File path is empty"
123
+ msgstr ""
124
+
125
+ #: wp-smushit.php:311
126
+ msgid "File URL is empty"
127
+ msgstr ""
128
+
129
+ #: wp-smushit.php:317
130
+ msgid "Did not smush due to previous errors"
131
+ msgstr ""
132
+
133
+ #: wp-smushit.php:322
134
+ #, php-format
135
+ msgid "Could not find <span class='code'>%s</span>"
136
+ msgstr ""
137
+
138
+ #: wp-smushit.php:327
139
+ #, php-format
140
+ msgid "<span class='code'>%s</span> is not writable"
141
+ msgstr ""
142
+
143
+ #: wp-smushit.php:333
144
+ #, php-format
145
+ msgid ""
146
+ "<span style=\"color:#FF0000;\">Skipped (%s) Unable to Smush due to Yahoo 1mb "
147
+ "size limits. See <a href=\"http://developer.yahoo.com/yslow/smushit/faq."
148
+ "html#faq_restrict\">FAQ</a></span>"
149
+ msgstr ""
150
+
151
+ #: wp-smushit.php:338
152
+ #, php-format
153
+ msgid ""
154
+ "<span class='code'>%s</span> must be within the website directory (<span "
155
+ "class='code'>%s</span>)"
156
+ msgstr ""
157
+
158
+ #: wp-smushit.php:349
159
+ #, php-format
160
+ msgid ""
161
+ "<span class='code'>%s</span> must be within the website home URL (<span "
162
+ "class='code'>%s</span>)"
163
+ msgstr ""
164
+
165
+ #: wp-smushit.php:359
166
+ msgid "Error posting to Smush.it"
167
+ msgstr ""
168
+
169
+ #: wp-smushit.php:365 wp-smushit.php:379
170
+ msgid "Bad response from Smush.it"
171
+ msgstr ""
172
+
173
+ #: wp-smushit.php:385
174
+ msgid "Smush.it error: "
175
+ msgstr ""
176
+
177
+ #: wp-smushit.php:385
178
+ msgid "unknown error"
179
+ msgstr ""
180
+
181
+ #: wp-smushit.php:386
182
+ #, php-format
183
+ msgid ""
184
+ " while processing <span class='code'>%s</span> (<span class='code'>%s</span>)"
185
+ msgstr ""
186
+
187
+ #: wp-smushit.php:402
188
+ #, php-format
189
+ msgid "Error downloading file (%s)"
190
+ msgstr ""
191
+
192
+ #: wp-smushit.php:406
193
+ #, php-format
194
+ msgid "Unable to locate Smuch.it downloaded file (%s)"
195
+ msgstr ""
196
+
197
+ #: wp-smushit.php:420
198
+ #, php-format
199
+ msgid "Reduced by %01.1f%% (%s)"
200
+ msgstr ""
201
+
202
+ #: wp-smushit.php:527
203
+ msgid "WP Smush.it requires WordPress 2.8 or greater"
204
+ msgstr ""
205
+
206
+ #: wp-smushit.php:567
207
+ msgid "Re-smush"
208
+ msgstr ""
209
+
210
+ #: wp-smushit.php:570
211
+ msgid "Not processed"
212
+ msgstr ""
213
+
214
+ #: wp-smushit.php:573
215
+ msgid "Smush.it now!"
216
+ msgstr ""
217
+
218
+ #. Plugin Name of the plugin/theme
219
+ msgid "WP Smush.it"
220
+ msgstr ""
221
+
222
+ #. Plugin URI of the plugin/theme
223
+ msgid "http://wordpress.org/extend/plugins/wp-smushit/"
224
+ msgstr ""
225
+
226
+ #. Description of the plugin/theme
227
+ msgid ""
228
+ "Reduce image file sizes and improve performance using the <a href=\"http://"
229
+ "smush.it/\">Smush.it</a> API within WordPress."
230
+ msgstr ""
231
+
232
+ #. Author of the plugin/theme
233
+ msgid "WPMU DEV"
234
+ msgstr ""
235
+
236
+ #. Author URI of the plugin/theme
237
+ msgid "http://premium.wpmudev.org/"
238
+ msgstr ""
languages/wp_smushit-it_IT.po ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2013 WP Smush.it
2
+ # This file is distributed under the same license as the WP Smush.it package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: WP Smush.it 1.6.5\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-smushit\n"
7
+ "POT-Creation-Date: 2013-05-08 07:05:03+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2013-05-08 09:08+0100\n"
12
+ "Last-Translator: Daniele Arduini <d.arduini@optimalab.it>\n"
13
+ "Language-Team: WPMU DEV\n"
14
+
15
+ #: wp-smushit.php:103
16
+ msgid "Use Smush.it on upload?"
17
+ msgstr "Uso Smush.it negli upload?"
18
+
19
+ #: wp-smushit.php:104
20
+ msgid "How many seconds should we wait for a response from Smush.it?"
21
+ msgstr "Quanti secondi occorre attendere per una risposta da Smush.it?"
22
+
23
+ #: wp-smushit.php:116
24
+ msgid "Automatically process on upload"
25
+ msgstr "Elabora automaticamente sull'upload"
26
+
27
+ #: wp-smushit.php:117
28
+ msgid "Do not process on upload"
29
+ msgstr "Non elaborare sull'upload"
30
+
31
+ #: wp-smushit.php:121
32
+ msgid "Temporarily disabled until %s"
33
+ msgstr "Temporaneamente disabilitato fino a %s"
34
+
35
+ #: wp-smushit.php:174
36
+ msgid "Bulk WP Smush.it"
37
+ msgstr "Smush.it massivo"
38
+
39
+ #: wp-smushit.php:178
40
+ msgid "<p>You don&#39;t appear to have uploaded any images yet.</p>"
41
+ msgstr "<p>Apparentemente al momento non sono state inviate immagini.</p>"
42
+
43
+ #: wp-smushit.php:182
44
+ msgid ""
45
+ "<p>This tool will run all of the images in your media library through the WP "
46
+ "Smush.it web service. It won't re-smush images that were successfully "
47
+ "smushed before. It will retry images that were not successfully smushed.</p>"
48
+ msgstr ""
49
+ "<p>Questo strumento processer&agrave; tutte le immagini presenti nella galleria attraverso il servizio web "
50
+ "WP Smush.it. Non processer&agrave; nuovamente le immagini gi&agrave; ridotte precedentemente con "
51
+ "successo. Cercher&agrave; di riprocessare le immagini che non sono state ridotte con successo.</p>"
52
+
53
+ #: wp-smushit.php:184
54
+ msgid ""
55
+ "<p>It uploads each and every file to Yahoo! and then downloads the resulting "
56
+ "file. It can take a long time.</p>"
57
+ msgstr ""
58
+ "<p>Ogni immagine verr&agrave; inviata a Yahoo! e quindi scaricata l&#39;immagine risultante."
59
+ "L&#39;operazione potrebbe impiegare molto tempo.</p>"
60
+
61
+ #: wp-smushit.php:186
62
+ msgid ""
63
+ "<p>We found %d images in your media library. Be forewarned, <strong>it will "
64
+ "take <em>at least</em> %d minutes</strong> to process all these images if "
65
+ "they have never been smushed before.</p>"
66
+ msgstr ""
67
+ "<p>Sono state trovate %d immagini nella galleria. Si avverte che <strong>si impiegheranno "
68
+ "<em>come minimo</em> %d minuti</strong> per elaborare tutte queste immagini se "
69
+ "non sono mai state elaborate in precedenza.</p>"
70
+
71
+ #: wp-smushit.php:188
72
+ msgid ""
73
+ "<p><em>N.B. If your server <tt>gzip</tt>s content you may not see the "
74
+ "progress updates as your files are processed.</em></p>"
75
+ msgstr ""
76
+ "<p><em>NOTA: Se il tuo server comprime i contenuti con <tt>gzip</tt> potresti non vedere "
77
+ "l&#39;aggiornamento dello stato durante il processo di elaborazione delle immagini.</em></p>"
78
+
79
+ #: wp-smushit.php:190
80
+ msgid ""
81
+ "<p><strong>This is an experimental feature.</strong> Please post any "
82
+ "feedback to the %s.</p>"
83
+ msgstr ""
84
+ "<p><strong>Questa &egrave; una funzionalit&agrave; sperimentale.</strong> Per favore invia ogni "
85
+ "commento al %s.</p>"
86
+
87
+ #: wp-smushit.php:190
88
+ msgid "WordPress WP Smush.it forums"
89
+ msgstr "Forum di WordPress WP Smush.it"
90
+
91
+ #: wp-smushit.php:194
92
+ msgid "Run all my images through WP Smush.it right now"
93
+ msgstr "Avvia l&#39;elaborazione delle immagini tramite WP Smush.it"
94
+
95
+ #: wp-smushit.php:201
96
+ msgid "Cheatin&#8217; uh?"
97
+ msgstr "Fai il furbo eh?"
98
+
99
+ #: wp-smushit.php:254
100
+ msgid "You don't have permission to work with uploaded files."
101
+ msgstr "Non si hanno i permessi per elaborare i file inviati."
102
+
103
+ #: wp-smushit.php:258
104
+ msgid "No attachment ID was provided."
105
+ msgstr "Non &egrave; stato fornito alcun ID allegato."
106
+
107
+ #: wp-smushit.php:294
108
+ msgid "Did not smush due to previous errors"
109
+ msgstr "Smush non effetuato a causa dei precedenti errori"
110
+
111
+ #: wp-smushit.php:301
112
+ msgid "Could not find <span class='code'>%s</span>"
113
+ msgstr "Impossibile trovare <span class='code'>%s</span>"
114
+
115
+ #: wp-smushit.php:307
116
+ msgid "<span class='code'>%s</span> is not writable"
117
+ msgstr "<span class='code'>%s</span> non &egrave; scrivibile"
118
+
119
+ #: wp-smushit.php:313
120
+ msgid ""
121
+ "<a href='http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict'>Too "
122
+ "big</a> for Smush.it (%s)"
123
+ msgstr ""
124
+ "<a href='http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict'>Troppo "
125
+ "grande</a> per Smush.it (%s)"
126
+
127
+ #: wp-smushit.php:322
128
+ msgid ""
129
+ "<span class='code'>%s</span> must be within the content directory (<span "
130
+ "class='code'>%s</span>)"
131
+ msgstr ""
132
+ "<span class='code'>%s</span> deve essere all'interno della cartella dei contenuti (<span "
133
+ "class='code'>%s</span>)"
134
+
135
+ #: wp-smushit.php:337
136
+ msgid "Error posting to Smush.it"
137
+ msgstr "Errore d'invio a Smush.it"
138
+
139
+ #: wp-smushit.php:343 wp-smushit.php:356
140
+ msgid "Bad response from Smush.it"
141
+ msgstr "Risposta errata da Smush.it"
142
+
143
+ #: wp-smushit.php:359
144
+ msgid "No savings"
145
+ msgstr "Nessun risparmio"
146
+
147
+ #: wp-smushit.php:362
148
+ msgid "Smush.it error: "
149
+ msgstr "Errore Smush.it: "
150
+
151
+ #: wp-smushit.php:362
152
+ msgid "unknown error"
153
+ msgstr "errore sconosciuto"
154
+
155
+ #: wp-smushit.php:363
156
+ msgid ""
157
+ " while processing <span class='code'>%s</span> (<span class='code'>%s</span>)"
158
+ msgstr ""
159
+ " durante l'elaborazione di <span class='code'>%s</span> (<span class='code'>%s</span>)"
160
+
161
+ #: wp-smushit.php:379
162
+ msgid "Error downloading file (%s)"
163
+ msgstr "Errore scaricando il file (%s)"
164
+
165
+ #: wp-smushit.php:390
166
+ msgid "Reduced by %01.1f%% (%s)"
167
+ msgstr "Ridotta del %01.1f%% (%s)"
168
+
169
+ #: wp-smushit.php:482
170
+ msgid "WP Smush.it requires WordPress 2.8 or greater"
171
+ msgstr "WP Smush.it richiede WordPress 2.8 o superiore"
172
+
173
+ #: wp-smushit.php:522
174
+ msgid "Re-smush"
175
+ msgstr "Ri-smush"
176
+
177
+ #: wp-smushit.php:525
178
+ msgid "Not processed"
179
+ msgstr "Non elaborata"
180
+
181
+ #: wp-smushit.php:528
182
+ msgid "Smush.it now!"
183
+ msgstr "Smush.it adesso!"
184
+
185
+ #. Plugin Name of the plugin/theme
186
+ msgid "WP Smush.it"
187
+ msgstr "WP Smush.it"
188
+
189
+ #. Plugin URI of the plugin/theme
190
+ msgid "http://wordpress.org/extend/plugins/wp-smushit/"
191
+ msgstr "http://wordpress.org/extend/plugins/wp-smushit/"
192
+
193
+ #. Description of the plugin/theme
194
+ msgid ""
195
+ "Reduce image file sizes and improve performance using the <a href=\"http://"
196
+ "smush.it/\">Smush.it</a> API within WordPress."
197
+ msgstr ""
198
+ "Riduce la dimensione delle immagini e migliora le prestazioni utilizzando le "
199
+ "API Wordpress di <a href=\"http://smush.it/\">Smush.it</a>."
200
+
201
+ #. Author of the plugin/theme
202
+ msgid "WPMU DEV"
203
+ msgstr "WPMU DEV"
204
+
205
+ #. Author URI of the plugin/theme
206
+ msgid "http://premium.wpmudev.org/"
207
+ msgstr "http://premium.wpmudev.org/"
208
+
languages/wp_smushit.po DELETED
@@ -1,146 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: WP Smushit\n"
4
- "POT-Creation-Date: 2013-04-14 20:54+0700\n"
5
- "PO-Revision-Date: 2013-04-14 20:55+0700\n"
6
- "Last-Translator: incsub.com <hakan@incsub.com>\n"
7
- "Language-Team: WPMU DEV\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.5.3\n"
12
- "X-Poedit-KeywordsList: _;__\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: C:\\Users\\Hakan\\Desktop\\wp-smushit\n"
15
-
16
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:103
17
- msgid "Use Smush.it on upload?"
18
- msgstr ""
19
-
20
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:104
21
- msgid "How many seconds should we wait for a response from Smush.it?"
22
- msgstr ""
23
-
24
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:116
25
- msgid "Automatically process on upload"
26
- msgstr ""
27
-
28
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:117
29
- msgid "Do not process on upload"
30
- msgstr ""
31
-
32
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:121
33
- #, php-format
34
- msgid "Temporarily disabled until %s"
35
- msgstr ""
36
-
37
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:186
38
- #, php-format
39
- msgid ""
40
- "<p>We found %d images in your media library. Be forewarned, <strong>it will "
41
- "take <em>at least</em> %d minutes</strong> to process all these images if "
42
- "they have never been smushed before.</p>"
43
- msgstr ""
44
-
45
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:190
46
- #, php-format
47
- msgid ""
48
- "<p><strong>This is an experimental feature.</strong> Please post any "
49
- "feedback to the %s.</p>"
50
- msgstr ""
51
-
52
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:190
53
- msgid "WordPress WP Smush.it forums"
54
- msgstr ""
55
-
56
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:201
57
- msgid "Cheatin&#8217; uh?"
58
- msgstr ""
59
-
60
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:254
61
- msgid "You don't have permission to work with uploaded files."
62
- msgstr ""
63
-
64
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:258
65
- msgid "No attachment ID was provided."
66
- msgstr ""
67
-
68
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:294
69
- msgid "Did not smush due to previous errors"
70
- msgstr ""
71
-
72
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:301
73
- #, php-format
74
- msgid "Could not find <span class='code'>%s</span>"
75
- msgstr ""
76
-
77
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:307
78
- #, php-format
79
- msgid "<span class='code'>%s</span> is not writable"
80
- msgstr ""
81
-
82
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:313
83
- #, php-format
84
- msgid ""
85
- "<a href='http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict'>Too "
86
- "big</a> for Smush.it (%s)"
87
- msgstr ""
88
-
89
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:322
90
- #, php-format
91
- msgid ""
92
- "<span class='code'>%s</span> must be within the content directory (<span "
93
- "class='code'>%s</span>)"
94
- msgstr ""
95
-
96
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:337
97
- msgid "Error posting to Smush.it"
98
- msgstr ""
99
-
100
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:343
101
- msgid "Bad response from Smush.it"
102
- msgstr ""
103
-
104
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:356
105
- msgid "No savings"
106
- msgstr ""
107
-
108
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:359
109
- msgid "Smush.it error: "
110
- msgstr ""
111
-
112
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:359
113
- msgid "unknown error"
114
- msgstr ""
115
-
116
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:360
117
- #, php-format
118
- msgid ""
119
- " while processing <span class='code'>%s</span> (<span class='code'>%s</span>)"
120
- msgstr ""
121
-
122
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:376
123
- #, php-format
124
- msgid "Error downloading file (%s)"
125
- msgstr ""
126
-
127
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:387
128
- #, php-format
129
- msgid "Reduced by %01.1f%% (%s)"
130
- msgstr ""
131
-
132
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:479
133
- msgid "WP Smush.it requires WordPress 2.8 or greater"
134
- msgstr ""
135
-
136
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:519
137
- msgid "Re-smush"
138
- msgstr ""
139
-
140
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:522
141
- msgid "Not processed"
142
- msgstr ""
143
-
144
- #: C:\Users\Hakan\Desktop\wp-smushit/wp-smushit.php:525
145
- msgid "Smush.it now!"
146
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,47 +1,47 @@
1
- === WP Smush.it ===
2
- Plugin Name: WP Smush.it
3
- Version: 1.6.5
4
- Author: WPMU DEV
5
- Author URI: http://premium.wpmudev.org
6
- Contributors: WPMUDEV, alexdunae
7
- Tags: images, image, attachments, attachment
8
- Requires at least: 2.9
9
- Tested up to: 3.6
10
- Stable tag: 1.6.5
11
- License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
-
13
- Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
14
-
15
- == Description ==
16
-
17
- Yahoo's excellent <a href="http://developer.yahoo.com/performance/">Exceptional Performance series</a> recommends <a href="http://developer.yahoo.com/performance/rules.html#opt_images">optimizing images</a> in several lossless ways:
18
-
19
- * stripping meta data from JPEGs
20
- * optimizing JPEG compression
21
- * converting certain GIFs to indexed PNGs
22
- * stripping the un-used colours from indexed images
23
-
24
- <a href="http://smush.it/">Smush.it</a> offers an API that performs these optimizations (except for stripping JPEG meta data) automatically, and this plugin seamlessly integrates Smush.it with WordPress.
25
 
26
  = Dear Smushers: WPMU DEV has taken over maintenance and support for WP Smush.it =
27
  With the backing of <a href="http://premium.wpmudev.org/">WPMU DEV's professional WordPress team</a> you can expect faster support, bug-fixes, and new features!
28
-
29
- = How does it work? =
30
- Every image you add to a page or post will be automatically run through Smush.it behind the scenes. You don&rsquo;t have to do anything different.
31
-
32
- = Existing images =
33
- You can also run your existing images through Smush.it via the WordPress `Media Library`. Click on the `Smush.it now!` link for any image you'd like to smush.
34
-
35
- As of version 1.4.0 there is a new, experimental `Bulk Smush.it` feature. You can find the link under the `Media Library` tab.
36
-
37
- = Errors =
38
-
39
- Sometimes the Smush.it service goes down or is under heavy load. If the plugin has difficulty connecting to Smush.it then automatically smushing is temporarily disabled (currently for 6 hours). You can always re-enable it via the `Media > Settings` screen or manually smush the image from the Media Library.
40
-
41
- You can also define how long you want to wait for the Smush.it server to respond.
42
-
43
- = Privacy =
44
- Be sure you&rsquo;re comfortable with Smush.it&rsquo;s privacy policy (found on their <a href="http://info.yahoo.com/legal/us/yahoo/smush_it/smush_it-4378.html">FAQ</a>).
45
 
46
  = About Us =
47
  WPMU DEV is a premium supplier of quality WordPress plugins and themes. For premium support with any WordPress related issues you can join us here:
@@ -50,142 +50,148 @@ WPMU DEV is a premium supplier of quality WordPress plugins and themes. For prem
50
  Don't forget to stay up to date on everything WordPress from the Internet's number one resource:
51
  <a href="http://wpmu.org/">http://wpmu.org</a>
52
 
53
-
54
- == Screenshots ==
55
-
56
- 1. See the savings from Smush.it in the Media Library.
57
-
58
- == Installation ==
59
-
60
- 1. Upload the `wp-smushit` plugin to your `/wp-content/plugins/` directory.
61
- 1. Activate the plugin through the 'Plugins' menu in WordPress.
62
- 1. Automatic smushing of uploaded images can be controlled on the `Settings > Media` screen
63
- 1. Done!
64
-
65
- == Upgrade Notice ==
66
-
67
  In this first official release from WPMU DEV, we've done a code cleanup and reformat to get started, as well as
68
  attempting to handle smush.it API errors a bit better. We've also made all the text fully i18n translatable.
69
 
70
- This will give us a good foundation to start adding some new features!
71
-
72
-
73
- == Changelog ==
74
-
75
- = 1.6.5 =
76
- * Codes reformatted and cleaned up into a php class
77
- * More texts are translatable now
78
-
79
- = 1.6.4 =
80
- * Fixed a bug that prevents execution
81
-
82
- = 1.6.3 =
83
- * check image size before uploading (1 MB limit)
84
- * attempt to smush more than one image before bailing (kind thanks to <a href="http://wordpress.org/support/profile/xrampage16">xrampage16</a>)
85
- * allow setting timeout value under `Media > Settings` (default is 60 seconds)
86
-
87
- = 1.6.2 =
88
- * about to get a new lease on life notice
89
-
90
- = 1.6.1 =
91
- * no longer maintained notice
92
-
93
- = 1.6.0 =
94
- * added setting to disable automatic smushing on upload (default is true)
95
- * on HTTP error, smushing will be temporarily disabled for 6 hours
96
-
97
- = 1.5.0 =
98
- * added basic integration for the <a href="http://wordpress.org/extend/plugins/wp-smushit-nextgen-gallery-integration/">NextGEN gallery plugin</a>
99
- * add support for media bulk action dropdown
100
- * compatibility with WordPress earlier than 3.1
101
- * added a <a href="http://dunae.ca/donate.html">donate link</a>
102
-
103
- = 1.4.3 =
104
- * cleaner handling of file paths
105
-
106
- = 1.4.2 =
107
- * bulk smush.it will no longer re-smush images that were successful
108
-
109
- = 1.4.1 =
110
- * bug fixes
111
-
112
- = 1.4.0 =
113
- * bulk smush.it
114
-
115
- = 1.3.4 =
116
- * bug fixes
117
-
118
- = 1.3.3 =
119
- * add debugging output on failure
120
-
121
- = 1.3.2 =
122
- * removed realpath() call
123
- * IPv6 compat
124
-
125
- = 1.3.1 =
126
- * handle images stored on other domains -- props to [ka-ri-ne](http://wordpress.org/support/profile/ka-ri-ne) for the fix
127
- * avoid time-out errors when working with larger files -- props to [Milan Dinić](http://wordpress.org/support/profile/dimadin) for the fix
128
-
129
- = 1.2.10 =
130
- * removed testing link
131
-
132
- = 1.2.9 =
133
- * updated Smush.it endpoint URL
134
-
135
- = 1.2.8 =
136
- * fixed path checking on Windows servers
137
-
138
- = 1.2.7 =
139
- * update to workaround WordPress's new JSON compat layer (see [trac ticket](http://core.trac.wordpress.org/ticket/11827))
140
-
141
- = 1.2.6 =
142
- * updated Smush.it endpoint URL
143
- * fixed undefined constant
144
-
145
- = 1.2.5 =
146
- * updated Smush.it endpoint URL
147
-
148
- = 1.2.4 =
149
- * removed debugging code that was interfering with the Flash uploader
150
-
151
- = 1.2.3 =
152
- * bug fix
153
-
154
- = 1.2.2 =
155
- * updated to use Yahoo! hosted Smush.it service
156
- * added security checks to files passed to `wp_smushit()`
157
-
158
- = 1.2.1 =
159
- * added support for PHP 4
160
- * created admin action hook as workaround to WordPress 2.9's `$_registered_pages` security (see [changeset 11596](http://core.trac.wordpress.org/changeset/11596))
161
- * add savings amount in bytes to Media Library (thx [Yoast](http://www.yoast.com/))
162
-
163
- = 1.2 =
164
- * added support for `WP_Http`
165
-
166
- = 1.1.3 =
167
- * fixed activation error when the PEAR JSON library is already loaded
168
-
169
- = 1.1.2 =
170
- * added test for `allow_url_fopen`
171
-
172
- = 1.1.1 =
173
- * added error message on PHP copy error
174
-
175
- = 1.1 =
176
- * improved handling of errors from Smush.it
177
- * added ability to manually smush images from media library
178
- * fixed inconsistent path handling from WP 2.5 -> WP 2.7
179
-
180
- = 1.0.2 =
181
- * added 'Not processed' status message when browsing media library
182
-
183
- = 1.0.1 =
184
- * added i10n functions
185
-
186
- = 1.0 =
187
- * first edition
188
-
 
 
 
 
 
 
189
  == About Us ==
190
  WPMU DEV is a premium supplier of quality WordPress plugins and themes. For premium support with any WordPress related issues you can join us here:
191
  <a href="http://premium.wpmudev.org/join/">http://premium.wpmudev.org/join/</a>
@@ -194,11 +200,11 @@ Don't forget to stay up to date on everything WordPress from the Internet's numb
194
  <a href="http://wpmu.org/">http://wpmu.org</a>
195
 
196
  Hey, one more thing... we hope you <a href="http://profiles.wordpress.org/WPMUDEV/">enjoy our free offerings</a> as much as we've loved making them for you!
197
-
198
- == Contact and Credits ==
199
-
200
- Originally written by Alex Dunae at Dialect ([dialect.ca](http://dialect.ca/?wp_smush_it), e-mail 'alex' at 'dialect dot ca'), 2008-11.
201
-
202
- WP Smush.it includes a copy of the [PEAR JSON library](http://pear.php.net/pepr/pepr-proposal-show.php?id=198) written by Michal Migurski.
203
-
204
- Smush.it was created by [Nicole Sullivan](http://www.stubbornella.org/content/) and [Stoyan Stefanov](http://phpied.com/).
1
+ === WP Smush.it ===
2
+ Plugin Name: WP Smush.it
3
+ Version: 1.6.5.1
4
+ Author: WPMU DEV
5
+ Author URI: http://premium.wpmudev.org
6
+ Contributors: WPMUDEV, alexdunae
7
+ Tags: images, image, attachments, attachment, Smush.it
8
+ Requires at least: 3.5
9
+ Tested up to: 3.6
10
+ Stable tag: 1.6.5.1
11
+ License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
+
13
+ Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
14
+
15
+ == Description ==
16
+
17
+ Yahoo's excellent <a href="http://developer.yahoo.com/performance/">Exceptional Performance series</a> recommends <a href="http://developer.yahoo.com/performance/rules.html#opt_images">optimizing images</a> in several lossless ways:
18
+
19
+ * stripping meta data from JPEGs
20
+ * optimizing JPEG compression
21
+ * converting certain GIFs to indexed PNGs
22
+ * stripping the un-used colours from indexed images
23
+
24
+ <a href="http://smush.it/">Smush.it</a> offers an API that performs these optimizations (except for stripping JPEG meta data) automatically, and this plugin seamlessly integrates Smush.it with WordPress.
25
 
26
  = Dear Smushers: WPMU DEV has taken over maintenance and support for WP Smush.it =
27
  With the backing of <a href="http://premium.wpmudev.org/">WPMU DEV's professional WordPress team</a> you can expect faster support, bug-fixes, and new features!
28
+
29
+ = How does it work? =
30
+ Every image you add to a page or post will be automatically run through Smush.it behind the scenes. You don&rsquo;t have to do anything different.
31
+
32
+ = Existing images =
33
+ You can also run your existing images through Smush.it via the WordPress `Media Library`. Click on the `Smush.it now!` link for any image you'd like to smush.
34
+
35
+ As of version 1.4.0 there is a new, experimental `Bulk Smush.it` feature. You can find the link under the `Media Library` tab.
36
+
37
+ = Errors =
38
+
39
+ Sometimes the Smush.it service goes down or is under heavy load. If the plugin has difficulty connecting to Smush.it then automatically smushing is temporarily disabled (currently for 6 hours). You can always re-enable it via the `Media > Settings` screen or manually smush the image from the Media Library.
40
+
41
+ You can also define how long you want to wait for the Smush.it server to respond.
42
+
43
+ = Privacy =
44
+ Be sure you&rsquo;re comfortable with Smush.it&rsquo;s privacy policy (found on their <a href="http://info.yahoo.com/legal/us/yahoo/smush_it/smush_it-4378.html">FAQ</a>).
45
 
46
  = About Us =
47
  WPMU DEV is a premium supplier of quality WordPress plugins and themes. For premium support with any WordPress related issues you can join us here:
50
  Don't forget to stay up to date on everything WordPress from the Internet's number one resource:
51
  <a href="http://wpmu.org/">http://wpmu.org</a>
52
 
53
+
54
+ == Screenshots ==
55
+
56
+ 1. See the savings from Smush.it in the Media Library.
57
+
58
+ == Installation ==
59
+
60
+ 1. Upload the `wp-smushit` plugin to your `/wp-content/plugins/` directory.
61
+ 1. Activate the plugin through the 'Plugins' menu in WordPress.
62
+ 1. Automatic smushing of uploaded images can be controlled on the `Settings > Media` screen
63
+ 1. Done!
64
+
65
+ == Upgrade Notice ==
66
+
67
  In this first official release from WPMU DEV, we've done a code cleanup and reformat to get started, as well as
68
  attempting to handle smush.it API errors a bit better. We've also made all the text fully i18n translatable.
69
 
70
+ This will give us a good foundation to start adding some new features!
71
+
72
+
73
+ == Changelog ==
74
+
75
+ = 1.6.5.1 =
76
+ * Correct Settings > Media issue causing settings to report warnings and not save.
77
+ * Corrected some processing logic to better handling or image path. Images still need to be within ABSPATH of site
78
+ * Correct image URL passed to Smush.it API to convert https:// urls to http:// since the API does not allow https:// images
79
+
80
+
81
+ = 1.6.5 =
82
+ * Codes reformatted and cleaned up into a php class
83
+ * More texts are translatable now
84
+
85
+ = 1.6.4 =
86
+ * Fixed a bug that prevents execution
87
+
88
+ = 1.6.3 =
89
+ * check image size before uploading (1 MB limit)
90
+ * attempt to smush more than one image before bailing (kind thanks to <a href="http://wordpress.org/support/profile/xrampage16">xrampage16</a>)
91
+ * allow setting timeout value under `Media > Settings` (default is 60 seconds)
92
+
93
+ = 1.6.2 =
94
+ * about to get a new lease on life notice
95
+
96
+ = 1.6.1 =
97
+ * no longer maintained notice
98
+
99
+ = 1.6.0 =
100
+ * added setting to disable automatic smushing on upload (default is true)
101
+ * on HTTP error, smushing will be temporarily disabled for 6 hours
102
+
103
+ = 1.5.0 =
104
+ * added basic integration for the <a href="http://wordpress.org/extend/plugins/wp-smushit-nextgen-gallery-integration/">NextGEN gallery plugin</a>
105
+ * add support for media bulk action dropdown
106
+ * compatibility with WordPress earlier than 3.1
107
+ * added a <a href="http://dunae.ca/donate.html">donate link</a>
108
+
109
+ = 1.4.3 =
110
+ * cleaner handling of file paths
111
+
112
+ = 1.4.2 =
113
+ * bulk smush.it will no longer re-smush images that were successful
114
+
115
+ = 1.4.1 =
116
+ * bug fixes
117
+
118
+ = 1.4.0 =
119
+ * bulk smush.it
120
+
121
+ = 1.3.4 =
122
+ * bug fixes
123
+
124
+ = 1.3.3 =
125
+ * add debugging output on failure
126
+
127
+ = 1.3.2 =
128
+ * removed realpath() call
129
+ * IPv6 compat
130
+
131
+ = 1.3.1 =
132
+ * handle images stored on other domains -- props to [ka-ri-ne](http://wordpress.org/support/profile/ka-ri-ne) for the fix
133
+ * avoid time-out errors when working with larger files -- props to [Milan Dinić](http://wordpress.org/support/profile/dimadin) for the fix
134
+
135
+ = 1.2.10 =
136
+ * removed testing link
137
+
138
+ = 1.2.9 =
139
+ * updated Smush.it endpoint URL
140
+
141
+ = 1.2.8 =
142
+ * fixed path checking on Windows servers
143
+
144
+ = 1.2.7 =
145
+ * update to workaround WordPress's new JSON compat layer (see [trac ticket](http://core.trac.wordpress.org/ticket/11827))
146
+
147
+ = 1.2.6 =
148
+ * updated Smush.it endpoint URL
149
+ * fixed undefined constant
150
+
151
+ = 1.2.5 =
152
+ * updated Smush.it endpoint URL
153
+
154
+ = 1.2.4 =
155
+ * removed debugging code that was interfering with the Flash uploader
156
+
157
+ = 1.2.3 =
158
+ * bug fix
159
+
160
+ = 1.2.2 =
161
+ * updated to use Yahoo! hosted Smush.it service
162
+ * added security checks to files passed to `wp_smushit()`
163
+
164
+ = 1.2.1 =
165
+ * added support for PHP 4
166
+ * created admin action hook as workaround to WordPress 2.9's `$_registered_pages` security (see [changeset 11596](http://core.trac.wordpress.org/changeset/11596))
167
+ * add savings amount in bytes to Media Library (thx [Yoast](http://www.yoast.com/))
168
+
169
+ = 1.2 =
170
+ * added support for `WP_Http`
171
+
172
+ = 1.1.3 =
173
+ * fixed activation error when the PEAR JSON library is already loaded
174
+
175
+ = 1.1.2 =
176
+ * added test for `allow_url_fopen`
177
+
178
+ = 1.1.1 =
179
+ * added error message on PHP copy error
180
+
181
+ = 1.1 =
182
+ * improved handling of errors from Smush.it
183
+ * added ability to manually smush images from media library
184
+ * fixed inconsistent path handling from WP 2.5 -> WP 2.7
185
+
186
+ = 1.0.2 =
187
+ * added 'Not processed' status message when browsing media library
188
+
189
+ = 1.0.1 =
190
+ * added i10n functions
191
+
192
+ = 1.0 =
193
+ * first edition
194
+
195
  == About Us ==
196
  WPMU DEV is a premium supplier of quality WordPress plugins and themes. For premium support with any WordPress related issues you can join us here:
197
  <a href="http://premium.wpmudev.org/join/">http://premium.wpmudev.org/join/</a>
200
  <a href="http://wpmu.org/">http://wpmu.org</a>
201
 
202
  Hey, one more thing... we hope you <a href="http://profiles.wordpress.org/WPMUDEV/">enjoy our free offerings</a> as much as we've loved making them for you!
203
+
204
+ == Contact and Credits ==
205
+
206
+ Originally written by Alex Dunae at Dialect ([dialect.ca](http://dialect.ca/?wp_smush_it), e-mail 'alex' at 'dialect dot ca'), 2008-11.
207
+
208
+ WP Smush.it includes a copy of the [PEAR JSON library](http://pear.php.net/pepr/pepr-proposal-show.php?id=198) written by Michal Migurski.
209
+
210
+ Smush.it was created by [Nicole Sullivan](http://www.stubbornella.org/content/) and [Stoyan Stefanov](http://phpied.com/).
wp-smushit.php CHANGED
@@ -1,574 +1,619 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Smush.it
4
- Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
- Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
6
- Author: WPMU DEV
7
- Version: 1.6.5
8
- Author URI: http://premium.wpmudev.org/
9
- Textdomain: wp_smushit
10
- */
11
-
12
- /*
13
- This plugin was originally developed by Alex Dunae.
14
- http://dialect.ca/
15
- */
16
-
17
- /*
18
- Copyright 2007-2013 Incsub (http://incsub.com)
19
-
20
- This program is free software; you can redistribute it and/or modify
21
- it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
22
- the Free Software Foundation.
23
-
24
- This program is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
-
29
- You should have received a copy of the GNU General Public License
30
- along with this program; if not, write to the Free Software
31
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
- */
33
-
34
- if ( !class_exists( 'WpSmushit' ) ) {
35
-
36
- class WpSmushit {
37
-
38
- var $version = "1.6.5";
39
-
40
- /**
41
- * Constructor
42
- */
43
- function WpSmushit( ) {
44
- $this->__construct( );
45
- }
46
- function __construct( ) {
47
-
48
- if ( !function_exists( 'download_url' ) ) {
49
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
50
- }
51
-
52
- /**
53
- * Constants
54
- */
55
- define( 'SMUSHIT_REQ_URL', 'http://www.smushit.com/ysmush.it/ws.php?img=%s' );
56
- define( 'SMUSHIT_BASE_URL', 'http://www.smushit.com/' );
57
-
58
- define( 'WP_SMUSHIT_DOMAIN', 'wp_smushit' );
59
- define( 'WP_SMUSHIT_UA', "WP Smush.it/{$this->version} (+http://wordpress.org/extend/plugins/wp-smushit/)" );
60
- define( 'WP_SMUSHIT_PLUGIN_DIR', dirname( plugin_basename(__FILE__) ) );
61
- define( 'WP_SMUSHIT_MAX_BYTES', 1048576 );
62
-
63
- // The number of images (including generated sizes) that can return errors before abandoning all hope.
64
- // N.B. this doesn't work with the bulk uploader, since it creates a new HTTP request
65
- // for each image. It does work with the bulk smusher, though.
66
- define( 'WP_SMUSHIT_ERRORS_BEFORE_QUITTING', 3 * count( get_intermediate_image_sizes( ) ) );
67
-
68
- define( 'WP_SMUSHIT_AUTO', intval( get_option( 'wp_smushit_smushit_auto', 0) ) );
69
- define( 'WP_SMUSHIT_TIMEOUT', intval( get_option( 'wp_smushit_smushit_timeout', 60) ) );
70
-
71
- /*
72
- Each service has a setting specifying whether it should be used automatically on upload.
73
- Values are:
74
- -1 Don't use (until manually enabled via Media > Settings)
75
- 0 Use automatically
76
- n Any other number is a Unix timestamp indicating when the service can be used again
77
- */
78
-
79
- define('WP_SMUSHIT_AUTO_OK', 0);
80
- define('WP_SMUSHIT_AUTO_NEVER', -1);
81
-
82
- /**
83
- * Hooks
84
- */
85
- if ( WP_SMUSHIT_AUTO == WP_SMUSHIT_AUTO_OK ) {
86
- add_filter( 'wp_generate_attachment_metadata', array( &$this, 'resize_from_meta_data' ), 10, 2 );
87
- }
88
- add_filter( 'manage_media_columns', array( &$this, 'columns' ) );
89
- add_action( 'manage_media_custom_column', array( &$this, 'custom_column' ), 10, 2 );
90
- add_action( 'admin_init', array( &$this, 'admin_init' ) );
91
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
92
- add_action( 'admin_action_wp_smushit_manual', array( &$this, 'smushit_manual' ) );
93
- add_action( 'admin_head-upload.php', array( &$this, 'add_bulk_actions_via_javascript' ) );
94
- add_action( 'admin_action_bulk_smushit', array( &$this, 'bulk_action_handler' ) );
95
- add_action( 'admin_init', array( &$this, 'register_settings' ) );
96
- }
97
-
98
- /**
99
- * Plugin setting functions
100
- */
101
- function register_settings( ) {
102
- add_settings_section( 'wp_smushit_settings', 'WP Smush.it', array( &$this, 'settings_cb' ), 'media' );
103
- add_settings_field( 'wp_smushit_smushit_auto', __( 'Use Smush.it on upload?', WP_SMUSHIT_DOMAIN ), array( &$this, 'render_auto_opts' ), 'media', 'wp_smushit_settings' );
104
- add_settings_field( 'wp_smushit_smushit_timeout', __( 'How many seconds should we wait for a response from Smush.it?', WP_SMUSHIT_DOMAIN ), array( &$this, 'render_timeout_opts' ), 'media', 'wp_smushit_settings' );
105
- register_setting( 'media', array( &$this, 'smushit_auto' ) );
106
- register_setting( 'media', array( &$this, 'smushit_timeout' ) );
107
- }
108
-
109
- function settings_cb( ) {
110
- }
111
-
112
- function render_auto_opts( ) {
113
- $key = 'wp_smushit_smushit_auto';
114
- $val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) );
115
- printf( "<select name='%1\$s' id='%1\$s'>", esc_attr( $key ) );
116
- echo '<option value=' . WP_SMUSHIT_AUTO_OK . ' ' . selected( WP_SMUSHIT_AUTO_OK, $val ) . '>'. __( 'Automatically process on upload', WP_SMUSHIT_DOMAIN ) . '</option>';
117
- echo '<option value=' . WP_SMUSHIT_AUTO_NEVER . ' ' . selected( WP_SMUSHIT_AUTO_NEVER, $val ) . '>'. __( 'Do not process on upload', WP_SMUSHIT_DOMAIN ) . '</option>';
118
-
119
- if ( $val > 0 ) {
120
- printf( '<option value="%d" selected="selected">', $val ) .
121
- printf( __( 'Temporarily disabled until %s', WP_SMUSHIT_DOMAIN ), date( 'M j, Y \a\t H:i', $val ) ).'</option>';
122
- }
123
- echo '</select>';
124
- }
125
-
126
- function render_timeout_opts( $key ) {
127
- $key = 'wp_smushit_smushit_timeout';
128
- $val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) );
129
- printf( "<input type='text' name='%1\$s' id='%1\$s' value='%2\%d'>", esc_attr( $key ), intval( get_option( $key, 60 ) ) );
130
- }
131
-
132
- // default is 6hrs
133
- function temporarily_disable( $seconds = 21600 ) {
134
- update_option( 'wp_smushit_smushit_auto', time() + $seconds );
135
- }
136
-
137
- function admin_init( ) {
138
- load_plugin_textdomain( WP_SMUSHIT_DOMAIN );
139
- wp_enqueue_script( 'common' );
140
- }
141
-
142
- function admin_menu( ) {
143
- add_media_page( 'Bulk Smush.it', 'Bulk Smush.it', 'edit_others_posts', 'wp-smushit-bulk', array( &$this, 'bulk_preview' ) );
144
- }
145
-
146
- function bulk_preview( ) {
147
- if ( function_exists( 'apache_setenv' ) ) {
148
- @apache_setenv('no-gzip', 1);
149
- }
150
- @ini_set('output_buffering','on');
151
- @ini_set('zlib.output_compression', 0);
152
- @ini_set('implicit_flush', 1);
153
-
154
- $attachments = null;
155
- $auto_start = false;
156
-
157
- if ( isset($_REQUEST['ids'] ) ) {
158
- $attachments = get_posts( array(
159
- 'numberposts' => -1,
160
- 'include' => explode(',', $_REQUEST['ids']),
161
- 'post_type' => 'attachment',
162
- 'post_mime_type' => 'image'
163
- ));
164
- $auto_start = true;
165
- } else {
166
- $attachments = get_posts( array(
167
- 'numberposts' => -1,
168
- 'post_type' => 'attachment',
169
- 'post_mime_type' => 'image'
170
- ));
171
- }
172
- ?>
173
- <div class="wrap">
174
- <div id="icon-upload" class="icon32"><br /></div><h2><?php _e( 'Bulk WP Smush.it', WP_SMUSHIT_DOMAIN ) ?></h2>
175
- <?php
176
-
177
- if ( sizeof($attachments) < 1 ):
178
- _e( '<p>You don�t appear to have uploaded any images yet.</p>', WP_SMUSHIT_DOMAIN );
179
- else:
180
- if ( empty($_POST) && !$auto_start ): // instructions page
181
-
182
- _e( "<p>This tool will run all of the images in your media library through the WP Smush.it web service. It won't re-smush images that were successfully smushed before. It will retry images that were not successfully smushed.</p>", WP_SMUSHIT_DOMAIN );
183
-
184
- _e( "<p>It uploads each and every file to Yahoo! and then downloads the resulting file. It can take a long time.</p>", WP_SMUSHIT_DOMAIN );
185
-
186
- printf( __( "<p>We found %d images in your media library. Be forewarned, <strong>it will take <em>at least</em> %d minutes</strong> to process all these images if they have never been smushed before.</p>", WP_SMUSHIT_DOMAIN ), sizeof($attachments), sizeof($attachments) * 3 / 60 );
187
-
188
- _e( "<p><em>N.B. If your server <tt>gzip</tt>s content you may not see the progress updates as your files are processed.</em></p>", WP_SMUSHIT_DOMAIN );
189
-
190
- printf( __( "<p><strong>This is an experimental feature.</strong> Please post any feedback to the %s.</p>", WP_SMUSHIT_DOMAIN ), '<a href="http://wordpress.org/tags/wp-smushit">'. __( 'WordPress WP Smush.it forums', WP_SMUSHIT_DOMAIN ). '</a>' );
191
- ?>
192
- <form method="post" action="">
193
- <?php wp_nonce_field( 'wp-smushit-bulk', '_wpnonce'); ?>
194
- <button type="submit" class="button-secondary action"><?php _e( 'Run all my images through WP Smush.it right now', WP_SMUSHIT_DOMAIN ) ?></button>
195
- </form>
196
-
197
- <?php
198
- else: // run the script
199
-
200
- if ( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'wp-smushit-bulk' ) || !current_user_can( 'edit_others_posts' ) ) {
201
- wp_die( __( 'Cheatin&#8217; uh?' ) );
202
- }
203
-
204
-
205
- @ob_implicit_flush( true );
206
- @ob_end_flush();
207
- foreach( $attachments as $attachment ) {
208
- printf( "<p>Processing <strong>%s</strong>&hellip;<br>", esc_html( $attachment->post_name ) );
209
- $original_meta = wp_get_attachment_metadata( $attachment->ID, true );
210
-
211
- $meta = $this->resize_from_meta_data( $original_meta, $attachment->ID, false );
212
-
213
- printf( "� %dx%d: ", intval($meta['width']), intval($meta['height']) );
214
-
215
- if ( $original_meta['wp_smushit'] == $meta['wp_smushit'] && stripos( $meta['wp_smushit'], 'Smush.it error' ) === false ) {
216
- echo 'already smushed' . $meta['wp_smushit'];
217
- } else {
218
- echo $meta['wp_smushit'];
219
- }
220
- echo '<br>';
221
-
222
- if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
223
- foreach( $meta['sizes'] as $size_name => $size ) {
224
- printf( "� %dx%d: ", intval($size['width']), intval($size['height']) );
225
- if ( $original_meta['sizes'][$size_name]['wp_smushit'] == $size['wp_smushit'] && stripos( $meta['sizes'][$size_name]['wp_smushit'], 'Smush.it error' ) === false ) {
226
- echo 'already smushed';
227
- } else {
228
- echo $size['wp_smushit'];
229
- }
230
- echo '<br>';
231
- }
232
- }
233
- echo "</p>";
234
-
235
- wp_update_attachment_metadata( $attachment->ID, $meta );
236
-
237
- // rate limiting is good manners, let's be nice to Yahoo!
238
- sleep(0.5);
239
- @ob_flush();
240
- flush();
241
- }
242
- endif;
243
- endif;
244
- ?>
245
- </div>
246
- <?php
247
- }
248
-
249
- /**
250
- * Manually process an image from the Media Library
251
- */
252
- function smushit_manual( ) {
253
- if ( !current_user_can('upload_files') ) {
254
- wp_die( __( 'You don\'t have permission to work with uploaded files.', WP_SMUSHIT_DOMAIN ) );
255
- }
256
-
257
- if ( !isset( $_GET['attachment_ID'] ) ) {
258
- wp_die( __( 'No attachment ID was provided.', WP_SMUSHIT_DOMAIN ) );
259
- }
260
-
261
- $attachment_ID = intval( $_GET['attachment_ID'] );
262
-
263
- $original_meta = wp_get_attachment_metadata( $attachment_ID );
264
-
265
- $new_meta = $this->resize_from_meta_data( $original_meta, $attachment_ID );
266
- wp_update_attachment_metadata( $attachment_ID, $new_meta );
267
-
268
- wp_redirect( preg_replace( '|[^a-z0-9-~+_.?#=&;,/:]|i', '', wp_get_referer( ) ) );
269
- exit();
270
- }
271
-
272
- /**
273
- * Process an image with Smush.it.
274
- *
275
- * Returns an array of the $file $results.
276
- *
277
- * @param string $file Full absolute path to the image file
278
- * @param string $file_url Optional full URL to the image file
279
- * @returns array
280
- */
281
- function do_smushit( $file, $file_url = null ) {
282
- // don't run on localhost, IPv4 and IPv6 checks
283
- // if( in_array($_SERVER['SERVER_ADDR'], array('127.0.0.1', '::1')) )
284
- // return array($file, __('Not processed (local file)', WP_SMUSHIT_DOMAIN));
285
-
286
- // canonicalize path - disabled 2011-02-1 troubleshooting 'Could not find...' errors.
287
- // From the PHP docs: "The running script must have executable permissions on
288
- // all directories in the hierarchy, otherwise realpath() will return false."
289
- // $file_path = realpath($file);
290
-
291
- static $error_count = 0;
292
-
293
- if ( $error_count >= WP_SMUSHIT_ERRORS_BEFORE_QUITTING ) {
294
- $msg = __( "Did not smush due to previous errors", WP_SMUSHIT_DOMAIN );
295
- return array( $file, $msg );
296
- }
297
-
298
- $file_path = $file;
299
- // check that the file exists
300
- if ( !file_exists( $file_path ) || !is_file( $file_path ) ) {
301
- $msg = sprintf( __( "Could not find <span class='code'>%s</span>", WP_SMUSHIT_DOMAIN ), $file_path );
302
- return array( $file, $msg );
303
- }
304
-
305
- // check that the file is writable
306
- if ( !is_writable( $file_path ) ) {
307
- $msg = sprintf( __("<span class='code'>%s</span> is not writable", WP_SMUSHIT_DOMAIN ), $file_path );
308
- return array( $file, $msg );
309
- }
310
-
311
- $file_size = filesize( $file_path );
312
- if ( $file_size > WP_SMUSHIT_MAX_BYTES ) {
313
- $msg = sprintf(__("<a href='http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict'>Too big</a> for Smush.it (%s)", WP_SMUSHIT_DOMAIN), $this->format_bytes($file_size));
314
- return array( $file, $msg );
315
- }
316
-
317
- // check that the file is within the WP_CONTENT_DIR
318
- $upload_dir = wp_upload_dir();
319
- $wp_upload_dir = $upload_dir['basedir'];
320
- $wp_upload_url = $upload_dir['baseurl'];
321
- if ( 0 !== stripos(realpath($file_path), realpath(ABSPATH)) ) {
322
- $msg = sprintf( __( "<span class='code'>%s</span> must be within the content directory (<span class='code'>%s</span>)",
323
- WP_SMUSHIT_DOMAIN ), htmlentities( $file_path ), $wp_upload_dir);
324
-
325
- return array($file, $msg);
326
- }
327
-
328
- if ( !$file_url ) {
329
- // determine the public URL
330
- $file_url = str_replace( $wp_upload_dir, $wp_upload_url, $file );
331
- }
332
-
333
- $data = $this->_post( $file_url );
334
-
335
- if ( false === $data ) {
336
- $error_count++;
337
- return array( $file, __( 'Error posting to Smush.it', WP_SMUSHIT_DOMAIN ) );
338
- }
339
-
340
- // make sure the response looks like JSON -- added 2008-12-19 when
341
- // Smush.it was returning PHP warnings before the JSON output
342
- if ( strpos( trim($data), '{' ) != 0 ) {
343
- return array( $file, __('Bad response from Smush.it', WP_SMUSHIT_DOMAIN ) );
344
- }
345
-
346
- // read the JSON response
347
- if ( function_exists('json_decode') ) {
348
- $data = json_decode( $data );
349
- } else {
350
- require_once( 'JSON/JSON.php' );
351
- $json = new Services_JSON( );
352
- $data = $json->decode( $data );
353
- }
354
-
355
- if ( !isset( $data->dest_size ) )
356
- return array( $file, __('Bad response from Smush.it', WP_SMUSHIT_DOMAIN ) );
357
-
358
- if ( -1 === intval( $data->dest_size ) )
359
- return array( $file, __('No savings', WP_SMUSHIT_DOMAIN ) );
360
-
361
- if ( !isset( $data->dest ) ) {
362
- $err = ( $data->error ? __( 'Smush.it error: ', WP_SMUSHIT_DOMAIN ) . $data->error : __( 'unknown error', WP_SMUSHIT_DOMAIN ) );
363
- $err .= sprintf( __( " while processing <span class='code'>%s</span> (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ), $file_url, $file_path);
364
- return array( $file, $err );
365
- }
366
-
367
- $processed_url = $data->dest;
368
-
369
- // The smush.it web service does not append the domain;
370
- // smushit.com web service does
371
- if ( 0 !== stripos($processed_url, 'http://') ) {
372
- $processed_url = SMUSHIT_BASE_URL . $processed_url;
373
- }
374
-
375
- $temp_file = download_url( $processed_url );
376
-
377
- if ( is_wp_error( $temp_file ) ) {
378
- @unlink($tmp);
379
- $results_msg = sprintf( __("Error downloading file (%s)", WP_SMUSHIT_DOMAIN ),
380
- $temp_file->get_error_message());
381
- return array($file, $results_msg );
382
- }
383
-
384
- @rename( $temp_file, $file_path );
385
-
386
- $savings = intval( $data->src_size ) - intval( $data->dest_size );
387
- $savings_str = $this->format_bytes( $savings, 1 );
388
- $savings_str = str_replace( ' ', '&nbsp;', $savings_str );
389
-
390
- $results_msg = sprintf( __("Reduced by %01.1f%% (%s)", WP_SMUSHIT_DOMAIN ),
391
- $data->percent,
392
- $savings_str );
393
-
394
- return array( $file, $results_msg );
395
- }
396
-
397
- function should_resmush($previous_status) {
398
- if ( !$previous_status || empty($previous_status ) ) {
399
- return true;
400
- }
401
-
402
- if ( stripos( $previous_status, 'no savings' ) !== false || stripos( $previous_status, 'reduced' ) !== false ) {
403
- return false;
404
- }
405
-
406
- // otherwise an error
407
- return true;
408
- }
409
-
410
-
411
- /**
412
- * Read the image paths from an attachment's meta data and process each image
413
- * with wp_smushit().
414
- *
415
- * This method also adds a `wp_smushit` meta key for use in the media library.
416
- *
417
- * Called after `wp_generate_attachment_metadata` is completed.
418
- */
419
- function resize_from_meta_data( $meta, $ID = null, $force_resmush = true ) {
420
- if ( $ID && wp_attachment_is_image( $ID ) === false ) {
421
- return $meta;
422
- }
423
-
424
- $file_path = $meta['file'];
425
- $store_absolute_path = true;
426
- $upload_dir = wp_upload_dir();
427
- $upload_path = trailingslashit( $upload_dir['basedir'] );
428
-
429
- // WordPress >= 2.6.2: determine the absolute $file_path (http://core.trac.wordpress.org/changeset/8796)
430
- if ( false === strpos($file_path, $upload_path) ) {
431
- $store_absolute_path = false;
432
- $file_path = $upload_path . $file_path;
433
- }
434
-
435
- if ( $force_resmush || $this->should_resmush( @$meta['wp_smushit'] ) ) {
436
- list($file, $msg) = $this->do_smushit($file_path);
437
- $meta['wp_smushit'] = $msg;
438
- }
439
-
440
- // strip absolute path for Wordpress >= 2.6.2
441
- if ( false === $store_absolute_path ) {
442
- $meta['file'] = str_replace($upload_path, '', $meta['file']);
443
- }
444
-
445
- // no resized versions, so we can exit
446
- if ( !isset( $meta['sizes'] ) )
447
- return $meta;
448
-
449
- // meta sizes don't contain a path, so we calculate one
450
- $base_dir = trailingslashit( dirname($file_path) );
451
-
452
- foreach($meta['sizes'] as $size => $data) {
453
- if ( !$force_resmush && $this->should_resmush( @$meta['sizes'][$size]['wp_smushit'] ) === false ) {
454
- continue;
455
- }
456
-
457
- list($smushed_file, $results) = $this->do_smushit( $base_dir . wp_basename( $data['file'] ) );
458
- $meta['sizes'][$size]['wp_smushit'] = $results;
459
- }
460
- return $meta;
461
- }
462
-
463
- /**
464
- * Post an image to Smush.it.
465
- *
466
- * @param string $file_url URL of the file to send to Smush.it
467
- * @return string|boolean Returns the JSON response on success or else false
468
- */
469
- function _post( $file_url ) {
470
- $req = sprintf( SMUSHIT_REQ_URL, urlencode( $file_url ) );
471
-
472
- $data = false;
473
-
474
- if ( function_exists( 'wp_remote_get' ) ) {
475
- $response = wp_remote_get( $req, array('user-agent' => WP_SMUSHIT_UA, 'timeout' => WP_SMUSHIT_TIMEOUT ) );
476
- if ( !$response || is_wp_error( $response ) ) {
477
- $data = false;
478
- } else {
479
- $data = wp_remote_retrieve_body( $response );
480
- }
481
- } else {
482
- wp_die( __('WP Smush.it requires WordPress 2.8 or greater', WP_SMUSHIT_DOMAIN) );
483
- }
484
-
485
- return $data;
486
- }
487
-
488
-
489
- /**
490
- * Print column header for Smush.it results in the media library using
491
- * the `manage_media_columns` hook.
492
- */
493
- function columns( $defaults ) {
494
- $defaults['smushit'] = 'Smush.it';
495
- return $defaults;
496
- }
497
-
498
- /**
499
- * Return the filesize in a humanly readable format.
500
- * Taken from http://www.php.net/manual/en/function.filesize.php#91477
501
- */
502
- function format_bytes( $bytes, $precision = 2 ) {
503
- $units = array('B', 'KB', 'MB', 'GB', 'TB');
504
- $bytes = max($bytes, 0);
505
- $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
506
- $pow = min($pow, count($units) - 1);
507
- $bytes /= pow(1024, $pow);
508
- return round($bytes, $precision) . ' ' . $units[$pow];
509
- }
510
-
511
- /**
512
- * Print column data for Smush.it results in the media library using
513
- * the `manage_media_custom_column` hook.
514
- */
515
- function custom_column( $column_name, $id ) {
516
- if( 'smushit' == $column_name ) {
517
- $data = wp_get_attachment_metadata($id);
518
- if ( isset( $data['wp_smushit'] ) && !empty( $data['wp_smushit'] ) ) {
519
- print $data['wp_smushit'];
520
- printf( "<br><a href=\"admin.php?action=wp_smushit_manual&amp;attachment_ID=%d\">%s</a>",
521
- $id,
522
- __( 'Re-smush', WP_SMUSHIT_DOMAIN ) );
523
- } else {
524
- if ( wp_attachment_is_image( $id ) ) {
525
- print __( 'Not processed', WP_SMUSHIT_DOMAIN );
526
- printf( "<br><a href=\"admin.php?action=wp_smushit_manual&amp;attachment_ID=%d\">%s</a>",
527
- $id,
528
- __('Smush.it now!', WP_SMUSHIT_DOMAIN));
529
- }
530
- }
531
- }
532
- }
533
-
534
-
535
- // Borrowed from http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/
536
- function add_bulk_actions_via_javascript() { ?>
537
- <script type="text/javascript">
538
- jQuery(document).ready(function($){
539
- $('select[name^="action"] option:last-child').before('<option value="bulk_smushit">Bulk Smush.it</option>');
540
- });
541
- </script>
542
- <?php }
543
-
544
-
545
- // Handles the bulk actions POST
546
- // Borrowed from http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/
547
- function bulk_action_handler() {
548
- check_admin_referer( 'bulk-media' );
549
-
550
- if ( empty( $_REQUEST['media'] ) || ! is_array( $_REQUEST['media'] ) )
551
- return;
552
-
553
- $ids = implode( ',', array_map( 'intval', $_REQUEST['media'] ) );
554
-
555
- // Can't use wp_nonce_url() as it escapes HTML entities
556
- wp_redirect( add_query_arg( '_wpnonce', wp_create_nonce( 'wp-smushit-bulk' ), admin_url( 'upload.php?page=wp-smushit-bulk&goback=1&ids=' . $ids ) ) );
557
- exit();
558
- }
559
-
560
- }
561
-
562
- $WpSmushit = new WpSmushit();
563
- global $WpSmushit;
564
-
565
- }
566
-
567
- if ( !function_exists( 'wp_basename' ) ) {
568
- /**
569
- * Introduced in WP 3.1... this is copied verbatim from wp-includes/formatting.php.
570
- */
571
- function wp_basename( $path, $suffix = '' ) {
572
- return urldecode( basename( str_replace( '%2F', '/', urlencode( $path ) ), $suffix ) );
573
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  }
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Smush.it
4
+ Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
+ Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
6
+ Author: WPMU DEV
7
+ Version: 1.6.5.1
8
+ Author URI: http://premium.wpmudev.org/
9
+ Textdomain: wp_smushit
10
+ */
11
+
12
+ /*
13
+ This plugin was originally developed by Alex Dunae.
14
+ http://dialect.ca/
15
+ */
16
+
17
+ /*
18
+ Copyright 2007-2013 Incsub (http://incsub.com)
19
+
20
+ This program is free software; you can redistribute it and/or modify
21
+ it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
22
+ the Free Software Foundation.
23
+
24
+ This program is distributed in the hope that it will be useful,
25
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ GNU General Public License for more details.
28
+
29
+ You should have received a copy of the GNU General Public License
30
+ along with this program; if not, write to the Free Software
31
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
+ */
33
+
34
+ if ( !class_exists( 'WpSmushit' ) ) {
35
+
36
+ class WpSmushit {
37
+
38
+ var $version = "1.6.5.1";
39
+
40
+ /**
41
+ * Constructor
42
+ */
43
+ function WpSmushit( ) {
44
+ $this->__construct( );
45
+ }
46
+ function __construct( ) {
47
+
48
+ if ( !function_exists( 'download_url' ) ) {
49
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
50
+ }
51
+
52
+ /**
53
+ * Constants
54
+ */
55
+ define( 'SMUSHIT_REQ_URL', 'http://www.smushit.com/ysmush.it/ws.php?img=%s' );
56
+ define( 'SMUSHIT_BASE_URL', 'http://www.smushit.com/' );
57
+
58
+ define( 'WP_SMUSHIT_DOMAIN', 'wp_smushit' );
59
+ define( 'WP_SMUSHIT_UA', "WP Smush.it/{$this->version} (+http://wordpress.org/extend/plugins/wp-smushit/)" );
60
+ define( 'WP_SMUSHIT_PLUGIN_DIR', dirname( plugin_basename(__FILE__) ) );
61
+ define( 'WP_SMUSHIT_MAX_BYTES', 1048576 );
62
+
63
+ // The number of images (including generated sizes) that can return errors before abandoning all hope.
64
+ // N.B. this doesn't work with the bulk uploader, since it creates a new HTTP request
65
+ // for each image. It does work with the bulk smusher, though.
66
+ define( 'WP_SMUSHIT_ERRORS_BEFORE_QUITTING', 3 * count( get_intermediate_image_sizes( ) ) );
67
+
68
+ define( 'WP_SMUSHIT_AUTO', intval( get_option( 'wp_smushit_smushit_auto', 0) ) );
69
+ define( 'WP_SMUSHIT_TIMEOUT', intval( get_option( 'wp_smushit_smushit_timeout', 60) ) );
70
+
71
+ /*
72
+ Each service has a setting specifying whether it should be used automatically on upload.
73
+ Values are:
74
+ -1 Don't use (until manually enabled via Media > Settings)
75
+ 0 Use automatically
76
+ n Any other number is a Unix timestamp indicating when the service can be used again
77
+ */
78
+
79
+ define('WP_SMUSHIT_AUTO_OK', 0);
80
+ define('WP_SMUSHIT_AUTO_NEVER', -1);
81
+
82
+ /**
83
+ * Hooks
84
+ */
85
+ if ( WP_SMUSHIT_AUTO == WP_SMUSHIT_AUTO_OK ) {
86
+ add_filter( 'wp_generate_attachment_metadata', array( &$this, 'resize_from_meta_data' ), 10, 2 );
87
+ }
88
+ add_filter( 'manage_media_columns', array( &$this, 'columns' ) );
89
+ add_action( 'manage_media_custom_column', array( &$this, 'custom_column' ), 10, 2 );
90
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
91
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
92
+ add_action( 'admin_action_wp_smushit_manual', array( &$this, 'smushit_manual' ) );
93
+ add_action( 'admin_head-upload.php', array( &$this, 'add_bulk_actions_via_javascript' ) );
94
+ add_action( 'admin_action_bulk_smushit', array( &$this, 'bulk_action_handler' ) );
95
+ add_action( 'admin_init', array( &$this, 'register_settings' ) );
96
+ }
97
+
98
+ /**
99
+ * Plugin setting functions
100
+ */
101
+ function register_settings( ) {
102
+ add_settings_section( 'wp_smushit_settings', 'WP Smush.it', array( &$this, 'settings_cb' ), 'media' );
103
+
104
+ add_settings_field( 'wp_smushit_smushit_auto', __( 'Use Smush.it on upload?', WP_SMUSHIT_DOMAIN ), array( &$this, 'render_auto_opts' ),
105
+ 'media', 'wp_smushit_settings' );
106
+ add_settings_field( 'wp_smushit_smushit_timeout', __( 'How many seconds should we wait for a response from Smush.it?', WP_SMUSHIT_DOMAIN ),
107
+ array( &$this, 'render_timeout_opts' ), 'media', 'wp_smushit_settings' );
108
+
109
+ register_setting( 'media', 'wp_smushit_smushit_auto' );
110
+ register_setting( 'media', 'wp_smushit_smushit_timeout' );
111
+ }
112
+
113
+ function settings_cb( ) {
114
+ }
115
+
116
+ function render_auto_opts( ) {
117
+ $key = 'wp_smushit_smushit_auto';
118
+ $val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) );
119
+ printf( "<select name='%1\$s' id='%1\$s'>", esc_attr( $key ) );
120
+ echo '<option value=' . WP_SMUSHIT_AUTO_OK . ' ' . selected( WP_SMUSHIT_AUTO_OK, $val ) . '>'. __( 'Automatically process on upload', WP_SMUSHIT_DOMAIN ) . '</option>';
121
+ echo '<option value=' . WP_SMUSHIT_AUTO_NEVER . ' ' . selected( WP_SMUSHIT_AUTO_NEVER, $val ) . '>'. __( 'Do not process on upload', WP_SMUSHIT_DOMAIN ) . '</option>';
122
+
123
+ if ( $val > 0 ) {
124
+ printf( '<option value="%d" selected="selected">', $val ) .
125
+ printf( __( 'Temporarily disabled until %s', WP_SMUSHIT_DOMAIN ), date( 'M j, Y \a\t H:i', $val ) ).'</option>';
126
+ }
127
+ echo '</select>';
128
+ }
129
+
130
+ function render_timeout_opts( $key ) {
131
+ $key = 'wp_smushit_smushit_timeout';
132
+ $val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) );
133
+ printf( "<input type='text' name='%1\$s' id='%1\$s' value='%2\%d'>", esc_attr( $key ), intval( get_option( $key, 60 ) ) );
134
+ }
135
+
136
+ // default is 6hrs
137
+ function temporarily_disable( $seconds = 21600 ) {
138
+ update_option( 'wp_smushit_smushit_auto', time() + $seconds );
139
+ }
140
+
141
+ function admin_init( ) {
142
+ load_plugin_textdomain(WP_SMUSHIT_DOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages/');
143
+ wp_enqueue_script( 'common' );
144
+ }
145
+
146
+ function admin_menu( ) {
147
+ add_media_page( 'Bulk Smush.it', 'Bulk Smush.it', 'edit_others_posts', 'wp-smushit-bulk', array( &$this, 'bulk_preview' ) );
148
+ }
149
+
150
+ function bulk_preview( ) {
151
+ if ( function_exists( 'apache_setenv' ) ) {
152
+ @apache_setenv('no-gzip', 1);
153
+ }
154
+ @ini_set('output_buffering','on');
155
+ @ini_set('zlib.output_compression', 0);
156
+ @ini_set('implicit_flush', 1);
157
+
158
+ $attachments = null;
159
+ $auto_start = false;
160
+
161
+ if ( isset($_REQUEST['ids'] ) ) {
162
+ $attachments = get_posts( array(
163
+ 'numberposts' => -1,
164
+ 'include' => explode(',', $_REQUEST['ids']),
165
+ 'post_type' => 'attachment',
166
+ 'post_mime_type' => 'image'
167
+ ));
168
+ $auto_start = true;
169
+ } else {
170
+ $attachments = get_posts( array(
171
+ 'numberposts' => -1,
172
+ 'post_type' => 'attachment',
173
+ 'post_mime_type' => 'image'
174
+ ));
175
+ }
176
+ ?>
177
+ <div class="wrap">
178
+ <div id="icon-upload" class="icon32"><br /></div><h2><?php _e( 'Bulk WP Smush.it', WP_SMUSHIT_DOMAIN ) ?></h2>
179
+ <?php
180
+
181
+ if ( sizeof($attachments) < 1 ):
182
+ _e( "<p>You don't appear to have uploaded any images yet.</p>", WP_SMUSHIT_DOMAIN );
183
+ else:
184
+ if ( empty($_POST) && !$auto_start ): // instructions page
185
+
186
+ _e( "<p>This tool will run all of the images in your media library through the WP Smush.it web service. It won't re-smush images that were successfully smushed before. It will retry images that were not successfully smushed.</p>", WP_SMUSHIT_DOMAIN );
187
+
188
+ _e( "<p>It uploads each and every file to Yahoo! and then downloads the resulting file. Note: the Yahoo! Smush.it service does not support https:// urls. So the image MUST be accessible via the public internet over a non-SSL URL. It can take a long time.</p>", WP_SMUSHIT_DOMAIN );
189
+
190
+ printf( __( "<p>We found %d images in your media library. Be forewarned, <strong>it will take <em>at least</em> %d minutes</strong> to process all these images if they have never been smushed before.</p>", WP_SMUSHIT_DOMAIN ), sizeof($attachments), sizeof($attachments) * 3 / 60 );
191
+
192
+ _e( "<p><em>N.B. If your server <tt>gzip</tt>s content you may not see the progress updates as your files are processed.</em></p>", WP_SMUSHIT_DOMAIN );
193
+
194
+ printf( __( "<p><strong>This is an experimental feature.</strong> Please post any feedback to the %s.</p>", WP_SMUSHIT_DOMAIN ), '<a href="http://wordpress.org/tags/wp-smushit">'. __( 'WordPress WP Smush.it forums', WP_SMUSHIT_DOMAIN ). '</a>' );
195
+ ?>
196
+ <form method="post" action="">
197
+ <?php wp_nonce_field( 'wp-smushit-bulk', '_wpnonce'); ?>
198
+ <button type="submit" class="button-secondary action"><?php _e( 'Run all my images through WP Smush.it right now', WP_SMUSHIT_DOMAIN ) ?></button>
199
+ </form>
200
+
201
+ <?php
202
+ else: // run the script
203
+
204
+ if ( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'wp-smushit-bulk' ) || !current_user_can( 'edit_others_posts' ) ) {
205
+ wp_die( __( 'Cheatin&#8217; uh?' ) );
206
+ }
207
+
208
+
209
+ @ob_implicit_flush( true );
210
+ @ob_end_flush();
211
+ foreach( $attachments as $attachment ) {
212
+ printf( __("<p>Processing <strong>%s</strong>&hellip;<br />", WP_SMUSHIT_DOMAIN), esc_html( $attachment->post_name ) );
213
+ $original_meta = wp_get_attachment_metadata( $attachment->ID, true );
214
+ //if (isset($original_meta['wp_smushit']))
215
+ // unset($original_meta['wp_smushit']);
216
+
217
+ $meta = $this->resize_from_meta_data( $original_meta, $attachment->ID, false );
218
+ //echo "meta<pre>"; print_r($meta); echo "</pre>";
219
+ //die();
220
+
221
+ printf( "&mdash; [original] %d x %d: ", intval($meta['width']), intval($meta['height']) );
222
+
223
+ if ((isset( $original_meta['wp_smushit'] ))
224
+ && ( $original_meta['wp_smushit'] == $meta['wp_smushit'])
225
+ && (stripos( $meta['wp_smushit'], 'Smush.it error' ) === false ) ) {
226
+ if ((stripos( $meta['wp_smushit'], '<a' ) === false)
227
+ && (stripos( $meta['wp_smushit'], __('No savings', WP_SMUSHIT_DOMAIN )) === false))
228
+ echo $meta['wp_smushit'] .' '. __('<strong>already smushed</strong>', WP_SMUSHIT_DOMAIN);
229
+ else
230
+ echo $meta['wp_smushit'];
231
+ } else {
232
+ echo $meta['wp_smushit'];
233
+ }
234
+ echo '<br />';
235
+
236
+ if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
237
+ foreach( $meta['sizes'] as $size_name => $size ) {
238
+ printf( "&mdash; [%s] %d x %d: ", $size_name, intval($size['width']), intval($size['height']) );
239
+ if ( $original_meta['sizes'][$size_name]['wp_smushit'] == $size['wp_smushit'] && stripos( $meta['sizes'][$size_name]['wp_smushit'], 'Smush.it error' ) === false ) {
240
+ echo $size['wp_smushit'] .' '. __('<strong>already smushed</strong>', WP_SMUSHIT_DOMAIN);
241
+ } else {
242
+ echo $size['wp_smushit'];
243
+ }
244
+ echo '<br />';
245
+ }
246
+ }
247
+ echo "</p>";
248
+
249
+ wp_update_attachment_metadata( $attachment->ID, $meta );
250
+
251
+ // rate limiting is good manners, let's be nice to Yahoo!
252
+ sleep(0.5);
253
+ @ob_flush();
254
+ flush();
255
+ }
256
+ _e('<hr /></p>Smush.it finished processing.</p>', WP_SMUSHIT_DOMAIN);
257
+ endif;
258
+ endif;
259
+ ?>
260
+ </div>
261
+ <?php
262
+ }
263
+
264
+ /**
265
+ * Manually process an image from the Media Library
266
+ */
267
+ function smushit_manual( ) {
268
+ if ( !current_user_can('upload_files') ) {
269
+ wp_die( __( "You don't have permission to work with uploaded files.", WP_SMUSHIT_DOMAIN ) );
270
+ }
271
+
272
+ if ( !isset( $_GET['attachment_ID'] ) ) {
273
+ wp_die( __( 'No attachment ID was provided.', WP_SMUSHIT_DOMAIN ) );
274
+ }
275
+
276
+ $attachment_ID = intval( $_GET['attachment_ID'] );
277
+
278
+ $original_meta = wp_get_attachment_metadata( $attachment_ID );
279
+
280
+ $new_meta = $this->resize_from_meta_data( $original_meta, $attachment_ID );
281
+ wp_update_attachment_metadata( $attachment_ID, $new_meta );
282
+
283
+ wp_redirect( preg_replace( '|[^a-z0-9-~+_.?#=&;,/:]|i', '', wp_get_referer( ) ) );
284
+ exit();
285
+ }
286
+
287
+ /**
288
+ * Process an image with Smush.it.
289
+ *
290
+ * Returns an array of the $file $results.
291
+ *
292
+ * @param string $file Full absolute path to the image file
293
+ * @param string $file_url Optional full URL to the image file
294
+ * @returns array
295
+ */
296
+ function do_smushit( $file_path = '', $file_url = '' ) {
297
+ // don't run on localhost, IPv4 and IPv6 checks
298
+ // if( in_array($_SERVER['SERVER_ADDR'], array('127.0.0.1', '::1')) )
299
+ // return array($file, __('Not processed (local file)', WP_SMUSHIT_DOMAIN));
300
+
301
+ // canonicalize path - disabled 2011-02-1 troubleshooting 'Could not find...' errors.
302
+ // From the PHP docs: "The running script must have executable permissions on
303
+ // all directories in the hierarchy, otherwise realpath() will return false."
304
+ // $file_path = realpath($file);
305
+
306
+ if (empty($file_path)) {
307
+ return __( "File path is empty", WP_SMUSHIT_DOMAIN );
308
+ }
309
+
310
+ if (empty($file_url)) {
311
+ return __( "File URL is empty", WP_SMUSHIT_DOMAIN );
312
+ }
313
+
314
+ static $error_count = 0;
315
+
316
+ if ( $error_count >= WP_SMUSHIT_ERRORS_BEFORE_QUITTING ) {
317
+ return __( "Did not smush due to previous errors", WP_SMUSHIT_DOMAIN );
318
+ }
319
+
320
+ // check that the file exists
321
+ if ( !file_exists( $file_path ) || !is_file( $file_path ) ) {
322
+ return sprintf( __( "Could not find <span class='code'>%s</span>", WP_SMUSHIT_DOMAIN ), $file_path );
323
+ }
324
+
325
+ // check that the file is writable
326
+ if ( !is_writable( dirname( $file_path)) ) {
327
+ return sprintf( __("<span class='code'>%s</span> is not writable", WP_SMUSHIT_DOMAIN ), dirname($file_path) );
328
+ }
329
+
330
+ $file_size = filesize( $file_path );
331
+ if ( $file_size > WP_SMUSHIT_MAX_BYTES ) {
332
+ //return sprintf(__("<a href='http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict'>Too big</a> for Smush.it (%s)", WP_SMUSHIT_DOMAIN), $this->format_bytes($file_size));
333
+ return sprintf(__('<span style="color:#FF0000;">Skipped (%s) Unable to Smush due to Yahoo 1mb size limits. See <a href="http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict">FAQ</a></span>', WP_SMUSHIT_DOMAIN), $this->format_bytes($file_size));
334
+ }
335
+
336
+ // check that the file is within the WP_CONTENT_DIR
337
+ if (stripos(realpath($file_path), realpath(ABSPATH)) !== 0) {
338
+ return sprintf( __( "<span class='code'>%s</span> must be within the website directory (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ),
339
+ htmlentities( $file_path ), ABSPATH);
340
+ }
341
+
342
+ // The Yahoo! Smush.it service does not working with https images.
343
+ $file_url = str_replace('https://', 'http://', $file_url);
344
+
345
+ $home_url = get_option('home');
346
+ $home_url = str_replace('https://', 'http://', $home_url);
347
+
348
+ if (stripos($file_url, $home_url) !== 0) {
349
+ return sprintf( __( "<span class='code'>%s</span> must be within the website home URL (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ),
350
+ htmlentities( $file_url ), $home_url);
351
+ }
352
+
353
+ //echo "calling _post(". $file_url .")<br />";
354
+ $data = $this->_post( $file_url );
355
+ //echo "returned from _post data<pre>"; print_r($data); echo "</pre>";
356
+
357
+ if ( false === $data ) {
358
+ $error_count++;
359
+ return __( 'Error posting to Smush.it', WP_SMUSHIT_DOMAIN );
360
+ }
361
+
362
+ // make sure the response looks like JSON -- added 2008-12-19 when
363
+ // Smush.it was returning PHP warnings before the JSON output
364
+ if ( strpos( trim($data), '{' ) != 0 ) {
365
+ return __('Bad response from Smush.it', WP_SMUSHIT_DOMAIN );
366
+ }
367
+
368
+ // read the JSON response
369
+ if ( function_exists('json_decode') ) {
370
+ $data = json_decode( $data );
371
+ } else {
372
+ require_once( 'JSON/JSON.php' );
373
+ $json = new Services_JSON( );
374
+ $data = $json->decode( $data );
375
+ }
376
+ //echo "returned from _post data<pre>"; print_r($data); echo "</pre>";
377
+
378
+ if ( !isset( $data->dest_size ) )
379
+ return __('Bad response from Smush.it', WP_SMUSHIT_DOMAIN );
380
+
381
+ if ( -1 === intval( $data->dest_size ) )
382
+ return __('No savings', WP_SMUSHIT_DOMAIN );
383
+
384
+ if ( !isset( $data->dest ) ) {
385
+ $err = ( $data->error ? __( 'Smush.it error: ', WP_SMUSHIT_DOMAIN ) . $data->error : __( 'unknown error', WP_SMUSHIT_DOMAIN ) );
386
+ $err .= sprintf( __( " while processing <span class='code'>%s</span> (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ), $file_url, $file_path);
387
+ return $err ;
388
+ }
389
+
390
+ $processed_url = $data->dest;
391
+
392
+ // The smush.it web service does not append the domain;
393
+ // smushit.com web service does
394
+ if ( 0 !== stripos($processed_url, 'http://') ) {
395
+ $processed_url = SMUSHIT_BASE_URL . $processed_url;
396
+ }
397
+
398
+ $temp_file = download_url( $processed_url );
399
+
400
+ if ( is_wp_error( $temp_file ) ) {
401
+ @unlink($temp_file);
402
+ return sprintf( __("Error downloading file (%s)", WP_SMUSHIT_DOMAIN ), $temp_file->get_error_message());
403
+ }
404
+
405
+ if (!file_exists($temp_file)) {
406
+ return sprintf( __("Unable to locate Smuch.it downloaded file (%s)", WP_SMUSHIT_DOMAIN ), $temp_file);
407
+ }
408
+
409
+ @unlink( $file_path );
410
+ $success = @rename( $temp_file, $file_path );
411
+ if (!$success) {
412
+ copy($temp_file, $file_path);
413
+ unlink($temp_file);
414
+ }
415
+
416
+ $savings = intval( $data->src_size ) - intval( $data->dest_size );
417
+ $savings_str = $this->format_bytes( $savings, 1 );
418
+ $savings_str = str_replace( ' ', '&nbsp;', $savings_str );
419
+
420
+ $results_msg = sprintf( __("Reduced by %01.1f%% (%s)", WP_SMUSHIT_DOMAIN ),
421
+ $data->percent,
422
+ $savings_str );
423
+
424
+ return $results_msg;
425
+ }
426
+
427
+ function should_resmush($previous_status) {
428
+ if ( !$previous_status || empty($previous_status ) ) {
429
+ return true;
430
+ }
431
+
432
+ if ( stripos( $previous_status, 'no savings' ) !== false || stripos( $previous_status, 'reduced' ) !== false ) {
433
+ return false;
434
+ }
435
+
436
+ // otherwise an error
437
+ return true;
438
+ }
439
+
440
+
441
+ /**
442
+ * Read the image paths from an attachment's meta data and process each image
443
+ * with wp_smushit().
444
+ *
445
+ * This method also adds a `wp_smushit` meta key for use in the media library.
446
+ *
447
+ * Called after `wp_generate_attachment_metadata` is completed.
448
+ */
449
+ function resize_from_meta_data( $meta, $ID = null, $force_resmush = true ) {
450
+ if ( $ID && wp_attachment_is_image( $ID ) === false ) {
451
+ return $meta;
452
+ }
453
+
454
+ //$file_path = $meta['file'];
455
+ //$store_absolute_path = true;
456
+ //$upload_dir = wp_upload_dir();
457
+ //$upload_path = trailingslashit( $upload_dir['basedir'] );
458
+
459
+ // WordPress >= 2.6.2: determine the absolute $file_path (http://core.trac.wordpress.org/changeset/8796)
460
+ //if ( false === strpos($file_path, $upload_path) ) {
461
+ // $store_absolute_path = false;
462
+ // $file_path = $upload_path . $file_path;
463
+ //}
464
+
465
+ $attachment_file_path = get_attached_file($ID);
466
+ //echo "attachment_file_path=[". $attachment_file_path ."]<br />";
467
+ $attachment_file_url = wp_get_attachment_url($ID);
468
+ //echo "attachment_file_url=[". $attachment_file_url ."]<br />";
469
+
470
+ if ( $force_resmush || $this->should_resmush( @$meta['wp_smushit'] ) ) {
471
+ $meta['wp_smushit'] = $this->do_smushit($attachment_file_path, $attachment_file_url);
472
+ }
473
+
474
+ // strip absolute path for Wordpress >= 2.6.2
475
+ //if ( false === $store_absolute_path ) {
476
+ // $meta['file'] = str_replace($upload_path, '', $meta['file']);
477
+ //}
478
+
479
+ // no resized versions, so we can exit
480
+ if ( !isset( $meta['sizes'] ) )
481
+ return $meta;
482
+
483
+ // meta sizes don't contain a path, so we calculate one
484
+ //$base_dir = trailingslashit( dirname($file_path) );
485
+
486
+ foreach($meta['sizes'] as $size_key => $size_data) {
487
+ if ( !$force_resmush && $this->should_resmush( @$meta['sizes'][$size_key]['wp_smushit'] ) === false ) {
488
+ continue;
489
+ }
490
+
491
+ // We take the original image. The 'sizes' will all match the same URL and
492
+ // path. So just get the dirname and rpelace the filename.
493
+ $attachment_file_path_size = trailingslashit(dirname($attachment_file_path)) . $size_data['file'];
494
+ //echo "attachment_file_path_size=[". $attachment_file_path_size ."]<br />";
495
+
496
+ $attachment_file_url_size = trailingslashit(dirname($attachment_file_url)) . $size_data['file'];
497
+ //echo "attachment_file_url_size=[". $attachment_file_url_size ."]<br />";
498
+
499
+ $meta['sizes'][$size_key]['wp_smushit'] = $this->do_smushit( $attachment_file_path_size, $attachment_file_url_size ) ;
500
+
501
+ //echo "size_key[". $size_key ."] wp_smushit<pre>"; print_r($meta['sizes'][$size_key]['wp_smushit']); echo "</pre>";
502
+ }
503
+
504
+ //echo "meta<pre>"; print_r($meta); echo "</pre>";
505
+ return $meta;
506
+ }
507
+
508
+ /**
509
+ * Post an image to Smush.it.
510
+ *
511
+ * @param string $file_url URL of the file to send to Smush.it
512
+ * @return string|boolean Returns the JSON response on success or else false
513
+ */
514
+ function _post( $file_url ) {
515
+ $req = sprintf( SMUSHIT_REQ_URL, urlencode( $file_url ) );
516
+
517
+ $data = false;
518
+
519
+ if ( function_exists( 'wp_remote_get' ) ) {
520
+ $response = wp_remote_get( $req, array('user-agent' => WP_SMUSHIT_UA, 'timeout' => WP_SMUSHIT_TIMEOUT ) );
521
+ if ( !$response || is_wp_error( $response ) ) {
522
+ $data = false;
523
+ } else {
524
+ $data = wp_remote_retrieve_body( $response );
525
+ }
526
+ } else {
527
+ wp_die( __('WP Smush.it requires WordPress 2.8 or greater', WP_SMUSHIT_DOMAIN) );
528
+ }
529
+
530
+ return $data;
531
+ }
532
+
533
+
534
+ /**
535
+ * Print column header for Smush.it results in the media library using
536
+ * the `manage_media_columns` hook.
537
+ */
538
+ function columns( $defaults ) {
539
+ $defaults['smushit'] = 'Smush.it';
540
+ return $defaults;
541
+ }
542
+
543
+ /**
544
+ * Return the filesize in a humanly readable format.
545
+ * Taken from http://www.php.net/manual/en/function.filesize.php#91477
546
+ */
547
+ function format_bytes( $bytes, $precision = 2 ) {
548
+ $units = array('B', 'KB', 'MB', 'GB', 'TB');
549
+ $bytes = max($bytes, 0);
550
+ $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
551
+ $pow = min($pow, count($units) - 1);
552
+ $bytes /= pow(1024, $pow);
553
+ return round($bytes, $precision) . ' ' . $units[$pow];
554
+ }
555
+
556
+ /**
557
+ * Print column data for Smush.it results in the media library using
558
+ * the `manage_media_custom_column` hook.
559
+ */
560
+ function custom_column( $column_name, $id ) {
561
+ if( 'smushit' == $column_name ) {
562
+ $data = wp_get_attachment_metadata($id);
563
+ if ( isset( $data['wp_smushit'] ) && !empty( $data['wp_smushit'] ) ) {
564
+ print $data['wp_smushit'];
565
+ printf( "<br><a href=\"admin.php?action=wp_smushit_manual&amp;attachment_ID=%d\">%s</a>",
566
+ $id,
567
+ __( 'Re-smush', WP_SMUSHIT_DOMAIN ) );
568
+ } else {
569
+ if ( wp_attachment_is_image( $id ) ) {
570
+ print __( 'Not processed', WP_SMUSHIT_DOMAIN );
571
+ printf( "<br><a href=\"admin.php?action=wp_smushit_manual&amp;attachment_ID=%d\">%s</a>",
572
+ $id,
573
+ __('Smush.it now!', WP_SMUSHIT_DOMAIN));
574
+ }
575
+ }
576
+ }
577
+ }
578
+
579
+
580
+ // Borrowed from http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/
581
+ function add_bulk_actions_via_javascript() { ?>
582
+ <script type="text/javascript">
583
+ jQuery(document).ready(function($){
584
+ $('select[name^="action"] option:last-child').before('<option value="bulk_smushit">Bulk Smush.it</option>');
585
+ });
586
+ </script>
587
+ <?php }
588
+
589
+
590
+ // Handles the bulk actions POST
591
+ // Borrowed from http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/
592
+ function bulk_action_handler() {
593
+ check_admin_referer( 'bulk-media' );
594
+
595
+ if ( empty( $_REQUEST['media'] ) || ! is_array( $_REQUEST['media'] ) )
596
+ return;
597
+
598
+ $ids = implode( ',', array_map( 'intval', $_REQUEST['media'] ) );
599
+
600
+ // Can't use wp_nonce_url() as it escapes HTML entities
601
+ wp_redirect( add_query_arg( '_wpnonce', wp_create_nonce( 'wp-smushit-bulk' ), admin_url( 'upload.php?page=wp-smushit-bulk&goback=1&ids=' . $ids ) ) );
602
+ exit();
603
+ }
604
+
605
+ }
606
+
607
+ $WpSmushit = new WpSmushit();
608
+ global $WpSmushit;
609
+
610
+ }
611
+
612
+ if ( !function_exists( 'wp_basename' ) ) {
613
+ /**
614
+ * Introduced in WP 3.1... this is copied verbatim from wp-includes/formatting.php.
615
+ */
616
+ function wp_basename( $path, $suffix = '' ) {
617
+ return urldecode( basename( str_replace( '%2F', '/', urlencode( $path ) ), $suffix ) );
618
+ }
619
  }