Version Description
- meta box in Media Library image editing form with informations about optimization status and results
- delete WebP images when image is deleted from Media Library
- change language domain to match the plugin slug in order to be automatically translatable on translate.wordpress.org.
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 4.2.1 |
Comparing to | |
See all releases |
Code changes from version 4.2.0 to 4.2.1
- class/db/shortpixel-custom-meta-dao.php +19 -12
- class/db/shortpixel-meta-facade.php +2 -3
- class/db/wp-shortpixel-db.php +5 -0
- class/model/shortpixel-folder.php +2 -2
- class/view/shortpixel-list-table.php +26 -26
- class/view/shortpixel_view.php +235 -225
- class/wp-shortpixel-settings.php +0 -25
- lang/{shortpixel-de_DE.mo → shortpixel-image-optimiser-de_DE.mo} +0 -0
- lang/{shortpixel-de_DE.po → shortpixel-image-optimiser-de_DE.po} +0 -0
- lang/{shortpixel-en_US.mo → shortpixel-image-optimiser-en_US.mo} +0 -0
- lang/{shortpixel-en_US.po → shortpixel-image-optimiser-en_US.po} +0 -0
- lang/{shortpixel-fr_FR.mo → shortpixel-image-optimiser-fr_FR.mo} +0 -0
- lang/{shortpixel-fr_FR.po → shortpixel-image-optimiser-fr_FR.po} +0 -0
- lang/{shortpixel-ro_RO.mo → shortpixel-image-optimiser-ro_RO.mo} +0 -0
- lang/{shortpixel-ro_RO.po → shortpixel-image-optimiser-ro_RO.po} +0 -0
- lang/{shortpixel.pot → shortpixel-image-optimiser.pot} +0 -0
- readme.txt +22 -4
- res/js/short-pixel.js +6 -1
- shortpixel_api.php +17 -17
- wp-shortpixel.php +148 -91
class/db/shortpixel-custom-meta-dao.php
CHANGED
@@ -94,14 +94,20 @@ class ShortPixelCustomMetaDao {
|
|
94 |
}
|
95 |
|
96 |
public function tablesExist() {
|
97 |
-
$hasTablesSql = "SELECT COUNT(1) tableCount FROM information_schema.tables WHERE table_schema='
|
98 |
-
. "AND table_name='
|
99 |
-
$hasTables = $this->db->query(
|
100 |
if($hasTables[0]->tableCount == 2){
|
101 |
return true;
|
102 |
}
|
103 |
return false;
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
public function createUpdateShortPixelTables() {
|
@@ -166,7 +172,7 @@ class ShortPixelCustomMetaDao {
|
|
166 |
|
167 |
public function removeFolder($folderPath) {
|
168 |
$sql = "SELECT id FROM {$this->db->getPrefix()}shortpixel_folders WHERE path = %s";
|
169 |
-
$row = $this->db->query($sql, array($folderPath));
|
170 |
if(!isset($row[0]->id)) return false;
|
171 |
$id = $row[0]->id;
|
172 |
$sql = "UPDATE {$this->db->getPrefix()}shortpixel_folders SET status = -1 WHERE id = %d";
|
@@ -183,12 +189,13 @@ class ShortPixelCustomMetaDao {
|
|
183 |
public function newFolderFromPath($path, $uploadPath, $rootPath) {
|
184 |
WpShortPixelDb::checkCustomTables(); // check if custom tables are created, if not, create them
|
185 |
$addedFolder = ShortPixelFolder::checkFolder($path, $uploadPath);
|
|
|
186 |
if($this->getFolder($addedFolder)) {
|
187 |
-
return __('Folder already added.','shortpixel');
|
188 |
}
|
189 |
if(strpos($addedFolder, $rootPath) !== 0) {
|
190 |
|
191 |
-
return( sprintf(__('The %s folder cannot be processed as it\'s not inside the root path of your website.','shortpixel'),$addedFolder));
|
192 |
}
|
193 |
$folder = new ShortPixelFolder(array("path" => $addedFolder));
|
194 |
try {
|
@@ -197,11 +204,11 @@ class ShortPixelCustomMetaDao {
|
|
197 |
return $ex->getMessage();
|
198 |
}
|
199 |
if(ShortPixelMetaFacade::isMediaSubfolder($folder->getPath())) {
|
200 |
-
return __('This folder contains Media Library images. To optimize Media Library images please go to <a href="upload.php?mode=list">Media Library list view</a> or to <a href="upload.php?page=wp-short-pixel-bulk">SortPixel Bulk page</a>.','shortpixel');
|
201 |
}
|
202 |
$folderMsg = $this->saveFolder($folder);
|
203 |
if(!$folder->getId()) {
|
204 |
-
throw new Exception(__('Inserted folder doesn\'t have an ID!','shortpixel'));
|
205 |
}
|
206 |
//die(var_dump($folder));
|
207 |
if(!$folderMsg) {
|
@@ -221,7 +228,7 @@ class ShortPixelCustomMetaDao {
|
|
221 |
if($addedPath) {
|
222 |
//first check if it does contain the Backups Folder - we don't allow that
|
223 |
if(ShortPixelFolder::checkFolderIsSubfolder(SP_BACKUP_FOLDER, $addedPath)) {
|
224 |
-
return __('This folder contains the ShortPixel Backups. Please select a different folder.','shortpixel');
|
225 |
}
|
226 |
$customFolderPaths = array_map(array('ShortPixelFolder','path'), $this->getFolders());
|
227 |
$allFolders = $this->getFolders(true);
|
@@ -244,10 +251,10 @@ class ShortPixelCustomMetaDao {
|
|
244 |
}
|
245 |
}
|
246 |
//var_dump($allFolders);
|
247 |
-
return sprintf(__('Folder already included in %s.','shortpixel'),$parent);
|
248 |
}
|
249 |
} else {
|
250 |
-
return __('Folder does not exist.','shortpixel');
|
251 |
}
|
252 |
}
|
253 |
|
94 |
}
|
95 |
|
96 |
public function tablesExist() {
|
97 |
+
$hasTablesSql = "SELECT COUNT(1) tableCount FROM information_schema.tables WHERE table_schema='".$this->db->getDbName()."' "
|
98 |
+
. "AND (table_name='".$this->db->getPrefix()."shortpixel_meta' OR table_name='".$this->db->getPrefix()."shortpixel_folders')";
|
99 |
+
$hasTables = $this->db->query($hasTablesSql);
|
100 |
if($hasTables[0]->tableCount == 2){
|
101 |
return true;
|
102 |
}
|
103 |
return false;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function dropTables() {
|
107 |
+
if($this->tablesExist()) {
|
108 |
+
$this->db->query("DROP TABLE ".$this->db->getPrefix()."shortpixel_meta");
|
109 |
+
$this->db->query("DROP TABLE ".$this->db->getPrefix()."shortpixel_folders");
|
110 |
+
}
|
111 |
}
|
112 |
|
113 |
public function createUpdateShortPixelTables() {
|
172 |
|
173 |
public function removeFolder($folderPath) {
|
174 |
$sql = "SELECT id FROM {$this->db->getPrefix()}shortpixel_folders WHERE path = %s";
|
175 |
+
$row = $this->db->query($sql, array(stripslashes($folderPath)));
|
176 |
if(!isset($row[0]->id)) return false;
|
177 |
$id = $row[0]->id;
|
178 |
$sql = "UPDATE {$this->db->getPrefix()}shortpixel_folders SET status = -1 WHERE id = %d";
|
189 |
public function newFolderFromPath($path, $uploadPath, $rootPath) {
|
190 |
WpShortPixelDb::checkCustomTables(); // check if custom tables are created, if not, create them
|
191 |
$addedFolder = ShortPixelFolder::checkFolder($path, $uploadPath);
|
192 |
+
|
193 |
if($this->getFolder($addedFolder)) {
|
194 |
+
return __('Folder already added.','shortpixel-image-optimiser');
|
195 |
}
|
196 |
if(strpos($addedFolder, $rootPath) !== 0) {
|
197 |
|
198 |
+
return( sprintf(__('The %s folder cannot be processed as it\'s not inside the root path of your website.','shortpixel-image-optimiser'),$addedFolder));
|
199 |
}
|
200 |
$folder = new ShortPixelFolder(array("path" => $addedFolder));
|
201 |
try {
|
204 |
return $ex->getMessage();
|
205 |
}
|
206 |
if(ShortPixelMetaFacade::isMediaSubfolder($folder->getPath())) {
|
207 |
+
return __('This folder contains Media Library images. To optimize Media Library images please go to <a href="upload.php?mode=list">Media Library list view</a> or to <a href="upload.php?page=wp-short-pixel-bulk">SortPixel Bulk page</a>.','shortpixel-image-optimiser');
|
208 |
}
|
209 |
$folderMsg = $this->saveFolder($folder);
|
210 |
if(!$folder->getId()) {
|
211 |
+
throw new Exception(__('Inserted folder doesn\'t have an ID!','shortpixel-image-optimiser'));
|
212 |
}
|
213 |
//die(var_dump($folder));
|
214 |
if(!$folderMsg) {
|
228 |
if($addedPath) {
|
229 |
//first check if it does contain the Backups Folder - we don't allow that
|
230 |
if(ShortPixelFolder::checkFolderIsSubfolder(SP_BACKUP_FOLDER, $addedPath)) {
|
231 |
+
return __('This folder contains the ShortPixel Backups. Please select a different folder.','shortpixel-image-optimiser');
|
232 |
}
|
233 |
$customFolderPaths = array_map(array('ShortPixelFolder','path'), $this->getFolders());
|
234 |
$allFolders = $this->getFolders(true);
|
251 |
}
|
252 |
}
|
253 |
//var_dump($allFolders);
|
254 |
+
return sprintf(__('Folder already included in %s.','shortpixel-image-optimiser'),$parent);
|
255 |
}
|
256 |
} else {
|
257 |
+
return __('Folder does not exist.','shortpixel-image-optimiser');
|
258 |
}
|
259 |
}
|
260 |
|
class/db/shortpixel-meta-facade.php
CHANGED
@@ -164,7 +164,7 @@ class ShortPixelMetaFacade {
|
|
164 |
}
|
165 |
|
166 |
function setError($errorCode, $errorMessage) {
|
167 |
-
$this->meta->setMessage(__('Error','shortpixel') . ': <i>' . $errorMessage . '</i>');
|
168 |
$this->meta->setStatus($errorCode);
|
169 |
if($this->type == self::CUSTOM_TYPE) {
|
170 |
if($errorCode == ShortPixelAPI::ERR_FILE_NOT_FOUND) {
|
@@ -245,9 +245,8 @@ class ShortPixelMetaFacade {
|
|
245 |
$ext = pathinfo($path, PATHINFO_EXTENSION);
|
246 |
$retinaPath = substr($path, 0, strlen($path) - 1 - strlen($ext)) . "@2x." . $ext;
|
247 |
if(file_exists($retinaPath)) {
|
248 |
-
// echo($retinaPath . " added\n");
|
249 |
$urlList[] = substr($url, 0, strlen($url) -1 - strlen($ext)) . "@2x." . $ext;
|
250 |
-
$fileList[] = $retinaPath;
|
251 |
}
|
252 |
}
|
253 |
|
164 |
}
|
165 |
|
166 |
function setError($errorCode, $errorMessage) {
|
167 |
+
$this->meta->setMessage(__('Error','shortpixel-image-optimiser') . ': <i>' . $errorMessage . '</i>');
|
168 |
$this->meta->setStatus($errorCode);
|
169 |
if($this->type == self::CUSTOM_TYPE) {
|
170 |
if($errorCode == ShortPixelAPI::ERR_FILE_NOT_FOUND) {
|
245 |
$ext = pathinfo($path, PATHINFO_EXTENSION);
|
246 |
$retinaPath = substr($path, 0, strlen($path) - 1 - strlen($ext)) . "@2x." . $ext;
|
247 |
if(file_exists($retinaPath)) {
|
|
|
248 |
$urlList[] = substr($url, 0, strlen($url) -1 - strlen($ext)) . "@2x." . $ext;
|
249 |
+
$fileList[] = $retinaPath;
|
250 |
}
|
251 |
}
|
252 |
|
class/db/wp-shortpixel-db.php
CHANGED
@@ -44,6 +44,11 @@ class WpShortPixelDb implements ShortPixelDb {
|
|
44 |
return $this->prefix ? $this->prefix : $wpdb->prefix;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
47 |
public function query($sql, $params = false) {
|
48 |
global $wpdb;
|
49 |
if($params) {
|
44 |
return $this->prefix ? $this->prefix : $wpdb->prefix;
|
45 |
}
|
46 |
|
47 |
+
public function getDbName() {
|
48 |
+
global $wpdb;
|
49 |
+
return $wpdb->dbname;
|
50 |
+
}
|
51 |
+
|
52 |
public function query($sql, $params = false) {
|
53 |
global $wpdb;
|
54 |
if($params) {
|
class/model/shortpixel-folder.php
CHANGED
@@ -73,7 +73,7 @@ class ShortPixelFolder extends ShortPixelEntity{
|
|
73 |
}
|
74 |
$ignore = array('.','..');
|
75 |
if(!is_writable($path)) {
|
76 |
-
throw new SpFileRightsException(sprintf(__('Folder %s is not writeable. Please check permissions and try again.','shortpixel'),$path));
|
77 |
}
|
78 |
$files = scandir($path);
|
79 |
foreach($files as $t) {
|
@@ -146,7 +146,7 @@ class ShortPixelFolder extends ShortPixelEntity{
|
|
146 |
protected static function getFolderContentsChangeDateRecursive($path, $mtime, $refMtime) {
|
147 |
$ignore = array('.','..');
|
148 |
if(!is_writable($path)) {
|
149 |
-
throw new SpFileRightsException(sprintf(__('Folder %s is not writeable. Please check permissions and try again.','shortpixel'),$path));
|
150 |
}
|
151 |
$files = scandir($path);
|
152 |
$mtime = max($mtime, filemtime($path));
|
73 |
}
|
74 |
$ignore = array('.','..');
|
75 |
if(!is_writable($path)) {
|
76 |
+
throw new SpFileRightsException(sprintf(__('Folder %s is not writeable. Please check permissions and try again.','shortpixel-image-optimiser'),$path));
|
77 |
}
|
78 |
$files = scandir($path);
|
79 |
foreach($files as $t) {
|
146 |
protected static function getFolderContentsChangeDateRecursive($path, $mtime, $refMtime) {
|
147 |
$ignore = array('.','..');
|
148 |
if(!is_writable($path)) {
|
149 |
+
throw new SpFileRightsException(sprintf(__('Folder %s is not writeable. Please check permissions and try again.','shortpixel-image-optimiser'),$path));
|
150 |
}
|
151 |
$files = scandir($path);
|
152 |
$mtime = max($mtime, filemtime($path));
|
class/view/shortpixel-list-table.php
CHANGED
@@ -12,8 +12,8 @@ class ShortPixelListTable extends WP_List_Table {
|
|
12 |
|
13 |
public function __construct($ctrl, $spMetaDao, $hasNextGen) {
|
14 |
parent::__construct( array(
|
15 |
-
'singular' => __('Image','shortpixel'), //singular name of the listed records
|
16 |
-
'plural' => __('Images','shortpixel'), //plural name of the listed records
|
17 |
'ajax' => false //should this table support ajax?
|
18 |
));
|
19 |
$this->ctrl = $ctrl;
|
@@ -26,11 +26,11 @@ class ShortPixelListTable extends WP_List_Table {
|
|
26 |
$columns = array();
|
27 |
|
28 |
//pe viitor. $columns['cb'] = '<input type="checkbox" />';
|
29 |
-
$columns['name'] = __('Filename','shortpixel');
|
30 |
-
$columns['folder'] = __('Folder','shortpixel');
|
31 |
-
$columns['media_type'] = __('Type','shortpixel');
|
32 |
-
$columns['status'] = __('Status','shortpixel');
|
33 |
-
$columns['options'] = __('Options','shortpixel');
|
34 |
//$columns = apply_filters('shortpixel_list_columns', $columns);
|
35 |
|
36 |
return $columns;
|
@@ -49,23 +49,23 @@ class ShortPixelListTable extends WP_List_Table {
|
|
49 |
$actions = array(
|
50 |
'optimize' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
51 |
esc_attr( $_REQUEST['page'] ), 'optimize', absint( $item->id ), wp_create_nonce( 'sp_optimize_image' ),
|
52 |
-
__('Optimize','shortpixel')),
|
53 |
'retry' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
54 |
esc_attr( $_REQUEST['page'] ), 'optimize', absint( $item->id ), wp_create_nonce( 'sp_optimize_image' ),
|
55 |
-
__('Retry','shortpixel')),
|
56 |
'restore' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
57 |
esc_attr( $_REQUEST['page'] ), 'restore', absint( $item->id ), wp_create_nonce( 'sp_restore_image' ),
|
58 |
-
__('Restore','shortpixel')),
|
59 |
'redolossless' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
60 |
esc_attr( $_REQUEST['page'] ), 'redo', absint( $item->id ), wp_create_nonce( 'sp_redo_image' ),
|
61 |
-
__('Re-optimize lossless','shortpixel')),
|
62 |
'redolossy' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
63 |
esc_attr( $_REQUEST['page'] ), 'redo', absint( $item->id ), wp_create_nonce( 'sp_redo_image' ),
|
64 |
-
__('Re-optimize lossy','shortpixel')),
|
65 |
'quota' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
66 |
esc_attr( $_REQUEST['page'] ), 'quota', absint( $item->id ), wp_create_nonce( 'sp_check_quota' ),
|
67 |
-
__('Check quota','shortpixel')),
|
68 |
-
'view' => sprintf( '<a href="%s" target="_blank">%s</a>', $url, __('View','shortpixel'))
|
69 |
);
|
70 |
$settings = $this->ctrl->getSettings();
|
71 |
$actionsEnabled = array();
|
@@ -86,21 +86,21 @@ class ShortPixelListTable extends WP_List_Table {
|
|
86 |
return ShortPixelMetaFacade::pathToRootRelative($item->folder);
|
87 |
case 'status':
|
88 |
switch($item->status) {
|
89 |
-
case 3: $msg = __('Restored','shortpixel');
|
90 |
break;
|
91 |
case 2: $msg = 0 + $item->message == 0
|
92 |
-
? __('Bonus processing','shortpixel')
|
93 |
-
: __('Reduced by','shortpixel') . " <strong>" . $item->message . "%</strong>"
|
94 |
-
. (0 + $item->message < 5 ? "<br>" . __('Bonus processing','shortpixel') . "." : "");
|
95 |
break;
|
96 |
case 1: $msg = "<img src=\"" . plugins_url( 'shortpixel-image-optimiser/res/img/loading.gif') . "\" class='sp-loading-small'> "
|
97 |
-
. __('Pending','shortpixel');
|
98 |
break;
|
99 |
-
case 0: $msg = __('Waiting','shortpixel');
|
100 |
break;
|
101 |
default:
|
102 |
if($item->status < 0) {
|
103 |
-
$msg = $item->message . "(" . __('code','shortpixel') . ": " . $item->status . ")";
|
104 |
} else {
|
105 |
$msg = "";
|
106 |
}
|
@@ -108,9 +108,9 @@ class ShortPixelListTable extends WP_List_Table {
|
|
108 |
return "<div id='sp-cust-msg-C-" . $item->id . "'>" . $msg . "</div>";
|
109 |
break;
|
110 |
case 'options':
|
111 |
-
return ($item->compression_type == 1 ? __('Lossy','shortpixel') : __('Lossless','shortpixel'))
|
112 |
-
. ($item->keep_exif == 1 ? "": ", " . __('Keep EXIF','shortpixel'))
|
113 |
-
. ($item->cmyk2rgb ? "": ", " . __('Preserve CMYK','shortpixel'));
|
114 |
case 'media_type':
|
115 |
return $item->$column_name;
|
116 |
default:
|
@@ -119,7 +119,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
119 |
}
|
120 |
|
121 |
public function no_items() {
|
122 |
-
echo(__('No images avaliable. Go to <a href="options-general.php?page=wp-shortpixel#adv-settings">Advanced Settings</a> to configure additional folders to be optimized.','shortpixel'));
|
123 |
}
|
124 |
|
125 |
/**
|
@@ -252,7 +252,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
252 |
}
|
253 |
$out .= '</div>';
|
254 |
|
255 |
-
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'shortpixel' ) . '</span></button>';
|
256 |
|
257 |
return $out;
|
258 |
}
|
12 |
|
13 |
public function __construct($ctrl, $spMetaDao, $hasNextGen) {
|
14 |
parent::__construct( array(
|
15 |
+
'singular' => __('Image','shortpixel-image-optimiser'), //singular name of the listed records
|
16 |
+
'plural' => __('Images','shortpixel-image-optimiser'), //plural name of the listed records
|
17 |
'ajax' => false //should this table support ajax?
|
18 |
));
|
19 |
$this->ctrl = $ctrl;
|
26 |
$columns = array();
|
27 |
|
28 |
//pe viitor. $columns['cb'] = '<input type="checkbox" />';
|
29 |
+
$columns['name'] = __('Filename','shortpixel-image-optimiser');
|
30 |
+
$columns['folder'] = __('Folder','shortpixel-image-optimiser');
|
31 |
+
$columns['media_type'] = __('Type','shortpixel-image-optimiser');
|
32 |
+
$columns['status'] = __('Status','shortpixel-image-optimiser');
|
33 |
+
$columns['options'] = __('Options','shortpixel-image-optimiser');
|
34 |
//$columns = apply_filters('shortpixel_list_columns', $columns);
|
35 |
|
36 |
return $columns;
|
49 |
$actions = array(
|
50 |
'optimize' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
51 |
esc_attr( $_REQUEST['page'] ), 'optimize', absint( $item->id ), wp_create_nonce( 'sp_optimize_image' ),
|
52 |
+
__('Optimize','shortpixel-image-optimiser')),
|
53 |
'retry' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
54 |
esc_attr( $_REQUEST['page'] ), 'optimize', absint( $item->id ), wp_create_nonce( 'sp_optimize_image' ),
|
55 |
+
__('Retry','shortpixel-image-optimiser')),
|
56 |
'restore' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
57 |
esc_attr( $_REQUEST['page'] ), 'restore', absint( $item->id ), wp_create_nonce( 'sp_restore_image' ),
|
58 |
+
__('Restore','shortpixel-image-optimiser')),
|
59 |
'redolossless' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
60 |
esc_attr( $_REQUEST['page'] ), 'redo', absint( $item->id ), wp_create_nonce( 'sp_redo_image' ),
|
61 |
+
__('Re-optimize lossless','shortpixel-image-optimiser')),
|
62 |
'redolossy' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
63 |
esc_attr( $_REQUEST['page'] ), 'redo', absint( $item->id ), wp_create_nonce( 'sp_redo_image' ),
|
64 |
+
__('Re-optimize lossy','shortpixel-image-optimiser')),
|
65 |
'quota' => sprintf( '<a href="?page=%s&action=%s&image=%s&_wpnonce=%s">%s</a>',
|
66 |
esc_attr( $_REQUEST['page'] ), 'quota', absint( $item->id ), wp_create_nonce( 'sp_check_quota' ),
|
67 |
+
__('Check quota','shortpixel-image-optimiser')),
|
68 |
+
'view' => sprintf( '<a href="%s" target="_blank">%s</a>', $url, __('View','shortpixel-image-optimiser'))
|
69 |
);
|
70 |
$settings = $this->ctrl->getSettings();
|
71 |
$actionsEnabled = array();
|
86 |
return ShortPixelMetaFacade::pathToRootRelative($item->folder);
|
87 |
case 'status':
|
88 |
switch($item->status) {
|
89 |
+
case 3: $msg = __('Restored','shortpixel-image-optimiser');
|
90 |
break;
|
91 |
case 2: $msg = 0 + $item->message == 0
|
92 |
+
? __('Bonus processing','shortpixel-image-optimiser')
|
93 |
+
: __('Reduced by','shortpixel-image-optimiser') . " <strong>" . $item->message . "%</strong>"
|
94 |
+
. (0 + $item->message < 5 ? "<br>" . __('Bonus processing','shortpixel-image-optimiser') . "." : "");
|
95 |
break;
|
96 |
case 1: $msg = "<img src=\"" . plugins_url( 'shortpixel-image-optimiser/res/img/loading.gif') . "\" class='sp-loading-small'> "
|
97 |
+
. __('Pending','shortpixel-image-optimiser');
|
98 |
break;
|
99 |
+
case 0: $msg = __('Waiting','shortpixel-image-optimiser');
|
100 |
break;
|
101 |
default:
|
102 |
if($item->status < 0) {
|
103 |
+
$msg = $item->message . "(" . __('code','shortpixel-image-optimiser') . ": " . $item->status . ")";
|
104 |
} else {
|
105 |
$msg = "";
|
106 |
}
|
108 |
return "<div id='sp-cust-msg-C-" . $item->id . "'>" . $msg . "</div>";
|
109 |
break;
|
110 |
case 'options':
|
111 |
+
return ($item->compression_type == 1 ? __('Lossy','shortpixel-image-optimiser') : __('Lossless','shortpixel-image-optimiser'))
|
112 |
+
. ($item->keep_exif == 1 ? "": ", " . __('Keep EXIF','shortpixel-image-optimiser'))
|
113 |
+
. ($item->cmyk2rgb ? "": ", " . __('Preserve CMYK','shortpixel-image-optimiser'));
|
114 |
case 'media_type':
|
115 |
return $item->$column_name;
|
116 |
default:
|
119 |
}
|
120 |
|
121 |
public function no_items() {
|
122 |
+
echo(__('No images avaliable. Go to <a href="options-general.php?page=wp-shortpixel#adv-settings">Advanced Settings</a> to configure additional folders to be optimized.','shortpixel-image-optimiser'));
|
123 |
}
|
124 |
|
125 |
/**
|
252 |
}
|
253 |
$out .= '</div>';
|
254 |
|
255 |
+
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'shortpixel-image-optimiser' ) . '</span></button>';
|
256 |
|
257 |
return $out;
|
258 |
}
|
class/view/shortpixel_view.php
CHANGED
@@ -13,14 +13,14 @@ class ShortPixelView {
|
|
13 |
$this->__construct($controller);
|
14 |
}
|
15 |
|
16 |
-
public function displayQuotaExceededAlert($quotaData, $averageCompression = false)
|
17 |
{ ?>
|
18 |
<br/>
|
19 |
<div class="wrap sp-quota-exceeded-alert">
|
20 |
<?php if($averageCompression) { ?>
|
21 |
<div style="float:right; margin-top: 10px">
|
22 |
<div class="bulk-progress-indicator">
|
23 |
-
<div style="margin-bottom:5px"><?php _e('Average reduction','shortpixel');?></div>
|
24 |
<div id="sp-avg-optimization"><input type="text" id="sp-avg-optimization-dial" value="<?php echo("" . round($averageCompression))?>" class="dial"></div>
|
25 |
<script>
|
26 |
jQuery(function() {
|
@@ -30,24 +30,28 @@ class ShortPixelView {
|
|
30 |
</div>
|
31 |
</div>
|
32 |
<?php } ?>
|
33 |
-
<h3><?php /* translators: header of the alert box */ _e('Quota Exceeded','shortpixel');?></h3>
|
34 |
<p><?php /* translators: body of the alert box */
|
35 |
-
|
|
|
|
|
|
|
36 |
number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric']));?>
|
37 |
<?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
|
38 |
<?php
|
39 |
-
printf(__('<strong>%s images and %s thumbnails</strong> are not yet optimized by ShortPixel.','shortpixel'),
|
40 |
number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles']),
|
41 |
number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']))); ?>
|
42 |
<?php } ?></p>
|
43 |
<div> <!-- style='float:right;margin-top:20px;'> -->
|
44 |
-
<a class='button button-primary' href='https://shortpixel.com/login/<?php echo($this->ctrl->getApiKey());?>' target='_blank'><?php _e('Upgrade','shortpixel');?></a>
|
45 |
-
<input type='button' name='checkQuota' class='button' value='<?php _e('Confirm New Quota','shortpixel');?>'
|
|
|
46 |
</div>
|
47 |
-
<p><?php _e('Get more image credits by referring ShortPixel to your friends!','shortpixel');?>
|
48 |
<a href="https://shortpixel.com/login/<?php echo($this->ctrl->getApiKey());?>/tell-a-friend" target="_blank">
|
49 |
-
<?php _e('Check your account','shortpixel');?>
|
50 |
-
</a> <?php _e('for your unique referral link. For each user that joins, you will receive +100 additional image credits/month.','shortpixel');?>
|
51 |
</p>
|
52 |
|
53 |
</div> <?php
|
@@ -56,10 +60,10 @@ class ShortPixelView {
|
|
56 |
public static function displayApiKeyAlert()
|
57 |
{ ?>
|
58 |
<p><?php _e('In order to start the optimization process, you need to validate your API Key in the '
|
59 |
-
. '<a href="options-general.php?page=wp-shortpixel">ShortPixel Settings</a> page in your WordPress Admin.','shortpixel');?>
|
60 |
</p>
|
61 |
-
<p><?php _e('If you don’t have an API Key, you can get one delivered to your inbox, for free.','shortpixel');?></p>
|
62 |
-
<p><?php _e('Please <a href="https://shortpixel.com/wp-apikey" target="_blank">sign up to get your API key.</a>','shortpixel');?>
|
63 |
</p>
|
64 |
<?php
|
65 |
}
|
@@ -67,15 +71,15 @@ class ShortPixelView {
|
|
67 |
public static function displayActivationNotice($when = 'activate') { ?>
|
68 |
<div class='notice notice-warning' id='short-pixel-notice-<?php echo($when);?>'>
|
69 |
<?php if($when != 'activate') { ?>
|
70 |
-
<div style="float:right;"><a href="javascript:dismissShortPixelNotice('<?php echo($when);?>')" class="button" style="margin-top:10px;"><?php _e('Dismiss','shortpixel');?></a></div>
|
71 |
<?php } ?>
|
72 |
-
<h3><?php _e('ShortPixel Optimization','shortpixel');?></h3> <?php
|
73 |
switch($when) {
|
74 |
case '2h' :
|
75 |
-
_e("Action needed. Please <a href='https://shortpixel.com/wp-apikey' target='_blank'>get your API key</a> to activate your ShortPixel plugin.",'shortpixel') . "<BR><BR>";
|
76 |
break;
|
77 |
case '3d':
|
78 |
-
_e("Your image gallery is not optimized. It takes 2 minutes to <a href='https://shortpixel.com/wp-apikey' target='_blank'>get your API key</a> and activate your ShortPixel plugin.",'shortpixel') . "<BR><BR>";
|
79 |
break;
|
80 |
case 'activate':
|
81 |
self::displayApiKeyAlert();
|
@@ -99,29 +103,29 @@ class ShortPixelView {
|
|
99 |
<input type='hidden' id='mainToProcess' value='<?php echo($quotaData['mainFiles'] - $quotaData['mainProcessedFiles']);?>'/>
|
100 |
<input type='hidden' id='totalToProcess' value='<?php echo($quotaData['totalFiles'] - $quotaData['totalProcessedFiles']);?>'/>
|
101 |
<div class="bulk-stats-container">
|
102 |
-
<h3 style='margin-top:0;'><?php _e('Your media library','shortpixel');?></h3>
|
103 |
-
<div class="bulk-label"><?php _e('Original images','shortpixel');?></div>
|
104 |
<div class="bulk-val"><?php echo(number_format($quotaData['mainMlFiles']));?></div><br>
|
105 |
-
<div class="bulk-label"><?php _e('Smaller thumbnails','shortpixel');?></div>
|
106 |
<div class="bulk-val"><?php echo(number_format($quotaData['totalMlFiles'] - $quotaData['mainMlFiles']));?></div>
|
107 |
<div style='width:165px; display:inline-block; padding-left: 5px'>
|
108 |
<input type='checkbox' id='thumbnails' name='thumbnails' onclick='ShortPixel.checkThumbsUpdTotal(this)' <?php echo($this->ctrl->processThumbnails() ? "checked":"");?>>
|
109 |
-
<?php _e('Include thumbnails','shortpixel');?>
|
110 |
</div><br>
|
111 |
<?php if($quotaData["totalProcessedMlFiles"] > 0) { ?>
|
112 |
-
<div class="bulk-label bulk-total"><?php _e('Total images','shortpixel');?></div>
|
113 |
<div class="bulk-val bulk-total"><?php echo(number_format($quotaData['totalMlFiles']));?></div>
|
114 |
-
<br><div class="bulk-label"><?php _e('Already optimized originals','shortpixel');?></div>
|
115 |
<div class="bulk-val"><?php echo(number_format($quotaData['mainProcessedMlFiles']));?></div><br>
|
116 |
-
<div class="bulk-label"><?php _e('Already optimized thumbnails','shortpixel');?></div>
|
117 |
<div class="bulk-val"><?php echo(number_format($quotaData['totalProcessedMlFiles'] - $quotaData['mainProcessedMlFiles']));?></div><br>
|
118 |
<?php } ?>
|
119 |
-
<div class="bulk-label bulk-total"><?php _e('Total to be optimized','shortpixel');?></div>
|
120 |
<div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format($quotaData['totalMlFiles'] - $quotaData['totalProcessedMlFiles']));?></div>
|
121 |
|
122 |
<?php if($customCount > 0) { ?>
|
123 |
-
<h3 style='margin-bottom:10px;'><?php _e('Your custom folders','shortpixel');?></h3>
|
124 |
-
<div class="bulk-label bulk-total"><?php _e('Total to be optimized','shortpixel');?></div>
|
125 |
<div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format($customCount));?></div>
|
126 |
<?php } ?>
|
127 |
</div>
|
@@ -134,7 +138,7 @@ class ShortPixelView {
|
|
134 |
<img src='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-slider.png' ));?>'/>
|
135 |
</div>
|
136 |
<div class="bulk-btn-txt">
|
137 |
-
<?php printf(__('<span class="label">Start Optimizing</span><br> <span class="total">%s</span> images','shortpixel'),
|
138 |
number_format($quotaData['totalFiles'] - $quotaData['totalProcessedFiles']));?>
|
139 |
</div>
|
140 |
<div class="bulk-btn-img" class="bulk-btn-img">
|
@@ -145,7 +149,7 @@ class ShortPixelView {
|
|
145 |
</div>
|
146 |
<?php } else {?>
|
147 |
<div class="bulk-play bulk-nothing-optimize">
|
148 |
-
<?php _e('Nothing to optimize! The images that you add to Media Gallery will be automatically optimized after upload.','shortpixel');?>
|
149 |
</div>
|
150 |
<?php } ?>
|
151 |
</form>
|
@@ -154,37 +158,37 @@ class ShortPixelView {
|
|
154 |
<div class='shortpixel-clearfix'></div>
|
155 |
<div class="bulk-wide">
|
156 |
<h3 style='font-size: 1.1em; font-weight: bold;'>
|
157 |
-
<?php _e('After you start the bulk process, in order for the optimization to run, you must keep this page open and your computer running. If you close the page for whatever reason, just turn back to it and the bulk process will resume.','shortpixel');?>
|
158 |
</h3>
|
159 |
</div>
|
160 |
<?php } ?>
|
161 |
<div class='shortpixel-clearfix'></div>
|
162 |
<div class="bulk-text-container">
|
163 |
-
<h3><?php _e('What are Thumbnails?','shortpixel');?></h3>
|
164 |
-
<p><?php _e('Thumbnails are smaller images usually generated by your WP theme. Most themes generate between 3 and 6 thumbnails for each Media Library image.','shortpixel');?></p>
|
165 |
-
<p><?php _e("The thumbnails also generate traffic on your website pages and they influence your website's speed.",'shortpixel');?></p>
|
166 |
-
<p><?php _e("It's highly recommended that you include thumbnails in the optimization as well.",'shortpixel');?></p>
|
167 |
</div>
|
168 |
<div class="bulk-text-container" style="padding-right:0">
|
169 |
-
<h3><?php _e('How does it work?','shortpixel');?></h3>
|
170 |
-
<p><?php _e('The plugin processes images starting with the newest ones you uploaded in your Media Library.','shortpixel');?></p>
|
171 |
-
<p><?php _e('You will be able to pause the process anytime.','shortpixel');?></p>
|
172 |
-
<p><?php echo($this->ctrl->backupImages() ? __("<p>Your original images will be stored in a separate back-up folder.</p>",'shortpixel') : "");?></p>
|
173 |
-
<p><?php _e('You can watch the images being processed live, right here, after you start optimizing.','shortpixel');?></p>
|
174 |
</div>
|
175 |
<?php
|
176 |
} elseif($percent) // bulk is paused
|
177 |
{ ?>
|
178 |
<?php echo($this->displayBulkProgressBar(false, $percent, "", $quotaData['APICallsRemaining'], $this->ctrl->getAverageCompression(), 1, $customCount));?>
|
179 |
-
<p><?php _e('Please see below the optimization status so far:','shortpixel');?></p>
|
180 |
<?php $this->displayBulkStats($quotaData['totalProcessedFiles'], $quotaData['mainProcessedFiles'], $under5PercentCount, $averageCompression, $savedSpace);?>
|
181 |
<?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
|
182 |
-
<p><?php printf(__('%d images and %d thumbnails are not yet optimized by ShortPixel.','shortpixel'),
|
183 |
number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles']),
|
184 |
number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles'])));?>
|
185 |
</p>
|
186 |
<?php } ?>
|
187 |
-
<p><?php _e('You can continue optimizing your Media Gallery from where you left, by clicking the Resume processing button. Already optimized images will not be reprocessed.','shortpixel');?></p>
|
188 |
<?php
|
189 |
} else { ?>
|
190 |
<div class="sp-container">
|
@@ -194,15 +198,15 @@ class ShortPixelView {
|
|
194 |
<input type="text" value="<?php echo("" . round($averageCompression))?>" id="sp-total-optimization-dial" class="dial">
|
195 |
</div>
|
196 |
<p style="margin-top:4px;">
|
197 |
-
<span style="font-size:1.2em;font-weight:bold"><?php _e('Congratulations!','shortpixel');?></span><br>
|
198 |
-
<?php _e('Your media library has been successfully optimized!','shortpixel');?>
|
199 |
-
<span class="sp-bulk-summary"><a href='javascript:void(0);'><?php _e('Summary','shortpixel');?></a></span>
|
200 |
</p>
|
201 |
</div>
|
202 |
<div class='notice notice-success sp-floating-block sp-single-width' style="height: 80px;overflow:hidden;padding-right: 0;">
|
203 |
<div style="float:left; margin-top:-5px">
|
204 |
<p style='margin-bottom: -2px; font-weight: bold;'>
|
205 |
-
<?php _e('Share your optimization results:','shortpixel');?>
|
206 |
</p>
|
207 |
<div style='display:inline-block; margin: 16px 16px 6px 0;float:left'>
|
208 |
<div id="fb-root"></div>
|
@@ -222,13 +226,13 @@ class ShortPixelView {
|
|
222 |
<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://shortpixel.com"
|
223 |
data-text="<?php
|
224 |
if(0+$averageCompression>20) {
|
225 |
-
_e("I just optimized my images by ",'shortpixel');
|
226 |
} else {
|
227 |
-
_e("I just optimized my images ",'shortpixel');
|
228 |
}
|
229 |
echo(round($averageCompression) ."%");
|
230 |
-
|
231 |
-
data-size='large'><?php _e('Tweet','shortpixel');?></a>
|
232 |
</div>
|
233 |
<script>
|
234 |
jQuery(function() {
|
@@ -254,7 +258,7 @@ class ShortPixelView {
|
|
254 |
<div class='shortpixel-rate-us' style='float:left;padding-top:0'>
|
255 |
<a href="https://wordpress.org/support/view/plugin-reviews/shortpixel-image-optimiser?rate=5#postform" target="_blank">
|
256 |
<span>
|
257 |
-
<?php _e('Please rate us!','shortpixel');?>
|
258 |
</span><br><img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/stars.png' ));?>">
|
259 |
</a>
|
260 |
</div>
|
@@ -266,13 +270,13 @@ class ShortPixelView {
|
|
266 |
</div>
|
267 |
<p><?php printf(__('Go to the ShortPixel <a href="%soptions-general.php?page=wp-shortpixel#stats">Stats</a> '
|
268 |
. 'and see all your websites\' optimized stats. Download your detailed <a href="https://api.shortpixel.com/v2/report.php?key=%s">Optimization Report</a> '
|
269 |
-
. 'to check your image optimization statistics for the last 40 days.','shortpixel'), get_admin_url(), $this->ctrl->getApiKey());?></p>
|
270 |
<?php
|
271 |
$failed = $this->ctrl->getPrioQ()->getFailed();
|
272 |
if(count($failed)) { ?>
|
273 |
<div class="bulk-progress" style="margin-bottom: 15px">
|
274 |
<p>
|
275 |
-
<?php _e('The following images could not be processed because of their limited write rights. This usually happens if you have changed your hosting provider. Please restart the optimization process after you granted write rights to all the files below.','shortpixel');?>
|
276 |
</p>
|
277 |
<?php $this->displayFailed($failed); ?>
|
278 |
</div>
|
@@ -288,16 +292,16 @@ class ShortPixelView {
|
|
288 |
<p>
|
289 |
<?php
|
290 |
if($mainNotProcessed && $thumbsNotProcessed) {
|
291 |
-
printf(__("%s images and %s thumbnails are not yet optimized by ShortPixel.",'shortpixel'),
|
292 |
number_format($mainNotProcessed), number_format($thumbsNotProcessed));
|
293 |
} elseif($mainNotProcessed) {
|
294 |
-
printf(__("%s images are not yet optimized by ShortPixel.",'shortpixel'), number_format($mainNotProcessed));
|
295 |
} elseif($thumbsNotProcessed) {
|
296 |
-
printf(__("%s thumbnails are not yet optimized by ShortPixel.",'shortpixel'), number_format($thumbsNotProcessed));
|
297 |
}
|
298 |
-
_e('','shortpixel');
|
299 |
if (count($quotaData['filesWithErrors'])) {
|
300 |
-
_e('Some have errors:','shortpixel');
|
301 |
foreach($quotaData['filesWithErrors'] as $id => $data) {
|
302 |
if(ShortPixelMetaFacade::isCustomQueuedId($id)) {
|
303 |
echo('<a href="'.trailingslashit(network_site_url("/")) . ShortPixelMetaFacade::filenameToRootRelative($data['Path']).'" title="'.$data['Message'].'" target="_blank">'.$data['Name'].'</a>, ');
|
@@ -320,33 +324,33 @@ class ShortPixelView {
|
|
320 |
$thumbsCount = $quotaData['totalProc'.$statType.'Files'] - $quotaData['mainProc'.$statType.'Files'];
|
321 |
?>
|
322 |
<p id="with-thumbs" <?php echo(!$settings->processThumbnails ? 'style="display:none;"' : "");?>>
|
323 |
-
<?php printf(__('%s images and %s thumbnails were optimized <strong>%s</strong>. You can re-optimize <strong>%s</strong> the ones that have backup.','shortpixel'),
|
324 |
number_format($quotaData['mainProc'.$statType.'Files']),
|
325 |
number_format($thumbsCount), $otherType, $optType);?>
|
326 |
</p>
|
327 |
<p id="without-thumbs" <?php echo($settings->processThumbnails ? 'style="display:none;"' : "");?>>
|
328 |
-
<?php printf(__('%s images were optimized <strong>%s</strong>. You can re-optimize <strong>%s</strong> the ones that have backup. ','shortpixel'),
|
329 |
number_format($quotaData['mainProc'.$statType.'Files']),
|
330 |
$otherType, $optType);?>
|
331 |
-
<?php echo($thumbsCount ? number_format($thumbsCount) . __(' thumbnails will be restored to originals.','shortpixel') : '');?>
|
332 |
</p>
|
333 |
<?php
|
334 |
} ?>
|
335 |
<p><?php if($todo) {
|
336 |
-
_e('Restart the optimization process for these images by clicking the button below.','shortpixel');
|
337 |
} else {
|
338 |
-
_e('Restart the optimization process for new images added to your library by clicking the button below.','shortpixel');
|
339 |
}
|
340 |
-
printf(__('Already <strong>%s</strong> optimized images will not be reprocessed.','shortpixel'), $todo ? ($optType) : '');
|
341 |
if($reopt) { ?>
|
342 |
-
<br><?php _e('Please note that reoptimizing images as <strong>lossy/lossless</strong> may use additional credits.','shortpixel')?>
|
343 |
-
<a href="http://blog.shortpixel.com/the-all-new-re-optimization-functions-in-shortpixel/" target="_blank"><?php _e('More info','shortpixel');?></a>
|
344 |
<?php } ?>
|
345 |
</p>
|
346 |
<form action='' method='POST' >
|
347 |
<input type='checkbox' id='bulk-thumbnails' name='thumbnails' <?php echo($this->ctrl->processThumbnails() ? "checked":"");?>
|
348 |
-
onchange="ShortPixel.onBulkThumbsCheck(this)"> <?php _e('Include thumbnails','shortpixel');?><br><br>
|
349 |
-
<input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='<?php _e('Restart Optimizing','shortpixel');?>'>
|
350 |
</form>
|
351 |
</div>
|
352 |
<?php } ?>
|
@@ -357,41 +361,41 @@ class ShortPixelView {
|
|
357 |
public function displayBulkProcessingRunning($percent, $message, $remainingQuota, $averageCompression, $type) {
|
358 |
?>
|
359 |
<div class="wrap short-pixel-bulk-page">
|
360 |
-
<h1><?php _e('Bulk Image Optimization by ShortPixel','shortpixel');?></h1>
|
361 |
<?php $this->displayBulkProgressBar(true, $percent, $message, $remainingQuota, $averageCompression, $type);?>
|
362 |
<div class="sp-floating-block notice bulk-notices-parent">
|
363 |
<div class="bulk-notice-container">
|
364 |
<div class="bulk-notice-msg bulk-lengthy">
|
365 |
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/loading-dark-big.gif' ));?>">
|
366 |
-
<?php _e('Lengthy operation in progress:','shortpixel');?><br>
|
367 |
-
<?php _e('Optimizing image','shortpixel');?> <a href="#" data-href="<?php echo(get_admin_url());?>/post.php?post=__ID__&action=edit" target="_blank">placeholder.png</a>
|
368 |
</div>
|
369 |
<div class="bulk-notice-msg bulk-error" id="bulk-error-template">
|
370 |
<div style="float: right; margin-top: -4px; margin-right: -8px;">
|
371 |
<a href="javascript:void(0);" onclick="ShortPixel.removeBulkMsg(this)" style='color: #c32525;'>✖</a>
|
372 |
</div>
|
373 |
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/exclamation-big.png' ));?>">
|
374 |
-
<span class="sp-err-title"><?php _e('Error processing file:','shortpixel');?><br></span>
|
375 |
<span class="sp-err-content"><?php echo $message; ?></span> <a class="sp-post-link" href="<?php echo(get_admin_url());?>/post.php?post=__ID__&action=edit" target="_blank">placeholder.png</a>
|
376 |
</div>
|
377 |
</div>
|
378 |
</div>
|
379 |
<div class="bulk-progress bulk-slider-container notice notice-info sp-floating-block sp-full-width">
|
380 |
-
<div class="short-pixel-block-title"><span><?php _e('Just optimized:','shortpixel');?></span><span class="filename"></span></div>
|
381 |
<div class="bulk-slider">
|
382 |
<div class="bulk-slide" id="empty-slide">
|
383 |
<div class="bulk-slide-images">
|
384 |
<div class="img-original">
|
385 |
<div><img class="bulk-img-orig" src=""></div>
|
386 |
-
<div><?php _e('Original image','shortpixel');?></div>
|
387 |
</div>
|
388 |
<div class="img-optimized">
|
389 |
<div><img class="bulk-img-opt" src=""></div>
|
390 |
-
<div><?php _e('Optimized image','shortpixel');?></div>
|
391 |
</div>
|
392 |
</div>
|
393 |
<div class="img-info">
|
394 |
-
<div style="font-size: 14px; line-height: 10px; margin-bottom:16px;"><?php /*translators: percent follows */ _e('Optimized by:','shortpixel');?></div>
|
395 |
<span class="bulk-opt-percent"></span>
|
396 |
</div>
|
397 |
</div>
|
@@ -413,13 +417,13 @@ class ShortPixelView {
|
|
413 |
<div style="float:right">
|
414 |
<?php if(false) { ?>
|
415 |
<div class="bulk-progress-indicator">
|
416 |
-
<div style="margin-bottom:5px"><?php _e('Remaining credits','shortpixel');?></div>
|
417 |
<div style="margin-top:22px;margin-bottom: 5px;font-size:2em;font-weight: bold;"><?php echo(number_format($remainingQuota))?></div>
|
418 |
<div>images</div>
|
419 |
</div>
|
420 |
<?php } ?>
|
421 |
<div class="bulk-progress-indicator">
|
422 |
-
<div style="margin-bottom:5px"><?php _e('Average reduction','shortpixel');?></div>
|
423 |
<div id="sp-avg-optimization"><input type="text" id="sp-avg-optimization-dial" value="<?php echo("" . round($averageCompression))?>" class="dial"></div>
|
424 |
<script>
|
425 |
jQuery(function() {
|
@@ -429,17 +433,17 @@ class ShortPixelView {
|
|
429 |
</div>
|
430 |
</div>
|
431 |
<?php if($running) { ?>
|
432 |
-
<h2><?php echo($type & 1 ? __('Media Library','shortpixel') . " " : "");
|
433 |
-
echo($type & 3 == 3 ? __('and','shortpixel') . " " : "");
|
434 |
-
echo($type & 2 ? __('Custom folders','shortpixel') . " " : ""); _e('optimization in progress ...','shortpixel');?></h2>
|
435 |
-
<p style="margin: 0 0 18px;"><?php _e('Bulk optimization has started.','shortpixel');?><br>
|
436 |
<?php printf(__('This process will take some time, depending on the number of images in your library. In the meantime, you can continue using
|
437 |
the admin as usual, <a href="%s" target="_blank">in a different browser window or tab</a>.<br>
|
438 |
-
However, <strong>if you close this window, the bulk processing will pause</strong> until you open the media gallery or the ShortPixel bulk page again.','shortpixel'), get_admin_url());?>
|
439 |
</p>
|
440 |
<?php } else { ?>
|
441 |
-
<h2><?php echo(__('Media Library','shortpixel') . ' ' . ($type & 2 ? __("and Custom folders",'shortpixel') . ' ' : "") . __('optimization paused','shortpixel')); ?></h2>
|
442 |
-
<p style="margin: 0 0 50px;"><?php _e('Bulk processing is paused until you resume the optimization process.','shortpixel');?></p>
|
443 |
<?php }?>
|
444 |
<div id="bulk-progress" class="progress" >
|
445 |
<div class="progress-img" style="left: <?php echo($percent);?>%;">
|
@@ -456,14 +460,14 @@ class ShortPixelView {
|
|
456 |
<input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
|
457 |
name="bulkProcessStop" value="Stop" style="margin-left:10px"/>
|
458 |
<input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
|
459 |
-
name="<?php echo($running ? "bulkProcessPause" : "bulkProcessResume");?>" value="<?php echo($running ? __('Pause','shortpixel') : __('Resume processing','shortpixel'));?>"/>
|
460 |
<?php if(!$running && $customPending) {?>
|
461 |
<input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
|
462 |
-
name="skipToCustom" value="<?php _e('Only other media','shortpixel');?>" title="<?php _e('Process only the other media, skipping the Media Library','shortpixel');?>" style="margin-right:10px"/>
|
463 |
<?php }?>
|
464 |
</form>
|
465 |
<?php } else { ?>
|
466 |
-
<a href="options-general.php?page=wp-shortpixel" class="button button-primary bulk-cancel" style="margin-left:10px"><?php _e('Manage custom folders','shortpixel');?></a>
|
467 |
<?php }?>
|
468 |
</div>
|
469 |
<?php
|
@@ -471,14 +475,14 @@ class ShortPixelView {
|
|
471 |
|
472 |
public function displayBulkStats($totalOptimized, $mainOptimized, $under5PercentCount, $averageCompression, $savedSpace) {?>
|
473 |
<div class="bulk-progress bulk-stats">
|
474 |
-
<div class="label"><?php _e('Processed Images and PDFs:','shortpixel');?></div><div class="stat-value"><?php echo(number_format($mainOptimized));?></div><br>
|
475 |
-
<div class="label"><?php _e('Processed Thumbnails:','shortpixel');?></div><div class="stat-value"><?php echo(number_format($totalOptimized - $mainOptimized));?></div><br>
|
476 |
-
<div class="label totals"><?php _e('Total files processed:','shortpixel');?></div><div class="stat-value"><?php echo(number_format($totalOptimized));?></div><br>
|
477 |
-
<div class="label totals"><?php _e('Minus files with <5% optimization (free):','shortpixel');?></div><div class="stat-value"><?php echo(number_format($under5PercentCount));?></div><br><br>
|
478 |
-
<div class="label totals"><?php _e('Used quota:','shortpixel');?></div><div class="stat-value"><?php echo(number_format($totalOptimized - $under5PercentCount));?></div><br>
|
479 |
<br>
|
480 |
-
<div class="label"><?php _e('Average optimization:','shortpixel');?></div><div class="stat-value"><?php echo($averageCompression);?>%</div><br>
|
481 |
-
<div class="label"><?php _e('Saved space:','shortpixel');?></div><div class="stat-value"><?php echo($savedSpace);?></div>
|
482 |
</div>
|
483 |
<?php
|
484 |
}
|
@@ -504,12 +508,12 @@ class ShortPixelView {
|
|
504 |
$customFolders = null, $folderMsg = false, $addedFolder = false, $showAdvanced = false) {
|
505 |
//wp_enqueue_script('jquery.idTabs.js', plugins_url('/js/jquery.idTabs.js',__FILE__) );
|
506 |
?>
|
507 |
-
<h1><?php _e('ShortPixel Plugin Settings','shortpixel');?></h1>
|
508 |
<p style="font-size:18px">
|
509 |
<a href="https://shortpixel.com/<?php echo($this->ctrl->getVerifiedKey() ? "login/".$this->ctrl->getApiKey() : "pricing");?>" target="_blank" style="font-size:18px">
|
510 |
-
<?php _e('Upgrade now','shortpixel');?>
|
511 |
</a> |
|
512 |
-
<a href="https://shortpixel.com/contact/<?php echo($this->ctrl->getEncryptedData());?>" target="_blank" style="font-size:18px"><?php _e('Support','shortpixel');?> </a>
|
513 |
</p>
|
514 |
<?php if($notice !== null) { ?>
|
515 |
<br/>
|
@@ -527,19 +531,19 @@ class ShortPixelView {
|
|
527 |
<article id="shortpixel-settings-tabs" class="sp-tabs">
|
528 |
<form name='wp_shortpixel_options' action='options-general.php?page=wp-shortpixel&noheader=true' method='post' id='wp_shortpixel_options'>
|
529 |
<section <?php echo($showAdvanced ? "" : "class='sel-tab'");?> id="tab-settings">
|
530 |
-
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-settings"><?php _e('General','shortpixel');?></a></h2>
|
531 |
<?php $this->displaySettingsForm($showApiKey, $editApiKey, $quotaData);?>
|
532 |
</section>
|
533 |
<?php if($this->ctrl->getVerifiedKey()) {?>
|
534 |
<section <?php echo($showAdvanced ? "class='sel-tab'" : "");?> id="tab-adv-settings">
|
535 |
-
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-adv-settings"><?php _e('Advanced','shortpixel');?></a></h2>
|
536 |
<?php $this->displayAdvancedSettingsForm($customFolders, $addedFolder);?>
|
537 |
</section>
|
538 |
<?php } ?>
|
539 |
</form><span style="display:none"> </span><?php //the span is a trick to keep the sections ordered as nth-child in styles: 1,2,3,4 (otherwise the third section would be nth-child(2) too, because of the form)
|
540 |
if($averageCompression !== null) {?>
|
541 |
<section id="tab-stats">
|
542 |
-
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-stats"><?php _e('Statistics','shortpixel');?></a></h2>
|
543 |
<?php
|
544 |
$this->displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
|
545 |
$remainingImages, $totalCallsMade, $fileCount, $backupFolderSize);?>
|
@@ -547,8 +551,8 @@ class ShortPixelView {
|
|
547 |
<?php }
|
548 |
if($resources !== null) {?>
|
549 |
<section id="tab-resources">
|
550 |
-
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-resources"><?php _e('WP Resources','shortpixel');?></a></h2>
|
551 |
-
<?php echo((isset($resources['body']) ? $resources['body'] : __("Please reload",'shortpixel')));?>
|
552 |
</section>
|
553 |
<?php } ?>
|
554 |
</article>
|
@@ -581,35 +585,35 @@ class ShortPixelView {
|
|
581 |
?>
|
582 |
<div class="wp-shortpixel-options">
|
583 |
<?php if($this->ctrl->getVerifiedKey()) { ?>
|
584 |
-
<p><?php printf(__('New images uploaded to the Media Library will be optimized automatically.<br/>If you have existing images you would like to optimize, you can use the <a href="%supload.php?page=wp-short-pixel-bulk">Bulk Optimization Tool</a>.','shortpixel'),get_admin_url());?></p>
|
585 |
<?php } else {
|
586 |
if($showApiKey) {?>
|
587 |
-
<h3><?php _e('Step 1:','shortpixel');?></h3>
|
588 |
-
<p style='font-size: 14px'><?php printf(__('If you don\'t have an API Key, <a href="https://shortpixel.com/wp-apikey%s" target="_blank">sign up here.</a> It\'s free and it only takes one minute, we promise!','shortpixel'),$this->ctrl->getAffiliateSufix());?></p>
|
589 |
-
<h3><?php _e('Step 2:','shortpixel');?></h3>
|
590 |
-
<p style='font-size: 14px'><?php _e('Please enter here the API Key you received by email and press Validate.','shortpixel');?></p>
|
591 |
<?php }
|
592 |
}?>
|
593 |
<table class="form-table">
|
594 |
<tbody>
|
595 |
<tr>
|
596 |
-
<th scope="row"><label for="key"><?php _e('API Key:','shortpixel');?></label></th>
|
597 |
<td>
|
598 |
<?php
|
599 |
$canValidate = false;
|
600 |
if($showApiKey) {
|
601 |
$canValidate = true;?>
|
602 |
-
|
603 |
class="regular-text" <?php echo($editApiKey ? "" : 'disabled') ?>>
|
604 |
<?php } elseif(defined("SHORTPIXEL_API_KEY")) {
|
605 |
$canValidate = true;?>
|
606 |
-
|
607 |
<?php } ?>
|
608 |
-
|
609 |
-
|
610 |
-
onclick="ShortPixel.validateKey()" <?php echo $canValidate ? "" : "disabled"?>><?php _e('Validate','shortpixel');?></button>
|
611 |
<?php if($showApiKey && !$editApiKey) { ?>
|
612 |
-
|
613 |
<?php } ?>
|
614 |
|
615 |
</td>
|
@@ -620,18 +624,18 @@ class ShortPixelView {
|
|
620 |
<?php } else { //if valid key we display the rest of the options ?>
|
621 |
<tr>
|
622 |
<th scope="row">
|
623 |
-
<label for="compressionType"><?php _e('Compression type:','shortpixel');?></label>
|
624 |
</th>
|
625 |
<td>
|
626 |
<input type="radio" name="compressionType" value="1" <?php echo( $this->ctrl->getCompressionType() == 1 ? "checked" : "" );?>><?php
|
627 |
-
_e('Lossy (recommended)','shortpixel');?></br>
|
628 |
-
<p class="settings-info"><?php _e('<b>Lossy compression: </b>lossy has a better compression rate than lossless compression.</br>The resulting image is identical with the original to the human eye. You can run a test for free ','shortpixel');?>
|
629 |
-
<a href="https://shortpixel.com/online-image-compression" target="_blank"><?php _e('here','shortpixel');?></a>.</p></br>
|
630 |
<input type="radio" name="compressionType" value="0" <?php echo( $this->ctrl->getCompressionType() != 1 ? "checked" : "" );?>><?php
|
631 |
-
_e('Lossless','shortpixel');?>
|
632 |
<p class="settings-info">
|
633 |
<?php _e('<b>Lossless compression: </b> the shrunk image will be identical with the original and smaller in size.</br>In some rare cases you will need to use
|
634 |
-
this type of compression. Some technical drawings or images from vector graphics are possible situations.','shortpixel');?>
|
635 |
</p>
|
636 |
</td>
|
637 |
</tr>
|
@@ -640,62 +644,62 @@ class ShortPixelView {
|
|
640 |
<table class="form-table">
|
641 |
<tbody>
|
642 |
<tr>
|
643 |
-
<th scope="row"><label for="thumbnails"><?php _e('Also include thumbnails:','shortpixel');?></label></th>
|
644 |
<td><input name="thumbnails" type="checkbox" id="thumbnails" <?php echo( $checked );?>> <?php
|
645 |
-
_e('Apply compression also to <strong>image thumbnails.</strong> ','shortpixel');?>
|
646 |
-
<?php echo($thumbnailsToProcess ? "(" . number_format($thumbnailsToProcess) . " " . __('thumbnails to optimize','shortpixel') . ")" : "");?>
|
647 |
<p class="settings-info">
|
648 |
-
<?php _e('It is highly recommended that you optimize the thumbnails as they are usually the images most viewed by end users and can generate most traffic.<br>Please note that thumbnails count up to your total quota.','shortpixel');?>
|
649 |
</p>
|
650 |
</td>
|
651 |
</tr>
|
652 |
<tr>
|
653 |
-
<th scope="row"><label for="backupImages"><?php _e('Image backup','shortpixel');?></label></th>
|
654 |
<td>
|
655 |
-
<input name="backupImages" type="checkbox" id="backupImages" <?php echo( $checkedBackupImages );?>> <?php _e('Save and keep a backup of your original images in a separate folder.','shortpixel');?>
|
656 |
-
<p class="settings-info"><?php _e('You <strong>need to have backup active</strong> in order to be able to restore images to originals or to convert from Lossy to Lossless and back.','shortpixel');?></p>
|
657 |
</td>
|
658 |
</tr>
|
659 |
<tr>
|
660 |
-
<th scope="row"><label for="cmyk2rgb"><?php _e('CMYK to RGB conversion','shortpixel');?></label></th>
|
661 |
<td>
|
662 |
-
<input name="cmyk2rgb" type="checkbox" id="cmyk2rgb" <?php echo( $cmyk2rgb );?>><?php _e('Adjust your images for computer and mobile screen display.','shortpixel');?>
|
663 |
-
<p class="settings-info"><?php _e('Images for the web only need RGB format and converting them from CMYK to RGB makes them smaller.','shortpixel');?></p>
|
664 |
</td>
|
665 |
</tr>
|
666 |
<tr>
|
667 |
-
<th scope="row"><label for="removeExif"><?php _e('Remove EXIF','shortpixel');?></label></th>
|
668 |
<td>
|
669 |
-
<input name="removeExif" type="checkbox" id="removeExif" <?php echo( $removeExif );?>><?php _e('Remove the EXIF tag of the image (recommended).','shortpixel');?>
|
670 |
<p class="settings-info"> <?php _e('EXIF is a set of various pieces of information that are automatically embedded into the image upon creation. This can include GPS position, camera manufacturer, date and time, etc.
|
671 |
-
Unless you really need that data to be preserved, we recommend removing it as it can lead to <a href="http://blog.shortpixel.com/how-much-smaller-can-be-images-without-exif-icc" target="_blank">better compression rates</a>.','shortpixel');?></p>
|
672 |
</td>
|
673 |
</tr>
|
674 |
<tr>
|
675 |
-
<th scope="row"><label for="resize"><?php _e('Resize large images','shortpixel');?></label></th>
|
676 |
<td>
|
677 |
<input name="resize" type="checkbox" id="resize" <?php echo( $resize );?>> <?php
|
678 |
-
_e('to maximum','shortpixel');?> <input type="text" name="width" id="width" style="width:70px"
|
679 |
value="<?php echo( max($this->ctrl->getResizeWidth(), min(1024, $minSizes['width'])) );?>" <?php echo( $resizeDisabled );?>/> <?php
|
680 |
-
_e('pixels wide ×','shortpixel');?>
|
681 |
<input type="text" name="height" id="height" style="width:70px" value="<?php echo( max($this->ctrl->getResizeHeight(), min(1024, $minSizes['height'])) );?>" <?php echo( $resizeDisabled );?>/> <?php
|
682 |
-
_e('pixels high (original aspect ratio is preserved and image is not cropped)','shortpixel');?>
|
683 |
<p class="settings-info">
|
684 |
-
<?php _e('Recommended for large photos, like the ones taken with your phone. Saved space can go up to 80% or more after resizing.','shortpixel');?><br/>
|
685 |
</p>
|
686 |
<div style="margin-top: 10px;">
|
687 |
<input type="radio" name="resize_type" id="resize_type_outer" value="outer" <?php echo($settings->resizeType == 'inner' ? '' : 'checked') ?> style="margin: -50px 10px 60px 0;">
|
688 |
-
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/resize-outer.png' ));?>" title="<?php _e('Sizes will be greater or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 1000x1500px while an image of 3000x2000px will be resized to 1800x1200px','shortpixel');?>">
|
689 |
<input type="radio" name="resize_type" id="resize_type_inner" value="inner" <?php echo($settings->resizeType == 'inner' ? 'checked' : '') ?> style="margin: -50px 10px 60px 35px;">
|
690 |
-
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/resize-inner.png' ));?>" title="<?php _e('Sizes will be smaller or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 800x1200px while an image of 3000x2000px will be resized to 1000x667px','shortpixel');?>">
|
691 |
</div>
|
692 |
</td>
|
693 |
</tr>
|
694 |
</tbody>
|
695 |
</table>
|
696 |
<p class="submit">
|
697 |
-
<input type="submit" name="save" id="save" class="button button-primary" title="<?php _e('Save Changes','shortpixel');?>" value="<?php _e('Save Changes','shortpixel');?>">
|
698 |
-
<input type="submit" name="save" id="bulk" class="button button-primary" title="<?php _e('Save and go to the Bulk Processing page','shortpixel');?>" value="<?php _e('Save and Go to Bulk Process','shortpixel');?>">
|
699 |
</p>
|
700 |
</div>
|
701 |
<script>
|
@@ -720,20 +724,20 @@ class ShortPixelView {
|
|
720 |
?>
|
721 |
<div class="wp-shortpixel-options">
|
722 |
<?php if(!$this->ctrl->getVerifiedKey()) { ?>
|
723 |
-
<p><?php _e('Please enter your API key in the General tab first.','shortpixel');?></p>
|
724 |
<?php } else { //if valid key we display the rest of the options ?>
|
725 |
<table class="form-table">
|
726 |
<tbody>
|
727 |
<tr>
|
728 |
-
<th scope="row"><label for="resize"><?php _e('Additional media folders','shortpixel');?></label></th>
|
729 |
<td>
|
730 |
<?php if($customFolders) { ?>
|
731 |
<table class="shortpixel-folders-list">
|
732 |
<tr style="font-weight: bold;">
|
733 |
-
<td><?php _e('Folder name','shortpixel');?></td>
|
734 |
-
<td><?php _e('Type &<br>Status','shortpixel');?></td>
|
735 |
-
<td><?php _e('Files','shortpixel');?></td>
|
736 |
-
<td><?php _e('Last change','shortpixel');?></td>
|
737 |
<td></td>
|
738 |
</tr>
|
739 |
<?php foreach($customFolders as $folder) {
|
@@ -742,18 +746,18 @@ class ShortPixelView {
|
|
742 |
$stat = $this->ctrl->getSpMetaDao()->getFolderOptimizationStatus($folder->getId());
|
743 |
$cnt = $folder->getFileCount();
|
744 |
$st = ($cnt == 0
|
745 |
-
? __("Empty",'shortpixel')
|
746 |
: ($stat->Total == $stat->Optimized
|
747 |
-
? __("Optimized",'shortpixel')
|
748 |
-
: ($stat->Optimized + $stat->Pending > 0 ? __("Pending",'shortpixel') : __("Waiting",'shortpixel'))));
|
749 |
|
750 |
-
$err = $stat->Failed > 0 && !$st == __("Empty",'shortpixel') ? " ({$stat->Failed} failed)" : "";
|
751 |
|
752 |
-
$action = ($st == __("Optimized",'shortpixel') || $st == __("Empty",'shortpixel') ? __("Stop monitoring",'shortpixel') : __("Stop optimizing",'shortpixel'));
|
753 |
|
754 |
-
$fullStat = $st == __("Empty",'shortpixel') ? "" : __("Optimized",'shortpixel') . ": " . $stat->Optimized . ", "
|
755 |
-
. __("Pending",'shortpixel') . ": " . $stat->Pending . ", " . __("Waiting",'shortpixel') . ": " . $stat->Waiting . ", "
|
756 |
-
. __("Failed",'shortpixel') . ": " . $stat->Failed;
|
757 |
?>
|
758 |
<tr>
|
759 |
<td>
|
@@ -775,8 +779,8 @@ class ShortPixelView {
|
|
775 |
<td>
|
776 |
<input type="button" class="button remove-folder-button" data-value="<?php echo($folder->getPath()); ?>" title="<?php echo($action . " " . $folder->getPath()); ?>" value="<?php echo $action;?>">
|
777 |
<input type="button" style="display:none;" class="button button-alert recheck-folder-button" data-value="<?php echo($folder->getPath()); ?>"
|
778 |
-
title="<?php _e('Full folder refresh, check each file of the folder if it changed since it was optimized. Might take up to 1 min. for big folders.','shortpixel');?>"
|
779 |
-
value="<?php _e('Refresh','shortpixel');?>">
|
780 |
</td>
|
781 |
</tr>
|
782 |
<?php }?>
|
@@ -787,19 +791,19 @@ class ShortPixelView {
|
|
787 |
<input type="text" name="addCustomFolderView" id="addCustomFolderView" class="regular-text" value="<?php echo($addedFolder);?>" disabled style="width: 50em;max-width: 70%;">
|
788 |
<input type="hidden" name="addCustomFolder" id="addCustomFolder" value="<?php echo($addedFolder);?>"/>
|
789 |
<input type="hidden" id="customFolderBase" value="<?php echo $this->ctrl->getCustomFolderBase(); ?>">
|
790 |
-
<a class="button button-primary select-folder-button" title="<?php _e('Select the images folder on your server.','shortpixel');?>" href="javascript:void(0);">
|
791 |
-
<?php _e('Select ...','shortpixel');?>
|
792 |
</a>
|
793 |
-
<input type="submit" name="saveAdv" id="saveAdvAddFolder" class="button button-primary" title="<?php _e('Add Folder','shortpixel');?>" value="<?php _e('Add Folder','shortpixel');?>">
|
794 |
<p class="settings-info">
|
795 |
-
<?php _e('Use the Select... button to select site folders. ShortPixel will optimize images and PDFs from the specified folders and their subfolders. The optimization status for each image or PDF in these folders can be seen in the <a href="upload.php?page=wp-short-pixel-custom">Other Media list</a>, under the Media menu.','shortpixel');?>
|
796 |
</p>
|
797 |
<div class="sp-folder-picker-shade">
|
798 |
<div class="sp-folder-picker-popup">
|
799 |
-
<div class="sp-folder-picker-title"><?php _e('Select the images folder','shortpixel');?></div>
|
800 |
<div class="sp-folder-picker"></div>
|
801 |
-
<input type="button" class="button button-info select-folder-cancel" value="<?php _e('Cancel','shortpixel');?>" style="margin-right: 30px;">
|
802 |
-
<input type="button" class="button button-primary select-folder" value="<?php _e('Select','shortpixel');?>">
|
803 |
</div>
|
804 |
</div>
|
805 |
<script>
|
@@ -811,66 +815,66 @@ class ShortPixelView {
|
|
811 |
</tr>
|
812 |
<?php if($hasNextGen) { ?>
|
813 |
<tr>
|
814 |
-
<th scope="row"><label for="nextGen"><?php _e('Optimize NextGen galleries','shortpixel');?></label></th>
|
815 |
<td>
|
816 |
-
<input name="nextGen" type="checkbox" id="nextGen" <?php echo( $includeNextGen );?>> <?php _e('Optimize NextGen galleries.','shortpixel');?>
|
817 |
<p class="settings-info">
|
818 |
-
<?php _e('Check this to add all your current NextGen galleries to the custom folders list and to also have all the future NextGen galleries and images optimized automatically by ShortPixel.','shortpixel');?>
|
819 |
</p>
|
820 |
</td>
|
821 |
</tr>
|
822 |
<?php } ?>
|
823 |
<tr>
|
824 |
-
<th scope="row"><label for="createWebp"><?php _e('WebP versions','shortpixel');?></label></th>
|
825 |
<td>
|
826 |
-
<input name="createWebp" type="checkbox" id="createWebp" <?php echo( $createWebp );?>> <?php _e('Create also <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank">WebP versions</a> of the images <strong>for free</strong>.','shortpixel');?>
|
827 |
<p class="settings-info">
|
828 |
-
<?php _e('WebP images can be up to three times smaller than PNGs and 25% smaller than JPGs. Choosing this option <strong>does not use up additional credits</strong>.','shortpixel');?>
|
829 |
</p>
|
830 |
</td>
|
831 |
</tr>
|
832 |
<tr>
|
833 |
-
<th scope="row"><label for="optimizeRetina"><?php _e('Optimize Retina images','shortpixel');?></label></th>
|
834 |
<td>
|
835 |
-
<input name="optimizeRetina" type="checkbox" id="optimizeRetina" <?php echo( $optimizeRetina );?>> <?php _e('Optimize also the Retina images (@2x) if they exist.','shortpixel');?>
|
836 |
<p class="settings-info">
|
837 |
-
<?php _e('If you have a Retina plugin that generates Retina-specific images (@2x), ShortPixel can optimize them too, alongside the regular Media Library images and thumbnails. <a href="http://blog.shortpixel.com/how-to-use-optimized-retina-images-on-your-wordpress-site-for-best-user-experience-on-apple-devices/" target="_blank">More info.</a>','shortpixel');?>
|
838 |
</p>
|
839 |
</td>
|
840 |
</tr>
|
841 |
<tr>
|
842 |
-
<th scope="row"><label for="authentication"><?php _e('HTTP AUTH credentials','shortpixel');?></label></th>
|
843 |
<td>
|
844 |
-
<input name="siteAuthUser" type="text" id="siteAuthUser" value="<?php echo( $settings->siteAuthUser );?>" class="regular-text" placeholder="<?php _e('User','shortpixel');?>"><br>
|
845 |
-
<input name="siteAuthPass" type="text" id="siteAuthPass" value="<?php echo( $settings->siteAuthPass );?>" class="regular-text" placeholder="<?php _e('Password','shortpixel');?>">
|
846 |
<p class="settings-info">
|
847 |
-
<?php _e('Only fill in these fields if your site (front-end) is not publicly accessible and visitors need a user/pass to connect to it. If you don\'t know what is this then just <strong>leave the fields empty</strong>.','shortpixel');?>
|
848 |
</p>
|
849 |
</td>
|
850 |
</tr>
|
851 |
<tr>
|
852 |
-
<th scope="row"><label for="resize"><?php _e('Process in front-end','shortpixel');?></label></th>
|
853 |
<td>
|
854 |
-
<input name="frontBootstrap" type="checkbox" id="resize" <?php echo( $frontBootstrap );?>> <?php _e('Automatically optimize images added by users in front end.','shortpixel');?>
|
855 |
<p class="settings-info">
|
856 |
-
<?php _e('Check this if you have users that add images or PDF documents from custom forms in the front-end. This could increase the load on your server if you have a lot of users simultaneously connected.','shortpixel');?>
|
857 |
</p>
|
858 |
</td>
|
859 |
</tr>
|
860 |
<tr>
|
861 |
-
<th scope="row"><label for="autoMediaLibrary"><?php _e('Optimize media on upload','shortpixel');?></label></th>
|
862 |
<td>
|
863 |
-
<input name="autoMediaLibrary" type="checkbox" id="autoMediaLibrary" <?php echo( $autoMediaLibrary );?>> <?php _e('Automatically optimize Media Library items after they are uploaded (recommended).','shortpixel');?>
|
864 |
<p class="settings-info">
|
865 |
-
<?php _e('By default, ShortPixel will automatically optimize all the freshly uploaded image and PDF files. If you uncheck this you\'ll need to either run Bulk ShortPixel or go to Media Library (in list view) and click on the right side "Optimize now" button(s).','shortpixel');?>
|
866 |
</p>
|
867 |
</td>
|
868 |
</tr>
|
869 |
</tbody>
|
870 |
</table>
|
871 |
<p class="submit">
|
872 |
-
<input type="submit" name="saveAdv" id="saveAdv" class="button button-primary" title="<?php _e('Save Changes','shortpixel');?>" value="<?php _e('Save Changes','shortpixel');?>">
|
873 |
-
<input type="submit" name="saveAdv" id="bulkAdvGo" class="button button-primary" title="<?php _e('Save and go to the Bulk Processing page','shortpixel');?>" value="<?php _e('Save and Go to Bulk Process','shortpixel');?>">
|
874 |
</p>
|
875 |
</div>
|
876 |
<script>
|
@@ -882,75 +886,75 @@ class ShortPixelView {
|
|
882 |
function displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
|
883 |
$remainingImages, $totalCallsMade, $fileCount, $backupFolderSize) { ?>
|
884 |
<a id="facts"></a>
|
885 |
-
<h3><?php _e('Your ShortPixel Stats','shortpixel');?></h3>
|
886 |
<table class="form-table">
|
887 |
<tbody>
|
888 |
<tr>
|
889 |
-
<th scope="row"><label for="averagCompression"><?php _e('Average compression of your files:','shortpixel');?></label></th>
|
890 |
<td><?php echo($averageCompression);?>%</td>
|
891 |
</tr>
|
892 |
<tr>
|
893 |
-
<th scope="row"><label for="savedSpace"><?php _e('Saved disk space by ShortPixel','shortpixel');?></label></th>
|
894 |
<td><?php echo($savedSpace);?></td>
|
895 |
</tr>
|
896 |
<tr>
|
897 |
-
<th scope="row"><label for="savedBandwidth"><?php _e('Bandwith* saved with ShortPixel:','shortpixel');?></label></th>
|
898 |
<td><?php echo($savedBandwidth);?></td>
|
899 |
</tr>
|
900 |
</tbody>
|
901 |
</table>
|
902 |
|
903 |
-
<p style="padding-top: 0px; color: #818181;" ><?php _e('* Saved bandwidth is calculated at 10,000 impressions/image','shortpixel');?></p>
|
904 |
|
905 |
-
<h3><?php _e('Your ShortPixel Plan','shortpixel');?></h3>
|
906 |
<table class="form-table">
|
907 |
<tbody>
|
908 |
<tr>
|
909 |
-
<th scope="row" bgcolor="#ffffff"><label for="apiQuota"><?php _e('Your ShortPixel plan','shortpixel');?></label></th>
|
910 |
<td bgcolor="#ffffff">
|
911 |
-
<?php printf(__('%s/month, renews in %s days, on %s ( <a href="https://shortpixel.com/login/%s" target="_blank">Need More? See the options available</a> )','shortpixel'),
|
912 |
$quotaData['APICallsQuota'], floor(30 + (strtotime($quotaData['APILastRenewalDate']) - time()) / 86400),
|
913 |
date('M d, Y', strtotime($quotaData['APILastRenewalDate']. ' + 30 days')), $this->ctrl->getApiKey());?><br/>
|
914 |
-
<?php printf(__('<a href="https://shortpixel.com/login/%s/tell-a-friend" target="_blank">Join our friend referral system</a> to win more credits. For each user that joins, you receive +100 images credits/month.','shortpixel'),
|
915 |
$this->ctrl->getApiKey());?>
|
916 |
</td>
|
917 |
</tr>
|
918 |
<tr>
|
919 |
-
<th scope="row"><label for="usedQUota"><?php _e('One time credits:','shortpixel');?></label></th>
|
920 |
<td><?php echo( number_format($quotaData['APICallsQuotaOneTimeNumeric']));?></td>
|
921 |
</tr>
|
922 |
<tr>
|
923 |
-
<th scope="row"><label for="usedQUota"><?php _e('Number of images processed this month:','shortpixel');?></label></th>
|
924 |
<td><?php echo($totalCallsMade);?> (<a href="https://api.shortpixel.com/v2/report.php?key=<?php echo($this->ctrl->getApiKey());?>" target="_blank">
|
925 |
-
<?php _e('see report','shortpixel');?>
|
926 |
</a>)
|
927 |
</td>
|
928 |
</tr>
|
929 |
<tr>
|
930 |
-
<th scope="row"><label for="remainingImages"><?php _e('Remaining** images in your plan:','shortpixel');?></label></th>
|
931 |
-
<td><?php echo($remainingImages);?> <?php _e('images','shortpixel');?></td>
|
932 |
</tr>
|
933 |
</tbody>
|
934 |
</table>
|
935 |
|
936 |
<p style="padding-top: 0px; color: #818181;" >
|
937 |
-
<?php printf(__('** Increase your image quota by <a href="https://shortpixel.com/login/%s" target="_blank">upgrading your ShortPixel plan.</a>','shortpixel'),
|
938 |
$this->ctrl->getApiKey());?>
|
939 |
</p>
|
940 |
|
941 |
<table class="form-table">
|
942 |
<tbody>
|
943 |
<tr>
|
944 |
-
<th scope="row"><label for="totalFiles"><?php _e('Total number of processed files:','shortpixel');?></label></th>
|
945 |
<td><?php echo($fileCount);?></td>
|
946 |
</tr>
|
947 |
<?php if($this->ctrl->backupImages()) { ?>
|
948 |
<tr>
|
949 |
-
<th scope="row"><label for="sizeBackup"><?php _e('Original images are stored in a backup folder. Your backup folder size is now:','shortpixel');?></label></th>
|
950 |
<td>
|
951 |
<form action="" method="POST">
|
952 |
<?php echo($backupFolderSize);?>
|
953 |
-
<input type="submit" style="margin-left: 15px; vertical-align: middle;" class="button button-secondary" name="emptyBackup" value="<?php _e('Empty backups','shortpixel');?>"/>
|
954 |
</form>
|
955 |
</td>
|
956 |
</tr>
|
@@ -963,21 +967,21 @@ class ShortPixelView {
|
|
963 |
<?php
|
964 |
}
|
965 |
|
966 |
-
public function renderCustomColumn($id, $data){ ?>
|
967 |
<div id='sp-msg-<?php echo($id);?>' class='column-wp-shortPixel'>
|
968 |
|
969 |
<?php switch($data['status']) {
|
970 |
case 'n/a': ?>
|
971 |
-
<?php _e('Optimization N/A','shortpixel');?> <?php
|
972 |
break;
|
973 |
case 'notFound': ?>
|
974 |
-
<?php _e('Image does not exist.','shortpixel');?> <?php
|
975 |
break;
|
976 |
case 'invalidKey':
|
977 |
if(defined("SHORTPIXEL_API_KEY")) { // multisite key - need to be validated on each site but it's not invalid
|
978 |
-
?> <?php _e('Please <a href="options-general.php?page=wp-shortpixel">go to Settings</a> to validate the API Key.','shortpixel');?> <?php
|
979 |
} else {
|
980 |
-
?> <?php _e('Invalid API Key. <a href="options-general.php?page=wp-shortpixel">Check your Settings</a>','shortpixel');?> <?php
|
981 |
}
|
982 |
break;
|
983 |
case 'quotaExceeded':
|
@@ -986,7 +990,7 @@ class ShortPixelView {
|
|
986 |
case 'optimizeNow':
|
987 |
if($data['showActions']) { ?>
|
988 |
<a class='button button-smaller button-primary' href="javascript:manualOptimization('<?php echo($id)?>')">
|
989 |
-
<?php _e('Optimize now','shortpixel');?>
|
990 |
</a>
|
991 |
<?php }
|
992 |
echo($data['message']);
|
@@ -996,14 +1000,20 @@ class ShortPixelView {
|
|
996 |
break;
|
997 |
case 'retry': ?>
|
998 |
<?php echo($data['message'])?> <a class='button button-smaller button-primary' href="javascript:manualOptimization('<?php echo($id)?>')">
|
999 |
-
<?php _e('Retry','shortpixel');?>
|
1000 |
</a> <?php
|
1001 |
break;
|
1002 |
case 'pdfOptimized':
|
1003 |
case 'imgOptimized':
|
|
|
|
|
|
|
|
|
|
|
|
|
1004 |
$this->renderListCell($id, $data['showActions'],
|
1005 |
-
!$data['thumbsOpt'] && $data['thumbsTotal'], $data['thumbsTotal'], $data['backup'], $data['type'],
|
1006 |
-
|
1007 |
break;
|
1008 |
}
|
1009 |
//die(var_dump($data));
|
@@ -1013,15 +1023,15 @@ class ShortPixelView {
|
|
1013 |
}
|
1014 |
|
1015 |
public function getSuccessText($percent, $bonus, $type, $thumbsOpt = 0, $thumbsTotal = 0, $retinasOpt = 0) {
|
1016 |
-
return ($percent ? __('Reduced by','shortpixel') . ' <strong>' . $percent . '%</strong> ' : '')
|
1017 |
.(!$bonus ? ' ('.$type.')':'')
|
1018 |
.($bonus && $percent ? '<br>' : '')
|
1019 |
-
.($bonus ? __('Bonus processing','shortpixel') : '')
|
1020 |
.($bonus ? ' ('.$type.')':'') . '<br>'
|
1021 |
.($thumbsOpt ? ( $thumbsTotal > $thumbsOpt
|
1022 |
-
? sprintf(__('+%s of %s thumbnails optimized','shortpixel'),$thumbsOpt,$thumbsTotal)
|
1023 |
-
: sprintf(__('+%s thumbnails optimized','shortpixel'),$thumbsOpt)) : '')
|
1024 |
-
.($retinasOpt ? '<br>' . sprintf(__('+%s Retina images optimized','shortpixel') , $retinasOpt) : '' ) ;
|
1025 |
}
|
1026 |
|
1027 |
public function renderListCell($id, $showActions, $optimizeThumbs, $thumbsTotal, $backup, $type, $message) {
|
@@ -1029,19 +1039,19 @@ class ShortPixelView {
|
|
1029 |
<div class='sp-column-actions'>
|
1030 |
<?php if($optimizeThumbs) { ?>
|
1031 |
<a class='button button-smaller button-primary' href="javascript:optimizeThumbs(<?php echo($id)?>);">
|
1032 |
-
<?php printf(__('Optimize %s thumbnails','shortpixel'),$thumbsTotal);?>
|
1033 |
</a>
|
1034 |
<?php }
|
1035 |
if($backup) {
|
1036 |
if($type) {
|
1037 |
$invType = $type == 'lossy' ? 'lossless' : 'lossy'; ?>
|
1038 |
<a class='button button-smaller' href="javascript:reoptimize('<?php echo($id)?>', '<?php echo($invType)?>');"
|
1039 |
-
title="<?php _e('Reoptimize from the backed-up image','shortpixel');?>">
|
1040 |
-
<?php _e('Re-optimize','shortpixel');?> <?php echo($invType)?>
|
1041 |
</a><?php
|
1042 |
} ?>
|
1043 |
<a class='button button-smaller' href="admin.php?action=shortpixel_restore_backup&attachment_ID=<?php echo($id)?>">
|
1044 |
-
<?php _e('Restore backup','shortpixel');?>
|
1045 |
</a>
|
1046 |
<?php } ?>
|
1047 |
</div>
|
@@ -1054,10 +1064,10 @@ class ShortPixelView {
|
|
1054 |
public function getQuotaExceededHTML($message = '') {
|
1055 |
return "<div class='sp-column-actions' style='width:110px;'>
|
1056 |
<a class='button button-smaller button-primary' href='https://shortpixel.com/login/". $this->ctrl->getApiKey() . "' target='_blank'>"
|
1057 |
-
. __('Extend Quota','shortpixel') .
|
1058 |
"</a>
|
1059 |
<a class='button button-smaller' href='admin.php?action=shortpixel_check_quota'>"
|
1060 |
-
. __('Check Quota','shortpixel') .
|
1061 |
"</a></div>
|
1062 |
<div class='sp-column-info'>" . $message . " Quota Exceeded.</div>";
|
1063 |
}
|
13 |
$this->__construct($controller);
|
14 |
}
|
15 |
|
16 |
+
public function displayQuotaExceededAlert($quotaData, $averageCompression = false, $recheck = false)
|
17 |
{ ?>
|
18 |
<br/>
|
19 |
<div class="wrap sp-quota-exceeded-alert">
|
20 |
<?php if($averageCompression) { ?>
|
21 |
<div style="float:right; margin-top: 10px">
|
22 |
<div class="bulk-progress-indicator">
|
23 |
+
<div style="margin-bottom:5px"><?php _e('Average reduction','shortpixel-image-optimiser');?></div>
|
24 |
<div id="sp-avg-optimization"><input type="text" id="sp-avg-optimization-dial" value="<?php echo("" . round($averageCompression))?>" class="dial"></div>
|
25 |
<script>
|
26 |
jQuery(function() {
|
30 |
</div>
|
31 |
</div>
|
32 |
<?php } ?>
|
33 |
+
<h3><?php /* translators: header of the alert box */ _e('Quota Exceeded','shortpixel-image-optimiser');?></h3>
|
34 |
<p><?php /* translators: body of the alert box */
|
35 |
+
if($recheck) {
|
36 |
+
echo('<span style="color: red">' . __('You have no available image credits. If you just bought a package, please note that sometimes it takes a few minutes for the payment confirmation to be sent to us by the payment processor.','shortpixel-image-optimiser') . '</span><br>');
|
37 |
+
}
|
38 |
+
printf(__('The plugin has optimized <strong>%s images</strong> and stopped because it reached the available quota limit.','shortpixel-image-optimiser'),
|
39 |
number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric']));?>
|
40 |
<?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
|
41 |
<?php
|
42 |
+
printf(__('<strong>%s images and %s thumbnails</strong> are not yet optimized by ShortPixel.','shortpixel-image-optimiser'),
|
43 |
number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles']),
|
44 |
number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']))); ?>
|
45 |
<?php } ?></p>
|
46 |
<div> <!-- style='float:right;margin-top:20px;'> -->
|
47 |
+
<a class='button button-primary' href='https://shortpixel.com/login/<?php echo($this->ctrl->getApiKey());?>' target='_blank'><?php _e('Upgrade','shortpixel-image-optimiser');?></a>
|
48 |
+
<input type='button' name='checkQuota' class='button' value='<?php _e('Confirm New Quota','shortpixel-image-optimiser');?>'
|
49 |
+
onclick="ShortPixel.recheckQuota()">
|
50 |
</div>
|
51 |
+
<p><?php _e('Get more image credits by referring ShortPixel to your friends!','shortpixel-image-optimiser');?>
|
52 |
<a href="https://shortpixel.com/login/<?php echo($this->ctrl->getApiKey());?>/tell-a-friend" target="_blank">
|
53 |
+
<?php _e('Check your account','shortpixel-image-optimiser');?>
|
54 |
+
</a> <?php _e('for your unique referral link. For each user that joins, you will receive +100 additional image credits/month.','shortpixel-image-optimiser');?>
|
55 |
</p>
|
56 |
|
57 |
</div> <?php
|
60 |
public static function displayApiKeyAlert()
|
61 |
{ ?>
|
62 |
<p><?php _e('In order to start the optimization process, you need to validate your API Key in the '
|
63 |
+
. '<a href="options-general.php?page=wp-shortpixel">ShortPixel Settings</a> page in your WordPress Admin.','shortpixel-image-optimiser');?>
|
64 |
</p>
|
65 |
+
<p><?php _e('If you don’t have an API Key, you can get one delivered to your inbox, for free.','shortpixel-image-optimiser');?></p>
|
66 |
+
<p><?php _e('Please <a href="https://shortpixel.com/wp-apikey" target="_blank">sign up to get your API key.</a>','shortpixel-image-optimiser');?>
|
67 |
</p>
|
68 |
<?php
|
69 |
}
|
71 |
public static function displayActivationNotice($when = 'activate') { ?>
|
72 |
<div class='notice notice-warning' id='short-pixel-notice-<?php echo($when);?>'>
|
73 |
<?php if($when != 'activate') { ?>
|
74 |
+
<div style="float:right;"><a href="javascript:dismissShortPixelNotice('<?php echo($when);?>')" class="button" style="margin-top:10px;"><?php _e('Dismiss','shortpixel-image-optimiser');?></a></div>
|
75 |
<?php } ?>
|
76 |
+
<h3><?php _e('ShortPixel Optimization','shortpixel-image-optimiser');?></h3> <?php
|
77 |
switch($when) {
|
78 |
case '2h' :
|
79 |
+
_e("Action needed. Please <a href='https://shortpixel.com/wp-apikey' target='_blank'>get your API key</a> to activate your ShortPixel plugin.",'shortpixel-image-optimiser') . "<BR><BR>";
|
80 |
break;
|
81 |
case '3d':
|
82 |
+
_e("Your image gallery is not optimized. It takes 2 minutes to <a href='https://shortpixel.com/wp-apikey' target='_blank'>get your API key</a> and activate your ShortPixel plugin.",'shortpixel-image-optimiser') . "<BR><BR>";
|
83 |
break;
|
84 |
case 'activate':
|
85 |
self::displayApiKeyAlert();
|
103 |
<input type='hidden' id='mainToProcess' value='<?php echo($quotaData['mainFiles'] - $quotaData['mainProcessedFiles']);?>'/>
|
104 |
<input type='hidden' id='totalToProcess' value='<?php echo($quotaData['totalFiles'] - $quotaData['totalProcessedFiles']);?>'/>
|
105 |
<div class="bulk-stats-container">
|
106 |
+
<h3 style='margin-top:0;'><?php _e('Your media library','shortpixel-image-optimiser');?></h3>
|
107 |
+
<div class="bulk-label"><?php _e('Original images','shortpixel-image-optimiser');?></div>
|
108 |
<div class="bulk-val"><?php echo(number_format($quotaData['mainMlFiles']));?></div><br>
|
109 |
+
<div class="bulk-label"><?php _e('Smaller thumbnails','shortpixel-image-optimiser');?></div>
|
110 |
<div class="bulk-val"><?php echo(number_format($quotaData['totalMlFiles'] - $quotaData['mainMlFiles']));?></div>
|
111 |
<div style='width:165px; display:inline-block; padding-left: 5px'>
|
112 |
<input type='checkbox' id='thumbnails' name='thumbnails' onclick='ShortPixel.checkThumbsUpdTotal(this)' <?php echo($this->ctrl->processThumbnails() ? "checked":"");?>>
|
113 |
+
<?php _e('Include thumbnails','shortpixel-image-optimiser');?>
|
114 |
</div><br>
|
115 |
<?php if($quotaData["totalProcessedMlFiles"] > 0) { ?>
|
116 |
+
<div class="bulk-label bulk-total"><?php _e('Total images','shortpixel-image-optimiser');?></div>
|
117 |
<div class="bulk-val bulk-total"><?php echo(number_format($quotaData['totalMlFiles']));?></div>
|
118 |
+
<br><div class="bulk-label"><?php _e('Already optimized originals','shortpixel-image-optimiser');?></div>
|
119 |
<div class="bulk-val"><?php echo(number_format($quotaData['mainProcessedMlFiles']));?></div><br>
|
120 |
+
<div class="bulk-label"><?php _e('Already optimized thumbnails','shortpixel-image-optimiser');?></div>
|
121 |
<div class="bulk-val"><?php echo(number_format($quotaData['totalProcessedMlFiles'] - $quotaData['mainProcessedMlFiles']));?></div><br>
|
122 |
<?php } ?>
|
123 |
+
<div class="bulk-label bulk-total"><?php _e('Total to be optimized','shortpixel-image-optimiser');?></div>
|
124 |
<div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format($quotaData['totalMlFiles'] - $quotaData['totalProcessedMlFiles']));?></div>
|
125 |
|
126 |
<?php if($customCount > 0) { ?>
|
127 |
+
<h3 style='margin-bottom:10px;'><?php _e('Your custom folders','shortpixel-image-optimiser');?></h3>
|
128 |
+
<div class="bulk-label bulk-total"><?php _e('Total to be optimized','shortpixel-image-optimiser');?></div>
|
129 |
<div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format($customCount));?></div>
|
130 |
<?php } ?>
|
131 |
</div>
|
138 |
<img src='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-slider.png' ));?>'/>
|
139 |
</div>
|
140 |
<div class="bulk-btn-txt">
|
141 |
+
<?php printf(__('<span class="label">Start Optimizing</span><br> <span class="total">%s</span> images','shortpixel-image-optimiser'),
|
142 |
number_format($quotaData['totalFiles'] - $quotaData['totalProcessedFiles']));?>
|
143 |
</div>
|
144 |
<div class="bulk-btn-img" class="bulk-btn-img">
|
149 |
</div>
|
150 |
<?php } else {?>
|
151 |
<div class="bulk-play bulk-nothing-optimize">
|
152 |
+
<?php _e('Nothing to optimize! The images that you add to Media Gallery will be automatically optimized after upload.','shortpixel-image-optimiser');?>
|
153 |
</div>
|
154 |
<?php } ?>
|
155 |
</form>
|
158 |
<div class='shortpixel-clearfix'></div>
|
159 |
<div class="bulk-wide">
|
160 |
<h3 style='font-size: 1.1em; font-weight: bold;'>
|
161 |
+
<?php _e('After you start the bulk process, in order for the optimization to run, you must keep this page open and your computer running. If you close the page for whatever reason, just turn back to it and the bulk process will resume.','shortpixel-image-optimiser');?>
|
162 |
</h3>
|
163 |
</div>
|
164 |
<?php } ?>
|
165 |
<div class='shortpixel-clearfix'></div>
|
166 |
<div class="bulk-text-container">
|
167 |
+
<h3><?php _e('What are Thumbnails?','shortpixel-image-optimiser');?></h3>
|
168 |
+
<p><?php _e('Thumbnails are smaller images usually generated by your WP theme. Most themes generate between 3 and 6 thumbnails for each Media Library image.','shortpixel-image-optimiser');?></p>
|
169 |
+
<p><?php _e("The thumbnails also generate traffic on your website pages and they influence your website's speed.",'shortpixel-image-optimiser');?></p>
|
170 |
+
<p><?php _e("It's highly recommended that you include thumbnails in the optimization as well.",'shortpixel-image-optimiser');?></p>
|
171 |
</div>
|
172 |
<div class="bulk-text-container" style="padding-right:0">
|
173 |
+
<h3><?php _e('How does it work?','shortpixel-image-optimiser');?></h3>
|
174 |
+
<p><?php _e('The plugin processes images starting with the newest ones you uploaded in your Media Library.','shortpixel-image-optimiser');?></p>
|
175 |
+
<p><?php _e('You will be able to pause the process anytime.','shortpixel-image-optimiser');?></p>
|
176 |
+
<p><?php echo($this->ctrl->backupImages() ? __("<p>Your original images will be stored in a separate back-up folder.</p>",'shortpixel-image-optimiser') : "");?></p>
|
177 |
+
<p><?php _e('You can watch the images being processed live, right here, after you start optimizing.','shortpixel-image-optimiser');?></p>
|
178 |
</div>
|
179 |
<?php
|
180 |
} elseif($percent) // bulk is paused
|
181 |
{ ?>
|
182 |
<?php echo($this->displayBulkProgressBar(false, $percent, "", $quotaData['APICallsRemaining'], $this->ctrl->getAverageCompression(), 1, $customCount));?>
|
183 |
+
<p><?php _e('Please see below the optimization status so far:','shortpixel-image-optimiser');?></p>
|
184 |
<?php $this->displayBulkStats($quotaData['totalProcessedFiles'], $quotaData['mainProcessedFiles'], $under5PercentCount, $averageCompression, $savedSpace);?>
|
185 |
<?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
|
186 |
+
<p><?php printf(__('%d images and %d thumbnails are not yet optimized by ShortPixel.','shortpixel-image-optimiser'),
|
187 |
number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles']),
|
188 |
number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles'])));?>
|
189 |
</p>
|
190 |
<?php } ?>
|
191 |
+
<p><?php _e('You can continue optimizing your Media Gallery from where you left, by clicking the Resume processing button. Already optimized images will not be reprocessed.','shortpixel-image-optimiser');?></p>
|
192 |
<?php
|
193 |
} else { ?>
|
194 |
<div class="sp-container">
|
198 |
<input type="text" value="<?php echo("" . round($averageCompression))?>" id="sp-total-optimization-dial" class="dial">
|
199 |
</div>
|
200 |
<p style="margin-top:4px;">
|
201 |
+
<span style="font-size:1.2em;font-weight:bold"><?php _e('Congratulations!','shortpixel-image-optimiser');?></span><br>
|
202 |
+
<?php _e('Your media library has been successfully optimized!','shortpixel-image-optimiser');?>
|
203 |
+
<span class="sp-bulk-summary"><a href='javascript:void(0);'><?php _e('Summary','shortpixel-image-optimiser');?></a></span>
|
204 |
</p>
|
205 |
</div>
|
206 |
<div class='notice notice-success sp-floating-block sp-single-width' style="height: 80px;overflow:hidden;padding-right: 0;">
|
207 |
<div style="float:left; margin-top:-5px">
|
208 |
<p style='margin-bottom: -2px; font-weight: bold;'>
|
209 |
+
<?php _e('Share your optimization results:','shortpixel-image-optimiser');?>
|
210 |
</p>
|
211 |
<div style='display:inline-block; margin: 16px 16px 6px 0;float:left'>
|
212 |
<div id="fb-root"></div>
|
226 |
<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://shortpixel.com"
|
227 |
data-text="<?php
|
228 |
if(0+$averageCompression>20) {
|
229 |
+
_e("I just #optimized my site's images by ",'shortpixel-image-optimiser');
|
230 |
} else {
|
231 |
+
_e("I just #optimized my site's images ",'shortpixel-image-optimiser');
|
232 |
}
|
233 |
echo(round($averageCompression) ."%");
|
234 |
+
echo(__("with @ShortPixel, a #WordPress image optimization plugin",'shortpixel-image-optimiser') . " #pagespeed #seo");?>"
|
235 |
+
data-size='large'><?php _e('Tweet','shortpixel-image-optimiser');?></a>
|
236 |
</div>
|
237 |
<script>
|
238 |
jQuery(function() {
|
258 |
<div class='shortpixel-rate-us' style='float:left;padding-top:0'>
|
259 |
<a href="https://wordpress.org/support/view/plugin-reviews/shortpixel-image-optimiser?rate=5#postform" target="_blank">
|
260 |
<span>
|
261 |
+
<?php _e('Please rate us!','shortpixel-image-optimiser');?>
|
262 |
</span><br><img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/stars.png' ));?>">
|
263 |
</a>
|
264 |
</div>
|
270 |
</div>
|
271 |
<p><?php printf(__('Go to the ShortPixel <a href="%soptions-general.php?page=wp-shortpixel#stats">Stats</a> '
|
272 |
. 'and see all your websites\' optimized stats. Download your detailed <a href="https://api.shortpixel.com/v2/report.php?key=%s">Optimization Report</a> '
|
273 |
+
. 'to check your image optimization statistics for the last 40 days.','shortpixel-image-optimiser'), get_admin_url(), $this->ctrl->getApiKey());?></p>
|
274 |
<?php
|
275 |
$failed = $this->ctrl->getPrioQ()->getFailed();
|
276 |
if(count($failed)) { ?>
|
277 |
<div class="bulk-progress" style="margin-bottom: 15px">
|
278 |
<p>
|
279 |
+
<?php _e('The following images could not be processed because of their limited write rights. This usually happens if you have changed your hosting provider. Please restart the optimization process after you granted write rights to all the files below.','shortpixel-image-optimiser');?>
|
280 |
</p>
|
281 |
<?php $this->displayFailed($failed); ?>
|
282 |
</div>
|
292 |
<p>
|
293 |
<?php
|
294 |
if($mainNotProcessed && $thumbsNotProcessed) {
|
295 |
+
printf(__("%s images and %s thumbnails are not yet optimized by ShortPixel.",'shortpixel-image-optimiser'),
|
296 |
number_format($mainNotProcessed), number_format($thumbsNotProcessed));
|
297 |
} elseif($mainNotProcessed) {
|
298 |
+
printf(__("%s images are not yet optimized by ShortPixel.",'shortpixel-image-optimiser'), number_format($mainNotProcessed));
|
299 |
} elseif($thumbsNotProcessed) {
|
300 |
+
printf(__("%s thumbnails are not yet optimized by ShortPixel.",'shortpixel-image-optimiser'), number_format($thumbsNotProcessed));
|
301 |
}
|
302 |
+
_e('','shortpixel-image-optimiser');
|
303 |
if (count($quotaData['filesWithErrors'])) {
|
304 |
+
_e('Some have errors:','shortpixel-image-optimiser');
|
305 |
foreach($quotaData['filesWithErrors'] as $id => $data) {
|
306 |
if(ShortPixelMetaFacade::isCustomQueuedId($id)) {
|
307 |
echo('<a href="'.trailingslashit(network_site_url("/")) . ShortPixelMetaFacade::filenameToRootRelative($data['Path']).'" title="'.$data['Message'].'" target="_blank">'.$data['Name'].'</a>, ');
|
324 |
$thumbsCount = $quotaData['totalProc'.$statType.'Files'] - $quotaData['mainProc'.$statType.'Files'];
|
325 |
?>
|
326 |
<p id="with-thumbs" <?php echo(!$settings->processThumbnails ? 'style="display:none;"' : "");?>>
|
327 |
+
<?php printf(__('%s images and %s thumbnails were optimized <strong>%s</strong>. You can re-optimize <strong>%s</strong> the ones that have backup.','shortpixel-image-optimiser'),
|
328 |
number_format($quotaData['mainProc'.$statType.'Files']),
|
329 |
number_format($thumbsCount), $otherType, $optType);?>
|
330 |
</p>
|
331 |
<p id="without-thumbs" <?php echo($settings->processThumbnails ? 'style="display:none;"' : "");?>>
|
332 |
+
<?php printf(__('%s images were optimized <strong>%s</strong>. You can re-optimize <strong>%s</strong> the ones that have backup. ','shortpixel-image-optimiser'),
|
333 |
number_format($quotaData['mainProc'.$statType.'Files']),
|
334 |
$otherType, $optType);?>
|
335 |
+
<?php echo($thumbsCount ? number_format($thumbsCount) . __(' thumbnails will be restored to originals.','shortpixel-image-optimiser') : '');?>
|
336 |
</p>
|
337 |
<?php
|
338 |
} ?>
|
339 |
<p><?php if($todo) {
|
340 |
+
_e('Restart the optimization process for these images by clicking the button below.','shortpixel-image-optimiser');
|
341 |
} else {
|
342 |
+
_e('Restart the optimization process for new images added to your library by clicking the button below.','shortpixel-image-optimiser');
|
343 |
}
|
344 |
+
printf(__('Already <strong>%s</strong> optimized images will not be reprocessed.','shortpixel-image-optimiser'), $todo ? ($optType) : '');
|
345 |
if($reopt) { ?>
|
346 |
+
<br><?php _e('Please note that reoptimizing images as <strong>lossy/lossless</strong> may use additional credits.','shortpixel-image-optimiser')?>
|
347 |
+
<a href="http://blog.shortpixel.com/the-all-new-re-optimization-functions-in-shortpixel/" target="_blank"><?php _e('More info','shortpixel-image-optimiser');?></a>
|
348 |
<?php } ?>
|
349 |
</p>
|
350 |
<form action='' method='POST' >
|
351 |
<input type='checkbox' id='bulk-thumbnails' name='thumbnails' <?php echo($this->ctrl->processThumbnails() ? "checked":"");?>
|
352 |
+
onchange="ShortPixel.onBulkThumbsCheck(this)"> <?php _e('Include thumbnails','shortpixel-image-optimiser');?><br><br>
|
353 |
+
<input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='<?php _e('Restart Optimizing','shortpixel-image-optimiser');?>'>
|
354 |
</form>
|
355 |
</div>
|
356 |
<?php } ?>
|
361 |
public function displayBulkProcessingRunning($percent, $message, $remainingQuota, $averageCompression, $type) {
|
362 |
?>
|
363 |
<div class="wrap short-pixel-bulk-page">
|
364 |
+
<h1><?php _e('Bulk Image Optimization by ShortPixel','shortpixel-image-optimiser');?></h1>
|
365 |
<?php $this->displayBulkProgressBar(true, $percent, $message, $remainingQuota, $averageCompression, $type);?>
|
366 |
<div class="sp-floating-block notice bulk-notices-parent">
|
367 |
<div class="bulk-notice-container">
|
368 |
<div class="bulk-notice-msg bulk-lengthy">
|
369 |
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/loading-dark-big.gif' ));?>">
|
370 |
+
<?php _e('Lengthy operation in progress:','shortpixel-image-optimiser');?><br>
|
371 |
+
<?php _e('Optimizing image','shortpixel-image-optimiser');?> <a href="#" data-href="<?php echo(get_admin_url());?>/post.php?post=__ID__&action=edit" target="_blank">placeholder.png</a>
|
372 |
</div>
|
373 |
<div class="bulk-notice-msg bulk-error" id="bulk-error-template">
|
374 |
<div style="float: right; margin-top: -4px; margin-right: -8px;">
|
375 |
<a href="javascript:void(0);" onclick="ShortPixel.removeBulkMsg(this)" style='color: #c32525;'>✖</a>
|
376 |
</div>
|
377 |
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/exclamation-big.png' ));?>">
|
378 |
+
<span class="sp-err-title"><?php _e('Error processing file:','shortpixel-image-optimiser');?><br></span>
|
379 |
<span class="sp-err-content"><?php echo $message; ?></span> <a class="sp-post-link" href="<?php echo(get_admin_url());?>/post.php?post=__ID__&action=edit" target="_blank">placeholder.png</a>
|
380 |
</div>
|
381 |
</div>
|
382 |
</div>
|
383 |
<div class="bulk-progress bulk-slider-container notice notice-info sp-floating-block sp-full-width">
|
384 |
+
<div class="short-pixel-block-title"><span><?php _e('Just optimized:','shortpixel-image-optimiser');?></span><span class="filename"></span></div>
|
385 |
<div class="bulk-slider">
|
386 |
<div class="bulk-slide" id="empty-slide">
|
387 |
<div class="bulk-slide-images">
|
388 |
<div class="img-original">
|
389 |
<div><img class="bulk-img-orig" src=""></div>
|
390 |
+
<div><?php _e('Original image','shortpixel-image-optimiser');?></div>
|
391 |
</div>
|
392 |
<div class="img-optimized">
|
393 |
<div><img class="bulk-img-opt" src=""></div>
|
394 |
+
<div><?php _e('Optimized image','shortpixel-image-optimiser');?></div>
|
395 |
</div>
|
396 |
</div>
|
397 |
<div class="img-info">
|
398 |
+
<div style="font-size: 14px; line-height: 10px; margin-bottom:16px;"><?php /*translators: percent follows */ _e('Optimized by:','shortpixel-image-optimiser');?></div>
|
399 |
<span class="bulk-opt-percent"></span>
|
400 |
</div>
|
401 |
</div>
|
417 |
<div style="float:right">
|
418 |
<?php if(false) { ?>
|
419 |
<div class="bulk-progress-indicator">
|
420 |
+
<div style="margin-bottom:5px"><?php _e('Remaining credits','shortpixel-image-optimiser');?></div>
|
421 |
<div style="margin-top:22px;margin-bottom: 5px;font-size:2em;font-weight: bold;"><?php echo(number_format($remainingQuota))?></div>
|
422 |
<div>images</div>
|
423 |
</div>
|
424 |
<?php } ?>
|
425 |
<div class="bulk-progress-indicator">
|
426 |
+
<div style="margin-bottom:5px"><?php _e('Average reduction','shortpixel-image-optimiser');?></div>
|
427 |
<div id="sp-avg-optimization"><input type="text" id="sp-avg-optimization-dial" value="<?php echo("" . round($averageCompression))?>" class="dial"></div>
|
428 |
<script>
|
429 |
jQuery(function() {
|
433 |
</div>
|
434 |
</div>
|
435 |
<?php if($running) { ?>
|
436 |
+
<h2><?php echo($type & 1 ? __('Media Library','shortpixel-image-optimiser') . " " : "");
|
437 |
+
echo($type & 3 == 3 ? __('and','shortpixel-image-optimiser') . " " : "");
|
438 |
+
echo($type & 2 ? __('Custom folders','shortpixel-image-optimiser') . " " : ""); _e('optimization in progress ...','shortpixel-image-optimiser');?></h2>
|
439 |
+
<p style="margin: 0 0 18px;"><?php _e('Bulk optimization has started.','shortpixel-image-optimiser');?><br>
|
440 |
<?php printf(__('This process will take some time, depending on the number of images in your library. In the meantime, you can continue using
|
441 |
the admin as usual, <a href="%s" target="_blank">in a different browser window or tab</a>.<br>
|
442 |
+
However, <strong>if you close this window, the bulk processing will pause</strong> until you open the media gallery or the ShortPixel bulk page again.','shortpixel-image-optimiser'), get_admin_url());?>
|
443 |
</p>
|
444 |
<?php } else { ?>
|
445 |
+
<h2><?php echo(__('Media Library','shortpixel-image-optimiser') . ' ' . ($type & 2 ? __("and Custom folders",'shortpixel-image-optimiser') . ' ' : "") . __('optimization paused','shortpixel-image-optimiser')); ?></h2>
|
446 |
+
<p style="margin: 0 0 50px;"><?php _e('Bulk processing is paused until you resume the optimization process.','shortpixel-image-optimiser');?></p>
|
447 |
<?php }?>
|
448 |
<div id="bulk-progress" class="progress" >
|
449 |
<div class="progress-img" style="left: <?php echo($percent);?>%;">
|
460 |
<input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
|
461 |
name="bulkProcessStop" value="Stop" style="margin-left:10px"/>
|
462 |
<input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
|
463 |
+
name="<?php echo($running ? "bulkProcessPause" : "bulkProcessResume");?>" value="<?php echo($running ? __('Pause','shortpixel-image-optimiser') : __('Resume processing','shortpixel-image-optimiser'));?>"/>
|
464 |
<?php if(!$running && $customPending) {?>
|
465 |
<input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
|
466 |
+
name="skipToCustom" value="<?php _e('Only other media','shortpixel-image-optimiser');?>" title="<?php _e('Process only the other media, skipping the Media Library','shortpixel-image-optimiser');?>" style="margin-right:10px"/>
|
467 |
<?php }?>
|
468 |
</form>
|
469 |
<?php } else { ?>
|
470 |
+
<a href="options-general.php?page=wp-shortpixel" class="button button-primary bulk-cancel" style="margin-left:10px"><?php _e('Manage custom folders','shortpixel-image-optimiser');?></a>
|
471 |
<?php }?>
|
472 |
</div>
|
473 |
<?php
|
475 |
|
476 |
public function displayBulkStats($totalOptimized, $mainOptimized, $under5PercentCount, $averageCompression, $savedSpace) {?>
|
477 |
<div class="bulk-progress bulk-stats">
|
478 |
+
<div class="label"><?php _e('Processed Images and PDFs:','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo(number_format($mainOptimized));?></div><br>
|
479 |
+
<div class="label"><?php _e('Processed Thumbnails:','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo(number_format($totalOptimized - $mainOptimized));?></div><br>
|
480 |
+
<div class="label totals"><?php _e('Total files processed:','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo(number_format($totalOptimized));?></div><br>
|
481 |
+
<div class="label totals"><?php _e('Minus files with <5% optimization (free):','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo(number_format($under5PercentCount));?></div><br><br>
|
482 |
+
<div class="label totals"><?php _e('Used quota:','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo(number_format($totalOptimized - $under5PercentCount));?></div><br>
|
483 |
<br>
|
484 |
+
<div class="label"><?php _e('Average optimization:','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo($averageCompression);?>%</div><br>
|
485 |
+
<div class="label"><?php _e('Saved space:','shortpixel-image-optimiser');?></div><div class="stat-value"><?php echo($savedSpace);?></div>
|
486 |
</div>
|
487 |
<?php
|
488 |
}
|
508 |
$customFolders = null, $folderMsg = false, $addedFolder = false, $showAdvanced = false) {
|
509 |
//wp_enqueue_script('jquery.idTabs.js', plugins_url('/js/jquery.idTabs.js',__FILE__) );
|
510 |
?>
|
511 |
+
<h1><?php _e('ShortPixel Plugin Settings','shortpixel-image-optimiser');?></h1>
|
512 |
<p style="font-size:18px">
|
513 |
<a href="https://shortpixel.com/<?php echo($this->ctrl->getVerifiedKey() ? "login/".$this->ctrl->getApiKey() : "pricing");?>" target="_blank" style="font-size:18px">
|
514 |
+
<?php _e('Upgrade now','shortpixel-image-optimiser');?>
|
515 |
</a> |
|
516 |
+
<a href="https://shortpixel.com/contact/<?php echo($this->ctrl->getEncryptedData());?>" target="_blank" style="font-size:18px"><?php _e('Support','shortpixel-image-optimiser');?> </a>
|
517 |
</p>
|
518 |
<?php if($notice !== null) { ?>
|
519 |
<br/>
|
531 |
<article id="shortpixel-settings-tabs" class="sp-tabs">
|
532 |
<form name='wp_shortpixel_options' action='options-general.php?page=wp-shortpixel&noheader=true' method='post' id='wp_shortpixel_options'>
|
533 |
<section <?php echo($showAdvanced ? "" : "class='sel-tab'");?> id="tab-settings">
|
534 |
+
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-settings"><?php _e('General','shortpixel-image-optimiser');?></a></h2>
|
535 |
<?php $this->displaySettingsForm($showApiKey, $editApiKey, $quotaData);?>
|
536 |
</section>
|
537 |
<?php if($this->ctrl->getVerifiedKey()) {?>
|
538 |
<section <?php echo($showAdvanced ? "class='sel-tab'" : "");?> id="tab-adv-settings">
|
539 |
+
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-adv-settings"><?php _e('Advanced','shortpixel-image-optimiser');?></a></h2>
|
540 |
<?php $this->displayAdvancedSettingsForm($customFolders, $addedFolder);?>
|
541 |
</section>
|
542 |
<?php } ?>
|
543 |
</form><span style="display:none"> </span><?php //the span is a trick to keep the sections ordered as nth-child in styles: 1,2,3,4 (otherwise the third section would be nth-child(2) too, because of the form)
|
544 |
if($averageCompression !== null) {?>
|
545 |
<section id="tab-stats">
|
546 |
+
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-stats"><?php _e('Statistics','shortpixel-image-optimiser');?></a></h2>
|
547 |
<?php
|
548 |
$this->displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
|
549 |
$remainingImages, $totalCallsMade, $fileCount, $backupFolderSize);?>
|
551 |
<?php }
|
552 |
if($resources !== null) {?>
|
553 |
<section id="tab-resources">
|
554 |
+
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-resources"><?php _e('WP Resources','shortpixel-image-optimiser');?></a></h2>
|
555 |
+
<?php echo((isset($resources['body']) ? $resources['body'] : __("Please reload",'shortpixel-image-optimiser')));?>
|
556 |
</section>
|
557 |
<?php } ?>
|
558 |
</article>
|
585 |
?>
|
586 |
<div class="wp-shortpixel-options">
|
587 |
<?php if($this->ctrl->getVerifiedKey()) { ?>
|
588 |
+
<p><?php printf(__('New images uploaded to the Media Library will be optimized automatically.<br/>If you have existing images you would like to optimize, you can use the <a href="%supload.php?page=wp-short-pixel-bulk">Bulk Optimization Tool</a>.','shortpixel-image-optimiser'),get_admin_url());?></p>
|
589 |
<?php } else {
|
590 |
if($showApiKey) {?>
|
591 |
+
<h3><?php _e('Step 1:','shortpixel-image-optimiser');?></h3>
|
592 |
+
<p style='font-size: 14px'><?php printf(__('If you don\'t have an API Key, <a href="https://shortpixel.com/wp-apikey%s" target="_blank">sign up here.</a> It\'s free and it only takes one minute, we promise!','shortpixel-image-optimiser'),$this->ctrl->getAffiliateSufix());?></p>
|
593 |
+
<h3><?php _e('Step 2:','shortpixel-image-optimiser');?></h3>
|
594 |
+
<p style='font-size: 14px'><?php _e('Please enter here the API Key you received by email and press Validate.','shortpixel-image-optimiser');?></p>
|
595 |
<?php }
|
596 |
}?>
|
597 |
<table class="form-table">
|
598 |
<tbody>
|
599 |
<tr>
|
600 |
+
<th scope="row"><label for="key"><?php _e('API Key:','shortpixel-image-optimiser');?></label></th>
|
601 |
<td>
|
602 |
<?php
|
603 |
$canValidate = false;
|
604 |
if($showApiKey) {
|
605 |
$canValidate = true;?>
|
606 |
+
<input name="key" type="text" id="key" value="<?php echo( $this->ctrl->getApiKey() );?>"
|
607 |
class="regular-text" <?php echo($editApiKey ? "" : 'disabled') ?>>
|
608 |
<?php } elseif(defined("SHORTPIXEL_API_KEY")) {
|
609 |
$canValidate = true;?>
|
610 |
+
<input name="key" type="text" id="key" disabled="true" placeholder="<?php _e('Multisite API Key','shortpixel-image-optimiser');?>" class="regular-text">
|
611 |
<?php } ?>
|
612 |
+
<input type="hidden" name="validate" id="valid" value=""/>
|
613 |
+
<button type="button" id="validate" class="button button-primary" title="<?php _e('Validate the provided API key','shortpixel-image-optimiser');?>"
|
614 |
+
onclick="ShortPixel.validateKey()" <?php echo $canValidate ? "" : "disabled"?>><?php _e('Validate','shortpixel-image-optimiser');?></button>
|
615 |
<?php if($showApiKey && !$editApiKey) { ?>
|
616 |
+
<p class="settings-info"><?php _e('Key defined in wp-config.php.','shortpixel-image-optimiser');?></p>
|
617 |
<?php } ?>
|
618 |
|
619 |
</td>
|
624 |
<?php } else { //if valid key we display the rest of the options ?>
|
625 |
<tr>
|
626 |
<th scope="row">
|
627 |
+
<label for="compressionType"><?php _e('Compression type:','shortpixel-image-optimiser');?></label>
|
628 |
</th>
|
629 |
<td>
|
630 |
<input type="radio" name="compressionType" value="1" <?php echo( $this->ctrl->getCompressionType() == 1 ? "checked" : "" );?>><?php
|
631 |
+
_e('Lossy (recommended)','shortpixel-image-optimiser');?></br>
|
632 |
+
<p class="settings-info"><?php _e('<b>Lossy compression: </b>lossy has a better compression rate than lossless compression.</br>The resulting image is identical with the original to the human eye. You can run a test for free ','shortpixel-image-optimiser');?>
|
633 |
+
<a href="https://shortpixel.com/online-image-compression" target="_blank"><?php _e('here','shortpixel-image-optimiser');?></a>.</p></br>
|
634 |
<input type="radio" name="compressionType" value="0" <?php echo( $this->ctrl->getCompressionType() != 1 ? "checked" : "" );?>><?php
|
635 |
+
_e('Lossless','shortpixel-image-optimiser');?>
|
636 |
<p class="settings-info">
|
637 |
<?php _e('<b>Lossless compression: </b> the shrunk image will be identical with the original and smaller in size.</br>In some rare cases you will need to use
|
638 |
+
this type of compression. Some technical drawings or images from vector graphics are possible situations.','shortpixel-image-optimiser');?>
|
639 |
</p>
|
640 |
</td>
|
641 |
</tr>
|
644 |
<table class="form-table">
|
645 |
<tbody>
|
646 |
<tr>
|
647 |
+
<th scope="row"><label for="thumbnails"><?php _e('Also include thumbnails:','shortpixel-image-optimiser');?></label></th>
|
648 |
<td><input name="thumbnails" type="checkbox" id="thumbnails" <?php echo( $checked );?>> <?php
|
649 |
+
_e('Apply compression also to <strong>image thumbnails.</strong> ','shortpixel-image-optimiser');?>
|
650 |
+
<?php echo($thumbnailsToProcess ? "(" . number_format($thumbnailsToProcess) . " " . __('thumbnails to optimize','shortpixel-image-optimiser') . ")" : "");?>
|
651 |
<p class="settings-info">
|
652 |
+
<?php _e('It is highly recommended that you optimize the thumbnails as they are usually the images most viewed by end users and can generate most traffic.<br>Please note that thumbnails count up to your total quota.','shortpixel-image-optimiser');?>
|
653 |
</p>
|
654 |
</td>
|
655 |
</tr>
|
656 |
<tr>
|
657 |
+
<th scope="row"><label for="backupImages"><?php _e('Image backup','shortpixel-image-optimiser');?></label></th>
|
658 |
<td>
|
659 |
+
<input name="backupImages" type="checkbox" id="backupImages" <?php echo( $checkedBackupImages );?>> <?php _e('Save and keep a backup of your original images in a separate folder.','shortpixel-image-optimiser');?>
|
660 |
+
<p class="settings-info"><?php _e('You <strong>need to have backup active</strong> in order to be able to restore images to originals or to convert from Lossy to Lossless and back.','shortpixel-image-optimiser');?></p>
|
661 |
</td>
|
662 |
</tr>
|
663 |
<tr>
|
664 |
+
<th scope="row"><label for="cmyk2rgb"><?php _e('CMYK to RGB conversion','shortpixel-image-optimiser');?></label></th>
|
665 |
<td>
|
666 |
+
<input name="cmyk2rgb" type="checkbox" id="cmyk2rgb" <?php echo( $cmyk2rgb );?>><?php _e('Adjust your images for computer and mobile screen display.','shortpixel-image-optimiser');?>
|
667 |
+
<p class="settings-info"><?php _e('Images for the web only need RGB format and converting them from CMYK to RGB makes them smaller.','shortpixel-image-optimiser');?></p>
|
668 |
</td>
|
669 |
</tr>
|
670 |
<tr>
|
671 |
+
<th scope="row"><label for="removeExif"><?php _e('Remove EXIF','shortpixel-image-optimiser');?></label></th>
|
672 |
<td>
|
673 |
+
<input name="removeExif" type="checkbox" id="removeExif" <?php echo( $removeExif );?>><?php _e('Remove the EXIF tag of the image (recommended).','shortpixel-image-optimiser');?>
|
674 |
<p class="settings-info"> <?php _e('EXIF is a set of various pieces of information that are automatically embedded into the image upon creation. This can include GPS position, camera manufacturer, date and time, etc.
|
675 |
+
Unless you really need that data to be preserved, we recommend removing it as it can lead to <a href="http://blog.shortpixel.com/how-much-smaller-can-be-images-without-exif-icc" target="_blank">better compression rates</a>.','shortpixel-image-optimiser');?></p>
|
676 |
</td>
|
677 |
</tr>
|
678 |
<tr>
|
679 |
+
<th scope="row"><label for="resize"><?php _e('Resize large images','shortpixel-image-optimiser');?></label></th>
|
680 |
<td>
|
681 |
<input name="resize" type="checkbox" id="resize" <?php echo( $resize );?>> <?php
|
682 |
+
_e('to maximum','shortpixel-image-optimiser');?> <input type="text" name="width" id="width" style="width:70px"
|
683 |
value="<?php echo( max($this->ctrl->getResizeWidth(), min(1024, $minSizes['width'])) );?>" <?php echo( $resizeDisabled );?>/> <?php
|
684 |
+
_e('pixels wide ×','shortpixel-image-optimiser');?>
|
685 |
<input type="text" name="height" id="height" style="width:70px" value="<?php echo( max($this->ctrl->getResizeHeight(), min(1024, $minSizes['height'])) );?>" <?php echo( $resizeDisabled );?>/> <?php
|
686 |
+
_e('pixels high (original aspect ratio is preserved and image is not cropped)','shortpixel-image-optimiser');?>
|
687 |
<p class="settings-info">
|
688 |
+
<?php _e('Recommended for large photos, like the ones taken with your phone. Saved space can go up to 80% or more after resizing.','shortpixel-image-optimiser');?><br/>
|
689 |
</p>
|
690 |
<div style="margin-top: 10px;">
|
691 |
<input type="radio" name="resize_type" id="resize_type_outer" value="outer" <?php echo($settings->resizeType == 'inner' ? '' : 'checked') ?> style="margin: -50px 10px 60px 0;">
|
692 |
+
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/resize-outer.png' ));?>" title="<?php _e('Sizes will be greater or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 1000x1500px while an image of 3000x2000px will be resized to 1800x1200px','shortpixel-image-optimiser');?>">
|
693 |
<input type="radio" name="resize_type" id="resize_type_inner" value="inner" <?php echo($settings->resizeType == 'inner' ? 'checked' : '') ?> style="margin: -50px 10px 60px 35px;">
|
694 |
+
<img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/resize-inner.png' ));?>" title="<?php _e('Sizes will be smaller or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 800x1200px while an image of 3000x2000px will be resized to 1000x667px','shortpixel-image-optimiser');?>">
|
695 |
</div>
|
696 |
</td>
|
697 |
</tr>
|
698 |
</tbody>
|
699 |
</table>
|
700 |
<p class="submit">
|
701 |
+
<input type="submit" name="save" id="save" class="button button-primary" title="<?php _e('Save Changes','shortpixel-image-optimiser');?>" value="<?php _e('Save Changes','shortpixel-image-optimiser');?>">
|
702 |
+
<input type="submit" name="save" id="bulk" class="button button-primary" title="<?php _e('Save and go to the Bulk Processing page','shortpixel-image-optimiser');?>" value="<?php _e('Save and Go to Bulk Process','shortpixel-image-optimiser');?>">
|
703 |
</p>
|
704 |
</div>
|
705 |
<script>
|
724 |
?>
|
725 |
<div class="wp-shortpixel-options">
|
726 |
<?php if(!$this->ctrl->getVerifiedKey()) { ?>
|
727 |
+
<p><?php _e('Please enter your API key in the General tab first.','shortpixel-image-optimiser');?></p>
|
728 |
<?php } else { //if valid key we display the rest of the options ?>
|
729 |
<table class="form-table">
|
730 |
<tbody>
|
731 |
<tr>
|
732 |
+
<th scope="row"><label for="resize"><?php _e('Additional media folders','shortpixel-image-optimiser');?></label></th>
|
733 |
<td>
|
734 |
<?php if($customFolders) { ?>
|
735 |
<table class="shortpixel-folders-list">
|
736 |
<tr style="font-weight: bold;">
|
737 |
+
<td><?php _e('Folder name','shortpixel-image-optimiser');?></td>
|
738 |
+
<td><?php _e('Type &<br>Status','shortpixel-image-optimiser');?></td>
|
739 |
+
<td><?php _e('Files','shortpixel-image-optimiser');?></td>
|
740 |
+
<td><?php _e('Last change','shortpixel-image-optimiser');?></td>
|
741 |
<td></td>
|
742 |
</tr>
|
743 |
<?php foreach($customFolders as $folder) {
|
746 |
$stat = $this->ctrl->getSpMetaDao()->getFolderOptimizationStatus($folder->getId());
|
747 |
$cnt = $folder->getFileCount();
|
748 |
$st = ($cnt == 0
|
749 |
+
? __("Empty",'shortpixel-image-optimiser')
|
750 |
: ($stat->Total == $stat->Optimized
|
751 |
+
? __("Optimized",'shortpixel-image-optimiser')
|
752 |
+
: ($stat->Optimized + $stat->Pending > 0 ? __("Pending",'shortpixel-image-optimiser') : __("Waiting",'shortpixel-image-optimiser'))));
|
753 |
|
754 |
+
$err = $stat->Failed > 0 && !$st == __("Empty",'shortpixel-image-optimiser') ? " ({$stat->Failed} failed)" : "";
|
755 |
|
756 |
+
$action = ($st == __("Optimized",'shortpixel-image-optimiser') || $st == __("Empty",'shortpixel-image-optimiser') ? __("Stop monitoring",'shortpixel-image-optimiser') : __("Stop optimizing",'shortpixel-image-optimiser'));
|
757 |
|
758 |
+
$fullStat = $st == __("Empty",'shortpixel-image-optimiser') ? "" : __("Optimized",'shortpixel-image-optimiser') . ": " . $stat->Optimized . ", "
|
759 |
+
. __("Pending",'shortpixel-image-optimiser') . ": " . $stat->Pending . ", " . __("Waiting",'shortpixel-image-optimiser') . ": " . $stat->Waiting . ", "
|
760 |
+
. __("Failed",'shortpixel-image-optimiser') . ": " . $stat->Failed;
|
761 |
?>
|
762 |
<tr>
|
763 |
<td>
|
779 |
<td>
|
780 |
<input type="button" class="button remove-folder-button" data-value="<?php echo($folder->getPath()); ?>" title="<?php echo($action . " " . $folder->getPath()); ?>" value="<?php echo $action;?>">
|
781 |
<input type="button" style="display:none;" class="button button-alert recheck-folder-button" data-value="<?php echo($folder->getPath()); ?>"
|
782 |
+
title="<?php _e('Full folder refresh, check each file of the folder if it changed since it was optimized. Might take up to 1 min. for big folders.','shortpixel-image-optimiser');?>"
|
783 |
+
value="<?php _e('Refresh','shortpixel-image-optimiser');?>">
|
784 |
</td>
|
785 |
</tr>
|
786 |
<?php }?>
|
791 |
<input type="text" name="addCustomFolderView" id="addCustomFolderView" class="regular-text" value="<?php echo($addedFolder);?>" disabled style="width: 50em;max-width: 70%;">
|
792 |
<input type="hidden" name="addCustomFolder" id="addCustomFolder" value="<?php echo($addedFolder);?>"/>
|
793 |
<input type="hidden" id="customFolderBase" value="<?php echo $this->ctrl->getCustomFolderBase(); ?>">
|
794 |
+
<a class="button button-primary select-folder-button" title="<?php _e('Select the images folder on your server.','shortpixel-image-optimiser');?>" href="javascript:void(0);">
|
795 |
+
<?php _e('Select ...','shortpixel-image-optimiser');?>
|
796 |
</a>
|
797 |
+
<input type="submit" name="saveAdv" id="saveAdvAddFolder" class="button button-primary" title="<?php _e('Add Folder','shortpixel-image-optimiser');?>" value="<?php _e('Add Folder','shortpixel-image-optimiser');?>">
|
798 |
<p class="settings-info">
|
799 |
+
<?php _e('Use the Select... button to select site folders. ShortPixel will optimize images and PDFs from the specified folders and their subfolders. The optimization status for each image or PDF in these folders can be seen in the <a href="upload.php?page=wp-short-pixel-custom">Other Media list</a>, under the Media menu.','shortpixel-image-optimiser');?>
|
800 |
</p>
|
801 |
<div class="sp-folder-picker-shade">
|
802 |
<div class="sp-folder-picker-popup">
|
803 |
+
<div class="sp-folder-picker-title"><?php _e('Select the images folder','shortpixel-image-optimiser');?></div>
|
804 |
<div class="sp-folder-picker"></div>
|
805 |
+
<input type="button" class="button button-info select-folder-cancel" value="<?php _e('Cancel','shortpixel-image-optimiser');?>" style="margin-right: 30px;">
|
806 |
+
<input type="button" class="button button-primary select-folder" value="<?php _e('Select','shortpixel-image-optimiser');?>">
|
807 |
</div>
|
808 |
</div>
|
809 |
<script>
|
815 |
</tr>
|
816 |
<?php if($hasNextGen) { ?>
|
817 |
<tr>
|
818 |
+
<th scope="row"><label for="nextGen"><?php _e('Optimize NextGen galleries','shortpixel-image-optimiser');?></label></th>
|
819 |
<td>
|
820 |
+
<input name="nextGen" type="checkbox" id="nextGen" <?php echo( $includeNextGen );?>> <?php _e('Optimize NextGen galleries.','shortpixel-image-optimiser');?>
|
821 |
<p class="settings-info">
|
822 |
+
<?php _e('Check this to add all your current NextGen galleries to the custom folders list and to also have all the future NextGen galleries and images optimized automatically by ShortPixel.','shortpixel-image-optimiser');?>
|
823 |
</p>
|
824 |
</td>
|
825 |
</tr>
|
826 |
<?php } ?>
|
827 |
<tr>
|
828 |
+
<th scope="row"><label for="createWebp"><?php _e('WebP versions','shortpixel-image-optimiser');?></label></th>
|
829 |
<td>
|
830 |
+
<input name="createWebp" type="checkbox" id="createWebp" <?php echo( $createWebp );?>> <?php _e('Create also <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank">WebP versions</a> of the images <strong>for free</strong>.','shortpixel-image-optimiser');?>
|
831 |
<p class="settings-info">
|
832 |
+
<?php _e('WebP images can be up to three times smaller than PNGs and 25% smaller than JPGs. Choosing this option <strong>does not use up additional credits</strong>.','shortpixel-image-optimiser');?>
|
833 |
</p>
|
834 |
</td>
|
835 |
</tr>
|
836 |
<tr>
|
837 |
+
<th scope="row"><label for="optimizeRetina"><?php _e('Optimize Retina images','shortpixel-image-optimiser');?></label></th>
|
838 |
<td>
|
839 |
+
<input name="optimizeRetina" type="checkbox" id="optimizeRetina" <?php echo( $optimizeRetina );?>> <?php _e('Optimize also the Retina images (@2x) if they exist.','shortpixel-image-optimiser');?>
|
840 |
<p class="settings-info">
|
841 |
+
<?php _e('If you have a Retina plugin that generates Retina-specific images (@2x), ShortPixel can optimize them too, alongside the regular Media Library images and thumbnails. <a href="http://blog.shortpixel.com/how-to-use-optimized-retina-images-on-your-wordpress-site-for-best-user-experience-on-apple-devices/" target="_blank">More info.</a>','shortpixel-image-optimiser');?>
|
842 |
</p>
|
843 |
</td>
|
844 |
</tr>
|
845 |
<tr>
|
846 |
+
<th scope="row"><label for="authentication"><?php _e('HTTP AUTH credentials','shortpixel-image-optimiser');?></label></th>
|
847 |
<td>
|
848 |
+
<input name="siteAuthUser" type="text" id="siteAuthUser" value="<?php echo( $settings->siteAuthUser );?>" class="regular-text" placeholder="<?php _e('User','shortpixel-image-optimiser');?>"><br>
|
849 |
+
<input name="siteAuthPass" type="text" id="siteAuthPass" value="<?php echo( $settings->siteAuthPass );?>" class="regular-text" placeholder="<?php _e('Password','shortpixel-image-optimiser');?>">
|
850 |
<p class="settings-info">
|
851 |
+
<?php _e('Only fill in these fields if your site (front-end) is not publicly accessible and visitors need a user/pass to connect to it. If you don\'t know what is this then just <strong>leave the fields empty</strong>.','shortpixel-image-optimiser');?>
|
852 |
</p>
|
853 |
</td>
|
854 |
</tr>
|
855 |
<tr>
|
856 |
+
<th scope="row"><label for="resize"><?php _e('Process in front-end','shortpixel-image-optimiser');?></label></th>
|
857 |
<td>
|
858 |
+
<input name="frontBootstrap" type="checkbox" id="resize" <?php echo( $frontBootstrap );?>> <?php _e('Automatically optimize images added by users in front end.','shortpixel-image-optimiser');?>
|
859 |
<p class="settings-info">
|
860 |
+
<?php _e('Check this if you have users that add images or PDF documents from custom forms in the front-end. This could increase the load on your server if you have a lot of users simultaneously connected.','shortpixel-image-optimiser');?>
|
861 |
</p>
|
862 |
</td>
|
863 |
</tr>
|
864 |
<tr>
|
865 |
+
<th scope="row"><label for="autoMediaLibrary"><?php _e('Optimize media on upload','shortpixel-image-optimiser');?></label></th>
|
866 |
<td>
|
867 |
+
<input name="autoMediaLibrary" type="checkbox" id="autoMediaLibrary" <?php echo( $autoMediaLibrary );?>> <?php _e('Automatically optimize Media Library items after they are uploaded (recommended).','shortpixel-image-optimiser');?>
|
868 |
<p class="settings-info">
|
869 |
+
<?php _e('By default, ShortPixel will automatically optimize all the freshly uploaded image and PDF files. If you uncheck this you\'ll need to either run Bulk ShortPixel or go to Media Library (in list view) and click on the right side "Optimize now" button(s).','shortpixel-image-optimiser');?>
|
870 |
</p>
|
871 |
</td>
|
872 |
</tr>
|
873 |
</tbody>
|
874 |
</table>
|
875 |
<p class="submit">
|
876 |
+
<input type="submit" name="saveAdv" id="saveAdv" class="button button-primary" title="<?php _e('Save Changes','shortpixel-image-optimiser');?>" value="<?php _e('Save Changes','shortpixel-image-optimiser');?>">
|
877 |
+
<input type="submit" name="saveAdv" id="bulkAdvGo" class="button button-primary" title="<?php _e('Save and go to the Bulk Processing page','shortpixel-image-optimiser');?>" value="<?php _e('Save and Go to Bulk Process','shortpixel-image-optimiser');?>">
|
878 |
</p>
|
879 |
</div>
|
880 |
<script>
|
886 |
function displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
|
887 |
$remainingImages, $totalCallsMade, $fileCount, $backupFolderSize) { ?>
|
888 |
<a id="facts"></a>
|
889 |
+
<h3><?php _e('Your ShortPixel Stats','shortpixel-image-optimiser');?></h3>
|
890 |
<table class="form-table">
|
891 |
<tbody>
|
892 |
<tr>
|
893 |
+
<th scope="row"><label for="averagCompression"><?php _e('Average compression of your files:','shortpixel-image-optimiser');?></label></th>
|
894 |
<td><?php echo($averageCompression);?>%</td>
|
895 |
</tr>
|
896 |
<tr>
|
897 |
+
<th scope="row"><label for="savedSpace"><?php _e('Saved disk space by ShortPixel','shortpixel-image-optimiser');?></label></th>
|
898 |
<td><?php echo($savedSpace);?></td>
|
899 |
</tr>
|
900 |
<tr>
|
901 |
+
<th scope="row"><label for="savedBandwidth"><?php _e('Bandwith* saved with ShortPixel:','shortpixel-image-optimiser');?></label></th>
|
902 |
<td><?php echo($savedBandwidth);?></td>
|
903 |
</tr>
|
904 |
</tbody>
|
905 |
</table>
|
906 |
|
907 |
+
<p style="padding-top: 0px; color: #818181;" ><?php _e('* Saved bandwidth is calculated at 10,000 impressions/image','shortpixel-image-optimiser');?></p>
|
908 |
|
909 |
+
<h3><?php _e('Your ShortPixel Plan','shortpixel-image-optimiser');?></h3>
|
910 |
<table class="form-table">
|
911 |
<tbody>
|
912 |
<tr>
|
913 |
+
<th scope="row" bgcolor="#ffffff"><label for="apiQuota"><?php _e('Your ShortPixel plan','shortpixel-image-optimiser');?></label></th>
|
914 |
<td bgcolor="#ffffff">
|
915 |
+
<?php printf(__('%s/month, renews in %s days, on %s ( <a href="https://shortpixel.com/login/%s" target="_blank">Need More? See the options available</a> )','shortpixel-image-optimiser'),
|
916 |
$quotaData['APICallsQuota'], floor(30 + (strtotime($quotaData['APILastRenewalDate']) - time()) / 86400),
|
917 |
date('M d, Y', strtotime($quotaData['APILastRenewalDate']. ' + 30 days')), $this->ctrl->getApiKey());?><br/>
|
918 |
+
<?php printf(__('<a href="https://shortpixel.com/login/%s/tell-a-friend" target="_blank">Join our friend referral system</a> to win more credits. For each user that joins, you receive +100 images credits/month.','shortpixel-image-optimiser'),
|
919 |
$this->ctrl->getApiKey());?>
|
920 |
</td>
|
921 |
</tr>
|
922 |
<tr>
|
923 |
+
<th scope="row"><label for="usedQUota"><?php _e('One time credits:','shortpixel-image-optimiser');?></label></th>
|
924 |
<td><?php echo( number_format($quotaData['APICallsQuotaOneTimeNumeric']));?></td>
|
925 |
</tr>
|
926 |
<tr>
|
927 |
+
<th scope="row"><label for="usedQUota"><?php _e('Number of images processed this month:','shortpixel-image-optimiser');?></label></th>
|
928 |
<td><?php echo($totalCallsMade);?> (<a href="https://api.shortpixel.com/v2/report.php?key=<?php echo($this->ctrl->getApiKey());?>" target="_blank">
|
929 |
+
<?php _e('see report','shortpixel-image-optimiser');?>
|
930 |
</a>)
|
931 |
</td>
|
932 |
</tr>
|
933 |
<tr>
|
934 |
+
<th scope="row"><label for="remainingImages"><?php _e('Remaining** images in your plan:','shortpixel-image-optimiser');?></label></th>
|
935 |
+
<td><?php echo($remainingImages);?> <?php _e('images','shortpixel-image-optimiser');?></td>
|
936 |
</tr>
|
937 |
</tbody>
|
938 |
</table>
|
939 |
|
940 |
<p style="padding-top: 0px; color: #818181;" >
|
941 |
+
<?php printf(__('** Increase your image quota by <a href="https://shortpixel.com/login/%s" target="_blank">upgrading your ShortPixel plan.</a>','shortpixel-image-optimiser'),
|
942 |
$this->ctrl->getApiKey());?>
|
943 |
</p>
|
944 |
|
945 |
<table class="form-table">
|
946 |
<tbody>
|
947 |
<tr>
|
948 |
+
<th scope="row"><label for="totalFiles"><?php _e('Total number of processed files:','shortpixel-image-optimiser');?></label></th>
|
949 |
<td><?php echo($fileCount);?></td>
|
950 |
</tr>
|
951 |
<?php if($this->ctrl->backupImages()) { ?>
|
952 |
<tr>
|
953 |
+
<th scope="row"><label for="sizeBackup"><?php _e('Original images are stored in a backup folder. Your backup folder size is now:','shortpixel-image-optimiser');?></label></th>
|
954 |
<td>
|
955 |
<form action="" method="POST">
|
956 |
<?php echo($backupFolderSize);?>
|
957 |
+
<input type="submit" style="margin-left: 15px; vertical-align: middle;" class="button button-secondary" name="emptyBackup" value="<?php _e('Empty backups','shortpixel-image-optimiser');?>"/>
|
958 |
</form>
|
959 |
</td>
|
960 |
</tr>
|
967 |
<?php
|
968 |
}
|
969 |
|
970 |
+
public function renderCustomColumn($id, $data, $extended = false){ ?>
|
971 |
<div id='sp-msg-<?php echo($id);?>' class='column-wp-shortPixel'>
|
972 |
|
973 |
<?php switch($data['status']) {
|
974 |
case 'n/a': ?>
|
975 |
+
<?php _e('Optimization N/A','shortpixel-image-optimiser');?> <?php
|
976 |
break;
|
977 |
case 'notFound': ?>
|
978 |
+
<?php _e('Image does not exist.','shortpixel-image-optimiser');?> <?php
|
979 |
break;
|
980 |
case 'invalidKey':
|
981 |
if(defined("SHORTPIXEL_API_KEY")) { // multisite key - need to be validated on each site but it's not invalid
|
982 |
+
?> <?php _e('Please <a href="options-general.php?page=wp-shortpixel">go to Settings</a> to validate the API Key.','shortpixel-image-optimiser');?> <?php
|
983 |
} else {
|
984 |
+
?> <?php _e('Invalid API Key. <a href="options-general.php?page=wp-shortpixel">Check your Settings</a>','shortpixel-image-optimiser');?> <?php
|
985 |
}
|
986 |
break;
|
987 |
case 'quotaExceeded':
|
990 |
case 'optimizeNow':
|
991 |
if($data['showActions']) { ?>
|
992 |
<a class='button button-smaller button-primary' href="javascript:manualOptimization('<?php echo($id)?>')">
|
993 |
+
<?php _e('Optimize now','shortpixel-image-optimiser');?>
|
994 |
</a>
|
995 |
<?php }
|
996 |
echo($data['message']);
|
1000 |
break;
|
1001 |
case 'retry': ?>
|
1002 |
<?php echo($data['message'])?> <a class='button button-smaller button-primary' href="javascript:manualOptimization('<?php echo($id)?>')">
|
1003 |
+
<?php _e('Retry','shortpixel-image-optimiser');?>
|
1004 |
</a> <?php
|
1005 |
break;
|
1006 |
case 'pdfOptimized':
|
1007 |
case 'imgOptimized':
|
1008 |
+
$successText = $this->getSuccessText($data['percent'],$data['bonus'],$data['type'],$data['thumbsOpt'],$data['thumbsTotal'], $data['retinasOpt']);
|
1009 |
+
if($extended) {
|
1010 |
+
$successText .= ($data['webpCount'] ? "<br>+" . $data['webpCount'] . __(" WebP images", 'shortpixel-image-optimiser') : "")
|
1011 |
+
. "<br>EXIF: " . ($data['exifKept'] ? __('kept','shortpixel-image-optimiser') : __('removed','shortpixel-image-optimiser'))
|
1012 |
+
. "<br>" . __("Optimized on", 'shortpixel-image-optimiser') . ": " . $data['date'];
|
1013 |
+
}
|
1014 |
$this->renderListCell($id, $data['showActions'],
|
1015 |
+
!$data['thumbsOpt'] && $data['thumbsTotal'], $data['thumbsTotal'], $data['backup'], $data['type'], $successText);
|
1016 |
+
|
1017 |
break;
|
1018 |
}
|
1019 |
//die(var_dump($data));
|
1023 |
}
|
1024 |
|
1025 |
public function getSuccessText($percent, $bonus, $type, $thumbsOpt = 0, $thumbsTotal = 0, $retinasOpt = 0) {
|
1026 |
+
return ($percent ? __('Reduced by','shortpixel-image-optimiser') . ' <strong>' . $percent . '%</strong> ' : '')
|
1027 |
.(!$bonus ? ' ('.$type.')':'')
|
1028 |
.($bonus && $percent ? '<br>' : '')
|
1029 |
+
.($bonus ? __('Bonus processing','shortpixel-image-optimiser') : '')
|
1030 |
.($bonus ? ' ('.$type.')':'') . '<br>'
|
1031 |
.($thumbsOpt ? ( $thumbsTotal > $thumbsOpt
|
1032 |
+
? sprintf(__('+%s of %s thumbnails optimized','shortpixel-image-optimiser'),$thumbsOpt,$thumbsTotal)
|
1033 |
+
: sprintf(__('+%s thumbnails optimized','shortpixel-image-optimiser'),$thumbsOpt)) : '')
|
1034 |
+
.($retinasOpt ? '<br>' . sprintf(__('+%s Retina images optimized','shortpixel-image-optimiser') , $retinasOpt) : '' ) ;
|
1035 |
}
|
1036 |
|
1037 |
public function renderListCell($id, $showActions, $optimizeThumbs, $thumbsTotal, $backup, $type, $message) {
|
1039 |
<div class='sp-column-actions'>
|
1040 |
<?php if($optimizeThumbs) { ?>
|
1041 |
<a class='button button-smaller button-primary' href="javascript:optimizeThumbs(<?php echo($id)?>);">
|
1042 |
+
<?php printf(__('Optimize %s thumbnails','shortpixel-image-optimiser'),$thumbsTotal);?>
|
1043 |
</a>
|
1044 |
<?php }
|
1045 |
if($backup) {
|
1046 |
if($type) {
|
1047 |
$invType = $type == 'lossy' ? 'lossless' : 'lossy'; ?>
|
1048 |
<a class='button button-smaller' href="javascript:reoptimize('<?php echo($id)?>', '<?php echo($invType)?>');"
|
1049 |
+
title="<?php _e('Reoptimize from the backed-up image','shortpixel-image-optimiser');?>">
|
1050 |
+
<?php _e('Re-optimize','shortpixel-image-optimiser');?> <?php echo($invType)?>
|
1051 |
</a><?php
|
1052 |
} ?>
|
1053 |
<a class='button button-smaller' href="admin.php?action=shortpixel_restore_backup&attachment_ID=<?php echo($id)?>">
|
1054 |
+
<?php _e('Restore backup','shortpixel-image-optimiser');?>
|
1055 |
</a>
|
1056 |
<?php } ?>
|
1057 |
</div>
|
1064 |
public function getQuotaExceededHTML($message = '') {
|
1065 |
return "<div class='sp-column-actions' style='width:110px;'>
|
1066 |
<a class='button button-smaller button-primary' href='https://shortpixel.com/login/". $this->ctrl->getApiKey() . "' target='_blank'>"
|
1067 |
+
. __('Extend Quota','shortpixel-image-optimiser') .
|
1068 |
"</a>
|
1069 |
<a class='button button-smaller' href='admin.php?action=shortpixel_check_quota'>"
|
1070 |
+
. __('Check Quota','shortpixel-image-optimiser') .
|
1071 |
"</a></div>
|
1072 |
<div class='sp-column-info'>" . $message . " Quota Exceeded.</div>";
|
1073 |
}
|
class/wp-shortpixel-settings.php
CHANGED
@@ -116,31 +116,6 @@ class WPShortPixelSettings {
|
|
116 |
}
|
117 |
|
118 |
public static function debugResetOptions() {
|
119 |
-
/* delete_option('wp-short-pixel-apiKey');
|
120 |
-
delete_option('wp-short-pixel-verifiedKey');
|
121 |
-
delete_option('wp-short-pixel-compression');
|
122 |
-
delete_option('wp-short-process_thumbnails');
|
123 |
-
delete_option('wp-short-pixel_cmyk2rgb');
|
124 |
-
delete_option('wp-short-pixel-keep-exif');
|
125 |
-
delete_option('wp-short-backup_images');
|
126 |
-
delete_option('wp-short-pixel-view-mode');
|
127 |
-
update_option( 'wp-short-pixel-thumbnail-count', 0);
|
128 |
-
update_option( 'wp-short-pixel-files-under-5-percent', 0);
|
129 |
-
update_option( 'wp-short-pixel-savedSpace', 0);
|
130 |
-
delete_option( 'wp-short-pixel-averageCompression');
|
131 |
-
delete_option( 'wp-short-pixel-fileCount');
|
132 |
-
delete_option( 'wp-short-pixel-total-original');
|
133 |
-
delete_option( 'wp-short-pixel-total-optimized');
|
134 |
-
update_option( 'wp-short-pixel-api-retries', 0);//sometimes we need to retry processing/downloading a file multiple times
|
135 |
-
update_option( 'wp-short-pixel-quota-exceeded', 0);
|
136 |
-
delete_option( 'wp-short-pixel-protocol');
|
137 |
-
update_option( 'wp-short-pixel-bulk-ever-ran', 0);
|
138 |
-
delete_option('wp-short-pixel-priorityQueue');
|
139 |
-
delete_option( 'wp-short-pixel-resize-images');
|
140 |
-
delete_option( 'wp-short-pixel-resize-width');
|
141 |
-
delete_option( 'wp-short-pixel-resize-height');
|
142 |
-
delete_option( 'wp-short-pixel-dismissed-notices');
|
143 |
-
*/
|
144 |
foreach(self::$_optionsMap as $key => $val) {
|
145 |
delete_option($val);
|
146 |
}
|
116 |
}
|
117 |
|
118 |
public static function debugResetOptions() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
foreach(self::$_optionsMap as $key => $val) {
|
120 |
delete_option($val);
|
121 |
}
|
lang/{shortpixel-de_DE.mo → shortpixel-image-optimiser-de_DE.mo}
RENAMED
File without changes
|
lang/{shortpixel-de_DE.po → shortpixel-image-optimiser-de_DE.po}
RENAMED
File without changes
|
lang/{shortpixel-en_US.mo → shortpixel-image-optimiser-en_US.mo}
RENAMED
File without changes
|
lang/{shortpixel-en_US.po → shortpixel-image-optimiser-en_US.po}
RENAMED
File without changes
|
lang/{shortpixel-fr_FR.mo → shortpixel-image-optimiser-fr_FR.mo}
RENAMED
File without changes
|
lang/{shortpixel-fr_FR.po → shortpixel-image-optimiser-fr_FR.po}
RENAMED
File without changes
|
lang/{shortpixel-ro_RO.mo → shortpixel-image-optimiser-ro_RO.mo}
RENAMED
File without changes
|
lang/{shortpixel-ro_RO.po → shortpixel-image-optimiser-ro_RO.po}
RENAMED
File without changes
|
lang/{shortpixel.pot → shortpixel-image-optimiser.pot}
RENAMED
File without changes
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: image optimizer, image optimization, compress pdf, compress jpeg, compress
|
|
5 |
|
6 |
Requires at least: 3.2.0
|
7 |
Tested up to: 4.7
|
8 |
-
Stable tag: 4.2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -13,6 +13,8 @@ Speed up your website and boost your SEO by compressing old & new images and PDF
|
|
13 |
|
14 |
== Description ==
|
15 |
|
|
|
|
|
16 |
Increase your website's SEO ranking, number of visitors and ultimately your sales by optimizing any image or PDF document on your website.
|
17 |
ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a rel="friend" href="https://shortpixel.com" target="_blank">image optimization</a> plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background.
|
18 |
|
@@ -172,14 +174,30 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
|
|
172 |
|
173 |
1. Activate your API key in the plugin Settings. (Settings>ShortPixel)
|
174 |
|
175 |
-
2.
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
-
|
178 |
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
|
181 |
== Changelog ==
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
= 4.2.0 =
|
184 |
|
185 |
* multilanguage support
|
5 |
|
6 |
Requires at least: 3.2.0
|
7 |
Tested up to: 4.7
|
8 |
+
Stable tag: 4.2.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
**An easy to use, comprehensive, stable and frequently updated image optimization plugin supported by the friendly team that created it. :)**
|
17 |
+
|
18 |
Increase your website's SEO ranking, number of visitors and ultimately your sales by optimizing any image or PDF document on your website.
|
19 |
ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a rel="friend" href="https://shortpixel.com" target="_blank">image optimization</a> plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background.
|
20 |
|
174 |
|
175 |
1. Activate your API key in the plugin Settings. (Settings>ShortPixel)
|
176 |
|
177 |
+
2. Check out the main settings after API key activated. (Settings>ShortPixel)
|
178 |
+
|
179 |
+
3. Tweak it using Advanced settings. (Settings>ShortPixel)
|
180 |
+
|
181 |
+
4. Compress all your past images with one click. (Media>Bulk ShortPixel)
|
182 |
+
|
183 |
+
5. Check the progress of your bulk optimization process. (Media>Bulk ShortPixel)
|
184 |
|
185 |
+
6. Check your stats: number of processed files, saved space, average compression, saved bandwidth, remaining images. (Settings>ShortPixel)
|
186 |
|
187 |
+
7. Check images optimization status, restore or reoptimize the image. (Media>Library)
|
188 |
+
|
189 |
+
8. Check image optimization details. (Media>Library->Edit)
|
190 |
+
|
191 |
+
9. Check other optimized images status - themes or other plugins' images. (Media>Other Media)
|
192 |
|
193 |
== Changelog ==
|
194 |
|
195 |
+
= 4.2.1 =
|
196 |
+
|
197 |
+
* meta box in Media Library image editing form with informations about optimization status and results
|
198 |
+
* delete WebP images when image is deleted from Media Library
|
199 |
+
* change language domain to match the plugin slug in order to be automatically translatable on translate.wordpress.org.
|
200 |
+
|
201 |
= 4.2.0 =
|
202 |
|
203 |
* multilanguage support
|
res/js/short-pixel.js
CHANGED
@@ -287,6 +287,10 @@ var ShortPixel = function() {
|
|
287 |
function isCustomImageId(id) {
|
288 |
return id.substring(0,2) == "C-";
|
289 |
}
|
|
|
|
|
|
|
|
|
290 |
|
291 |
return {
|
292 |
setOptions : setOptions,
|
@@ -310,7 +314,8 @@ var ShortPixel = function() {
|
|
310 |
bulkHideLengthyMsg : bulkHideLengthyMsg,
|
311 |
bulkShowError : bulkShowError,
|
312 |
removeBulkMsg : removeBulkMsg,
|
313 |
-
isCustomImageId : isCustomImageId
|
|
|
314 |
}
|
315 |
}();
|
316 |
|
287 |
function isCustomImageId(id) {
|
288 |
return id.substring(0,2) == "C-";
|
289 |
}
|
290 |
+
|
291 |
+
function recheckQuota() {
|
292 |
+
window.location.href=window.location.href+(window.location.href.indexOf('?')>0?'&':'?')+'checkquota=1';
|
293 |
+
}
|
294 |
|
295 |
return {
|
296 |
setOptions : setOptions,
|
314 |
bulkHideLengthyMsg : bulkHideLengthyMsg,
|
315 |
bulkShowError : bulkShowError,
|
316 |
removeBulkMsg : removeBulkMsg,
|
317 |
+
isCustomImageId : isCustomImageId,
|
318 |
+
recheckQuota : recheckQuota
|
319 |
}
|
320 |
}();
|
321 |
|
shortpixel_api.php
CHANGED
@@ -142,7 +142,7 @@ class ShortPixelAPI {
|
|
142 |
|
143 |
$PATHs = self::CheckAndFixImagePaths($PATHs);//check for images to make sure they exist on disk
|
144 |
if ( $PATHs === false ) {
|
145 |
-
$msg = __('The file(s) do not exist on disk.','shortpixel');
|
146 |
$itemHandler->setError(self::ERR_FILE_NOT_FOUND, $msg );
|
147 |
return array("Status" => self::STATUS_SKIP, "Message" => $msg, "Silent" => $itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? 1 : 0);
|
148 |
}
|
@@ -157,18 +157,18 @@ class ShortPixelAPI {
|
|
157 |
{//keeps track of time
|
158 |
if ( $apiRetries > MAX_API_RETRIES )//we tried to process this time too many times, giving up...
|
159 |
{
|
160 |
-
$itemHandler->setError(self::ERR_TIMEOUT, __('Timed out while processing.','shortpixel'));
|
161 |
$itemHandler->incrementRetries();
|
162 |
$this->_settings->apiRetries = 0; //fai added to solve a bug?
|
163 |
return array("Status" => self::STATUS_SKIP,
|
164 |
-
"Message" => ($itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? __('Image ID','shortpixel') : __('Media ID','shortpixel'))
|
165 |
-
. ": " . $itemHandler->getId() .' ' . __('Skip this image, try the next one.','shortpixel'));
|
166 |
}
|
167 |
else
|
168 |
{//we'll try again next time user visits a page on admin panel
|
169 |
$apiRetries++;
|
170 |
$this->_settings->apiRetries = $apiRetries;
|
171 |
-
return array("Status" => self::STATUS_RETRY, "Message" => __('Timed out while processing.','shortpixel') . ' (pass '.$apiRetries.')',
|
172 |
"Count" => $apiRetries);
|
173 |
}
|
174 |
}
|
@@ -179,7 +179,7 @@ class ShortPixelAPI {
|
|
179 |
$response = $this->doRequests($URLs, true, $itemHandler, $compressionType);//send requests to API
|
180 |
|
181 |
if($response['response']['code'] != 200)//response <> 200 -> there was an error apparently?
|
182 |
-
return array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel'));
|
183 |
|
184 |
$APIresponse = $this->parseResponse($response);//get the actual response from API, its an array
|
185 |
|
@@ -212,10 +212,10 @@ class ShortPixelAPI {
|
|
212 |
elseif ( isset($APIresponse[0]->Status->Message) ) {
|
213 |
//return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed (" . $APIresponse[0]->Status->Message . "). REQ: " . json_encode($URLs));
|
214 |
$err = array("Status" => self::STATUS_FAIL, "Code" => (isset($APIresponse[0]->Status->Code) ? $APIresponse[0]->Status->Code : ""),
|
215 |
-
"Message" => __('There was an error and your request was not processed.','shortpixel')
|
216 |
. " (" . $APIresponse[0]->Status->Message . ")");
|
217 |
} else {
|
218 |
-
$err = array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel'));
|
219 |
}
|
220 |
|
221 |
$itemHandler->incrementRetries();
|
@@ -231,14 +231,14 @@ class ShortPixelAPI {
|
|
231 |
|
232 |
if(!isset($APIresponse['Status'])) {
|
233 |
WpShortPixel::log("API Response Status unfound : " . json_encode($APIresponse));
|
234 |
-
return array("Status" => self::STATUS_FAIL, "Message" => __('Unecognized API response. Please contact support.','shortpixel'));
|
235 |
} else {
|
236 |
switch($APIresponse['Status']->Code)
|
237 |
{
|
238 |
case -403:
|
239 |
@delete_option('bulkProcessingStatus');
|
240 |
$this->_settings->quotaExceeded = 1;
|
241 |
-
return array("Status" => self::STATUS_QUOTA_EXCEEDED, "Message" => __('Quota exceeded.','shortpixel'));
|
242 |
break;
|
243 |
}
|
244 |
|
@@ -327,7 +327,7 @@ class ShortPixelAPI {
|
|
327 |
@unlink($tempFile);
|
328 |
$returnMessage = array(
|
329 |
"Status" => self::STATUS_ERROR,
|
330 |
-
"Message" => __('Error downloading file','shortpixel') . " ({$fileData->$fileType}) " . $tempFile->get_error_message());
|
331 |
}
|
332 |
//check response so that download is OK
|
333 |
elseif( filesize($tempFile) != $correctFileSize) {
|
@@ -335,10 +335,10 @@ class ShortPixelAPI {
|
|
335 |
@unlink($tempFile);
|
336 |
$returnMessage = array(
|
337 |
"Status" => self::STATUS_ERROR,
|
338 |
-
"Message" => sprintf(__('Error downloading file - incorrect file size (downloaded: %s, correct: %s )','shortpixel'),$size, $correctFileSize));
|
339 |
}
|
340 |
elseif (!file_exists($tempFile)) {
|
341 |
-
$returnMessage = array("Status" => self::STATUS_ERROR, "Message" => __('Unable to locate downloaded file','shortpixel') . " " . $tempFile);
|
342 |
}
|
343 |
return $returnMessage;
|
344 |
}
|
@@ -400,7 +400,7 @@ class ShortPixelAPI {
|
|
400 |
$source = $PATHs; //array with final paths for these files
|
401 |
|
402 |
if( !file_exists(SP_BACKUP_FOLDER) && !@mkdir(SP_BACKUP_FOLDER, 0777, true) ) {//creates backup folder if it doesn't exist
|
403 |
-
return array("Status" => self::STATUS_FAIL, "Message" => __('Backup folder does not exist and it cannot be created','shortpixel'));
|
404 |
}
|
405 |
//create subdir in backup folder if needed
|
406 |
@mkdir( SP_BACKUP_FOLDER . '/' . $fullSubDir, 0777, true);
|
@@ -420,7 +420,7 @@ class ShortPixelAPI {
|
|
420 |
{
|
421 |
if ( !@copy($source[$fileID], $filePATH) )
|
422 |
{//file couldn't be saved in backup folder
|
423 |
-
$msg = sprintf(__('Cannot save file <i>%s</i> in backup directory','shortpixel'),self::MB_basename($source[$fileID]));
|
424 |
$itemHandler->setError(self::ERR_SAVE_BKP, $msg);
|
425 |
$itemHandler->incrementRetries();
|
426 |
return array("Status" => self::STATUS_FAIL, "Message" => $msg);
|
@@ -429,7 +429,7 @@ class ShortPixelAPI {
|
|
429 |
}
|
430 |
$NoBackup = true;
|
431 |
} else {//cannot write to the backup dir, return with an error
|
432 |
-
$msg = __('Cannot save file in backup directory','shortpixel');
|
433 |
$itemHandler->setError(self::ERR_SAVE_BKP, $msg);
|
434 |
$itemHandler->incrementRetries();
|
435 |
return array("Status" => self::STATUS_FAIL, "Message" => $msg);
|
@@ -490,7 +490,7 @@ class ShortPixelAPI {
|
|
490 |
|
491 |
if ( $writeFailed > 0 )//there was an error
|
492 |
{
|
493 |
-
$msg = sprintf(__('Optimized version of %s file(s) couldn\'t be updated.','shortpixel'),$writeFailed);
|
494 |
//#ShortPixelAPI::SaveMessageinMetadata($ID, 'Error: optimized version of ' . $writeFailed . ' file(s) couldn\'t be updated.');
|
495 |
$itemHandler->setError(self::ERR_SAVE, $msg);
|
496 |
$itemHandler->incrementRetries();
|
142 |
|
143 |
$PATHs = self::CheckAndFixImagePaths($PATHs);//check for images to make sure they exist on disk
|
144 |
if ( $PATHs === false ) {
|
145 |
+
$msg = __('The file(s) do not exist on disk.','shortpixel-image-optimiser');
|
146 |
$itemHandler->setError(self::ERR_FILE_NOT_FOUND, $msg );
|
147 |
return array("Status" => self::STATUS_SKIP, "Message" => $msg, "Silent" => $itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? 1 : 0);
|
148 |
}
|
157 |
{//keeps track of time
|
158 |
if ( $apiRetries > MAX_API_RETRIES )//we tried to process this time too many times, giving up...
|
159 |
{
|
160 |
+
$itemHandler->setError(self::ERR_TIMEOUT, __('Timed out while processing.','shortpixel-image-optimiser'));
|
161 |
$itemHandler->incrementRetries();
|
162 |
$this->_settings->apiRetries = 0; //fai added to solve a bug?
|
163 |
return array("Status" => self::STATUS_SKIP,
|
164 |
+
"Message" => ($itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? __('Image ID','shortpixel-image-optimiser') : __('Media ID','shortpixel-image-optimiser'))
|
165 |
+
. ": " . $itemHandler->getId() .' ' . __('Skip this image, try the next one.','shortpixel-image-optimiser'));
|
166 |
}
|
167 |
else
|
168 |
{//we'll try again next time user visits a page on admin panel
|
169 |
$apiRetries++;
|
170 |
$this->_settings->apiRetries = $apiRetries;
|
171 |
+
return array("Status" => self::STATUS_RETRY, "Message" => __('Timed out while processing.','shortpixel-image-optimiser') . ' (pass '.$apiRetries.')',
|
172 |
"Count" => $apiRetries);
|
173 |
}
|
174 |
}
|
179 |
$response = $this->doRequests($URLs, true, $itemHandler, $compressionType);//send requests to API
|
180 |
|
181 |
if($response['response']['code'] != 200)//response <> 200 -> there was an error apparently?
|
182 |
+
return array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser'));
|
183 |
|
184 |
$APIresponse = $this->parseResponse($response);//get the actual response from API, its an array
|
185 |
|
212 |
elseif ( isset($APIresponse[0]->Status->Message) ) {
|
213 |
//return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed (" . $APIresponse[0]->Status->Message . "). REQ: " . json_encode($URLs));
|
214 |
$err = array("Status" => self::STATUS_FAIL, "Code" => (isset($APIresponse[0]->Status->Code) ? $APIresponse[0]->Status->Code : ""),
|
215 |
+
"Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser')
|
216 |
. " (" . $APIresponse[0]->Status->Message . ")");
|
217 |
} else {
|
218 |
+
$err = array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser'));
|
219 |
}
|
220 |
|
221 |
$itemHandler->incrementRetries();
|
231 |
|
232 |
if(!isset($APIresponse['Status'])) {
|
233 |
WpShortPixel::log("API Response Status unfound : " . json_encode($APIresponse));
|
234 |
+
return array("Status" => self::STATUS_FAIL, "Message" => __('Unecognized API response. Please contact support.','shortpixel-image-optimiser'));
|
235 |
} else {
|
236 |
switch($APIresponse['Status']->Code)
|
237 |
{
|
238 |
case -403:
|
239 |
@delete_option('bulkProcessingStatus');
|
240 |
$this->_settings->quotaExceeded = 1;
|
241 |
+
return array("Status" => self::STATUS_QUOTA_EXCEEDED, "Message" => __('Quota exceeded.','shortpixel-image-optimiser'));
|
242 |
break;
|
243 |
}
|
244 |
|
327 |
@unlink($tempFile);
|
328 |
$returnMessage = array(
|
329 |
"Status" => self::STATUS_ERROR,
|
330 |
+
"Message" => __('Error downloading file','shortpixel-image-optimiser') . " ({$fileData->$fileType}) " . $tempFile->get_error_message());
|
331 |
}
|
332 |
//check response so that download is OK
|
333 |
elseif( filesize($tempFile) != $correctFileSize) {
|
335 |
@unlink($tempFile);
|
336 |
$returnMessage = array(
|
337 |
"Status" => self::STATUS_ERROR,
|
338 |
+
"Message" => sprintf(__('Error downloading file - incorrect file size (downloaded: %s, correct: %s )','shortpixel-image-optimiser'),$size, $correctFileSize));
|
339 |
}
|
340 |
elseif (!file_exists($tempFile)) {
|
341 |
+
$returnMessage = array("Status" => self::STATUS_ERROR, "Message" => __('Unable to locate downloaded file','shortpixel-image-optimiser') . " " . $tempFile);
|
342 |
}
|
343 |
return $returnMessage;
|
344 |
}
|
400 |
$source = $PATHs; //array with final paths for these files
|
401 |
|
402 |
if( !file_exists(SP_BACKUP_FOLDER) && !@mkdir(SP_BACKUP_FOLDER, 0777, true) ) {//creates backup folder if it doesn't exist
|
403 |
+
return array("Status" => self::STATUS_FAIL, "Message" => __('Backup folder does not exist and it cannot be created','shortpixel-image-optimiser'));
|
404 |
}
|
405 |
//create subdir in backup folder if needed
|
406 |
@mkdir( SP_BACKUP_FOLDER . '/' . $fullSubDir, 0777, true);
|
420 |
{
|
421 |
if ( !@copy($source[$fileID], $filePATH) )
|
422 |
{//file couldn't be saved in backup folder
|
423 |
+
$msg = sprintf(__('Cannot save file <i>%s</i> in backup directory','shortpixel-image-optimiser'),self::MB_basename($source[$fileID]));
|
424 |
$itemHandler->setError(self::ERR_SAVE_BKP, $msg);
|
425 |
$itemHandler->incrementRetries();
|
426 |
return array("Status" => self::STATUS_FAIL, "Message" => $msg);
|
429 |
}
|
430 |
$NoBackup = true;
|
431 |
} else {//cannot write to the backup dir, return with an error
|
432 |
+
$msg = __('Cannot save file in backup directory','shortpixel-image-optimiser');
|
433 |
$itemHandler->setError(self::ERR_SAVE_BKP, $msg);
|
434 |
$itemHandler->incrementRetries();
|
435 |
return array("Status" => self::STATUS_FAIL, "Message" => $msg);
|
490 |
|
491 |
if ( $writeFailed > 0 )//there was an error
|
492 |
{
|
493 |
+
$msg = sprintf(__('Optimized version of %s file(s) couldn\'t be updated.','shortpixel-image-optimiser'),$writeFailed);
|
494 |
//#ShortPixelAPI::SaveMessageinMetadata($ID, 'Error: optimized version of ' . $writeFailed . ' file(s) couldn\'t be updated.');
|
495 |
$itemHandler->setError(self::ERR_SAVE, $msg);
|
496 |
$itemHandler->incrementRetries();
|
wp-shortpixel.php
CHANGED
@@ -3,16 +3,18 @@
|
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
-
* Version: 4.2.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
define('SP_RESET_ON_ACTIVATE', false); //if true TODO set false
|
12 |
|
13 |
define('SP_AFFILIATE_CODE', '');
|
14 |
|
15 |
-
define('PLUGIN_VERSION', "4.2.
|
16 |
define('SP_MAX_TIMEOUT', 10);
|
17 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
18 |
define('SP_BACKUP', 'ShortpixelBackups');
|
@@ -62,7 +64,7 @@ class WPShortPixel {
|
|
62 |
}
|
63 |
|
64 |
require_once('wp-shortpixel-req.php');
|
65 |
-
load_plugin_textdomain('shortpixel', false, plugin_basename(dirname( __FILE__ )).'/lang');
|
66 |
|
67 |
$isAdminUser = current_user_can( 'manage_options' );
|
68 |
|
@@ -87,6 +89,11 @@ class WPShortPixel {
|
|
87 |
//Media custom column
|
88 |
add_filter( 'manage_media_columns', array( &$this, 'columns' ) );//add media library column header
|
89 |
add_action( 'manage_media_custom_column', array( &$this, 'generateCustomColumn' ), 10, 2 );//generate the media library column
|
|
|
|
|
|
|
|
|
|
|
90 |
//for NextGen
|
91 |
if($this->_settings->hasCustomFolders) {
|
92 |
add_filter( 'ngg_manage_images_columns', array( &$this, 'nggColumns' ) );
|
@@ -157,16 +164,16 @@ class WPShortPixel {
|
|
157 |
}
|
158 |
|
159 |
public function registerSettingsPage() {
|
160 |
-
add_options_page( __('ShortPixel Settings','shortpixel'), 'ShortPixel', 'manage_options', 'wp-shortpixel', array($this, 'renderSettingsMenu'));
|
161 |
}
|
162 |
|
163 |
function registerAdminPage( ) {
|
164 |
if($this->spMetaDao->hasFoldersTable() && count($this->spMetaDao->getFolders())) {
|
165 |
/*translators: title and menu name for the Other media page*/
|
166 |
-
add_media_page( __('Other Media Optimized by ShortPixel','shortpixel'), __('Other Media','shortpixel'), 'edit_others_posts', 'wp-short-pixel-custom', array( &$this, 'listCustomMedia' ) );
|
167 |
}
|
168 |
/*translators: title and menu name for the Bulk Processing page*/
|
169 |
-
add_media_page( __('ShortPixel Bulk Process','shortpixel'), __('Bulk ShortPixel','shortpixel'), 'edit_others_posts', 'wp-short-pixel-bulk', array( &$this, 'bulkProcess' ) );
|
170 |
}
|
171 |
|
172 |
public static function shortPixelActivatePlugin()//reset some params to avoid trouble for plugins that were activated/deactivated/activated
|
@@ -174,6 +181,10 @@ class WPShortPixel {
|
|
174 |
self::shortPixelDeactivatePlugin();
|
175 |
if(SP_RESET_ON_ACTIVATE === true && WP_DEBUG === true) { //force reset plugin counters, only on specific occasions and on test environments
|
176 |
WPShortPixelSettings::debugResetOptions();
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
WPShortPixelSettings::onActivate();
|
179 |
}
|
@@ -213,7 +224,7 @@ class WPShortPixel {
|
|
213 |
|
214 |
public function dismissMediaAlert() {
|
215 |
$this->_settings->mediaAlert = 1;
|
216 |
-
die(json_encode(array("Status" => 'success', "Message" => __('Media alert dismissed','shortpixel'))));
|
217 |
}
|
218 |
|
219 |
//set default move as "list". only set once, it won't try to set the default mode again.
|
@@ -266,23 +277,23 @@ class WPShortPixel {
|
|
266 |
|
267 |
wp_register_script('short-pixel.js', plugins_url('/res/js/short-pixel.js',__FILE__) );
|
268 |
$jsTranslation = array(
|
269 |
-
'optimizeWithSP' => __( 'Optimize with ShortPixel', 'shortpixel' ),
|
270 |
-
'changeMLToListMode' => __( 'In order to access the ShortPixel Optimization actions and info, please change to {0}List View{1}List View{2}Dismiss{3}', 'shortpixel' ),
|
271 |
-
'alertOnlyAppliesToNewImages' => __( 'This type of optimization will apply to new uploaded images.\nImages that were already processed will not be re-optimized unless you restart the bulk process.', 'shortpixel' ),
|
272 |
-
'areYouSureStopOptimizing' => __( 'Are you sure you want to stop optimizing the folder {0}?', 'shortpixel' ),
|
273 |
-
'reducedBy' => __( 'Reduced by', 'shortpixel' ),
|
274 |
-
'bonusProcessing' => __( 'Bonus processing', 'shortpixel' ),
|
275 |
-
'plusXthumbsOpt' => __( '+{0} thumbnails optimized', 'shortpixel' ),
|
276 |
-
'plusXretinasOpt' => __( '+{0} Retina images optimized', 'shortpixel' ),
|
277 |
-
'optXThumbs' => __( 'Optimize {0} thumbnails', 'shortpixel' ),
|
278 |
-
'reOptimizeAs' => __( 'Reoptimize {0}', 'shortpixel' ),
|
279 |
-
'restoreBackup' => __( 'Restore backup', 'shortpixel' ),
|
280 |
-
'getApiKey' => __( 'Get API Key', 'shortpixel' ),
|
281 |
-
'extendQuota' => __( 'Extend Quota', 'shortpixel' ),
|
282 |
-
'check__Quota' => __( 'Check Quota', 'shortpixel' ),
|
283 |
-
'retry' => __( 'Retry', 'shortpixel' ),
|
284 |
-
'thisContentNotProcessable' => __( 'This content is not processable.', 'shortpixel' ),
|
285 |
-
'imageWaitOptThumbs' => __( 'Image waiting to optimize thumbnails', 'shortpixel' )
|
286 |
);
|
287 |
wp_localize_script( 'short-pixel.js', '_spTr', $jsTranslation );
|
288 |
wp_enqueue_script('short-pixel.js');
|
@@ -295,7 +306,7 @@ class WPShortPixel {
|
|
295 |
|
296 |
$extraClasses = " shortpixel-hide";
|
297 |
/*translators: toolbar icon tooltip*/
|
298 |
-
$tooltip = __('ShortPixel optimizing...','shortpixel');
|
299 |
$icon = "shortpixel.png";
|
300 |
$successLink = $link = current_user_can( 'edit_others_posts')? 'upload.php?page=wp-short-pixel-bulk' : 'upload.php';
|
301 |
$blank = "";
|
@@ -305,7 +316,7 @@ class WPShortPixel {
|
|
305 |
if($this->_settings->quotaExceeded) {
|
306 |
$extraClasses = " shortpixel-alert shortpixel-quota-exceeded";
|
307 |
/*translators: toolbar icon tooltip*/
|
308 |
-
$tooltip = __('ShortPixel quota exceeded. Click for details.','shortpixel');
|
309 |
//$link = "http://shortpixel.com/login/" . $this->_settings->apiKey;
|
310 |
$link = "options-general.php?page=wp-shortpixel";
|
311 |
//$blank = '_blank';
|
@@ -345,7 +356,7 @@ class WPShortPixel {
|
|
345 |
$meta = wp_get_attachment_metadata($ID);
|
346 |
if( ( !isset($meta['ShortPixel']) //never touched by ShortPixel
|
347 |
|| (isset($meta['ShortPixel']['WaitingProcessing']) && $meta['ShortPixel']['WaitingProcessing'] == true))
|
348 |
-
&& (!isset($meta['ShortPixelImprovement']) || $meta['ShortPixelImprovement'] == __('Optimization N/A','shortpixel'))) {
|
349 |
$this->prioQ->push($ID);
|
350 |
$meta['ShortPixel']['WaitingProcessing'] = true;
|
351 |
wp_update_attachment_metadata($ID, $meta);
|
@@ -371,7 +382,7 @@ class WPShortPixel {
|
|
371 |
|
372 |
if( self::isProcessable($ID) == false )
|
373 |
{//not a file that we can process
|
374 |
-
$meta['ShortPixelImprovement'] = __('Optimization N/A','shortpixel');
|
375 |
return $meta;
|
376 |
}
|
377 |
else
|
@@ -565,7 +576,7 @@ class WPShortPixel {
|
|
565 |
$ids = $this->getFromPrioAndCheck();
|
566 |
$itemHandler = (count($ids) > 0 ? $ids[0] : null);
|
567 |
}
|
568 |
-
$response = array("Status" => ShortPixelAPI::STATUS_NO_KEY, "ImageID" => $itemHandler ? $itemHandler->getId() : "-1", "Message" => __('Missing API Key','shortpixel'));
|
569 |
$this->_settings->bulkLastStatus = $response;
|
570 |
die(json_encode($response));
|
571 |
}
|
@@ -615,7 +626,7 @@ class WPShortPixel {
|
|
615 |
$fileCount = $this->_settings->fileCount;
|
616 |
$response = array("Status" => self::BULK_EMPTY_QUEUE,
|
617 |
/* translators: console message Empty queue 1234 -> 1234 */
|
618 |
-
"Message" => __('Empty queue ','shortpixel') . $this->prioQ->getStartBulkId() . '->' . $this->prioQ->getStopBulkId(),
|
619 |
"BulkStatus" => ($this->prioQ->bulkRunning()
|
620 |
? "1" : ($this->prioQ->bulkPaused() ? "2" : "0")),
|
621 |
"AverageCompression" => $avg,
|
@@ -742,7 +753,7 @@ class WPShortPixel {
|
|
742 |
$itemHandler->deleteMeta(); //this deletes only the ShortPixel fields from meta, in case of WP Media library
|
743 |
}
|
744 |
$result["Status"] = ShortPixelAPI::STATUS_SKIP;
|
745 |
-
$result["Message"] .= __(' Retry limit reached. Skipping file ID ','shortpixel') . $itemId . ".";
|
746 |
$itemHandler->setError(ShortPixelAPI::ERR_INCORRECT_FILE_SIZE, $result["Message"] );
|
747 |
}
|
748 |
else {
|
@@ -837,7 +848,7 @@ class WPShortPixel {
|
|
837 |
return array("Status" => ShortPixelAPI::STATUS_SUCCESS, "message" => "");
|
838 |
}
|
839 |
}
|
840 |
-
return array("Status" => ShortPixelAPI::STATUS_FAIL, "message" => __('NextGen image not found','shortpixel'));
|
841 |
break;
|
842 |
case "C-":
|
843 |
throw new Exception("HandleManualOptimization for custom images not implemented");
|
@@ -1013,7 +1024,7 @@ class WPShortPixel {
|
|
1013 |
$this->prioQ->push($qID);
|
1014 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "Message" => "");
|
1015 |
} else {
|
1016 |
-
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "Message" => __('Could not restore from backup: ','shortpixel') . $qID);
|
1017 |
}
|
1018 |
} else {
|
1019 |
$ID = intval($qID);
|
@@ -1027,7 +1038,7 @@ class WPShortPixel {
|
|
1027 |
$this->sendToProcessing(new ShortPixelMetaFacade($ID), $compressionType == 'lossy' ? 1 : 0);
|
1028 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "Message" => "");
|
1029 |
} else {
|
1030 |
-
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "Message" => __('Could not restore from backup: ','shortpixel') . $ID);
|
1031 |
}
|
1032 |
}
|
1033 |
return $ret;
|
@@ -1046,7 +1057,7 @@ class WPShortPixel {
|
|
1046 |
$this->sendToProcessing(new ShortPixelMetaFacade($ID));
|
1047 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "message" => "");
|
1048 |
} else {
|
1049 |
-
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "message" => (isset($meta['ShortPixelImprovement']) ? __('No thumbnails to optimize for ID: ','shortpixel') : __('Please optimize image for ID: ','shortpixel')) . $ID);
|
1050 |
}
|
1051 |
die(json_encode($ret));
|
1052 |
}
|
@@ -1090,7 +1101,7 @@ class WPShortPixel {
|
|
1090 |
}
|
1091 |
}
|
1092 |
|
1093 |
-
public function checkQuotaAndAlert($quotaData = null) {
|
1094 |
if(!$quotaData) {
|
1095 |
$quotaData = $this->getQuotaInformation();
|
1096 |
}
|
@@ -1124,7 +1135,7 @@ class WPShortPixel {
|
|
1124 |
?><script>var shortPixelQuotaExceeded = 0;</script><?php
|
1125 |
}
|
1126 |
else {
|
1127 |
-
$this->view->displayQuotaExceededAlert($quotaData, self::getAverageCompression());
|
1128 |
?><script>var shortPixelQuotaExceeded = 1;</script><?php
|
1129 |
}
|
1130 |
return $quotaData;
|
@@ -1151,11 +1162,11 @@ class WPShortPixel {
|
|
1151 |
<div class="wrap shortpixel-other-media">
|
1152 |
<h2>
|
1153 |
<div style="float:right;">
|
1154 |
-
<a href="upload.php?page=wp-short-pixel-custom&refresh=1" id="refresh" class="button button-primary" title="<?php _e('Refresh custom folders content','shortpixel');?>">
|
1155 |
-
<?php _e('Refresh folders','shortpixel');?>
|
1156 |
</a>
|
1157 |
</div>
|
1158 |
-
<?php _e('Other Media optimized by ShortPixel','shortpixel');?>
|
1159 |
</h2>
|
1160 |
|
1161 |
<div id="poststuff">
|
@@ -1190,7 +1201,7 @@ class WPShortPixel {
|
|
1190 |
return;
|
1191 |
}
|
1192 |
|
1193 |
-
$quotaData = $this->checkQuotaAndAlert();
|
1194 |
if($this->_settings->quotaExceeded != 0) {
|
1195 |
return;
|
1196 |
}
|
@@ -1248,15 +1259,9 @@ class WPShortPixel {
|
|
1248 |
|| (0 + $pendingMeta > 0 && !$this->_settings->customBulkPaused && $this->prioQ->bulkRan())//bulk processing was started
|
1249 |
&& (!$this->prioQ->bulkPaused() || $this->_settings->skipToCustom)) //bulk not paused or if paused, user pressed Process Custom button
|
1250 |
{
|
1251 |
-
/*$percent = $this->prioQ->getBulkPercent();
|
1252 |
-
if(0 + $pendingMeta > 0) {
|
1253 |
-
$customMeta = $this->spMetaDao->getCustomMetaCount();
|
1254 |
-
$percent = round(($percent * $quotaData["totalFiles"] + ($customMeta - $pendingMeta) * 100) / ($quotaData["totalFiles"] + $customMeta));
|
1255 |
-
$percent = round($quotaData["totalProcessedFiles"] / $quotaData["totalFiles"]);
|
1256 |
-
}*/
|
1257 |
-
$percent = min(99, round($quotaData["totalProcessedFiles"] *100.0 / $quotaData["totalFiles"]));
|
1258 |
$msg = $this->bulkProgressMessage($this->prioQ->getDeltaBulkPercent(), $this->prioQ->getTimeRemaining());
|
1259 |
-
|
|
|
1260 |
($pendingMeta !== null ? ($this->prioQ->bulkRunning() ? 3 : 2) : 1));
|
1261 |
|
1262 |
} else
|
@@ -1271,7 +1276,8 @@ class WPShortPixel {
|
|
1271 |
|
1272 |
//average compression
|
1273 |
$averageCompression = self::getAverageCompression();
|
1274 |
-
$percent = $this->prioQ->bulkPaused() ?
|
|
|
1275 |
$this->view->displayBulkProcessingForm($quotaData, $thumbsProcessedCount, $under5PercentCount,
|
1276 |
$this->prioQ->bulkRan(), $averageCompression, $this->_settings->fileCount,
|
1277 |
self::formatBytes($this->_settings->savedSpace), $percent, $pendingMeta);
|
@@ -1279,6 +1285,14 @@ class WPShortPixel {
|
|
1279 |
}
|
1280 |
//end bulk processing
|
1281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1282 |
public function bulkProgressMessage($percent, $minutes) {
|
1283 |
$timeEst = "";
|
1284 |
self::log("bulkProgressMessage(): percent: " . $percent);
|
@@ -1331,7 +1345,7 @@ class WPShortPixel {
|
|
1331 |
|
1332 |
public function browseContent() {
|
1333 |
if ( !current_user_can( 'manage_options' ) ) {
|
1334 |
-
wp_die(__('You do not have sufficient permissions to access this page.','shortpixel'));
|
1335 |
}
|
1336 |
|
1337 |
$root = $this->getCustomFolderBase();
|
@@ -1356,7 +1370,7 @@ class WPShortPixel {
|
|
1356 |
|
1357 |
if($file == 'ShortpixelBackups') continue;
|
1358 |
|
1359 |
-
$htmlRel =
|
1360 |
$htmlName = htmlentities($file);
|
1361 |
$ext = preg_replace('/^.*\./', '', $file);
|
1362 |
|
@@ -1422,7 +1436,7 @@ class WPShortPixel {
|
|
1422 |
|
1423 |
public function renderSettingsMenu() {
|
1424 |
if ( !current_user_can( 'manage_options' ) ) {
|
1425 |
-
wp_die(__('You do not have sufficient permissions to access this page.','shortpixel'));
|
1426 |
}
|
1427 |
|
1428 |
wp_enqueue_style('sp-file-tree.css', plugins_url('/res/css/sp-file-tree.css',__FILE__) );
|
@@ -1460,14 +1474,14 @@ class WPShortPixel {
|
|
1460 |
$KeyLength = strlen($_POST['key']);
|
1461 |
|
1462 |
$notice = array("status" => "error",
|
1463 |
-
"msg" => sprintf(__("The key you provided has %s characters. The API key should have 20 characters, letters and numbers only.",'shortpixel'), $KeyLength)
|
1464 |
. "<BR> <b>"
|
1465 |
-
. __('Please check that the API key is the same as the one you received in your confirmation email.','shortpixel')
|
1466 |
. "</b><BR> "
|
1467 |
-
. __('If this problem persists, please contact us at ','shortpixel')
|
1468 |
. "<a href='mailto:help@shortpixel.com?Subject=API Key issues' target='_top'>help@shortpixel.com</a>"
|
1469 |
-
. __(' or ','shortpixel')
|
1470 |
-
. "<a href='https://shortpixel.com/contact' target='_blank'>" . __('here','shortpixel') . "</a>.");
|
1471 |
}
|
1472 |
else
|
1473 |
{
|
@@ -1484,20 +1498,20 @@ class WPShortPixel {
|
|
1484 |
//display notification
|
1485 |
$urlParts = explode("/", get_site_url());
|
1486 |
if( $validityData['DomainCheck'] == 'NOT Accessible'){
|
1487 |
-
$notice = array("status" => "warn", "msg" => __("API Key is valid but your site is not accessible from our servers. Please make sure that your server is accessible from the Internet before using the API or otherwise we won't be able to optimize them.",'shortpixel'));
|
1488 |
} else {
|
1489 |
if ( function_exists("is_multisite") && is_multisite() && !defined("SHORTPIXEL_API_KEY"))
|
1490 |
-
$notice = array("status" => "success", "msg" => __("API Key valid! <br>You seem to be running a multisite, please note that API Key can also be configured in wp-config.php like this:",'shortpixel')
|
1491 |
. "<BR> <b>define('SHORTPIXEL_API_KEY', '".$this->_settings->apiKey."');</b>");
|
1492 |
else
|
1493 |
-
$notice = array("status" => "success", "msg" => __('API Key valid
|
1494 |
}
|
1495 |
}
|
1496 |
$this->_settings->verifiedKey = true;
|
1497 |
//test that the "uploads" have the right rights and also we can create the backup dir for ShortPixel
|
1498 |
if ( !file_exists(SP_BACKUP_FOLDER) && !@mkdir(SP_BACKUP_FOLDER, 0777, true) )
|
1499 |
$notice = array("status" => "error",
|
1500 |
-
"msg" => sprintf(__("There is something preventing us to create a new folder for backing up your original files.<BR>Please make sure that folder <b>%s</b> has the necessary write and read rights.",'shortpixel'),
|
1501 |
WP_CONTENT_DIR . '/' . SP_UPLOADS_NAME ));
|
1502 |
} else {
|
1503 |
if(isset($_POST['validate'])) {
|
@@ -1526,8 +1540,8 @@ class WPShortPixel {
|
|
1526 |
$uploadDir = wp_upload_dir();
|
1527 |
$uploadPath = $uploadDir["basedir"];
|
1528 |
|
1529 |
-
if( isset($_POST['save']) && $_POST['save'] == __("Save and Go to Bulk Process",'shortpixel')
|
1530 |
-
|| isset($_POST['saveAdv']) && $_POST['saveAdv'] == __("Save and Go to Bulk Process",'shortpixel')) {
|
1531 |
wp_redirect("upload.php?page=wp-short-pixel-bulk");
|
1532 |
exit();
|
1533 |
}
|
@@ -1543,9 +1557,9 @@ class WPShortPixel {
|
|
1543 |
$this->_settings->includeNextGen = 0;
|
1544 |
}
|
1545 |
if(isset($_POST['addCustomFolder']) && strlen($_POST['addCustomFolder']) > 0) {
|
1546 |
-
$folderMsg = $this->spMetaDao->newFolderFromPath($_POST['addCustomFolder'], $uploadPath, $this->getCustomFolderBase());
|
1547 |
if(!$folderMsg) {
|
1548 |
-
$notice = array("status" => "success", "msg" => __('Folder added successfully.','shortpixel'));
|
1549 |
}
|
1550 |
$customFolders = $this->spMetaDao->getFolders();
|
1551 |
$this->_settings->hasCustomFolders = true;
|
@@ -1575,7 +1589,7 @@ class WPShortPixel {
|
|
1575 |
$this->emptyBackup();
|
1576 |
}
|
1577 |
|
1578 |
-
$quotaData = $this->checkQuotaAndAlert(isset($validityData) ? $validityData : null);
|
1579 |
|
1580 |
if($this->hasNextGen) {
|
1581 |
$ngg = array_map(array('ShortPixelNextGenAdapter','pathToAbsolute'), ShortPixelNextGenAdapter::getGalleries());
|
@@ -1588,10 +1602,7 @@ class WPShortPixel {
|
|
1588 |
}
|
1589 |
|
1590 |
$showApiKey = is_main_site() || (function_exists("is_multisite") && is_multisite() && !defined("SHORTPIXEL_API_KEY"));
|
1591 |
-
$editApiKey = (
|
1592 |
-
|| !function_exists("is_multisite")
|
1593 |
-
|| !is_multisite() )
|
1594 |
-
&& !defined("SHORTPIXEL_API_KEY");
|
1595 |
|
1596 |
if($this->_settings->verifiedKey) {
|
1597 |
$fileCount = number_format($this->_settings->fileCount);
|
@@ -1723,9 +1734,9 @@ class WPShortPixel {
|
|
1723 |
|
1724 |
$defaultData = array(
|
1725 |
"APIKeyValid" => false,
|
1726 |
-
"Message" => __('API Key could not be validated due to a connectivity error.<BR>Your firewall may be blocking us. Please contact your hosting provider and ask them to allow connections from your site to IP 176.9.106.46.<BR> If you still cannot validate your API Key after this, please <a href="https://shortpixel.com/contact" target="_blank">contact us</a> and we will try to help. ','shortpixel'),
|
1727 |
-
"APICallsMade" => __('Information unavailable. Please check your API key.','shortpixel'),
|
1728 |
-
"APICallsQuota" => __('Information unavailable. Please check your API key.','shortpixel'),
|
1729 |
"DomainCheck" => 'NOT Accessible');
|
1730 |
|
1731 |
if(is_object($response) && get_class($response) == 'WP_Error') {
|
@@ -1766,10 +1777,10 @@ class WPShortPixel {
|
|
1766 |
|
1767 |
return array(
|
1768 |
"APIKeyValid" => true,
|
1769 |
-
"APICallsMade" => number_format($data->APICallsMade) . __(' images','shortpixel'),
|
1770 |
-
"APICallsQuota" => number_format($data->APICallsQuota) . __(' images','shortpixel'),
|
1771 |
-
"APICallsMadeOneTime" => number_format($data->APICallsMadeOneTime) . __(' images','shortpixel'),
|
1772 |
-
"APICallsQuotaOneTime" => number_format($data->APICallsQuotaOneTime) . __(' images','shortpixel'),
|
1773 |
"APICallsMadeNumeric" => $data->APICallsMade,
|
1774 |
"APICallsQuotaNumeric" => $data->APICallsQuota,
|
1775 |
"APICallsMadeOneTimeNumeric" => $data->APICallsMadeOneTime,
|
@@ -1780,7 +1791,7 @@ class WPShortPixel {
|
|
1780 |
);
|
1781 |
}
|
1782 |
|
1783 |
-
public function generateCustomColumn( $column_name, $id ) {
|
1784 |
if( 'wp-shortPixel' == $column_name ) {
|
1785 |
|
1786 |
$data = wp_get_attachment_metadata($id);
|
@@ -1792,7 +1803,7 @@ class WPShortPixel {
|
|
1792 |
|
1793 |
if($invalidKey) { //invalid key - let the user first register and only then
|
1794 |
$renderData['status'] = 'invalidKey';
|
1795 |
-
$this->view->renderCustomColumn($id, $renderData);
|
1796 |
return;
|
1797 |
}
|
1798 |
|
@@ -1800,12 +1811,12 @@ class WPShortPixel {
|
|
1800 |
elseif (empty($data)) { //TODO asta devine if si decomentam returnurile
|
1801 |
if($fileExtension == "pdf") {
|
1802 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'optimizeNow';
|
1803 |
-
$renderData['message'] = __('PDF not processed.','shortpixel');
|
1804 |
}
|
1805 |
else { //Optimization N/A
|
1806 |
$renderData['status'] = 'n/a';
|
1807 |
}
|
1808 |
-
$this->view->renderCustomColumn($id, $renderData);
|
1809 |
return;
|
1810 |
}
|
1811 |
|
@@ -1823,19 +1834,34 @@ class WPShortPixel {
|
|
1823 |
$renderData['thumbsTotal'] = $sizes;
|
1824 |
$renderData['thumbsOpt'] = isset($data['ShortPixel']['thumbsOpt']) ? $data['ShortPixel']['thumbsOpt'] : $sizes;
|
1825 |
$renderData['retinasOpt'] = isset($data['ShortPixel']['retinasOpt']) ? $data['ShortPixel']['retinasOpt'] : null;
|
|
|
|
|
1826 |
$renderData['quotaExceeded'] = $quotaExceeded;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1827 |
}
|
1828 |
-
elseif($data['ShortPixelImprovement'] == __('Optimization N/A','shortpixel')) { //We don't optimize this
|
1829 |
$renderData['status'] = 'n/a';
|
1830 |
}
|
1831 |
elseif(isset($meta['ShortPixel']['BulkProcessing'])) { //Scheduled to bulk.
|
1832 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'optimizeNow';
|
1833 |
$renderData['message'] = 'Waiting for bulk processing.';
|
1834 |
}
|
1835 |
-
elseif( trim(strip_tags($data['ShortPixelImprovement'])) == __("Cannot write optimized file",'shortpixel') ) {
|
1836 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'retry';
|
1837 |
-
$renderData['message'] = __("Cannot write optimized file",'shortpixel') . " - <a href='https://shortpixel.com/faq#cannot-write-optimized-file' target='_blank'>"
|
1838 |
-
. __("Why?",'shortpixel') . "</a>";
|
1839 |
}
|
1840 |
elseif( strlen(trim(strip_tags($data['ShortPixelImprovement']))) > 0 ) {
|
1841 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'retry';
|
@@ -1843,11 +1869,11 @@ class WPShortPixel {
|
|
1843 |
}
|
1844 |
elseif(isset($data['ShortPixel']['NoFileOnDisk'])) {
|
1845 |
$renderData['status'] = 'notFound';
|
1846 |
-
$renderData['message'] = __('Image does not exist','shortpixel');
|
1847 |
}
|
1848 |
elseif(isset($data['ShortPixel']['WaitingProcessing'])) {
|
1849 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'retry';
|
1850 |
-
$renderData['message'] = "<img src=\"" . plugins_url( 'res/img/loading.gif', __FILE__ ) . "\" class='sp-loading-small'> " . __("Image waiting to be processed.",'shortpixel');
|
1851 |
if($id > $this->prioQ->getFlagBulkId() || !$this->prioQ->bulkRunning()) $this->prioQ->push($id); //should be there but just to make sure
|
1852 |
}
|
1853 |
else { //finally
|
@@ -1857,7 +1883,38 @@ class WPShortPixel {
|
|
1857 |
$renderData['message'] = ($fileExtension == "pdf" ? 'PDF' : 'Image') . ' not processed.';
|
1858 |
}
|
1859 |
|
1860 |
-
$this->view->renderCustomColumn($id, $renderData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1861 |
}
|
1862 |
}
|
1863 |
|
@@ -1865,7 +1922,7 @@ class WPShortPixel {
|
|
1865 |
$defaults['wp-shortPixel'] = 'ShortPixel Compression';
|
1866 |
if(current_user_can( 'manage_options' )) {
|
1867 |
$defaults['wp-shortPixel'] .= ' <a href="options-general.php?page=wp-shortpixel#stats" title="'
|
1868 |
-
. __('ShortPixel Statistics','shortpixel') . '"><span class="dashicons dashicons-dashboard"></span></a>';
|
1869 |
}
|
1870 |
return $defaults;
|
1871 |
}
|
@@ -1883,7 +1940,7 @@ class WPShortPixel {
|
|
1883 |
}
|
1884 |
|
1885 |
public function nggColumnHeader( $default ) {
|
1886 |
-
return __('ShortPixel Compression','shortpixel');
|
1887 |
}
|
1888 |
|
1889 |
public function nggColumnContent( $unknown, $picture ) {
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
+
* Version: 4.2.1
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
+
* Text Domain: shortpixel-image-optimiser
|
10 |
+
* Domain Path: /lang
|
11 |
*/
|
12 |
|
13 |
define('SP_RESET_ON_ACTIVATE', false); //if true TODO set false
|
14 |
|
15 |
define('SP_AFFILIATE_CODE', '');
|
16 |
|
17 |
+
define('PLUGIN_VERSION', "4.2.1");
|
18 |
define('SP_MAX_TIMEOUT', 10);
|
19 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
20 |
define('SP_BACKUP', 'ShortpixelBackups');
|
64 |
}
|
65 |
|
66 |
require_once('wp-shortpixel-req.php');
|
67 |
+
load_plugin_textdomain('shortpixel-image-optimiser', false, plugin_basename(dirname( __FILE__ )).'/lang');
|
68 |
|
69 |
$isAdminUser = current_user_can( 'manage_options' );
|
70 |
|
89 |
//Media custom column
|
90 |
add_filter( 'manage_media_columns', array( &$this, 'columns' ) );//add media library column header
|
91 |
add_action( 'manage_media_custom_column', array( &$this, 'generateCustomColumn' ), 10, 2 );//generate the media library column
|
92 |
+
//Edit media meta box
|
93 |
+
add_action( 'add_meta_boxes', array( &$this, 'shortpixelInfoBox') );
|
94 |
+
//for cleaning up the WebP images when an attachment is deleted
|
95 |
+
add_action( 'delete_attachment', array( &$this, 'onDeleteImage') );
|
96 |
+
|
97 |
//for NextGen
|
98 |
if($this->_settings->hasCustomFolders) {
|
99 |
add_filter( 'ngg_manage_images_columns', array( &$this, 'nggColumns' ) );
|
164 |
}
|
165 |
|
166 |
public function registerSettingsPage() {
|
167 |
+
add_options_page( __('ShortPixel Settings','shortpixel-image-optimiser'), 'ShortPixel', 'manage_options', 'wp-shortpixel', array($this, 'renderSettingsMenu'));
|
168 |
}
|
169 |
|
170 |
function registerAdminPage( ) {
|
171 |
if($this->spMetaDao->hasFoldersTable() && count($this->spMetaDao->getFolders())) {
|
172 |
/*translators: title and menu name for the Other media page*/
|
173 |
+
add_media_page( __('Other Media Optimized by ShortPixel','shortpixel-image-optimiser'), __('Other Media','shortpixel-image-optimiser'), 'edit_others_posts', 'wp-short-pixel-custom', array( &$this, 'listCustomMedia' ) );
|
174 |
}
|
175 |
/*translators: title and menu name for the Bulk Processing page*/
|
176 |
+
add_media_page( __('ShortPixel Bulk Process','shortpixel-image-optimiser'), __('Bulk ShortPixel','shortpixel-image-optimiser'), 'edit_others_posts', 'wp-short-pixel-bulk', array( &$this, 'bulkProcess' ) );
|
177 |
}
|
178 |
|
179 |
public static function shortPixelActivatePlugin()//reset some params to avoid trouble for plugins that were activated/deactivated/activated
|
181 |
self::shortPixelDeactivatePlugin();
|
182 |
if(SP_RESET_ON_ACTIVATE === true && WP_DEBUG === true) { //force reset plugin counters, only on specific occasions and on test environments
|
183 |
WPShortPixelSettings::debugResetOptions();
|
184 |
+
|
185 |
+
$settings = new WPShortPixelSettings();
|
186 |
+
$spMetaDao = new ShortPixelCustomMetaDao(new WpShortPixelDb(), $settings->hasCustomFolders);
|
187 |
+
$spMetaDao->dropTables();
|
188 |
}
|
189 |
WPShortPixelSettings::onActivate();
|
190 |
}
|
224 |
|
225 |
public function dismissMediaAlert() {
|
226 |
$this->_settings->mediaAlert = 1;
|
227 |
+
die(json_encode(array("Status" => 'success', "Message" => __('Media alert dismissed','shortpixel-image-optimiser'))));
|
228 |
}
|
229 |
|
230 |
//set default move as "list". only set once, it won't try to set the default mode again.
|
277 |
|
278 |
wp_register_script('short-pixel.js', plugins_url('/res/js/short-pixel.js',__FILE__) );
|
279 |
$jsTranslation = array(
|
280 |
+
'optimizeWithSP' => __( 'Optimize with ShortPixel', 'shortpixel-image-optimiser' ),
|
281 |
+
'changeMLToListMode' => __( 'In order to access the ShortPixel Optimization actions and info, please change to {0}List View{1}List View{2}Dismiss{3}', 'shortpixel-image-optimiser' ),
|
282 |
+
'alertOnlyAppliesToNewImages' => __( 'This type of optimization will apply to new uploaded images.\nImages that were already processed will not be re-optimized unless you restart the bulk process.', 'shortpixel-image-optimiser' ),
|
283 |
+
'areYouSureStopOptimizing' => __( 'Are you sure you want to stop optimizing the folder {0}?', 'shortpixel-image-optimiser' ),
|
284 |
+
'reducedBy' => __( 'Reduced by', 'shortpixel-image-optimiser' ),
|
285 |
+
'bonusProcessing' => __( 'Bonus processing', 'shortpixel-image-optimiser' ),
|
286 |
+
'plusXthumbsOpt' => __( '+{0} thumbnails optimized', 'shortpixel-image-optimiser' ),
|
287 |
+
'plusXretinasOpt' => __( '+{0} Retina images optimized', 'shortpixel-image-optimiser' ),
|
288 |
+
'optXThumbs' => __( 'Optimize {0} thumbnails', 'shortpixel-image-optimiser' ),
|
289 |
+
'reOptimizeAs' => __( 'Reoptimize {0}', 'shortpixel-image-optimiser' ),
|
290 |
+
'restoreBackup' => __( 'Restore backup', 'shortpixel-image-optimiser' ),
|
291 |
+
'getApiKey' => __( 'Get API Key', 'shortpixel-image-optimiser' ),
|
292 |
+
'extendQuota' => __( 'Extend Quota', 'shortpixel-image-optimiser' ),
|
293 |
+
'check__Quota' => __( 'Check Quota', 'shortpixel-image-optimiser' ),
|
294 |
+
'retry' => __( 'Retry', 'shortpixel-image-optimiser' ),
|
295 |
+
'thisContentNotProcessable' => __( 'This content is not processable.', 'shortpixel-image-optimiser' ),
|
296 |
+
'imageWaitOptThumbs' => __( 'Image waiting to optimize thumbnails', 'shortpixel-image-optimiser' )
|
297 |
);
|
298 |
wp_localize_script( 'short-pixel.js', '_spTr', $jsTranslation );
|
299 |
wp_enqueue_script('short-pixel.js');
|
306 |
|
307 |
$extraClasses = " shortpixel-hide";
|
308 |
/*translators: toolbar icon tooltip*/
|
309 |
+
$tooltip = __('ShortPixel optimizing...','shortpixel-image-optimiser');
|
310 |
$icon = "shortpixel.png";
|
311 |
$successLink = $link = current_user_can( 'edit_others_posts')? 'upload.php?page=wp-short-pixel-bulk' : 'upload.php';
|
312 |
$blank = "";
|
316 |
if($this->_settings->quotaExceeded) {
|
317 |
$extraClasses = " shortpixel-alert shortpixel-quota-exceeded";
|
318 |
/*translators: toolbar icon tooltip*/
|
319 |
+
$tooltip = __('ShortPixel quota exceeded. Click for details.','shortpixel-image-optimiser');
|
320 |
//$link = "http://shortpixel.com/login/" . $this->_settings->apiKey;
|
321 |
$link = "options-general.php?page=wp-shortpixel";
|
322 |
//$blank = '_blank';
|
356 |
$meta = wp_get_attachment_metadata($ID);
|
357 |
if( ( !isset($meta['ShortPixel']) //never touched by ShortPixel
|
358 |
|| (isset($meta['ShortPixel']['WaitingProcessing']) && $meta['ShortPixel']['WaitingProcessing'] == true))
|
359 |
+
&& (!isset($meta['ShortPixelImprovement']) || $meta['ShortPixelImprovement'] == __('Optimization N/A','shortpixel-image-optimiser'))) {
|
360 |
$this->prioQ->push($ID);
|
361 |
$meta['ShortPixel']['WaitingProcessing'] = true;
|
362 |
wp_update_attachment_metadata($ID, $meta);
|
382 |
|
383 |
if( self::isProcessable($ID) == false )
|
384 |
{//not a file that we can process
|
385 |
+
$meta['ShortPixelImprovement'] = __('Optimization N/A','shortpixel-image-optimiser');
|
386 |
return $meta;
|
387 |
}
|
388 |
else
|
576 |
$ids = $this->getFromPrioAndCheck();
|
577 |
$itemHandler = (count($ids) > 0 ? $ids[0] : null);
|
578 |
}
|
579 |
+
$response = array("Status" => ShortPixelAPI::STATUS_NO_KEY, "ImageID" => $itemHandler ? $itemHandler->getId() : "-1", "Message" => __('Missing API Key','shortpixel-image-optimiser'));
|
580 |
$this->_settings->bulkLastStatus = $response;
|
581 |
die(json_encode($response));
|
582 |
}
|
626 |
$fileCount = $this->_settings->fileCount;
|
627 |
$response = array("Status" => self::BULK_EMPTY_QUEUE,
|
628 |
/* translators: console message Empty queue 1234 -> 1234 */
|
629 |
+
"Message" => __('Empty queue ','shortpixel-image-optimiser') . $this->prioQ->getStartBulkId() . '->' . $this->prioQ->getStopBulkId(),
|
630 |
"BulkStatus" => ($this->prioQ->bulkRunning()
|
631 |
? "1" : ($this->prioQ->bulkPaused() ? "2" : "0")),
|
632 |
"AverageCompression" => $avg,
|
753 |
$itemHandler->deleteMeta(); //this deletes only the ShortPixel fields from meta, in case of WP Media library
|
754 |
}
|
755 |
$result["Status"] = ShortPixelAPI::STATUS_SKIP;
|
756 |
+
$result["Message"] .= __(' Retry limit reached. Skipping file ID ','shortpixel-image-optimiser') . $itemId . ".";
|
757 |
$itemHandler->setError(ShortPixelAPI::ERR_INCORRECT_FILE_SIZE, $result["Message"] );
|
758 |
}
|
759 |
else {
|
848 |
return array("Status" => ShortPixelAPI::STATUS_SUCCESS, "message" => "");
|
849 |
}
|
850 |
}
|
851 |
+
return array("Status" => ShortPixelAPI::STATUS_FAIL, "message" => __('NextGen image not found','shortpixel-image-optimiser'));
|
852 |
break;
|
853 |
case "C-":
|
854 |
throw new Exception("HandleManualOptimization for custom images not implemented");
|
1024 |
$this->prioQ->push($qID);
|
1025 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "Message" => "");
|
1026 |
} else {
|
1027 |
+
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "Message" => __('Could not restore from backup: ','shortpixel-image-optimiser') . $qID);
|
1028 |
}
|
1029 |
} else {
|
1030 |
$ID = intval($qID);
|
1038 |
$this->sendToProcessing(new ShortPixelMetaFacade($ID), $compressionType == 'lossy' ? 1 : 0);
|
1039 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "Message" => "");
|
1040 |
} else {
|
1041 |
+
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "Message" => __('Could not restore from backup: ','shortpixel-image-optimiser') . $ID);
|
1042 |
}
|
1043 |
}
|
1044 |
return $ret;
|
1057 |
$this->sendToProcessing(new ShortPixelMetaFacade($ID));
|
1058 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "message" => "");
|
1059 |
} else {
|
1060 |
+
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "message" => (isset($meta['ShortPixelImprovement']) ? __('No thumbnails to optimize for ID: ','shortpixel-image-optimiser') : __('Please optimize image for ID: ','shortpixel-image-optimiser')) . $ID);
|
1061 |
}
|
1062 |
die(json_encode($ret));
|
1063 |
}
|
1101 |
}
|
1102 |
}
|
1103 |
|
1104 |
+
public function checkQuotaAndAlert($quotaData = null, $recheck = false) {
|
1105 |
if(!$quotaData) {
|
1106 |
$quotaData = $this->getQuotaInformation();
|
1107 |
}
|
1135 |
?><script>var shortPixelQuotaExceeded = 0;</script><?php
|
1136 |
}
|
1137 |
else {
|
1138 |
+
$this->view->displayQuotaExceededAlert($quotaData, self::getAverageCompression(), $recheck);
|
1139 |
?><script>var shortPixelQuotaExceeded = 1;</script><?php
|
1140 |
}
|
1141 |
return $quotaData;
|
1162 |
<div class="wrap shortpixel-other-media">
|
1163 |
<h2>
|
1164 |
<div style="float:right;">
|
1165 |
+
<a href="upload.php?page=wp-short-pixel-custom&refresh=1" id="refresh" class="button button-primary" title="<?php _e('Refresh custom folders content','shortpixel-image-optimiser');?>">
|
1166 |
+
<?php _e('Refresh folders','shortpixel-image-optimiser');?>
|
1167 |
</a>
|
1168 |
</div>
|
1169 |
+
<?php _e('Other Media optimized by ShortPixel','shortpixel-image-optimiser');?>
|
1170 |
</h2>
|
1171 |
|
1172 |
<div id="poststuff">
|
1201 |
return;
|
1202 |
}
|
1203 |
|
1204 |
+
$quotaData = $this->checkQuotaAndAlert(null, isset($_GET['checkquota']));
|
1205 |
if($this->_settings->quotaExceeded != 0) {
|
1206 |
return;
|
1207 |
}
|
1259 |
|| (0 + $pendingMeta > 0 && !$this->_settings->customBulkPaused && $this->prioQ->bulkRan())//bulk processing was started
|
1260 |
&& (!$this->prioQ->bulkPaused() || $this->_settings->skipToCustom)) //bulk not paused or if paused, user pressed Process Custom button
|
1261 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1262 |
$msg = $this->bulkProgressMessage($this->prioQ->getDeltaBulkPercent(), $this->prioQ->getTimeRemaining());
|
1263 |
+
|
1264 |
+
$this->view->displayBulkProcessingRunning($this->getPercent($quotaData), $msg, $quotaData['APICallsRemaining'], $this->getAverageCompression(),
|
1265 |
($pendingMeta !== null ? ($this->prioQ->bulkRunning() ? 3 : 2) : 1));
|
1266 |
|
1267 |
} else
|
1276 |
|
1277 |
//average compression
|
1278 |
$averageCompression = self::getAverageCompression();
|
1279 |
+
$percent = $this->prioQ->bulkPaused() ? $this->getPercent($quotaData) : false;
|
1280 |
+
|
1281 |
$this->view->displayBulkProcessingForm($quotaData, $thumbsProcessedCount, $under5PercentCount,
|
1282 |
$this->prioQ->bulkRan(), $averageCompression, $this->_settings->fileCount,
|
1283 |
self::formatBytes($this->_settings->savedSpace), $percent, $pendingMeta);
|
1285 |
}
|
1286 |
//end bulk processing
|
1287 |
|
1288 |
+
public function getPercent($quotaData) {
|
1289 |
+
if($this->_settings->processThumbnails) {
|
1290 |
+
return min(99, round($quotaData["totalProcessedFiles"] *100.0 / $quotaData["totalFiles"]));
|
1291 |
+
} else {
|
1292 |
+
return min(99, round($quotaData["mainProcessedFiles"] *100.0 / $quotaData["mainFiles"]));
|
1293 |
+
}
|
1294 |
+
}
|
1295 |
+
|
1296 |
public function bulkProgressMessage($percent, $minutes) {
|
1297 |
$timeEst = "";
|
1298 |
self::log("bulkProgressMessage(): percent: " . $percent);
|
1345 |
|
1346 |
public function browseContent() {
|
1347 |
if ( !current_user_can( 'manage_options' ) ) {
|
1348 |
+
wp_die(__('You do not have sufficient permissions to access this page.','shortpixel-image-optimiser'));
|
1349 |
}
|
1350 |
|
1351 |
$root = $this->getCustomFolderBase();
|
1370 |
|
1371 |
if($file == 'ShortpixelBackups') continue;
|
1372 |
|
1373 |
+
$htmlRel = str_replace("'", "'", $returnDir . $file);
|
1374 |
$htmlName = htmlentities($file);
|
1375 |
$ext = preg_replace('/^.*\./', '', $file);
|
1376 |
|
1436 |
|
1437 |
public function renderSettingsMenu() {
|
1438 |
if ( !current_user_can( 'manage_options' ) ) {
|
1439 |
+
wp_die(__('You do not have sufficient permissions to access this page.','shortpixel-image-optimiser'));
|
1440 |
}
|
1441 |
|
1442 |
wp_enqueue_style('sp-file-tree.css', plugins_url('/res/css/sp-file-tree.css',__FILE__) );
|
1474 |
$KeyLength = strlen($_POST['key']);
|
1475 |
|
1476 |
$notice = array("status" => "error",
|
1477 |
+
"msg" => sprintf(__("The key you provided has %s characters. The API key should have 20 characters, letters and numbers only.",'shortpixel-image-optimiser'), $KeyLength)
|
1478 |
. "<BR> <b>"
|
1479 |
+
. __('Please check that the API key is the same as the one you received in your confirmation email.','shortpixel-image-optimiser')
|
1480 |
. "</b><BR> "
|
1481 |
+
. __('If this problem persists, please contact us at ','shortpixel-image-optimiser')
|
1482 |
. "<a href='mailto:help@shortpixel.com?Subject=API Key issues' target='_top'>help@shortpixel.com</a>"
|
1483 |
+
. __(' or ','shortpixel-image-optimiser')
|
1484 |
+
. "<a href='https://shortpixel.com/contact' target='_blank'>" . __('here','shortpixel-image-optimiser') . "</a>.");
|
1485 |
}
|
1486 |
else
|
1487 |
{
|
1498 |
//display notification
|
1499 |
$urlParts = explode("/", get_site_url());
|
1500 |
if( $validityData['DomainCheck'] == 'NOT Accessible'){
|
1501 |
+
$notice = array("status" => "warn", "msg" => __("API Key is valid but your site is not accessible from our servers. Please make sure that your server is accessible from the Internet before using the API or otherwise we won't be able to optimize them.",'shortpixel-image-optimiser'));
|
1502 |
} else {
|
1503 |
if ( function_exists("is_multisite") && is_multisite() && !defined("SHORTPIXEL_API_KEY"))
|
1504 |
+
$notice = array("status" => "success", "msg" => __("Great, your API Key is valid! <br>You seem to be running a multisite, please note that API Key can also be configured in wp-config.php like this:",'shortpixel-image-optimiser')
|
1505 |
. "<BR> <b>define('SHORTPIXEL_API_KEY', '".$this->_settings->apiKey."');</b>");
|
1506 |
else
|
1507 |
+
$notice = array("status" => "success", "msg" => __('Great, your API Key is valid. Please take a few moments to review the plugin settings below before starting to optimize your images.','shortpixel-image-optimiser'));
|
1508 |
}
|
1509 |
}
|
1510 |
$this->_settings->verifiedKey = true;
|
1511 |
//test that the "uploads" have the right rights and also we can create the backup dir for ShortPixel
|
1512 |
if ( !file_exists(SP_BACKUP_FOLDER) && !@mkdir(SP_BACKUP_FOLDER, 0777, true) )
|
1513 |
$notice = array("status" => "error",
|
1514 |
+
"msg" => sprintf(__("There is something preventing us to create a new folder for backing up your original files.<BR>Please make sure that folder <b>%s</b> has the necessary write and read rights.",'shortpixel-image-optimiser'),
|
1515 |
WP_CONTENT_DIR . '/' . SP_UPLOADS_NAME ));
|
1516 |
} else {
|
1517 |
if(isset($_POST['validate'])) {
|
1540 |
$uploadDir = wp_upload_dir();
|
1541 |
$uploadPath = $uploadDir["basedir"];
|
1542 |
|
1543 |
+
if( isset($_POST['save']) && $_POST['save'] == __("Save and Go to Bulk Process",'shortpixel-image-optimiser')
|
1544 |
+
|| isset($_POST['saveAdv']) && $_POST['saveAdv'] == __("Save and Go to Bulk Process",'shortpixel-image-optimiser')) {
|
1545 |
wp_redirect("upload.php?page=wp-short-pixel-bulk");
|
1546 |
exit();
|
1547 |
}
|
1557 |
$this->_settings->includeNextGen = 0;
|
1558 |
}
|
1559 |
if(isset($_POST['addCustomFolder']) && strlen($_POST['addCustomFolder']) > 0) {
|
1560 |
+
$folderMsg = $this->spMetaDao->newFolderFromPath(stripslashes($_POST['addCustomFolder']), $uploadPath, $this->getCustomFolderBase());
|
1561 |
if(!$folderMsg) {
|
1562 |
+
$notice = array("status" => "success", "msg" => __('Folder added successfully.','shortpixel-image-optimiser'));
|
1563 |
}
|
1564 |
$customFolders = $this->spMetaDao->getFolders();
|
1565 |
$this->_settings->hasCustomFolders = true;
|
1589 |
$this->emptyBackup();
|
1590 |
}
|
1591 |
|
1592 |
+
$quotaData = $this->checkQuotaAndAlert(isset($validityData) ? $validityData : null, isset($_GET['checkquota']));
|
1593 |
|
1594 |
if($this->hasNextGen) {
|
1595 |
$ngg = array_map(array('ShortPixelNextGenAdapter','pathToAbsolute'), ShortPixelNextGenAdapter::getGalleries());
|
1602 |
}
|
1603 |
|
1604 |
$showApiKey = is_main_site() || (function_exists("is_multisite") && is_multisite() && !defined("SHORTPIXEL_API_KEY"));
|
1605 |
+
$editApiKey = !defined("SHORTPIXEL_API_KEY") && $showApiKey;
|
|
|
|
|
|
|
1606 |
|
1607 |
if($this->_settings->verifiedKey) {
|
1608 |
$fileCount = number_format($this->_settings->fileCount);
|
1734 |
|
1735 |
$defaultData = array(
|
1736 |
"APIKeyValid" => false,
|
1737 |
+
"Message" => __('API Key could not be validated due to a connectivity error.<BR>Your firewall may be blocking us. Please contact your hosting provider and ask them to allow connections from your site to IP 176.9.106.46.<BR> If you still cannot validate your API Key after this, please <a href="https://shortpixel.com/contact" target="_blank">contact us</a> and we will try to help. ','shortpixel-image-optimiser'),
|
1738 |
+
"APICallsMade" => __('Information unavailable. Please check your API key.','shortpixel-image-optimiser'),
|
1739 |
+
"APICallsQuota" => __('Information unavailable. Please check your API key.','shortpixel-image-optimiser'),
|
1740 |
"DomainCheck" => 'NOT Accessible');
|
1741 |
|
1742 |
if(is_object($response) && get_class($response) == 'WP_Error') {
|
1777 |
|
1778 |
return array(
|
1779 |
"APIKeyValid" => true,
|
1780 |
+
"APICallsMade" => number_format($data->APICallsMade) . __(' images','shortpixel-image-optimiser'),
|
1781 |
+
"APICallsQuota" => number_format($data->APICallsQuota) . __(' images','shortpixel-image-optimiser'),
|
1782 |
+
"APICallsMadeOneTime" => number_format($data->APICallsMadeOneTime) . __(' images','shortpixel-image-optimiser'),
|
1783 |
+
"APICallsQuotaOneTime" => number_format($data->APICallsQuotaOneTime) . __(' images','shortpixel-image-optimiser'),
|
1784 |
"APICallsMadeNumeric" => $data->APICallsMade,
|
1785 |
"APICallsQuotaNumeric" => $data->APICallsQuota,
|
1786 |
"APICallsMadeOneTimeNumeric" => $data->APICallsMadeOneTime,
|
1791 |
);
|
1792 |
}
|
1793 |
|
1794 |
+
public function generateCustomColumn( $column_name, $id, $extended = false ) {
|
1795 |
if( 'wp-shortPixel' == $column_name ) {
|
1796 |
|
1797 |
$data = wp_get_attachment_metadata($id);
|
1803 |
|
1804 |
if($invalidKey) { //invalid key - let the user first register and only then
|
1805 |
$renderData['status'] = 'invalidKey';
|
1806 |
+
$this->view->renderCustomColumn($id, $renderData, $extended);
|
1807 |
return;
|
1808 |
}
|
1809 |
|
1811 |
elseif (empty($data)) { //TODO asta devine if si decomentam returnurile
|
1812 |
if($fileExtension == "pdf") {
|
1813 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'optimizeNow';
|
1814 |
+
$renderData['message'] = __('PDF not processed.','shortpixel-image-optimiser');
|
1815 |
}
|
1816 |
else { //Optimization N/A
|
1817 |
$renderData['status'] = 'n/a';
|
1818 |
}
|
1819 |
+
$this->view->renderCustomColumn($id, $renderData, $extended);
|
1820 |
return;
|
1821 |
}
|
1822 |
|
1834 |
$renderData['thumbsTotal'] = $sizes;
|
1835 |
$renderData['thumbsOpt'] = isset($data['ShortPixel']['thumbsOpt']) ? $data['ShortPixel']['thumbsOpt'] : $sizes;
|
1836 |
$renderData['retinasOpt'] = isset($data['ShortPixel']['retinasOpt']) ? $data['ShortPixel']['retinasOpt'] : null;
|
1837 |
+
$renderData['exifKept'] = isset($data['ShortPixel']['exifKept']) ? $data['ShortPixel']['exifKept'] : null;
|
1838 |
+
$renderData['date'] = isset($data['ShortPixel']['date']) ? $data['ShortPixel']['date'] : null;
|
1839 |
$renderData['quotaExceeded'] = $quotaExceeded;
|
1840 |
+
$webP = 0;
|
1841 |
+
if($extended) {
|
1842 |
+
if(file_exists(dirname($file) . '/' . basename($file, '.'.pathinfo($file, PATHINFO_EXTENSION)) . '.webp' )){
|
1843 |
+
$webP++;
|
1844 |
+
}
|
1845 |
+
foreach($data['sizes'] as $size) {
|
1846 |
+
$sizeName = $size['file'];
|
1847 |
+
if(file_exists(dirname($file) . '/' . basename($sizeName, '.'.pathinfo($sizeName, PATHINFO_EXTENSION)) . '.webp' )){
|
1848 |
+
$webP++;
|
1849 |
+
}
|
1850 |
+
}
|
1851 |
+
}
|
1852 |
+
$renderData['webpCount'] = $webP;
|
1853 |
}
|
1854 |
+
elseif($data['ShortPixelImprovement'] == __('Optimization N/A','shortpixel-image-optimiser')) { //We don't optimize this
|
1855 |
$renderData['status'] = 'n/a';
|
1856 |
}
|
1857 |
elseif(isset($meta['ShortPixel']['BulkProcessing'])) { //Scheduled to bulk.
|
1858 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'optimizeNow';
|
1859 |
$renderData['message'] = 'Waiting for bulk processing.';
|
1860 |
}
|
1861 |
+
elseif( trim(strip_tags($data['ShortPixelImprovement'])) == __("Cannot write optimized file",'shortpixel-image-optimiser') ) {
|
1862 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'retry';
|
1863 |
+
$renderData['message'] = __("Cannot write optimized file",'shortpixel-image-optimiser') . " - <a href='https://shortpixel.com/faq#cannot-write-optimized-file' target='_blank'>"
|
1864 |
+
. __("Why?",'shortpixel-image-optimiser') . "</a>";
|
1865 |
}
|
1866 |
elseif( strlen(trim(strip_tags($data['ShortPixelImprovement']))) > 0 ) {
|
1867 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'retry';
|
1869 |
}
|
1870 |
elseif(isset($data['ShortPixel']['NoFileOnDisk'])) {
|
1871 |
$renderData['status'] = 'notFound';
|
1872 |
+
$renderData['message'] = __('Image does not exist','shortpixel-image-optimiser');
|
1873 |
}
|
1874 |
elseif(isset($data['ShortPixel']['WaitingProcessing'])) {
|
1875 |
$renderData['status'] = $quotaExceeded ? 'quotaExceeded' : 'retry';
|
1876 |
+
$renderData['message'] = "<img src=\"" . plugins_url( 'res/img/loading.gif', __FILE__ ) . "\" class='sp-loading-small'> " . __("Image waiting to be processed.",'shortpixel-image-optimiser');
|
1877 |
if($id > $this->prioQ->getFlagBulkId() || !$this->prioQ->bulkRunning()) $this->prioQ->push($id); //should be there but just to make sure
|
1878 |
}
|
1879 |
else { //finally
|
1883 |
$renderData['message'] = ($fileExtension == "pdf" ? 'PDF' : 'Image') . ' not processed.';
|
1884 |
}
|
1885 |
|
1886 |
+
$this->view->renderCustomColumn($id, $renderData, $extended);
|
1887 |
+
}
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
function shortpixelInfoBox() {
|
1891 |
+
if(get_post_type( ) == 'attachment') {
|
1892 |
+
add_meta_box(
|
1893 |
+
'shortpixel_info_box', // this is HTML id of the box on edit screen
|
1894 |
+
__('ShortPixel Info', 'shortpixel-image-optimiser'), // title of the box
|
1895 |
+
array( &$this, 'shortpixelInfoBoxContent'), // function to be called to display the info
|
1896 |
+
null,//, // on which edit screen the box should appear
|
1897 |
+
'side'//'normal', // part of page where the box should appear
|
1898 |
+
//'default' // priority of the box
|
1899 |
+
);
|
1900 |
+
}
|
1901 |
+
}
|
1902 |
+
|
1903 |
+
function shortpixelInfoBoxContent( $post ) {
|
1904 |
+
$this->generateCustomColumn( 'wp-shortPixel', $post->ID, true );
|
1905 |
+
}
|
1906 |
+
|
1907 |
+
function onDeleteImage($post_id) {
|
1908 |
+
$itemHandler = new ShortPixelMetaFacade($post_id);
|
1909 |
+
$urlsPaths = $itemHandler->getURLsAndPATHs(true, false, false);
|
1910 |
+
foreach($urlsPaths['PATHs'] as $path) {
|
1911 |
+
$pos = strrpos($path, ".");
|
1912 |
+
if ($pos !== false) {
|
1913 |
+
//$webpPath = substr($path, 0, $pos) . ".webp";
|
1914 |
+
//echo($webpPath . "<br>");
|
1915 |
+
@unlink(substr($path, 0, $pos) . ".webp");
|
1916 |
+
@unlink(substr($path, 0, $pos) . "@2x.webp");
|
1917 |
+
}
|
1918 |
}
|
1919 |
}
|
1920 |
|
1922 |
$defaults['wp-shortPixel'] = 'ShortPixel Compression';
|
1923 |
if(current_user_can( 'manage_options' )) {
|
1924 |
$defaults['wp-shortPixel'] .= ' <a href="options-general.php?page=wp-shortpixel#stats" title="'
|
1925 |
+
. __('ShortPixel Statistics','shortpixel-image-optimiser') . '"><span class="dashicons dashicons-dashboard"></span></a>';
|
1926 |
}
|
1927 |
return $defaults;
|
1928 |
}
|
1940 |
}
|
1941 |
|
1942 |
public function nggColumnHeader( $default ) {
|
1943 |
+
return __('ShortPixel Compression','shortpixel-image-optimiser');
|
1944 |
}
|
1945 |
|
1946 |
public function nggColumnContent( $unknown, $picture ) {
|