Version Description
Download this release
Release Info
Developer | alexdunae |
Plugin | Smush Image Compression and Optimization |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- options.php +3 -3
- readme.txt +2 -2
- wp-smushit.php +19 -9
options.php
CHANGED
@@ -9,11 +9,11 @@
|
|
9 |
<?php wp_nonce_field('update-options'); ?>
|
10 |
<table class="form-table">
|
11 |
<tr valign="top">
|
12 |
-
<th scope="row"
|
13 |
<td>
|
14 |
<select name="wp_smushit_gif_to_png" id="wp_smushit_gif_to_png">
|
15 |
-
<option value="1"<?php echo $wp_smushit_gif_to_png == 1 ? ' selected="selected"' : '';
|
16 |
-
<option value="0"<?php echo $wp_smushit_gif_to_png == 0 ? ' selected="selected"' : '';
|
17 |
</select>
|
18 |
</td>
|
19 |
</tr>
|
9 |
<?php wp_nonce_field('update-options'); ?>
|
10 |
<table class="form-table">
|
11 |
<tr valign="top">
|
12 |
+
<th scope="row"><?php _e('When Smush.it suggests converting a GIF to a PNG file…', WP_SMUSHIT_DOMAIN); ?></th>
|
13 |
<td>
|
14 |
<select name="wp_smushit_gif_to_png" id="wp_smushit_gif_to_png">
|
15 |
+
<option value="1"<?php echo $wp_smushit_gif_to_png == 1 ? ' selected="selected"' : ''; ?>><?php _e('Overwrite the GIF with a PNG', WP_SMUSHIT_DOMAIN); ?></option>
|
16 |
+
<option value="0"<?php echo $wp_smushit_gif_to_png == 0 ? ' selected="selected"' : ''; ?>><?php _e('Leave the GIF alone', WP_SMUSHIT_DOMAIN); ?></option>
|
17 |
</select>
|
18 |
</td>
|
19 |
</tr>
|
readme.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
=== WP Smush.it ===
|
2 |
Plugin Name: WP Smush.it
|
3 |
-
Version: 1.0.
|
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.7
|
10 |
-
Stable tag: 1.0.
|
11 |
|
12 |
Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
13 |
|
1 |
=== WP Smush.it ===
|
2 |
Plugin Name: WP Smush.it
|
3 |
+
Version: 1.0.1
|
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.7
|
10 |
+
Stable tag: 1.0.1
|
11 |
|
12 |
Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
|
13 |
|
wp-smushit.php
CHANGED
@@ -24,6 +24,8 @@ define('SMUSHIT_REQ_URL', 'http://smush.it/ws.php?img=%s');
|
|
24 |
|
25 |
define('SMUSHIT_BASE_URL', 'http://smush.it/');
|
26 |
|
|
|
|
|
27 |
define('WP_SMUSHIT_GIF_TO_PNG', intval(get_option('wp_smushit_gif_to_png')));
|
28 |
|
29 |
if ( !defined('WP_CONTENT_URL') )
|
@@ -43,7 +45,7 @@ add_filter('wp_generate_attachment_metadata', 'wp_smushit_resize_from_meta_data'
|
|
43 |
add_filter('manage_media_columns', 'wp_smushit_columns');
|
44 |
add_action('manage_media_custom_column', 'wp_smushit_custom_column', 10, 2);
|
45 |
add_action('admin_menu', 'wp_smushit_add_pages');
|
46 |
-
|
47 |
|
48 |
/**
|
49 |
* Process an image with Smush.it.
|
@@ -56,7 +58,7 @@ add_action('admin_menu', 'wp_smushit_add_pages');
|
|
56 |
function wp_smushit($file) {
|
57 |
// dont't run on localhost
|
58 |
if( $_SERVER['SERVER_ADDR'] == '127.0.0.1' )
|
59 |
-
return array($file, 'Not processed (local file)');
|
60 |
|
61 |
$url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $file );
|
62 |
$req = sprintf( SMUSHIT_REQ_URL, urlencode( $url ) );
|
@@ -64,7 +66,7 @@ function wp_smushit($file) {
|
|
64 |
$fh = @fopen( $req, 'r' ); // post to Smush.it
|
65 |
|
66 |
if ( !$fh )
|
67 |
-
return array($file, 'Error posting to Smush.it');
|
68 |
|
69 |
$data = stream_get_contents( $fh );
|
70 |
fclose( $fh );
|
@@ -78,10 +80,10 @@ function wp_smushit($file) {
|
|
78 |
}
|
79 |
|
80 |
if ( intval($data->dest_size) == -1 )
|
81 |
-
return array($file, 'No savings');
|
82 |
|
83 |
if ( !$data->dest )
|
84 |
-
return array($file, 'Error: ' . $data->error);
|
85 |
|
86 |
// download the processed image to a temp file
|
87 |
$processed_url = SMUSHIT_BASE_URL . $data->dest;
|
@@ -103,7 +105,11 @@ function wp_smushit($file) {
|
|
103 |
|
104 |
@rename( $temp_file, $file );
|
105 |
|
106 |
-
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
|
109 |
|
@@ -166,7 +172,7 @@ function wp_smushit_resize_from_meta_data($meta) {
|
|
166 |
* the `manage_media_columns` hook.
|
167 |
*/
|
168 |
function wp_smushit_columns($defaults) {
|
169 |
-
$defaults['smushit'] =
|
170 |
return $defaults;
|
171 |
}
|
172 |
|
@@ -177,7 +183,7 @@ function wp_smushit_columns($defaults) {
|
|
177 |
function wp_smushit_custom_column($column_name, $id) {
|
178 |
if( $column_name == 'smushit' ) {
|
179 |
$data = wp_get_attachment_metadata($id);
|
180 |
-
print isset($data['wp_smushit']) ? $data['wp_smushit'] : 'Not processed';
|
181 |
}
|
182 |
}
|
183 |
|
@@ -196,8 +202,12 @@ function wp_smushit_install() {
|
|
196 |
add_option('wp_smushit_gif_to_png', 0);
|
197 |
}
|
198 |
|
|
|
|
|
|
|
|
|
199 |
function wp_smushit_add_pages() {
|
200 |
-
add_options_page('WP Smush.it Options', 'WP Smush.it', 8, dirname(__FILE__) . '/options.php');
|
201 |
}
|
202 |
|
203 |
function wp_smushit_options() {
|
24 |
|
25 |
define('SMUSHIT_BASE_URL', 'http://smush.it/');
|
26 |
|
27 |
+
define('WP_SMUSHIT_DOMAIN', 'wp_smushit');
|
28 |
+
|
29 |
define('WP_SMUSHIT_GIF_TO_PNG', intval(get_option('wp_smushit_gif_to_png')));
|
30 |
|
31 |
if ( !defined('WP_CONTENT_URL') )
|
45 |
add_filter('manage_media_columns', 'wp_smushit_columns');
|
46 |
add_action('manage_media_custom_column', 'wp_smushit_custom_column', 10, 2);
|
47 |
add_action('admin_menu', 'wp_smushit_add_pages');
|
48 |
+
add_action('admin_init', 'wp_smushit_init');
|
49 |
|
50 |
/**
|
51 |
* Process an image with Smush.it.
|
58 |
function wp_smushit($file) {
|
59 |
// dont't run on localhost
|
60 |
if( $_SERVER['SERVER_ADDR'] == '127.0.0.1' )
|
61 |
+
return array($file, __('Not processed (local file)', WP_SMUSHIT_DOMAIN));
|
62 |
|
63 |
$url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $file );
|
64 |
$req = sprintf( SMUSHIT_REQ_URL, urlencode( $url ) );
|
66 |
$fh = @fopen( $req, 'r' ); // post to Smush.it
|
67 |
|
68 |
if ( !$fh )
|
69 |
+
return array($file, __('Error posting to Smush.it', WP_SMUSHIT_DOMAIN));
|
70 |
|
71 |
$data = stream_get_contents( $fh );
|
72 |
fclose( $fh );
|
80 |
}
|
81 |
|
82 |
if ( intval($data->dest_size) == -1 )
|
83 |
+
return array($file, __('No savings', WP_SMUSHIT_DOMAIN));
|
84 |
|
85 |
if ( !$data->dest )
|
86 |
+
return array($file, __('Error: ', WP_SMUSHIT_DOMAIN) . $data->error);
|
87 |
|
88 |
// download the processed image to a temp file
|
89 |
$processed_url = SMUSHIT_BASE_URL . $data->dest;
|
105 |
|
106 |
@rename( $temp_file, $file );
|
107 |
|
108 |
+
$results_msg = sprintf(__("Reduced by %01.1f%%", WP_SMUSHIT_DOMAIN), $data->percent);
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
+
return array($file, $results_msg);
|
113 |
}
|
114 |
|
115 |
|
172 |
* the `manage_media_columns` hook.
|
173 |
*/
|
174 |
function wp_smushit_columns($defaults) {
|
175 |
+
$defaults['smushit'] = 'Smush.it';
|
176 |
return $defaults;
|
177 |
}
|
178 |
|
183 |
function wp_smushit_custom_column($column_name, $id) {
|
184 |
if( $column_name == 'smushit' ) {
|
185 |
$data = wp_get_attachment_metadata($id);
|
186 |
+
print isset($data['wp_smushit']) ? $data['wp_smushit'] : __('Not processed', WP_SMUSHIT_DOMAIN);
|
187 |
}
|
188 |
}
|
189 |
|
202 |
add_option('wp_smushit_gif_to_png', 0);
|
203 |
}
|
204 |
|
205 |
+
function wp_smushit_init() {
|
206 |
+
load_plugin_textdomain(WP_SMUSHIT_DOMAIN);
|
207 |
+
}
|
208 |
+
|
209 |
function wp_smushit_add_pages() {
|
210 |
+
add_options_page(__('WP Smush.it Options', WP_SMUSHIT_OPTIONS), 'WP Smush.it', 8, dirname(__FILE__) . '/options.php');
|
211 |
}
|
212 |
|
213 |
function wp_smushit_options() {
|