Version Description
- Improved the bulk optimizer
Download this release
Release Info
| Developer | keycdn |
| Plugin | |
| Version | 1.4.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.6 to 1.4.7
- inc/optimus_management.class.php +25 -4
- inc/optimus_request.class.php +12 -52
- inc/optimus_settings.class.php +5 -5
- js/scripts.js +5 -0
- optimus.php +2 -2
- readme.txt +8 -5
inc/optimus_management.class.php
CHANGED
|
@@ -66,21 +66,42 @@ class Optimus_Management
|
|
| 66 |
* Bulk optimizer page
|
| 67 |
*
|
| 68 |
* @since 1.3.8
|
| 69 |
-
* @change 1.
|
| 70 |
*
|
| 71 |
*/
|
| 72 |
|
| 73 |
public static function bulk_optimizer_page() {
|
| 74 |
global $wpdb;
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
if (!empty($_GET['ids'])) {
|
| 77 |
$ids = implode(',', array_map('intval', explode('-', $_GET['ids'])));
|
| 78 |
-
$
|
| 79 |
} else {
|
| 80 |
-
$
|
| 81 |
}
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
$assets = $wpdb->get_results($query, ARRAY_A);
|
| 85 |
$count = count($assets);
|
| 86 |
|
| 66 |
* Bulk optimizer page
|
| 67 |
*
|
| 68 |
* @since 1.3.8
|
| 69 |
+
* @change 1.4.7
|
| 70 |
*
|
| 71 |
*/
|
| 72 |
|
| 73 |
public static function bulk_optimizer_page() {
|
| 74 |
global $wpdb;
|
| 75 |
|
| 76 |
+
/* Get plugin options */
|
| 77 |
+
$options = Optimus::get_options();
|
| 78 |
+
|
| 79 |
+
/* Check if images are already optimized */
|
| 80 |
+
if ( $options['webp_convert'] ) {
|
| 81 |
+
$optimus_query = '%optimus%webp";i:1%';
|
| 82 |
+
} else {
|
| 83 |
+
$optimus_query = '%optimus%';
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/* Check if specific IDs are selected */
|
| 87 |
if (!empty($_GET['ids'])) {
|
| 88 |
$ids = implode(',', array_map('intval', explode('-', $_GET['ids'])));
|
| 89 |
+
$id_query = "AND ID IN($ids)";
|
| 90 |
} else {
|
| 91 |
+
$id_query = "";
|
| 92 |
}
|
| 93 |
|
| 94 |
+
/* Image query */
|
| 95 |
+
$query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_mime_type
|
| 96 |
+
FROM $wpdb->posts, $wpdb->postmeta
|
| 97 |
+
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
|
| 98 |
+
AND $wpdb->posts.post_type = 'attachment'
|
| 99 |
+
AND $wpdb->posts.post_mime_type LIKE 'image/%'
|
| 100 |
+
AND $wpdb->postmeta.meta_key = '_wp_attachment_metadata'
|
| 101 |
+
AND $wpdb->postmeta.meta_value NOT LIKE '$optimus_query'
|
| 102 |
+
$id_query
|
| 103 |
+
ORDER BY $wpdb->posts.ID DESC";
|
| 104 |
+
|
| 105 |
$assets = $wpdb->get_results($query, ARRAY_A);
|
| 106 |
$count = count($assets);
|
| 107 |
|
inc/optimus_request.class.php
CHANGED
|
@@ -86,7 +86,7 @@ class Optimus_Request
|
|
| 86 |
* Image optimization for wp retina 2x
|
| 87 |
*
|
| 88 |
* @since 1.4.6
|
| 89 |
-
* @change 1.4.
|
| 90 |
*
|
| 91 |
* @param integer $attachment_id Attachment ID
|
| 92 |
* @param string $upload_path_file_retina Retina file path
|
|
@@ -107,15 +107,6 @@ class Optimus_Request
|
|
| 107 |
// get optimus plugin options
|
| 108 |
$options = Optimus::get_options();
|
| 109 |
|
| 110 |
-
// set cURL options
|
| 111 |
-
add_action(
|
| 112 |
-
'http_api_curl',
|
| 113 |
-
array(
|
| 114 |
-
__CLASS__,
|
| 115 |
-
'set_curl_options'
|
| 116 |
-
)
|
| 117 |
-
);
|
| 118 |
-
|
| 119 |
// set https scheme
|
| 120 |
if ( $options['secure_transport'] && Optimus_HQ::is_unlocked() ) {
|
| 121 |
self::$_remote_scheme = 'https';
|
|
@@ -148,7 +139,7 @@ class Optimus_Request
|
|
| 148 |
* Build optimization for a upload image including previews
|
| 149 |
*
|
| 150 |
* @since 0.0.1
|
| 151 |
-
* @change 1.4.
|
| 152 |
*
|
| 153 |
* @param array $upload_data Incoming upload information
|
| 154 |
* @param integer $attachment_id Attachment ID
|
|
@@ -224,15 +215,6 @@ class Optimus_Request
|
|
| 224 |
);
|
| 225 |
}
|
| 226 |
|
| 227 |
-
/* Set cURL options */
|
| 228 |
-
add_action(
|
| 229 |
-
'http_api_curl',
|
| 230 |
-
array(
|
| 231 |
-
__CLASS__,
|
| 232 |
-
'set_curl_options'
|
| 233 |
-
)
|
| 234 |
-
);
|
| 235 |
-
|
| 236 |
/* Set https scheme */
|
| 237 |
if ( $options['secure_transport'] && Optimus_HQ::is_unlocked() ) {
|
| 238 |
self::$_remote_scheme = 'https';
|
|
@@ -291,13 +273,15 @@ class Optimus_Request
|
|
| 291 |
)
|
| 292 |
);
|
| 293 |
|
| 294 |
-
/*
|
| 295 |
if ( function_exists( 'wr2x_get_retina' ) ) {
|
| 296 |
$upload_path_file_retina = wr2x_get_retina( $upload_path_file );
|
|
|
|
|
|
|
| 297 |
}
|
| 298 |
|
| 299 |
/* Request: Optimize retina image [WP Retina 2x] */
|
| 300 |
-
if ( $upload_path_file_retina ) {
|
| 301 |
self::_do_image_action(
|
| 302 |
$upload_path_file_retina,
|
| 303 |
array(
|
|
@@ -326,8 +310,8 @@ class Optimus_Request
|
|
| 326 |
)
|
| 327 |
);
|
| 328 |
|
| 329 |
-
/*
|
| 330 |
-
if ( $upload_path_file_retina ) {
|
| 331 |
self::_do_image_action(
|
| 332 |
$upload_path_file_retina,
|
| 333 |
array(
|
|
@@ -463,34 +447,10 @@ class Optimus_Request
|
|
| 463 |
),
|
| 464 |
array(
|
| 465 |
'body' => file_get_contents($file),
|
| 466 |
-
'timeout' => 180
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
/**
|
| 473 |
-
* Set cURL request options
|
| 474 |
-
*
|
| 475 |
-
* @since 1.1.9
|
| 476 |
-
* @change 1.3.0
|
| 477 |
-
*
|
| 478 |
-
* @param object $handle cURL handle with default options
|
| 479 |
-
* @return object $handle cURL handle with added options
|
| 480 |
-
*/
|
| 481 |
-
|
| 482 |
-
public static function set_curl_options(&$handle)
|
| 483 |
-
{
|
| 484 |
-
curl_setopt(
|
| 485 |
-
$handle,
|
| 486 |
-
CURLOPT_BINARYTRANSFER,
|
| 487 |
-
true
|
| 488 |
-
);
|
| 489 |
-
curl_setopt(
|
| 490 |
-
$handle,
|
| 491 |
-
CURLOPT_HTTPHEADER,
|
| 492 |
-
array(
|
| 493 |
-
'Accept: image/*'
|
| 494 |
)
|
| 495 |
);
|
| 496 |
}
|
| 86 |
* Image optimization for wp retina 2x
|
| 87 |
*
|
| 88 |
* @since 1.4.6
|
| 89 |
+
* @change 1.4.7
|
| 90 |
*
|
| 91 |
* @param integer $attachment_id Attachment ID
|
| 92 |
* @param string $upload_path_file_retina Retina file path
|
| 107 |
// get optimus plugin options
|
| 108 |
$options = Optimus::get_options();
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
// set https scheme
|
| 111 |
if ( $options['secure_transport'] && Optimus_HQ::is_unlocked() ) {
|
| 112 |
self::$_remote_scheme = 'https';
|
| 139 |
* Build optimization for a upload image including previews
|
| 140 |
*
|
| 141 |
* @since 0.0.1
|
| 142 |
+
* @change 1.4.7
|
| 143 |
*
|
| 144 |
* @param array $upload_data Incoming upload information
|
| 145 |
* @param integer $attachment_id Attachment ID
|
| 215 |
);
|
| 216 |
}
|
| 217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
/* Set https scheme */
|
| 219 |
if ( $options['secure_transport'] && Optimus_HQ::is_unlocked() ) {
|
| 220 |
self::$_remote_scheme = 'https';
|
| 273 |
)
|
| 274 |
);
|
| 275 |
|
| 276 |
+
/* Get retina image [WP Retina 2x] */
|
| 277 |
if ( function_exists( 'wr2x_get_retina' ) ) {
|
| 278 |
$upload_path_file_retina = wr2x_get_retina( $upload_path_file );
|
| 279 |
+
} else {
|
| 280 |
+
$upload_path_file_retina = false;
|
| 281 |
}
|
| 282 |
|
| 283 |
/* Request: Optimize retina image [WP Retina 2x] */
|
| 284 |
+
if ( ! empty($upload_path_file_retina) ) {
|
| 285 |
self::_do_image_action(
|
| 286 |
$upload_path_file_retina,
|
| 287 |
array(
|
| 310 |
)
|
| 311 |
);
|
| 312 |
|
| 313 |
+
/* Convert retina image to webp [WP Retina 2x] */
|
| 314 |
+
if ( ! empty($upload_path_file_retina) ) {
|
| 315 |
self::_do_image_action(
|
| 316 |
$upload_path_file_retina,
|
| 317 |
array(
|
| 447 |
),
|
| 448 |
array(
|
| 449 |
'body' => file_get_contents($file),
|
| 450 |
+
'timeout' => 180,
|
| 451 |
+
'headers' => array(
|
| 452 |
+
'Accept' => 'image/*'
|
| 453 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
)
|
| 455 |
);
|
| 456 |
}
|
inc/optimus_settings.class.php
CHANGED
|
@@ -114,7 +114,7 @@ class Optimus_Settings
|
|
| 114 |
</p>
|
| 115 |
|
| 116 |
<p class="description">
|
| 117 |
-
<?php _e("In addition to the original image, Optimus compresses the registered image sizes in WordPress. [<a href=\"https://optimus.
|
| 118 |
</p>
|
| 119 |
<br>
|
| 120 |
<p class="description">
|
|
@@ -136,7 +136,7 @@ class Optimus_Settings
|
|
| 136 |
</label>
|
| 137 |
|
| 138 |
<p class="description">
|
| 139 |
-
<?php _e("Optimus only compresses preview images (Thumbnails). Original images uploaded to WordPress are not affected. [<a href=\"https://optimus.
|
| 140 |
</p>
|
| 141 |
</fieldset>
|
| 142 |
</td>
|
|
@@ -154,7 +154,7 @@ class Optimus_Settings
|
|
| 154 |
</label>
|
| 155 |
|
| 156 |
<p class="description">
|
| 157 |
-
<?php _e("Only <a href=\"https://optimus.io\" target=\"_blank\">Optimus HQ</a>. Active option keeps EXIF-, copyright and photo creation information in images. Size reduction is less significant. [<a href=\"https://optimus.
|
| 158 |
</p>
|
| 159 |
</fieldset>
|
| 160 |
</td>
|
|
@@ -172,7 +172,7 @@ class Optimus_Settings
|
|
| 172 |
</label>
|
| 173 |
|
| 174 |
<p class="description">
|
| 175 |
-
<?php _e("Only <a href=\"https://optimus.io\" target=\"_blank\">Optimus HQ</a>. It is recommended to use the <a href=\"https://wordpress.org/plugins/cache-enabler/\">Cache Enabler plugin</a> to integrate the WebP images. [<a href=\"https://optimus.
|
| 176 |
</p>
|
| 177 |
</fieldset>
|
| 178 |
</td>
|
|
@@ -208,7 +208,7 @@ class Optimus_Settings
|
|
| 208 |
</label>
|
| 209 |
|
| 210 |
<p class="description">
|
| 211 |
-
<?php _e("This setting prevents the automatic optimization during the upload process. Images need to be optimized via the Media Library later on. [<a href=\"https://optimus.
|
| 212 |
</p>
|
| 213 |
</fieldset>
|
| 214 |
</td>
|
| 114 |
</p>
|
| 115 |
|
| 116 |
<p class="description">
|
| 117 |
+
<?php _e("In addition to the original image, Optimus compresses the registered image sizes in WordPress. [<a href=\"https://optimus.keycdn.com/support/optimus-settings/#compression-thumbnail-images\" target=\"_blank\">Details</a>]", "optimus"); ?>
|
| 118 |
</p>
|
| 119 |
<br>
|
| 120 |
<p class="description">
|
| 136 |
</label>
|
| 137 |
|
| 138 |
<p class="description">
|
| 139 |
+
<?php _e("Optimus only compresses preview images (Thumbnails). Original images uploaded to WordPress are not affected. [<a href=\"https://optimus.keycdn.com/support/optimus-settings/#optimization-original-images\" target=\"_blank\">Details</a>]", "optimus"); ?>
|
| 140 |
</p>
|
| 141 |
</fieldset>
|
| 142 |
</td>
|
| 154 |
</label>
|
| 155 |
|
| 156 |
<p class="description">
|
| 157 |
+
<?php _e("Only <a href=\"https://optimus.io\" target=\"_blank\">Optimus HQ</a>. Active option keeps EXIF-, copyright and photo creation information in images. Size reduction is less significant. [<a href=\"https://optimus.keycdn.com/support/optimus-settings/#remove-metadata\" target=\"_blank\">Details</a>]", "optimus"); ?>
|
| 158 |
</p>
|
| 159 |
</fieldset>
|
| 160 |
</td>
|
| 172 |
</label>
|
| 173 |
|
| 174 |
<p class="description">
|
| 175 |
+
<?php _e("Only <a href=\"https://optimus.io\" target=\"_blank\">Optimus HQ</a>. It is recommended to use the <a href=\"https://wordpress.org/plugins/cache-enabler/\">Cache Enabler plugin</a> to integrate the WebP images. [<a href=\"https://optimus.keycdn.com/support/optimus-settings/#convert-to-webp\" target=\"_blank\">Details</a>]", "optimus"); ?>
|
| 176 |
</p>
|
| 177 |
</fieldset>
|
| 178 |
</td>
|
| 208 |
</label>
|
| 209 |
|
| 210 |
<p class="description">
|
| 211 |
+
<?php _e("This setting prevents the automatic optimization during the upload process. Images need to be optimized via the Media Library later on. [<a href=\"https://optimus.keycdn.com/support/image-bulk-optimization/\" target=\"_blank\">Details</a>]", "optimus"); ?>
|
| 212 |
</p>
|
| 213 |
</fieldset>
|
| 214 |
</td>
|
js/scripts.js
CHANGED
|
@@ -91,4 +91,9 @@ jQuery(document).ready(function() {
|
|
| 91 |
jQuery('<option>').val('optimus_bulk_optimizer').text(optimusOptimize.bulkAction).appendTo('select[name="action"]')
|
| 92 |
jQuery('<option>').val('optimus_bulk_optimizer').text(optimusOptimize.bulkAction).appendTo('select[name="action2"]')
|
| 93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
});
|
| 91 |
jQuery('<option>').val('optimus_bulk_optimizer').text(optimusOptimize.bulkAction).appendTo('select[name="action"]')
|
| 92 |
jQuery('<option>').val('optimus_bulk_optimizer').text(optimusOptimize.bulkAction).appendTo('select[name="action2"]')
|
| 93 |
}
|
| 94 |
+
|
| 95 |
+
var i = location.search.split('=');
|
| 96 |
+
if (i[0] == '?_optimus_action' && i[1] == 'rekey') {
|
| 97 |
+
jQuery("input[value='optimus/optimus.php']").prop('checked', true)
|
| 98 |
+
}
|
| 99 |
});
|
optimus.php
CHANGED
|
@@ -7,11 +7,11 @@ Author: KeyCDN
|
|
| 7 |
Author URI: https://www.keycdn.com
|
| 8 |
Plugin URI: https://optimus.io
|
| 9 |
License: GPLv2 or later
|
| 10 |
-
Version: 1.4.
|
| 11 |
*/
|
| 12 |
|
| 13 |
/*
|
| 14 |
-
Copyright (C) 2012-
|
| 15 |
|
| 16 |
This program is free software; you can redistribute it and/or modify
|
| 17 |
it under the terms of the GNU General Public License as published by
|
| 7 |
Author URI: https://www.keycdn.com
|
| 8 |
Plugin URI: https://optimus.io
|
| 9 |
License: GPLv2 or later
|
| 10 |
+
Version: 1.4.7
|
| 11 |
*/
|
| 12 |
|
| 13 |
/*
|
| 14 |
+
Copyright (C) 2012-2016 KeyCDN
|
| 15 |
|
| 16 |
This program is free software; you can redistribute it and/or modify
|
| 17 |
it under the terms of the GNU General Public License as published by
|
readme.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
Contributors: keycdn
|
| 3 |
Tags: images, optimize, compress, progressive, performance, png, jpeg, webp, image optimizer, wordpress image optimizer, optimize image, optimize jpg, optimize jpeg, optimize png, compress image, progressive jpeg, progressive jpg
|
| 4 |
Requires at least: 3.8
|
| 5 |
-
Tested up to: 4.
|
| 6 |
Stable tag: trunk
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
@@ -39,20 +39,20 @@ Optimus supports the conversion of images to the new [*WebP* image format](https
|
|
| 39 |
> It is recommended to use the [WordPress Cache Enabler](https://wordpress.org/plugins/cache-enabler/) plugin to integrate the converted WebP images.
|
| 40 |
|
| 41 |
= Features =
|
| 42 |
-
* [Progressive JPEGs](https://optimus.
|
| 43 |
* Reduction of file size *without loss in quality*
|
| 44 |
* Optimization of all preview images of a photo
|
| 45 |
* No adjustments to code necessary
|
| 46 |
* Optional: no removal of EXIF and IPTC metadata
|
| 47 |
* Optional: HTTPS connection for the image transfer (Optimus HQ)
|
| 48 |
-
* Optional: [conversion to the WebP](https://optimus.
|
| 49 |
-
* Optional: Disable automatic
|
| 50 |
* Optimized for WordPress Mobile Apps and Windows Live Writer
|
| 51 |
* More advantageous PageSpeed, influencing the Ranking Factor
|
| 52 |
* Faster load times for blog pages
|
| 53 |
* Support for WooCommerce
|
| 54 |
* WordPress multisite-support
|
| 55 |
-
* [Bulk optimization](https://optimus.
|
| 56 |
* Optimize images generated by [WP Retina 2x](https://wordpress.org/plugins/wp-retina-2x/) (incl. conversion to WebP)
|
| 57 |
|
| 58 |
|
|
@@ -88,6 +88,9 @@ Optimus supports the conversion of images to the new [*WebP* image format](https
|
|
| 88 |
|
| 89 |
== Changelog ==
|
| 90 |
|
|
|
|
|
|
|
|
|
|
| 91 |
= 1.4.6 =
|
| 92 |
* Added support for WP Retina 2x
|
| 93 |
|
| 2 |
Contributors: keycdn
|
| 3 |
Tags: images, optimize, compress, progressive, performance, png, jpeg, webp, image optimizer, wordpress image optimizer, optimize image, optimize jpg, optimize jpeg, optimize png, compress image, progressive jpeg, progressive jpg
|
| 4 |
Requires at least: 3.8
|
| 5 |
+
Tested up to: 4.6
|
| 6 |
Stable tag: trunk
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 39 |
> It is recommended to use the [WordPress Cache Enabler](https://wordpress.org/plugins/cache-enabler/) plugin to integrate the converted WebP images.
|
| 40 |
|
| 41 |
= Features =
|
| 42 |
+
* [Progressive JPEGs](https://optimus.keycdn.com/support/progressive-jpeg/)
|
| 43 |
* Reduction of file size *without loss in quality*
|
| 44 |
* Optimization of all preview images of a photo
|
| 45 |
* No adjustments to code necessary
|
| 46 |
* Optional: no removal of EXIF and IPTC metadata
|
| 47 |
* Optional: HTTPS connection for the image transfer (Optimus HQ)
|
| 48 |
+
* Optional: [conversion to the WebP](https://optimus.keycdn.com/support/convert-jpeg-and-png-to-webp-image-format/) image format (Optimus HQ)
|
| 49 |
+
* Optional: Disable automatic optimization during upload process
|
| 50 |
* Optimized for WordPress Mobile Apps and Windows Live Writer
|
| 51 |
* More advantageous PageSpeed, influencing the Ranking Factor
|
| 52 |
* Faster load times for blog pages
|
| 53 |
* Support for WooCommerce
|
| 54 |
* WordPress multisite-support
|
| 55 |
+
* [Bulk optimization](https://optimus.keycdn.com/support/image-bulk-optimization/) (optimize existing images)
|
| 56 |
* Optimize images generated by [WP Retina 2x](https://wordpress.org/plugins/wp-retina-2x/) (incl. conversion to WebP)
|
| 57 |
|
| 58 |
|
| 88 |
|
| 89 |
== Changelog ==
|
| 90 |
|
| 91 |
+
= 1.4.7 =
|
| 92 |
+
* Improved the bulk optimizer
|
| 93 |
+
|
| 94 |
= 1.4.6 =
|
| 95 |
* Added support for WP Retina 2x
|
| 96 |
|
