Smush Image Compression and Optimization - Version 1.2.7

Version Description

  • update to workaround WordPress's new JSON compat layer (see trac ticket)
Download this release

Release Info

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

Code changes from version 1.2.6 to 1.2.7

Files changed (2) hide show
  1. readme.txt +6 -3
  2. wp-smushit.php +14 -7
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Smush.it ===
2
  Plugin Name: WP Smush.it
3
- Version: 1.2.6
4
  Author: Dialect
5
  Author URI: http://dialect.ca/?wp_smush_it
6
  Contributors: alexdunae
7
  Tags: images, image, attachments, attachment
8
  Requires at least: 2.5
9
- Tested up to: 2.8.6
10
- Stable tag: 1.2.6
11
 
12
  Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
13
 
@@ -48,6 +48,9 @@ Plugin updates are announced on [http://www.twitter.com/TheCHANGELOG](http://www
48
  1. Done!
49
 
50
  == Changelog ==
 
 
 
51
  = 1.2.6 =
52
  * updated Smush.it endpoint URL
53
  * fixed undefined constant
1
  === WP Smush.it ===
2
  Plugin Name: WP Smush.it
3
+ Version: 1.2.7
4
  Author: Dialect
5
  Author URI: http://dialect.ca/?wp_smush_it
6
  Contributors: alexdunae
7
  Tags: images, image, attachments, attachment
8
  Requires at least: 2.5
9
+ Tested up to: 2.9.1
10
+ Stable tag: 1.2.7
11
 
12
  Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
13
 
48
  1. Done!
49
 
50
  == Changelog ==
51
+ = 1.2.7 =
52
+ * update to workaround WordPress's new JSON compat layer (see [trac ticket](http://core.trac.wordpress.org/ticket/11827))
53
+
54
  = 1.2.6 =
55
  * updated Smush.it endpoint URL
56
  * fixed undefined constant
wp-smushit.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Integrate the Smush.it API into WordPress.
4
- * @version 1.2.6
5
  * @package WP_SmushIt
6
  */
7
  /*
@@ -9,11 +9,11 @@ Plugin Name: WP Smush.it
9
  Plugin URI: http://dialect.ca/code/wp-smushit/
10
  Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
11
  Author: Dialect
12
- Version: 1.2.6
13
  Author URI: http://dialect.ca/?wp_smush_it
14
  */
15
 
16
- if ( !class_exists('Services_JSON') ) {
17
  require_once('JSON/JSON.php');
18
  }
19
 
@@ -31,7 +31,7 @@ define('SMUSHIT_BASE_URL', 'http://smushit.com/');
31
 
32
  define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
33
 
34
- define('WP_SMUSHIT_UA', 'WP Smush.it/1.2.5 (+http://dialect.ca/code/wp-smushit)');
35
 
36
  define('WP_SMUSHIT_GIF_TO_PNG', intval(get_option('wp_smushit_gif_to_png')));
37
 
@@ -39,7 +39,7 @@ define('WP_SMUSHIT_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
39
 
40
  if ( !defined('WP_CONTENT_URL') )
41
  define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
42
-
43
  if ( !defined('WP_CONTENT_DIR') )
44
  define('WP_CONTENT_DIR', ABSPATH . 'wp-content' );
45
 
@@ -153,7 +153,8 @@ function wp_smushit($file) {
153
 
154
  // check that the file is within the WP_CONTENT_DIR
155
  if ( 0 !== stripos($file_path, WP_CONTENT_DIR) || FALSE) {
156
- $msg = sprintf(__("<span class='code'>%s</span> must be within the content directory (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN), $file_path, WP_CONTENT_DIR);
 
157
  return array($file, $msg);
158
  }
159
 
@@ -264,6 +265,7 @@ function wp_smushit_update_attachment($data, $ID) {
264
  * Called after `wp_generate_attachment_metadata` is completed.
265
  */
266
  function wp_smushit_resize_from_meta_data($meta) {
 
267
  $file_path = $meta['file'];
268
  $store_absolute_path = true;
269
  $upload_dir = wp_upload_dir();
@@ -274,8 +276,12 @@ function wp_smushit_resize_from_meta_data($meta) {
274
  $store_absolute_path = false;
275
  $file_path = $upload_path . $file_path;
276
  }
 
277
 
278
- list($meta['file'], $meta['wp_smushit']) = wp_smushit($file_path);
 
 
 
279
 
280
  // strip absolute path for Wordpress >= 2.6.2
281
  if ( FALSE === $store_absolute_path ) {
@@ -289,6 +295,7 @@ function wp_smushit_resize_from_meta_data($meta) {
289
  // meta sizes don't contain a path, so we calculate one
290
  $base_dir = dirname($file_path) . '/';
291
 
 
292
  foreach($meta['sizes'] as $size => $data) {
293
  list($smushed_file, $results) = wp_smushit($base_dir . $data['file']);
294
 
1
  <?php
2
  /**
3
  * Integrate the Smush.it API into WordPress.
4
+ * @version 1.2.7
5
  * @package WP_SmushIt
6
  */
7
  /*
9
  Plugin URI: http://dialect.ca/code/wp-smushit/
10
  Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
11
  Author: Dialect
12
+ Version: 1.2.7
13
  Author URI: http://dialect.ca/?wp_smush_it
14
  */
15
 
16
+ if ( !function_exists('json_encode') ) {
17
  require_once('JSON/JSON.php');
18
  }
19
 
31
 
32
  define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
33
 
34
+ define('WP_SMUSHIT_UA', 'WP Smush.it/1.2.7 (+http://dialect.ca/code/wp-smushit)');
35
 
36
  define('WP_SMUSHIT_GIF_TO_PNG', intval(get_option('wp_smushit_gif_to_png')));
37
 
39
 
40
  if ( !defined('WP_CONTENT_URL') )
41
  define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
42
+ //PATH_SEPARATOR
43
  if ( !defined('WP_CONTENT_DIR') )
44
  define('WP_CONTENT_DIR', ABSPATH . 'wp-content' );
45
 
153
 
154
  // check that the file is within the WP_CONTENT_DIR
155
  if ( 0 !== stripos($file_path, WP_CONTENT_DIR) || FALSE) {
156
+ $msg = sprintf(__("<span class='code'>%s</span> must be within the content directory (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN), htmlentities($file_path), WP_CONTENT_DIR);
157
+
158
  return array($file, $msg);
159
  }
160
 
265
  * Called after `wp_generate_attachment_metadata` is completed.
266
  */
267
  function wp_smushit_resize_from_meta_data($meta) {
268
+
269
  $file_path = $meta['file'];
270
  $store_absolute_path = true;
271
  $upload_dir = wp_upload_dir();
276
  $store_absolute_path = false;
277
  $file_path = $upload_path . $file_path;
278
  }
279
+
280
 
281
+ list($file, $msg) = wp_smushit($file_path);
282
+
283
+ $meta['file'] = $file;
284
+ $meta['wp_smushit'] = $msg;
285
 
286
  // strip absolute path for Wordpress >= 2.6.2
287
  if ( FALSE === $store_absolute_path ) {
295
  // meta sizes don't contain a path, so we calculate one
296
  $base_dir = dirname($file_path) . '/';
297
 
298
+
299
  foreach($meta['sizes'] as $size => $data) {
300
  list($smushed_file, $results) = wp_smushit($base_dir . $data['file']);
301