Version Description
Release date: 7th June 2019 * Replace the two options Exact size for featured/non-featured images with one checkbox Only featured * Button to stop the regeneration * Make Keep existing be checked by default * Change "Regenerate selected thumbnails" checklist to a settings selection * ShortPixel Image Optimizer integration - call the 'shortpixel-thumbnails-regenerated' action passing only the changed sizes * Fix: Security - Image sizes XSS exploit * Fix: count(): Parameter must be an array
Download this release
Release Info
| Developer | ShortPixel |
| Plugin | |
| Version | 2.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.1 to 2.1.0
- classes/rta_admin_controller.php +19 -9
- css/rta-admin-view.css +28 -1
- includes/rta_class.php +30 -19
- includes/rta_install.php +42 -26
- includes/rta_uninstall.php +25 -25
- js/rta.js +62 -27
- js/rta.min.js +1 -1
- readme.txt +12 -1
- regenerate-thumbnails-advanced.php +12 -4
- rta_admin.php +13 -95
- rta_front.php +1 -1
- scss/rta-admin-view.scss +38 -1
- templates/admin/view_regenerate_process.php +52 -6
- templates/admin/view_rta_regenerate.php +4 -3
- templates/admin/view_rta_settings.php +3 -3
classes/rta_admin_controller.php
CHANGED
|
@@ -47,9 +47,15 @@ class rtaAdminController
|
|
| 47 |
|
| 48 |
if (isset($options['process_image_sizes']) && is_array($options['process_image_sizes']))
|
| 49 |
$this->process_image_sizes = $options['process_image_sizes'];
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
if (isset($options['process_image_options']) && is_array($options['process_image_options']) )
|
| 52 |
$this->process_image_options = $options['process_image_options'];
|
|
|
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
public function show()
|
|
@@ -88,25 +94,28 @@ class rtaAdminController
|
|
| 88 |
return false;
|
| 89 |
}
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
public function save_image_sizes() {
|
| 92 |
global $_wp_additional_image_sizes;
|
| 93 |
|
| 94 |
$jsonReponse = array('message' => '', 'error' => '');
|
| 95 |
$error = false;
|
| 96 |
-
global $rta_lang;
|
| 97 |
$rta_image_sizes = array();
|
| 98 |
$option = array();
|
| 99 |
$exclude = array();
|
| 100 |
|
| 101 |
-
$nonce = isset($_POST['
|
| 102 |
if (! wp_verify_nonce($nonce, 'rta_save_image_sizes'))
|
| 103 |
{
|
| 104 |
$jsonResponse['error'] = 'Invalid Nonce';
|
| 105 |
return $jsonResponse;
|
| 106 |
}
|
| 107 |
|
| 108 |
-
if (isset($_POST['
|
| 109 |
-
parse_str($_POST['
|
| 110 |
else
|
| 111 |
$formpost = array();
|
| 112 |
|
|
@@ -156,9 +165,7 @@ class rtaAdminController
|
|
| 156 |
$this->setOptionData();
|
| 157 |
|
| 158 |
$newsizes = $this->generateImageSizeOptions($sizes);
|
| 159 |
-
|
| 160 |
-
$message = $this->controller->rta_get_message_html( $rta_lang['image_sizes_save_message'], 'message' );
|
| 161 |
-
$jsonResponse = array( 'error' => $error, 'message' => $message, 'new_image_sizes' => $newsizes );
|
| 162 |
|
| 163 |
return $jsonResponse;
|
| 164 |
|
|
@@ -215,15 +222,18 @@ class rtaAdminController
|
|
| 215 |
$checked = ($check_all || in_array($value, $checked_ar)) ? 'checked' : '';
|
| 216 |
$hidden = ($checked == 'checked') ? '' : 'hidden'; // hide add. option if not checked.
|
| 217 |
|
| 218 |
-
$
|
|
|
|
| 219 |
|
|
|
|
|
|
|
| 220 |
|
| 221 |
$output .= "<div class='item'>";
|
| 222 |
$output .= "<span>
|
| 223 |
<label> <input type='checkbox' id='regenerate_sizes[$i]' name='regenerate_sizes[$i]' value='$value' $checked>
|
| 224 |
" . ucfirst($size) . "</label>
|
| 225 |
</span>";
|
| 226 |
-
$output .= "<span class='options $hidden'><label><input type='checkbox' $checked_keep name='keep_" . $value . "'> Keep existing</label></span>";
|
| 227 |
$output .= "</div>";
|
| 228 |
|
| 229 |
$i++;
|
| 47 |
|
| 48 |
if (isset($options['process_image_sizes']) && is_array($options['process_image_sizes']))
|
| 49 |
$this->process_image_sizes = $options['process_image_sizes'];
|
| 50 |
+
else
|
| 51 |
+
$this->process_image_sizes = array();
|
| 52 |
+
|
| 53 |
|
| 54 |
if (isset($options['process_image_options']) && is_array($options['process_image_options']) )
|
| 55 |
$this->process_image_options = $options['process_image_options'];
|
| 56 |
+
else
|
| 57 |
+
$this->process_image_options = array();
|
| 58 |
+
|
| 59 |
}
|
| 60 |
|
| 61 |
public function show()
|
| 94 |
return false;
|
| 95 |
}
|
| 96 |
|
| 97 |
+
/** Save thumbnail settings.
|
| 98 |
+
*
|
| 99 |
+
* @return JSON Returns json result data
|
| 100 |
+
*/
|
| 101 |
public function save_image_sizes() {
|
| 102 |
global $_wp_additional_image_sizes;
|
| 103 |
|
| 104 |
$jsonReponse = array('message' => '', 'error' => '');
|
| 105 |
$error = false;
|
|
|
|
| 106 |
$rta_image_sizes = array();
|
| 107 |
$option = array();
|
| 108 |
$exclude = array();
|
| 109 |
|
| 110 |
+
$nonce = isset($_POST['save_nonce']) ? $_POST['save_nonce'] : false;
|
| 111 |
if (! wp_verify_nonce($nonce, 'rta_save_image_sizes'))
|
| 112 |
{
|
| 113 |
$jsonResponse['error'] = 'Invalid Nonce';
|
| 114 |
return $jsonResponse;
|
| 115 |
}
|
| 116 |
|
| 117 |
+
if (isset($_POST['saveform']))
|
| 118 |
+
parse_str($_POST['saveform'], $formpost);
|
| 119 |
else
|
| 120 |
$formpost = array();
|
| 121 |
|
| 165 |
$this->setOptionData();
|
| 166 |
|
| 167 |
$newsizes = $this->generateImageSizeOptions($sizes);
|
| 168 |
+
$jsonResponse = array( 'error' => $error, 'message' => '', 'new_image_sizes' => $newsizes );
|
|
|
|
|
|
|
| 169 |
|
| 170 |
return $jsonResponse;
|
| 171 |
|
| 222 |
$checked = ($check_all || in_array($value, $checked_ar)) ? 'checked' : '';
|
| 223 |
$hidden = ($checked == 'checked') ? '' : 'hidden'; // hide add. option if not checked.
|
| 224 |
|
| 225 |
+
$option_in_db = (isset($process_options[$value])) ? true : false;
|
| 226 |
+
$checked_keep = (isset($process_options[$value]) && isset($process_options[$value]['overwrite_files']) && ! $process_options[$value]['overwrite_files'] ) ? 'checked' : '';
|
| 227 |
|
| 228 |
+
if ($option_in_db)
|
| 229 |
+
$checked .= ' data-setbyuser=true'; // if value was ever saved in DB, don't change it in the JS.
|
| 230 |
|
| 231 |
$output .= "<div class='item'>";
|
| 232 |
$output .= "<span>
|
| 233 |
<label> <input type='checkbox' id='regenerate_sizes[$i]' name='regenerate_sizes[$i]' value='$value' $checked>
|
| 234 |
" . ucfirst($size) . "</label>
|
| 235 |
</span>";
|
| 236 |
+
$output .= "<span class='options $hidden'><label><input value='1' type='checkbox' $checked_keep name='keep_" . $value . "'> " . __('Keep existing', 'regenerate-thumbnails-advanced') . "</label></span>";
|
| 237 |
$output .= "</div>";
|
| 238 |
|
| 239 |
$i++;
|
css/rta-admin-view.css
CHANGED
|
@@ -43,6 +43,7 @@
|
|
| 43 |
box-shadow: 0px 0px 4px #aaa; }
|
| 44 |
.rta-admin .container {
|
| 45 |
padding: 20px 8px;
|
|
|
|
| 46 |
margin: 0 auto; }
|
| 47 |
.rta-admin .option {
|
| 48 |
padding: 10px; }
|
|
@@ -136,7 +137,9 @@
|
|
| 136 |
width: 200px;
|
| 137 |
padding: 25px 0; }
|
| 138 |
.rta-admin section.regenerate .rta_progress {
|
| 139 |
-
display: inline-block;
|
|
|
|
|
|
|
| 140 |
.rta-admin section.regenerate .images {
|
| 141 |
margin-left: 225px;
|
| 142 |
float: left;
|
|
@@ -152,6 +155,26 @@
|
|
| 152 |
.rta-admin section.regenerate .rta_hidden {
|
| 153 |
display: inline-block;
|
| 154 |
display: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
.rta-admin .form_controls {
|
| 156 |
position: absolute;
|
| 157 |
left: 45px;
|
|
@@ -165,3 +188,7 @@
|
|
| 165 |
padding-left: 20px; }
|
| 166 |
.rta-admin .form_controls .save_indicator .saved {
|
| 167 |
font-size: 60px; }
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
box-shadow: 0px 0px 4px #aaa; }
|
| 44 |
.rta-admin .container {
|
| 45 |
padding: 20px 8px;
|
| 46 |
+
position: relative;
|
| 47 |
margin: 0 auto; }
|
| 48 |
.rta-admin .option {
|
| 49 |
padding: 10px; }
|
| 137 |
width: 200px;
|
| 138 |
padding: 25px 0; }
|
| 139 |
.rta-admin section.regenerate .rta_progress {
|
| 140 |
+
display: inline-block;
|
| 141 |
+
position: relative;
|
| 142 |
+
min-height: 310px; }
|
| 143 |
.rta-admin section.regenerate .images {
|
| 144 |
margin-left: 225px;
|
| 145 |
float: left;
|
| 155 |
.rta-admin section.regenerate .rta_hidden {
|
| 156 |
display: inline-block;
|
| 157 |
display: none; }
|
| 158 |
+
.rta-admin section.regenerate .shortpixel-notice {
|
| 159 |
+
background: #fff;
|
| 160 |
+
width: 250px;
|
| 161 |
+
min-height: 270px;
|
| 162 |
+
border: 1px solid #ccc;
|
| 163 |
+
padding: 15px;
|
| 164 |
+
margin: 0 5% 10px 25px;
|
| 165 |
+
float: right; }
|
| 166 |
+
.rta-admin section.regenerate .shortpixel-notice h3 {
|
| 167 |
+
line-height: 1.3em; }
|
| 168 |
+
.rta-admin section.regenerate .shortpixel-bulk-notice {
|
| 169 |
+
font-size: 14px;
|
| 170 |
+
font-weight: 700;
|
| 171 |
+
text-align: center; }
|
| 172 |
+
.rta-admin section.regenerate button.stop-process {
|
| 173 |
+
position: absolute;
|
| 174 |
+
bottom: 10px;
|
| 175 |
+
left: 80%;
|
| 176 |
+
font-weight: normal;
|
| 177 |
+
text-transform: none; }
|
| 178 |
.rta-admin .form_controls {
|
| 179 |
position: absolute;
|
| 180 |
left: 45px;
|
| 188 |
padding-left: 20px; }
|
| 189 |
.rta-admin .form_controls .save_indicator .saved {
|
| 190 |
font-size: 60px; }
|
| 191 |
+
.rta-admin .form_controls .save_note {
|
| 192 |
+
color: orange;
|
| 193 |
+
float: right;
|
| 194 |
+
margin-left: 30px; }
|
includes/rta_class.php
CHANGED
|
@@ -15,31 +15,26 @@
|
|
| 15 |
|
| 16 |
class RTA
|
| 17 |
{
|
|
|
|
| 18 |
|
| 19 |
//Plugin starting point. Will call appropriate actions
|
| 20 |
public function __construct() {
|
| 21 |
|
| 22 |
-
add_action( '
|
| 23 |
-
|
| 24 |
add_action( 'admin_enqueue_scripts', array( $this, 'rta_enqueue_scripts' ), 10 );
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
//Plugin initialization
|
| 28 |
public function rta_init() {
|
| 29 |
|
| 30 |
do_action('rta_before_init');
|
| 31 |
-
|
| 32 |
-
$rta_options = get_option( 'rta_settings' );
|
| 33 |
-
load_plugin_textdomain( 'rta', FALSE, RTA_LANG_DIR );
|
| 34 |
-
require_once RTA_PLUGIN_PATH.'language/rta_general.php';
|
| 35 |
-
|
| 36 |
-
if(is_admin()){
|
| 37 |
-
require_once RTA_PLUGIN_PATH.'rta_admin.php';
|
| 38 |
-
}
|
| 39 |
|
| 40 |
-
|
| 41 |
-
require_once(RTA_PLUGIN_PATH . 'classes/rta_admin_controller.php');
|
| 42 |
-
require_once(RTA_PLUGIN_PATH . 'classes/rta_image.php');
|
| 43 |
|
| 44 |
do_action('rta_after_init');
|
| 45 |
}
|
|
@@ -57,7 +52,8 @@ class RTA
|
|
| 57 |
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
| 58 |
'nonce_savesizes' => wp_create_nonce('rta_save_image_sizes'),
|
| 59 |
'nonce_generate' => wp_create_nonce('rta_regenerate_thumbnails'),
|
| 60 |
-
'
|
|
|
|
| 61 |
));
|
| 62 |
|
| 63 |
do_action('rta_after_enqueue_scripts');
|
|
@@ -82,7 +78,6 @@ class RTA
|
|
| 82 |
}
|
| 83 |
|
| 84 |
public function rta_load_template( $template='', $for='front', $attr=array() ) {
|
| 85 |
-
global $rta_options,$rta_lang;
|
| 86 |
|
| 87 |
do_action( 'rta_before_load_template', $template, $for, $attr );
|
| 88 |
$template = apply_filters( 'rta_template_to_load', $template, $for, $attr );
|
|
@@ -108,7 +103,6 @@ class RTA
|
|
| 108 |
}
|
| 109 |
|
| 110 |
public function rta_get_message_html( $message, $type = 'message' ) {
|
| 111 |
-
global $rta_options,$rta_lang;
|
| 112 |
do_action( 'rta_before_get_message_html', $message, $type );
|
| 113 |
$message = apply_filters( 'rta_message_text', $message, $type );
|
| 114 |
$type = apply_filters( 'rta_message_type', $type, $message );
|
|
@@ -145,6 +139,25 @@ class RTA
|
|
| 145 |
wp_send_json($response);
|
| 146 |
}
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
/* [BS] Seems not in use */
|
| 150 |
/*
|
|
@@ -402,6 +415,4 @@ class RTA
|
|
| 402 |
|
| 403 |
do_action('rta_after_uninstall');
|
| 404 |
}
|
| 405 |
-
}
|
| 406 |
-
|
| 407 |
-
$rta = new RTA();
|
| 15 |
|
| 16 |
class RTA
|
| 17 |
{
|
| 18 |
+
protected $admin;
|
| 19 |
|
| 20 |
//Plugin starting point. Will call appropriate actions
|
| 21 |
public function __construct() {
|
| 22 |
|
| 23 |
+
add_action( 'init', array( $this, 'rta_init' ) );
|
| 24 |
+
/// add_action( 'wp_enqueue_scripts', array( $this, 'rta_enqueue_scripts' ), 10 );
|
| 25 |
add_action( 'admin_enqueue_scripts', array( $this, 'rta_enqueue_scripts' ), 10 );
|
| 26 |
+
|
| 27 |
+
//add_filter('media_row_actions', array($this,'add_media_action'), 10, 2);
|
| 28 |
+
|
| 29 |
}
|
| 30 |
|
| 31 |
//Plugin initialization
|
| 32 |
public function rta_init() {
|
| 33 |
|
| 34 |
do_action('rta_before_init');
|
| 35 |
+
$this->admin = new RTA_Admin(); // admin hooks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
load_plugin_textdomain( 'regenerate-thumbnails-advanced', FALSE, RTA_LANG_DIR );
|
|
|
|
|
|
|
| 38 |
|
| 39 |
do_action('rta_after_init');
|
| 40 |
}
|
| 52 |
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
| 53 |
'nonce_savesizes' => wp_create_nonce('rta_save_image_sizes'),
|
| 54 |
'nonce_generate' => wp_create_nonce('rta_regenerate_thumbnails'),
|
| 55 |
+
'confirm_delete' => __('Are you sure you want to delete this image size?', 'regenerate-thumbnails-advanced'),
|
| 56 |
+
'confirm_stop' => __("This will stop the regeneration process. You want to stop?", 'regenerate-thumbnails-advanced' ),
|
| 57 |
));
|
| 58 |
|
| 59 |
do_action('rta_after_enqueue_scripts');
|
| 78 |
}
|
| 79 |
|
| 80 |
public function rta_load_template( $template='', $for='front', $attr=array() ) {
|
|
|
|
| 81 |
|
| 82 |
do_action( 'rta_before_load_template', $template, $for, $attr );
|
| 83 |
$template = apply_filters( 'rta_template_to_load', $template, $for, $attr );
|
| 103 |
}
|
| 104 |
|
| 105 |
public function rta_get_message_html( $message, $type = 'message' ) {
|
|
|
|
| 106 |
do_action( 'rta_before_get_message_html', $message, $type );
|
| 107 |
$message = apply_filters( 'rta_message_text', $message, $type );
|
| 108 |
$type = apply_filters( 'rta_message_type', $type, $message );
|
| 139 |
wp_send_json($response);
|
| 140 |
}
|
| 141 |
|
| 142 |
+
/* @todo To Implement
|
| 143 |
+
|
| 144 |
+
public function add_media_action( $actions, $post) {
|
| 145 |
+
$url = admin_url( "upload.php");
|
| 146 |
+
$url = add_query_arg(array(
|
| 147 |
+
'action' => 'media_replace',
|
| 148 |
+
'attachment_id' => $post->ID,
|
| 149 |
+
), $url);
|
| 150 |
+
$action = "regenerate_thumbnails";
|
| 151 |
+
|
| 152 |
+
$editurl = wp_nonce_url( $url, $action );
|
| 153 |
+
$link = "href=\"$editurl\"";
|
| 154 |
+
|
| 155 |
+
$newaction['regenerate'] = '<a ' . $link . ' aria-label="' . esc_html__("Replace media", "regenerate-thumbnails-advanced") . '" rel="permalink">' . esc_html__("Regenerate Thumbnails", "regenerate-thumbnails-advanced") . '</a>';
|
| 156 |
+
return array_merge($actions,$newaction);
|
| 157 |
+
}
|
| 158 |
+
*/
|
| 159 |
+
|
| 160 |
+
|
| 161 |
|
| 162 |
/* [BS] Seems not in use */
|
| 163 |
/*
|
| 415 |
|
| 416 |
do_action('rta_after_uninstall');
|
| 417 |
}
|
| 418 |
+
} // class
|
|
|
|
|
|
includes/rta_install.php
CHANGED
|
@@ -1,26 +1,42 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Class that will hold functionality for plugin activation
|
| 6 |
-
*
|
| 7 |
-
* PHP version 5
|
| 8 |
-
*
|
| 9 |
-
* @category Install
|
| 10 |
-
* @package Regenerate Thumbnails ID SCOUT
|
| 11 |
-
* @author Muhammad Atiq
|
| 12 |
-
* @version 1.0.0
|
| 13 |
-
* @since File available since Release 1.0.0
|
| 14 |
-
*/
|
| 15 |
-
|
| 16 |
-
class RTA_Install extends RTA
|
| 17 |
-
{
|
| 18 |
-
public function __construct() {
|
| 19 |
-
|
| 20 |
-
do_action('rta_before_install', $this );
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Class that will hold functionality for plugin activation
|
| 6 |
+
*
|
| 7 |
+
* PHP version 5
|
| 8 |
+
*
|
| 9 |
+
* @category Install
|
| 10 |
+
* @package Regenerate Thumbnails ID SCOUT
|
| 11 |
+
* @author Muhammad Atiq
|
| 12 |
+
* @version 1.0.0
|
| 13 |
+
* @since File available since Release 1.0.0
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
class RTA_Install extends RTA
|
| 17 |
+
{
|
| 18 |
+
public function __construct() {
|
| 19 |
+
|
| 20 |
+
do_action('rta_before_install', $this );
|
| 21 |
+
|
| 22 |
+
$options = get_option('rta_image_sizes');
|
| 23 |
+
|
| 24 |
+
if ($options === false) // if no default settings are there; add.
|
| 25 |
+
{
|
| 26 |
+
$standard_sizes = array( 'thumbnail', 'medium', 'medium_large', 'large' ); // directly from media.php, hardcoded there.
|
| 27 |
+
$process_image_options = array();
|
| 28 |
+
foreach($standard_sizes as $name)
|
| 29 |
+
{
|
| 30 |
+
$process_image_options[$name] = array('overwrite_files' => false);
|
| 31 |
+
}
|
| 32 |
+
$options = array();
|
| 33 |
+
$options['process_image_sizes'] = $standard_sizes;
|
| 34 |
+
$options['process_image_options'] = $process_image_options;
|
| 35 |
+
add_option('rta_image_sizes', $options);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
do_action('rta_after_install', $this );
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
$rta_install = new RTA_Install();
|
includes/rta_uninstall.php
CHANGED
|
@@ -1,26 +1,26 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Class that will hold functionality for plugin deactivation
|
| 6 |
-
*
|
| 7 |
-
* PHP version 5
|
| 8 |
-
*
|
| 9 |
-
* @category Uninstall
|
| 10 |
-
* @package Regenerate Thumbnails ID SCOUT
|
| 11 |
-
* @author Muhammad Atiq
|
| 12 |
-
* @version 1.0.0
|
| 13 |
-
* @since File available since Release 1.0.0
|
| 14 |
-
*/
|
| 15 |
-
|
| 16 |
-
class RTA_Uninstall extends RTA
|
| 17 |
-
{
|
| 18 |
-
public function __construct() {
|
| 19 |
-
|
| 20 |
-
do_action('rta_before_uninstall', $this );
|
| 21 |
-
|
| 22 |
-
do_action('rta_after_uninstall', $this );
|
| 23 |
-
}
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
$rta_uninstall = new RTA_Uninstall();
|
| 1 |
+
<?php
|
| 2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Class that will hold functionality for plugin deactivation
|
| 6 |
+
*
|
| 7 |
+
* PHP version 5
|
| 8 |
+
*
|
| 9 |
+
* @category Uninstall
|
| 10 |
+
* @package Regenerate Thumbnails ID SCOUT
|
| 11 |
+
* @author Muhammad Atiq
|
| 12 |
+
* @version 1.0.0
|
| 13 |
+
* @since File available since Release 1.0.0
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
class RTA_Uninstall extends RTA
|
| 17 |
+
{
|
| 18 |
+
public function __construct() {
|
| 19 |
+
|
| 20 |
+
do_action('rta_before_uninstall', $this );
|
| 21 |
+
|
| 22 |
+
do_action('rta_after_uninstall', $this );
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
$rta_uninstall = new RTA_Uninstall();
|
js/rta.js
CHANGED
|
@@ -5,8 +5,9 @@ function rtaJS() {};
|
|
| 5 |
rtaJS.prototype = {
|
| 6 |
offset: 0,
|
| 7 |
total: 0,
|
| 8 |
-
is_interrupted_process: false,
|
| 9 |
-
in_process: false,
|
|
|
|
| 10 |
formcookie: null,
|
| 11 |
is_saved: true,
|
| 12 |
|
|
@@ -27,7 +28,8 @@ rtaJS.prototype.init = function()
|
|
| 27 |
$(document).on('change', '.table.imagesizes input, .table.imagesizes select', $.proxy(this.image_size_changed, this));
|
| 28 |
$(document).on('click', 'button[name="save_settings"]', $.proxy(this.image_size_changed, this));
|
| 29 |
$(document).on('click', '.table.imagesizes .btn_remove_row', $.proxy(this.remove_image_size_row, this));
|
| 30 |
-
$(document).on('click', '#btn_add_image_size', $.proxy(this.add_image_size_row));
|
|
|
|
| 31 |
|
| 32 |
$(document).on('click', '.rta_error_link', $.proxy(function () { this.show_errorbox(true); }, this) ) ;
|
| 33 |
this.formcookie = this.get_form_cookie();
|
|
@@ -58,7 +60,7 @@ rtaJS.prototype.checkSubmitReady = function()
|
|
| 58 |
if (inputs.length == 0)
|
| 59 |
processReady = false;
|
| 60 |
|
| 61 |
-
if (this.in_process)
|
| 62 |
processReady = false;
|
| 63 |
|
| 64 |
if (processReady)
|
|
@@ -75,13 +77,16 @@ rtaJS.prototype.checkSubmitReady = function()
|
|
| 75 |
{
|
| 76 |
$('button[name="save_settings"]').prop('disabled', true);
|
| 77 |
$('button[name="save_settings"]').addClass('disabled');
|
|
|
|
|
|
|
| 78 |
}
|
| 79 |
else {
|
| 80 |
$('button[name="save_settings"]').prop('disabled', false);
|
| 81 |
$('button[name="save_settings"]').removeClass('disabled');
|
| 82 |
-
|
| 83 |
}
|
| 84 |
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
rtaJS.prototype.selectAll = function(e)
|
|
@@ -103,21 +108,15 @@ rtaJS.prototype.processInit = function (e)
|
|
| 103 |
{
|
| 104 |
e.preventDefault();
|
| 105 |
|
| 106 |
-
if (! this.is_saved)
|
| 107 |
-
{
|
| 108 |
-
if(! confirm(rta_data.confirm_nosave)) {
|
| 109 |
-
return false;
|
| 110 |
-
}
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
this.unset_all_cookies();
|
| 114 |
this.show_errorbox(false);
|
| 115 |
this.hide_progress();
|
| 116 |
-
|
| 117 |
-
|
| 118 |
this.show_wait(true);
|
| 119 |
|
| 120 |
this.in_process = true;
|
|
|
|
| 121 |
this.checkSubmitReady();
|
| 122 |
this.set_form_cookie();
|
| 123 |
|
|
@@ -129,11 +128,11 @@ rtaJS.prototype.processInit = function (e)
|
|
| 129 |
dataType: 'json',
|
| 130 |
url: rta_data.ajaxurl,
|
| 131 |
data: {
|
| 132 |
-
|
| 133 |
action: 'rta_regenerate_thumbnails',
|
| 134 |
type: 'general',
|
| 135 |
-
|
| 136 |
-
|
| 137 |
success: function (response) {
|
| 138 |
if( response.pCount > 0 ) {
|
| 139 |
self.offset = 0;
|
|
@@ -151,6 +150,8 @@ rtaJS.prototype.processInit = function (e)
|
|
| 151 |
|
| 152 |
rtaJS.prototype.process = function()
|
| 153 |
{
|
|
|
|
|
|
|
| 154 |
offset = this.offset;
|
| 155 |
total = this.total;
|
| 156 |
|
|
@@ -169,21 +170,24 @@ rtaJS.prototype.process = function()
|
|
| 169 |
dataType: 'json',
|
| 170 |
url: rta_data.ajaxurl,
|
| 171 |
data: {
|
| 172 |
-
|
| 173 |
action: 'rta_regenerate_thumbnails',
|
| 174 |
type: 'submit',
|
| 175 |
offset:offset,
|
| 176 |
-
|
| 177 |
},
|
| 178 |
success: function (response) {
|
| 179 |
if( response.offset <= total ) {
|
| 180 |
if(response.logstatus=='Processed') {
|
| 181 |
$(".rta_progress .images img").attr("src",response.imgUrl);
|
| 182 |
}
|
| 183 |
-
self.set_process_cookie(response.offset,total);
|
| 184 |
-
self.offset = response.offset;
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
}else{
|
| 188 |
self.set_cookie("rta_image_processed",$(".rta_progress .images img").attr("src"));
|
| 189 |
//this.show_buttons();
|
|
@@ -209,8 +213,22 @@ rtaJS.prototype.process = function()
|
|
| 209 |
this.is_interrupted_process = false;
|
| 210 |
|
| 211 |
this.show_wait(false);
|
|
|
|
|
|
|
| 212 |
this.checkSubmitReady();
|
|
|
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
rtaJS.prototype.show_progress = function(percentage_done) {
|
|
@@ -230,6 +248,7 @@ rtaJS.prototype.process = function()
|
|
| 230 |
|
| 231 |
this.show_wait(false);
|
| 232 |
$('.rta_progress').removeClass('rta_hidden');
|
|
|
|
| 233 |
$(".rta_progress").slideDown();
|
| 234 |
$(".rta_progress").css('display', 'inline-block');
|
| 235 |
}
|
|
@@ -300,8 +319,9 @@ rtaJS.prototype.process = function()
|
|
| 300 |
this.set_cookie('rta_last_settings', '');
|
| 301 |
}
|
| 302 |
|
| 303 |
-
|
| 304 |
-
|
|
|
|
| 305 |
|
| 306 |
rtaJS.prototype.set_process_cookie = function(offset, total)
|
| 307 |
{
|
|
@@ -443,8 +463,8 @@ rtaJS.prototype.process = function()
|
|
| 443 |
url: rta_data.ajaxurl,
|
| 444 |
data: {
|
| 445 |
action: action,
|
| 446 |
-
|
| 447 |
-
|
| 448 |
},
|
| 449 |
success: function (response) {
|
| 450 |
if (! response.error)
|
|
@@ -479,10 +499,18 @@ rtaJS.prototype.process = function()
|
|
| 479 |
this.checkSubmitReady();
|
| 480 |
}
|
| 481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
rtaJS.prototype.remove_image_size_row = function(e) {
|
| 483 |
var rowid = $(e.target).parents('.row').attr('id');
|
| 484 |
|
| 485 |
-
if(confirm(
|
| 486 |
var intName = $('#' + rowid).find('.image_sizes_name').val();
|
| 487 |
$('input[name^="regenerate_sizes"][value="' + intName + '"]').remove(); // remove the checkbox as well, otherwise this will remain saved.
|
| 488 |
|
|
@@ -499,6 +527,13 @@ rtaJS.prototype.process = function()
|
|
| 499 |
if ($(this).is(':checked'))
|
| 500 |
{
|
| 501 |
$(this).parents('.item').find('.options').removeClass('hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
}
|
| 503 |
else {
|
| 504 |
$(this).parents('.item').find('.options').addClass('hidden');
|
| 5 |
rtaJS.prototype = {
|
| 6 |
offset: 0,
|
| 7 |
total: 0,
|
| 8 |
+
is_interrupted_process: false, // was the process killed by reload earlier?
|
| 9 |
+
in_process: false, // currently pushing it through.
|
| 10 |
+
is_stopped: false,
|
| 11 |
formcookie: null,
|
| 12 |
is_saved: true,
|
| 13 |
|
| 28 |
$(document).on('change', '.table.imagesizes input, .table.imagesizes select', $.proxy(this.image_size_changed, this));
|
| 29 |
$(document).on('click', 'button[name="save_settings"]', $.proxy(this.image_size_changed, this));
|
| 30 |
$(document).on('click', '.table.imagesizes .btn_remove_row', $.proxy(this.remove_image_size_row, this));
|
| 31 |
+
$(document).on('click', '#btn_add_image_size', $.proxy(this.add_image_size_row, this));
|
| 32 |
+
$(document).on('click', '.stop-process', $.proxy(this.stopProcess,this));
|
| 33 |
|
| 34 |
$(document).on('click', '.rta_error_link', $.proxy(function () { this.show_errorbox(true); }, this) ) ;
|
| 35 |
this.formcookie = this.get_form_cookie();
|
| 60 |
if (inputs.length == 0)
|
| 61 |
processReady = false;
|
| 62 |
|
| 63 |
+
if (this.in_process || ! this.is_saved)
|
| 64 |
processReady = false;
|
| 65 |
|
| 66 |
if (processReady)
|
| 77 |
{
|
| 78 |
$('button[name="save_settings"]').prop('disabled', true);
|
| 79 |
$('button[name="save_settings"]').addClass('disabled');
|
| 80 |
+
$('.save_note').addClass('rta_hidden');
|
| 81 |
+
|
| 82 |
}
|
| 83 |
else {
|
| 84 |
$('button[name="save_settings"]').prop('disabled', false);
|
| 85 |
$('button[name="save_settings"]').removeClass('disabled');
|
| 86 |
+
$('.save_note').removeClass('rta_hidden');
|
| 87 |
}
|
| 88 |
|
| 89 |
+
|
| 90 |
}
|
| 91 |
|
| 92 |
rtaJS.prototype.selectAll = function(e)
|
| 108 |
{
|
| 109 |
e.preventDefault();
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
this.unset_all_cookies();
|
| 112 |
this.show_errorbox(false);
|
| 113 |
this.hide_progress();
|
| 114 |
+
this.toggleShortPixelNotice(false);
|
| 115 |
+
|
| 116 |
this.show_wait(true);
|
| 117 |
|
| 118 |
this.in_process = true;
|
| 119 |
+
this.is_stopped = false;
|
| 120 |
this.checkSubmitReady();
|
| 121 |
this.set_form_cookie();
|
| 122 |
|
| 128 |
dataType: 'json',
|
| 129 |
url: rta_data.ajaxurl,
|
| 130 |
data: {
|
| 131 |
+
gen_nonce: rta_data.nonce_generate,
|
| 132 |
action: 'rta_regenerate_thumbnails',
|
| 133 |
type: 'general',
|
| 134 |
+
genform: JSON.stringify(form),
|
| 135 |
+
},
|
| 136 |
success: function (response) {
|
| 137 |
if( response.pCount > 0 ) {
|
| 138 |
self.offset = 0;
|
| 150 |
|
| 151 |
rtaJS.prototype.process = function()
|
| 152 |
{
|
| 153 |
+
if (this.is_stopped)
|
| 154 |
+
return; // escape if process has been stopped.
|
| 155 |
offset = this.offset;
|
| 156 |
total = this.total;
|
| 157 |
|
| 170 |
dataType: 'json',
|
| 171 |
url: rta_data.ajaxurl,
|
| 172 |
data: {
|
| 173 |
+
gen_nonce: rta_data.nonce_generate,
|
| 174 |
action: 'rta_regenerate_thumbnails',
|
| 175 |
type: 'submit',
|
| 176 |
offset:offset,
|
| 177 |
+
genform: JSON.stringify(form),
|
| 178 |
},
|
| 179 |
success: function (response) {
|
| 180 |
if( response.offset <= total ) {
|
| 181 |
if(response.logstatus=='Processed') {
|
| 182 |
$(".rta_progress .images img").attr("src",response.imgUrl);
|
| 183 |
}
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
if (! self.is_stopped)
|
| 186 |
+
{
|
| 187 |
+
self.set_process_cookie(response.offset,total);
|
| 188 |
+
self.offset = response.offset;
|
| 189 |
+
setTimeout(function(){ self.process(); },400);
|
| 190 |
+
}
|
| 191 |
}else{
|
| 192 |
self.set_cookie("rta_image_processed",$(".rta_progress .images img").attr("src"));
|
| 193 |
//this.show_buttons();
|
| 213 |
this.is_interrupted_process = false;
|
| 214 |
|
| 215 |
this.show_wait(false);
|
| 216 |
+
this.toggleShortPixelNotice(true);
|
| 217 |
+
$('.stop-process').addClass('rta_hidden');
|
| 218 |
this.checkSubmitReady();
|
| 219 |
+
}
|
| 220 |
|
| 221 |
+
rtaJS.prototype.stopProcess = function()
|
| 222 |
+
{
|
| 223 |
+
if (confirm(rta_data.confirm_stop))
|
| 224 |
+
{
|
| 225 |
+
this.is_stopped = true;
|
| 226 |
+
this.unset_all_cookies();
|
| 227 |
+
this.finishProcess();
|
| 228 |
+
this.hide_progress();
|
| 229 |
+
this.toggleShortPixelNotice(false);
|
| 230 |
+
// this.checkSubmitReady();
|
| 231 |
+
}
|
| 232 |
}
|
| 233 |
|
| 234 |
rtaJS.prototype.show_progress = function(percentage_done) {
|
| 248 |
|
| 249 |
this.show_wait(false);
|
| 250 |
$('.rta_progress').removeClass('rta_hidden');
|
| 251 |
+
$('.stop-process').removeClass('rta_hidden');
|
| 252 |
$(".rta_progress").slideDown();
|
| 253 |
$(".rta_progress").css('display', 'inline-block');
|
| 254 |
}
|
| 319 |
this.set_cookie('rta_last_settings', '');
|
| 320 |
}
|
| 321 |
|
| 322 |
+
/* Empty function, disabling
|
| 323 |
+
rtaJS.prototype.set_default_values = function() {
|
| 324 |
+
} */
|
| 325 |
|
| 326 |
rtaJS.prototype.set_process_cookie = function(offset, total)
|
| 327 |
{
|
| 463 |
url: rta_data.ajaxurl,
|
| 464 |
data: {
|
| 465 |
action: action,
|
| 466 |
+
save_nonce: the_nonce,
|
| 467 |
+
saveform: $('#rta_settings_form').serialize(),
|
| 468 |
},
|
| 469 |
success: function (response) {
|
| 470 |
if (! response.error)
|
| 499 |
this.checkSubmitReady();
|
| 500 |
}
|
| 501 |
|
| 502 |
+
rtaJS.prototype.toggleShortPixelNotice = function(show)
|
| 503 |
+
{
|
| 504 |
+
if (show)
|
| 505 |
+
$('.shortpixel-bulk-notice, .shortpixel-notice').removeClass('rta_hidden');
|
| 506 |
+
else
|
| 507 |
+
$('.shortpixel-bulk-notice, .shortpixel-notice').addClass('rta_hidden');
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
rtaJS.prototype.remove_image_size_row = function(e) {
|
| 511 |
var rowid = $(e.target).parents('.row').attr('id');
|
| 512 |
|
| 513 |
+
if(confirm( rta_data.confirm_delete )) {
|
| 514 |
var intName = $('#' + rowid).find('.image_sizes_name').val();
|
| 515 |
$('input[name^="regenerate_sizes"][value="' + intName + '"]').remove(); // remove the checkbox as well, otherwise this will remain saved.
|
| 516 |
|
| 527 |
if ($(this).is(':checked'))
|
| 528 |
{
|
| 529 |
$(this).parents('.item').find('.options').removeClass('hidden');
|
| 530 |
+
var input = $(this).parents('.item').find('input[type="checkbox"]');
|
| 531 |
+
|
| 532 |
+
if (typeof $(input).data('setbyuser') == 'undefined')
|
| 533 |
+
{
|
| 534 |
+
$(input).prop('checked', true);
|
| 535 |
+
$(input).data('setbyuser', true);
|
| 536 |
+
}
|
| 537 |
}
|
| 538 |
else {
|
| 539 |
$(this).parents('.item').find('.options').addClass('hidden');
|
js/rta.min.js
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
jQuery(document).ready(function(e){function t(){}(t.prototype={offset:0,total:0,is_interrupted_process:!1,in_process:!1,formcookie:null,is_saved:!0}).init=function(){this.checkSubmitReady(),e(".select, .deselect").on("click",e.proxy(this.selectAll,this)),e(document).on("change","input, select",e.proxy(this.checkSubmitReady,this)),e(document).on("click",".rta_regenerate",e.proxy(this.processInit,this)),e(document).on("change",".table.imagesizes input, .table.imagesizes select",e.proxy(this.image_size_changed,this)),e(document).on("click",'button[name="save_settings"]',e.proxy(this.image_size_changed,this)),e(document).on("click",".table.imagesizes .btn_remove_row",e.proxy(this.remove_image_size_row,this)),e(document).on("click","#btn_add_image_size",e.proxy(this.add_image_size_row)),e(document).on("click",".rta_error_link",e.proxy(function(){this.show_errorbox(!0)},this)),this.formcookie=this.get_form_cookie(),e(document).on("change",".rta-settings-wrap input, .rta-settings-wrap select",e.proxy(this.show_save_indicator,this)),e(document).on("change",'input[name^="regenerate_sizes"]',e.proxy(this.checkOptionsVisible,this));var t=parseInt(this.get_cookie("rta_offset")),s=parseInt(this.get_cookie("rta_total"));isNaN(t)||isNaN(s)||t<s&&(this.is_interrupted_process=!0,this.offset=t,this.total=s,this.process())},t.prototype.checkSubmitReady=function(){processReady=!0,inputs=e('input[name^="regenerate_sizes"]:checked'),0==inputs.length&&(processReady=!1)
|
| 1 |
+
jQuery(document).ready(function(e){function t(){}(t.prototype={offset:0,total:0,is_interrupted_process:!1,in_process:!1,formcookie:null,is_saved:!0}).init=function(){this.checkSubmitReady(),e(".select, .deselect").on("click",e.proxy(this.selectAll,this)),e(document).on("change","input, select",e.proxy(this.checkSubmitReady,this)),e(document).on("click",".rta_regenerate",e.proxy(this.processInit,this)),e(document).on("change",".table.imagesizes input, .table.imagesizes select",e.proxy(this.image_size_changed,this)),e(document).on("click",'button[name="save_settings"]',e.proxy(this.image_size_changed,this)),e(document).on("click",".table.imagesizes .btn_remove_row",e.proxy(this.remove_image_size_row,this)),e(document).on("click","#btn_add_image_size",e.proxy(this.add_image_size_row)),e(document).on("click",".rta_error_link",e.proxy(function(){this.show_errorbox(!0)},this)),this.formcookie=this.get_form_cookie(),e(document).on("change",".rta-settings-wrap input, .rta-settings-wrap select",e.proxy(this.show_save_indicator,this)),e(document).on("change",'input[name^="regenerate_sizes"]',e.proxy(this.checkOptionsVisible,this));var t=parseInt(this.get_cookie("rta_offset")),s=parseInt(this.get_cookie("rta_total"));isNaN(t)||isNaN(s)||t<s&&(this.is_interrupted_process=!0,this.offset=t,this.total=s,this.process())},t.prototype.checkSubmitReady=function(){processReady=!0,inputs=e('input[name^="regenerate_sizes"]:checked'),0==inputs.length&&(processReady=!1),!this.in_process&&this.is_saved||(processReady=!1),processReady?(e("button.rta_regenerate").removeClass("disabled"),e("button.rta_regenerate").prop("disabled",!1)):(e("button.rta_regenerate").addClass("disabled"),e("button.rta_regenerate").prop("disabled",!0)),this.is_saved?(e('button[name="save_settings"]').prop("disabled",!0),e('button[name="save_settings"]').addClass("disabled"),e(".save_note").addClass("rta_hidden")):(e('button[name="save_settings"]').prop("disabled",!1),e('button[name="save_settings"]').removeClass("disabled"),e(".save_note").removeClass("rta_hidden"))},t.prototype.selectAll=function(t){var s=e(t.target).data("action"),r=e(t.target).data("target");checked="select"==s,e('input[name^="'+r+'"]').prop("checked",checked).trigger("change")},t.prototype.processInit=function(t){t.preventDefault(),this.unset_all_cookies(),this.show_errorbox(!1),this.hide_progress(),this.toggleShortPixelNotice(!1),this.show_wait(!0),this.in_process=!0,this.checkSubmitReady(),this.set_form_cookie();var s=this,r=this.get_form_cookie();e.ajax({type:"POST",dataType:"json",url:rta_data.ajaxurl,data:{gen_nonce:rta_data.nonce_generate,action:"rta_regenerate_thumbnails",type:"general",genform:JSON.stringify(r)},success:function(e){e.pCount>0?(s.offset=0,s.total=e.pCount,s.set_process_cookie(s.offset,s.total),s.process()):(s.finishProcess(),s.add_error(e.logstatus),s.show_errorlink(!0))}})},t.prototype.process=function(){offset=this.offset,total=this.total,this.in_process=!0,this.checkSubmitReady();var t=Math.round(offset/total*100);this.show_progress(t);var s=this,r=this.get_form_cookie();offset<total?e.ajax({type:"POST",dataType:"json",url:rta_data.ajaxurl,data:{gen_nonce:rta_data.nonce_generate,action:"rta_regenerate_thumbnails",type:"submit",offset:offset,genform:JSON.stringify(r)},success:function(t){t.offset<=total?("Processed"==t.logstatus&&e(".rta_progress .images img").attr("src",t.imgUrl),s.set_process_cookie(t.offset,total),s.offset=t.offset,setTimeout(function(){s.process()},1e3)):(s.set_cookie("rta_image_processed",e(".rta_progress .images img").attr("src")),s.show_errorlink(!0)),e.isArray(t.error)&&t.error.length>0&&s.add_error(t.logstatus)}}):(this.set_cookie("rta_image_processed",e(".rta_progress .images img").attr("src")),this.finishProcess(),this.show_errorlink(!0))},t.prototype.finishProcess=function(){this.in_process=!1,this.is_interrupted_process=!1,this.show_wait(!1),this.toggleShortPixelNotice(!0),this.checkSubmitReady()},t.prototype.show_progress=function(t){-1!=e(".rta_progress .images img").attr("src").indexOf("http")?e(".rta_progress .images").css("opacity",100):e(".rta_progress .images").css("opacity",0);var s=289.027;t>0&&(s=Math.round(s-s*t/100)),e(".CircularProgressbar-path").css("stroke-dashoffset",s+"px"),e(".CircularProgressbar-text").html(t+"%"),e(".rta_progress").is(":visible")||(this.show_wait(!1),e(".rta_progress").removeClass("rta_hidden"),e(".rta_progress").slideDown(),e(".rta_progress").css("display","inline-block"))},t.prototype.show_wait=function(t){t?e(".rta_wait_loader").show().removeClass("rta_hidden"):e(".rta_wait_loader").hide()},t.prototype.add_error=function(t){if(""!=t){var s="";if(e.isArray(t))for(var r=0;r<=t.length;r++)s=s+'<li class="list-group-item headLi">'+t[r]+"</li>";else s='<li class="list-group-item headLi">'+t+"</li>";e(".rta_error_box ul").append(s),this.set_cookie("rta_error_box_ul",e(".rta_error_box ul").html())}},t.prototype.show_errorbox=function(t){return t?!e(".rta_error_box").is(":visible")&&e(".rta_error_box ul li").length&&e(".rta_error_box").removeClass("rta_hidden").slideDown():(e(".rta_error_box").slideUp(10),e(".rta_error_box ul").html(""),e(".rta_error_link").slideUp(10)),!1},t.prototype.show_errorlink=function(){!e(".rta_error_link").is(":visible")&&e(".rta_error_box ul li").length&&e(".rta_error_link").removeClass("rta_hidden").slideDown()},t.prototype.hide_progress=function(){var e=jQuery;e(".rta_progress .images img").attr("src",""),e(".CircularProgressbar-path").css("stroke-dashoffset","289.027px"),e(".rta_progress .images").css("opacity",0),e(".rta_progress").slideUp(),e(".CircularProgressbar-text").html("0%")},t.prototype.unset_all_cookies=function(){this.set_cookie("rta_image_processed",""),this.set_cookie("rta_offset",""),this.set_cookie("rta_total",""),this.set_cookie("rta_last_settings","")},t.prototype.set_default_values=function(){},t.prototype.set_process_cookie=function(e,t){e=parseInt(e),t=parseInt(t),isNaN(e)||this.set_cookie("rta_offset",e),isNaN(t)||this.set_cookie("rta_total",t)},t.prototype.get_form_cookie=function(){var e=this.get_cookie("rta_last_settings");return formcookie={},e.length>0&&(formcookie=JSON.parse(e)),formcookie},t.prototype.set_form_cookie=function(){var t={};e("#frm_rta_image_sizes").find("input, select").each(function(){var s=e(this).val(),r=e(this).attr("name");return r.indexOf("image_sizes[")>=0||("checkbox"==e(this).attr("type")&&!e(this).prop("checked")||(matches=r.match(/(.*?)\[(.*)\]/),void(null!==matches?(t[matches[1]]||(t[matches[1]]=[]),t[matches[1]][matches[2]]=s):t[r]=s)))}),this.set_cookie("rta_last_settings",JSON.stringify(t),10)},t.prototype.set_cookie=function(e,t,s){var r=new Date;r.setTime(r.getTime()+24*s*60*60*1e3);var o="expires="+r.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},t.prototype.get_cookie=function(e){for(var t=e+"=",s=decodeURIComponent(document.cookie).split(";"),r=0;r<s.length;r++){for(var o=s[r];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""},t.prototype.add_image_size_row=function(){var e=jQuery,t=e(".table.imagesizes"),s=Math.random().toString(36).substring(2)+(new Date).getTime().toString(36),r=e(".row.proto").clone();e(r).attr("id",s),e(r).removeClass("proto"),t.append(r.css("display","table-row")),t.find(".header").removeClass("rta_hidden")},t.prototype.image_size_changed=function(t){t.preventDefault();var s=e(t.target).parents(".row").attr("id");this.update_thumb_name(s),this.save_image_sizes()},t.prototype.update_thumb_name=function(t){if(e("#"+t).length){var s=e("#"+t+" .image_sizes_name").val(),r=e("#"+t+" .image_sizes_width").val(),o=e("#"+t+" .image_sizes_height").val(),i=e("#"+t+" .image_sizes_cropping").val(),a=e("#"+t+" .image_sizes_pname").val();r<=0&&(r=""),o<=0&&(o="");var n=("rta_thumb "+i+" "+r+"x"+o).toLowerCase().replace(/ /g,"_");e('input[name^="regenerate_sizes"][value="'+s+'"]').val(n),a.length<=0&&e('input[name^="regenerate_sizes"][value="'+s+'"]').text(n),e('input[name="keep_'+s+'"]').attr("name","keep_"+n),e("#"+t+" .image_sizes_name").val(n)}},t.prototype.save_image_sizes=function(){this.settings_doingsave_indicator(!0);var t=rta_data.nonce_savesizes,s=this;e.ajax({type:"POST",dataType:"json",url:rta_data.ajaxurl,data:{action:"rta_save_image_sizes",save_nonce:t,saveform:e("#rta_settings_form").serialize()},success:function(t){t.error||t.new_image_sizes&&(e(".thumbnail_select .checkbox-list").fadeOut(80).html(t.new_image_sizes).fadeIn(80),s.checkOptionsVisible()),s.is_saved=!0,s.settings_doingsave_indicator(!1),s.checkSubmitReady()}})},t.prototype.settings_doingsave_indicator=function(t){t?e(".form_controls .save_indicator").fadeIn(20):e(".form_controls .save_indicator").fadeOut(100)},t.prototype.show_save_indicator=function(){this.is_saved=!1,this.checkSubmitReady()},t.prototype.toggleShortPixelNotice=function(t){t?e(".shortpixel-bulk-notice, .shortpixel-notice").removeClass("rta_hidden"):e(".shortpixel-bulk-notice, .shortpixel-notice").addClass("rta_hidden")},t.prototype.remove_image_size_row=function(t){var s=e(t.target).parents(".row").attr("id");if(confirm(rta_data.confirm_delete)){var r=e("#"+s).find(".image_sizes_name").val();e('input[name^="regenerate_sizes"][value="'+r+'"]').remove(),e("#"+s).remove(),this.save_image_sizes()}},t.prototype.checkOptionsVisible=function(){e('input[name^="regenerate_sizes"]').each(function(){e(this).is(":checked")?e(this).parents(".item").find(".options").removeClass("hidden"):e(this).parents(".item").find(".options").addClass("hidden")})},window.rtaJS=new t,window.rtaJS.init()});
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/resizeImage
|
|
| 4 |
Tags: regenerate, thumbnail, thumbnails, thumb, thumbs, easy, media, force regenerate, image, images, pics, date
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 5.2
|
| 7 |
-
Stable tag: 2.0
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -54,6 +54,17 @@ The script stops but it will resume after you open the settings page of the plug
|
|
| 54 |
|
| 55 |
== Changelog ==
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
= 2.0.1 =
|
| 58 |
|
| 59 |
Release date: 17th April 2019
|
| 4 |
Tags: regenerate, thumbnail, thumbnails, thumb, thumbs, easy, media, force regenerate, image, images, pics, date
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 5.2
|
| 7 |
+
Stable tag: 2.1.0
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 54 |
|
| 55 |
== Changelog ==
|
| 56 |
|
| 57 |
+
= 2.1.0 =
|
| 58 |
+
|
| 59 |
+
Release date: 7th June 2019
|
| 60 |
+
* Replace the two options Exact size for featured/non-featured images with one checkbox Only featured
|
| 61 |
+
* Button to stop the regeneration
|
| 62 |
+
* Make Keep existing be checked by default
|
| 63 |
+
* Change "Regenerate selected thumbnails" checklist to a settings selection
|
| 64 |
+
* ShortPixel Image Optimizer integration - call the 'shortpixel-thumbnails-regenerated' action passing only the changed sizes
|
| 65 |
+
* Fix: Security - Image sizes XSS exploit
|
| 66 |
+
* Fix: count(): Parameter must be an array
|
| 67 |
+
|
| 68 |
= 2.0.1 =
|
| 69 |
|
| 70 |
Release date: 17th April 2019
|
regenerate-thumbnails-advanced.php
CHANGED
|
@@ -2,11 +2,12 @@
|
|
| 2 |
/*
|
| 3 |
Plugin Name: Regenerate Thumbnails Advanced
|
| 4 |
Description: Regenerate thumbnails fast and easy while removing unused thumbnails of existing images; very useful when changing a theme.
|
| 5 |
-
Version: 2.0
|
| 6 |
Author: ShortPixel
|
| 7 |
Author URI: https://shortpixel.com/
|
| 8 |
License: GPLv2 or later
|
| 9 |
Text Domain: regenerate-thumbnails-advanced
|
|
|
|
| 10 |
*/
|
| 11 |
|
| 12 |
// Make sure we don't expose any info if called directly
|
|
@@ -15,16 +16,23 @@ if ( !function_exists( 'add_action' ) ) {
|
|
| 15 |
exit;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
define( 'RTA_PLUGIN_VERSION', '2.0
|
| 19 |
define( 'RTA_PLUGIN_PATH', plugin_dir_path(__FILE__) );
|
| 20 |
define( 'RTA_PLUGIN_URL', plugin_dir_url(__FILE__) );
|
| 21 |
define( 'RTA_SITE_BASE_URL', rtrim(get_bloginfo('url'),"/")."/");
|
| 22 |
define( 'RTA_PLUGIN_FILE', __FILE__);
|
| 23 |
-
define( 'RTA_LANG_DIR', dirname( plugin_basename(__FILE__) ).'/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
// define ('RTA_DEBUG', true);
|
| 26 |
|
| 27 |
-
require_once (RTA_PLUGIN_PATH . 'includes/rta_class.php');
|
| 28 |
|
| 29 |
register_activation_hook( __FILE__, array( 'RTA', 'rta_install' ) );
|
| 30 |
register_deactivation_hook( __FILE__, array( 'RTA', 'rta_uninstall' ) );
|
| 2 |
/*
|
| 3 |
Plugin Name: Regenerate Thumbnails Advanced
|
| 4 |
Description: Regenerate thumbnails fast and easy while removing unused thumbnails of existing images; very useful when changing a theme.
|
| 5 |
+
Version: 2.1.0
|
| 6 |
Author: ShortPixel
|
| 7 |
Author URI: https://shortpixel.com/
|
| 8 |
License: GPLv2 or later
|
| 9 |
Text Domain: regenerate-thumbnails-advanced
|
| 10 |
+
Domain Path: /languages
|
| 11 |
*/
|
| 12 |
|
| 13 |
// Make sure we don't expose any info if called directly
|
| 16 |
exit;
|
| 17 |
}
|
| 18 |
|
| 19 |
+
define( 'RTA_PLUGIN_VERSION', '2.1.0');
|
| 20 |
define( 'RTA_PLUGIN_PATH', plugin_dir_path(__FILE__) );
|
| 21 |
define( 'RTA_PLUGIN_URL', plugin_dir_url(__FILE__) );
|
| 22 |
define( 'RTA_SITE_BASE_URL', rtrim(get_bloginfo('url'),"/")."/");
|
| 23 |
define( 'RTA_PLUGIN_FILE', __FILE__);
|
| 24 |
+
define( 'RTA_LANG_DIR', dirname( plugin_basename(__FILE__) ).'/languages' );
|
| 25 |
+
|
| 26 |
+
require_once(RTA_PLUGIN_PATH . 'includes/rta_class.php');
|
| 27 |
+
require_once(RTA_PLUGIN_PATH .'rta_admin.php');
|
| 28 |
+
require_once(RTA_PLUGIN_PATH .'rta_front.php');
|
| 29 |
+
require_once(RTA_PLUGIN_PATH . 'classes/rta_admin_controller.php');
|
| 30 |
+
require_once(RTA_PLUGIN_PATH . 'classes/rta_image.php');
|
| 31 |
+
|
| 32 |
+
$rta = new RTA(); // start runtime
|
| 33 |
|
| 34 |
// define ('RTA_DEBUG', true);
|
| 35 |
|
|
|
|
| 36 |
|
| 37 |
register_activation_hook( __FILE__, array( 'RTA', 'rta_install' ) );
|
| 38 |
register_deactivation_hook( __FILE__, array( 'RTA', 'rta_uninstall' ) );
|
rta_admin.php
CHANGED
|
@@ -30,7 +30,7 @@ class RTA_Admin extends RTA
|
|
| 30 |
|
| 31 |
add_action( 'admin_menu', array( $this, 'rta_admin_menus' ) );
|
| 32 |
add_action( 'wp_ajax_rta_regenerate_thumbnails', array( $this, 'rta_regenerate_thumbnails') );
|
| 33 |
-
add_filter( 'image_size_names_choose', array( $this, 'rta_image_custom_sizes' ), 10, 1 );
|
| 34 |
add_action( 'wp_ajax_rta_save_image_sizes', array($this,'view_generate_thumbnails_save' ) );
|
| 35 |
|
| 36 |
add_filter( 'plugin_action_links_' . plugin_basename(RTA_PLUGIN_FILE), array(&$this, 'generate_plugin_links'));//for plugin settings page
|
|
@@ -50,75 +50,6 @@ class RTA_Admin extends RTA
|
|
| 50 |
|
| 51 |
}
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
/** [TODO] Check if this still exists **/
|
| 56 |
-
public function rta_image_sizes() {
|
| 57 |
-
|
| 58 |
-
global $rta_lang;
|
| 59 |
-
|
| 60 |
-
if( isset($_POST['btnsave']) && $_POST['btnsave'] != "" ) {
|
| 61 |
-
$exclude = array('btnsave');
|
| 62 |
-
$rta_image_sizes = array();
|
| 63 |
-
foreach( $_POST as $k => $v ) {
|
| 64 |
-
if( !in_array( $k, $exclude )) {
|
| 65 |
-
if(!is_array($v)) {
|
| 66 |
-
$val = $this->make_safe($v);
|
| 67 |
-
}else{
|
| 68 |
-
$val = $v;
|
| 69 |
-
}
|
| 70 |
-
$rta_image_sizes[$k] = $val;
|
| 71 |
-
}
|
| 72 |
-
}
|
| 73 |
-
update_option( 'rta_image_sizes', $rta_image_sizes );
|
| 74 |
-
$message = $this->rta_get_message_html( $rta_lang['image_sizes_save_message'], 'message' );
|
| 75 |
-
}
|
| 76 |
-
$rta_image_sizes = get_option( 'rta_image_sizes' );
|
| 77 |
-
|
| 78 |
-
$attr = $rta_image_sizes;
|
| 79 |
-
$attr['message'] = $message;
|
| 80 |
-
$html = $this->rta_load_template( "rta_image_sizes", "admin", $attr );
|
| 81 |
-
|
| 82 |
-
echo $html;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
// TODO Issue with this - function would remove all thumbnails. Need a better function.
|
| 86 |
-
/*function rta_del_associated_thumbs($mainFile='') {
|
| 87 |
-
//See ShortPixel Image Optimiser's findThumbs method
|
| 88 |
-
$ext = pathinfo($mainFile, PATHINFO_EXTENSION);
|
| 89 |
-
$base = substr($mainFile, 0, strlen($mainFile) - strlen($ext) - 1);
|
| 90 |
-
$pattern = '/' . preg_quote($base, '/') . '-\d+x\d+\.'. $ext .'/';
|
| 91 |
-
$thumbsCandidates = @glob($base . "-*." . $ext);
|
| 92 |
-
|
| 93 |
-
$thumbs = array();
|
| 94 |
-
if(is_array($thumbsCandidates)) {
|
| 95 |
-
foreach($thumbsCandidates as $th) {
|
| 96 |
-
if(preg_match($pattern, $th)) {
|
| 97 |
-
$thumbs[]= $th;
|
| 98 |
-
}
|
| 99 |
-
}
|
| 100 |
-
if( count($this->customThumbSuffixes)
|
| 101 |
-
&& !( is_plugin_active('envira-gallery/envira-gallery.php')
|
| 102 |
-
|| is_plugin_active('soliloquy/soliloquy.php')
|
| 103 |
-
|| is_plugin_active('soliloquy-lite/soliloquy-lite.php'))){
|
| 104 |
-
foreach ($this->customThumbSuffixes as $suffix){
|
| 105 |
-
$pattern = '/' . preg_quote($base, '/') . '-\d+x\d+'. $suffix . '\.'. $ext .'/';
|
| 106 |
-
foreach($thumbsCandidates as $th) {
|
| 107 |
-
if(preg_match($pattern, $th)) {
|
| 108 |
-
$thumbs[]= $th;
|
| 109 |
-
}
|
| 110 |
-
}
|
| 111 |
-
}
|
| 112 |
-
}
|
| 113 |
-
}
|
| 114 |
-
foreach($thumbs as $thumb) {
|
| 115 |
-
if($thumb !== $mainFile) {
|
| 116 |
-
@unlink($thumb);
|
| 117 |
-
}
|
| 118 |
-
}
|
| 119 |
-
return $thumbs;
|
| 120 |
-
} */
|
| 121 |
-
|
| 122 |
/**
|
| 123 |
* schedules the image's attachment post to be deleted if all the thumbnails are missing or just removes the missing thumbnails from the sizes array if some still are present.
|
| 124 |
* @param $image_id
|
|
@@ -192,18 +123,16 @@ class RTA_Admin extends RTA
|
|
| 192 |
$json = false;
|
| 193 |
}
|
| 194 |
|
| 195 |
-
$nonce = isset($_POST['
|
| 196 |
if (! wp_verify_nonce($nonce, 'rta_regenerate_thumbnails'))
|
| 197 |
{
|
| 198 |
$this->jsonResponse(array('error' => true, 'logstatus' => "Invalid Nonce", 'message' => "Site error, Invalid Nonce"));
|
| 199 |
exit();
|
| 200 |
}
|
| 201 |
|
| 202 |
-
if (isset($_POST['
|
| 203 |
{
|
| 204 |
-
$data = json_decode(html_entity_decode(stripslashes($_POST['
|
| 205 |
-
//parse_str($_POST['form'], $data);
|
| 206 |
-
|
| 207 |
}
|
| 208 |
else {
|
| 209 |
$this->jsonResponse(array('error' => true, 'logstatus' => "No Data", 'message' => "Site error, No Data"));
|
|
@@ -377,7 +306,6 @@ class RTA_Admin extends RTA
|
|
| 377 |
|
| 378 |
add_filter('intermediate_image_sizes_advanced', array($this, 'capture_generate_sizes'));
|
| 379 |
|
| 380 |
-
// TODO also make sure only the regenerated thumbnails are passed to the action
|
| 381 |
$new_metadata = wp_generate_attachment_metadata($image_id, $fullsizepath);
|
| 382 |
|
| 383 |
remove_filter('intermediate_image_sizes_advanced', array($this, 'capture_generate_sizes'));
|
|
@@ -406,15 +334,14 @@ class RTA_Admin extends RTA
|
|
| 406 |
|
| 407 |
$is_a_bulk = true; // we are sending multiple images.
|
| 408 |
$regenSizes = isset($new_metadata['sizes']) ? $new_metadata['sizes'] : array();
|
| 409 |
-
// TODO Something wrong with this hook.
|
| 410 |
-
|
| 411 |
-
$this->debug('Sending to ShortPixel: ');
|
| 412 |
-
$this->debug($original_meta);
|
| 413 |
-
$this->debug($regenSizes);
|
| 414 |
|
| 415 |
// Do not send if nothing was regenerated, otherwise SP thinks all needs to be redone
|
|
|
|
| 416 |
if (count($regenSizes) > 0)
|
|
|
|
| 417 |
do_action('shortpixel-thumbnails-regenerated', $image_id, $original_meta, $regenSizes, $is_a_bulk);
|
|
|
|
|
|
|
| 418 |
}
|
| 419 |
$imageUrl = $filename_only;
|
| 420 |
$logstatus = 'Processed';
|
|
@@ -519,14 +446,6 @@ class RTA_Admin extends RTA
|
|
| 519 |
}
|
| 520 |
|
| 521 |
|
| 522 |
-
public function rta_image_custom_sizes( $sizes ) {
|
| 523 |
-
|
| 524 |
-
global $rta_lang;
|
| 525 |
-
return array_merge( $sizes, array(
|
| 526 |
-
'rta_featured_image' => $rta_lang['featured_image_label'],
|
| 527 |
-
'rta_non_featured_image' => $rta_lang['no_featured_image_label'],
|
| 528 |
-
) );
|
| 529 |
-
}
|
| 530 |
|
| 531 |
public function view_generate_thumbnails() {
|
| 532 |
wp_enqueue_style('rta_css');
|
|
@@ -554,9 +473,8 @@ class RTA_Admin extends RTA
|
|
| 554 |
}
|
| 555 |
}
|
| 556 |
|
| 557 |
-
|
| 558 |
public function rta_settings() {
|
| 559 |
-
global $rta_options, $rta_lang;
|
| 560 |
do_action('rta_before_settings', $this, $rta_options );
|
| 561 |
|
| 562 |
$attr = $rta_options;
|
|
@@ -565,7 +483,9 @@ class RTA_Admin extends RTA
|
|
| 565 |
do_action('rta_after_settings', $this, $rta_options );
|
| 566 |
echo $html;
|
| 567 |
}
|
| 568 |
-
|
|
|
|
|
|
|
| 569 |
private function load_wp_media_uploader() {
|
| 570 |
|
| 571 |
wp_enqueue_script('media-upload');
|
|
@@ -573,7 +493,5 @@ class RTA_Admin extends RTA
|
|
| 573 |
wp_enqueue_style('thickbox');
|
| 574 |
$html = $this->rta_load_template( "load_media_upload_js", "admin" );
|
| 575 |
echo $html;
|
| 576 |
-
}
|
| 577 |
}
|
| 578 |
-
|
| 579 |
-
$rta_admin = new RTA_Admin();
|
| 30 |
|
| 31 |
add_action( 'admin_menu', array( $this, 'rta_admin_menus' ) );
|
| 32 |
add_action( 'wp_ajax_rta_regenerate_thumbnails', array( $this, 'rta_regenerate_thumbnails') );
|
| 33 |
+
//add_filter( 'image_size_names_choose', array( $this, 'rta_image_custom_sizes' ), 10, 1 );
|
| 34 |
add_action( 'wp_ajax_rta_save_image_sizes', array($this,'view_generate_thumbnails_save' ) );
|
| 35 |
|
| 36 |
add_filter( 'plugin_action_links_' . plugin_basename(RTA_PLUGIN_FILE), array(&$this, 'generate_plugin_links'));//for plugin settings page
|
| 50 |
|
| 51 |
}
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
/**
|
| 54 |
* schedules the image's attachment post to be deleted if all the thumbnails are missing or just removes the missing thumbnails from the sizes array if some still are present.
|
| 55 |
* @param $image_id
|
| 123 |
$json = false;
|
| 124 |
}
|
| 125 |
|
| 126 |
+
$nonce = isset($_POST['gen_nonce'])? $_POST['gen_nonce'] : false;
|
| 127 |
if (! wp_verify_nonce($nonce, 'rta_regenerate_thumbnails'))
|
| 128 |
{
|
| 129 |
$this->jsonResponse(array('error' => true, 'logstatus' => "Invalid Nonce", 'message' => "Site error, Invalid Nonce"));
|
| 130 |
exit();
|
| 131 |
}
|
| 132 |
|
| 133 |
+
if (isset($_POST['genform']))
|
| 134 |
{
|
| 135 |
+
$data = json_decode(html_entity_decode(stripslashes($_POST['genform'])), true);
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
else {
|
| 138 |
$this->jsonResponse(array('error' => true, 'logstatus' => "No Data", 'message' => "Site error, No Data"));
|
| 306 |
|
| 307 |
add_filter('intermediate_image_sizes_advanced', array($this, 'capture_generate_sizes'));
|
| 308 |
|
|
|
|
| 309 |
$new_metadata = wp_generate_attachment_metadata($image_id, $fullsizepath);
|
| 310 |
|
| 311 |
remove_filter('intermediate_image_sizes_advanced', array($this, 'capture_generate_sizes'));
|
| 334 |
|
| 335 |
$is_a_bulk = true; // we are sending multiple images.
|
| 336 |
$regenSizes = isset($new_metadata['sizes']) ? $new_metadata['sizes'] : array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
// Do not send if nothing was regenerated, otherwise SP thinks all needs to be redone
|
| 339 |
+
|
| 340 |
if (count($regenSizes) > 0)
|
| 341 |
+
{
|
| 342 |
do_action('shortpixel-thumbnails-regenerated', $image_id, $original_meta, $regenSizes, $is_a_bulk);
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
}
|
| 346 |
$imageUrl = $filename_only;
|
| 347 |
$logstatus = 'Processed';
|
| 446 |
}
|
| 447 |
|
| 448 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
|
| 450 |
public function view_generate_thumbnails() {
|
| 451 |
wp_enqueue_style('rta_css');
|
| 473 |
}
|
| 474 |
}
|
| 475 |
|
| 476 |
+
/* Probably outdated
|
| 477 |
public function rta_settings() {
|
|
|
|
| 478 |
do_action('rta_before_settings', $this, $rta_options );
|
| 479 |
|
| 480 |
$attr = $rta_options;
|
| 483 |
do_action('rta_after_settings', $this, $rta_options );
|
| 484 |
echo $html;
|
| 485 |
}
|
| 486 |
+
*/
|
| 487 |
+
/*
|
| 488 |
+
* Seems not in use.
|
| 489 |
private function load_wp_media_uploader() {
|
| 490 |
|
| 491 |
wp_enqueue_script('media-upload');
|
| 493 |
wp_enqueue_style('thickbox');
|
| 494 |
$html = $this->rta_load_template( "load_media_upload_js", "admin" );
|
| 495 |
echo $html;
|
| 496 |
+
} */
|
| 497 |
}
|
|
|
|
|
|
rta_front.php
CHANGED
|
@@ -31,7 +31,7 @@ class RTA_Front extends RTA
|
|
| 31 |
public function rta_jpeg_quality( $quality ) {
|
| 32 |
$rta_image_sizes = get_option( 'rta_image_sizes' );
|
| 33 |
if(is_array($rta_image_sizes) && sizeof($rta_image_sizes) > 0){
|
| 34 |
-
$jpeg_quality = $rta_image_sizes['jpeg_quality'];
|
| 35 |
if(!empty($jpeg_quality)) {
|
| 36 |
return (int)$jpeg_quality;
|
| 37 |
}
|
| 31 |
public function rta_jpeg_quality( $quality ) {
|
| 32 |
$rta_image_sizes = get_option( 'rta_image_sizes' );
|
| 33 |
if(is_array($rta_image_sizes) && sizeof($rta_image_sizes) > 0){
|
| 34 |
+
$jpeg_quality = isset($rta_image_sizes['jpeg_quality']) ? $rta_image_sizes['jpeg_quality'] : null;
|
| 35 |
if(!empty($jpeg_quality)) {
|
| 36 |
return (int)$jpeg_quality;
|
| 37 |
}
|
scss/rta-admin-view.scss
CHANGED
|
@@ -75,6 +75,7 @@
|
|
| 75 |
// max-width:90%;
|
| 76 |
padding: 20px 8px;
|
| 77 |
//background: #fff;
|
|
|
|
| 78 |
margin: 0 auto;
|
| 79 |
}
|
| 80 |
|
|
@@ -223,6 +224,8 @@
|
|
| 223 |
}
|
| 224 |
.rta_progress {
|
| 225 |
display: inline-block;
|
|
|
|
|
|
|
| 226 |
}
|
| 227 |
.images {
|
| 228 |
margin-left: 225px;
|
|
@@ -245,7 +248,35 @@
|
|
| 245 |
display: inline-block;
|
| 246 |
display: none;
|
| 247 |
}
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
.form_controls
|
| 251 |
{
|
|
@@ -265,6 +296,12 @@
|
|
| 265 |
font-size: 60px;
|
| 266 |
}
|
| 267 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
}
|
| 269 |
|
| 270 |
// low in the tree, to override most.
|
| 75 |
// max-width:90%;
|
| 76 |
padding: 20px 8px;
|
| 77 |
//background: #fff;
|
| 78 |
+
position: relative;
|
| 79 |
margin: 0 auto;
|
| 80 |
}
|
| 81 |
|
| 224 |
}
|
| 225 |
.rta_progress {
|
| 226 |
display: inline-block;
|
| 227 |
+
position: relative;
|
| 228 |
+
min-height: 310px;
|
| 229 |
}
|
| 230 |
.images {
|
| 231 |
margin-left: 225px;
|
| 248 |
display: inline-block;
|
| 249 |
display: none;
|
| 250 |
}
|
| 251 |
+
.shortpixel-notice
|
| 252 |
+
{
|
| 253 |
+
background: #fff;
|
| 254 |
+
width: 250px;
|
| 255 |
+
min-height: 270px;
|
| 256 |
+
border: 1px solid #ccc;
|
| 257 |
+
padding: 15px;
|
| 258 |
+
margin: 0 5% 10px 25px;
|
| 259 |
+
float: right;
|
| 260 |
+
h3 {
|
| 261 |
+
line-height: 1.3em; // match size
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
}
|
| 265 |
+
.shortpixel-bulk-notice
|
| 266 |
+
{
|
| 267 |
+
font-size: 14px;
|
| 268 |
+
font-weight: 700;
|
| 269 |
+
text-align: center;
|
| 270 |
+
}
|
| 271 |
+
button.stop-process
|
| 272 |
+
{
|
| 273 |
+
position: absolute;
|
| 274 |
+
bottom: 10px;
|
| 275 |
+
left: 80%;
|
| 276 |
+
font-weight: normal;
|
| 277 |
+
text-transform: none;
|
| 278 |
+
}
|
| 279 |
+
} // section.regenerate
|
| 280 |
|
| 281 |
.form_controls
|
| 282 |
{
|
| 296 |
font-size: 60px;
|
| 297 |
}
|
| 298 |
}
|
| 299 |
+
.save_note
|
| 300 |
+
{
|
| 301 |
+
color: orange;
|
| 302 |
+
float: right;
|
| 303 |
+
margin-left: 30px;
|
| 304 |
+
}
|
| 305 |
}
|
| 306 |
|
| 307 |
// low in the tree, to override most.
|
templates/admin/view_regenerate_process.php
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
|
| 2 |
-
<!--- TODO Move this to its own part -->
|
| 3 |
-
|
| 4 |
<section class='regenerate'>
|
| 5 |
<div class='container'>
|
| 6 |
-
<div class="rta_wait_loader"
|
| 7 |
|
| 8 |
<div class="cpbParent rta_progress rta_hidden">
|
| 9 |
<svg class="CircularProgressbar " viewBox="0 0 100 100">
|
|
@@ -24,18 +22,66 @@
|
|
| 24 |
<text class="CircularProgressbar-text" x="50" y="50">0%</text>
|
| 25 |
</svg>
|
| 26 |
<div class="images">
|
| 27 |
-
<h5
|
| 28 |
<img src="" alt="">
|
| 29 |
</div>
|
|
|
|
|
|
|
|
|
|
| 30 |
</div>
|
| 31 |
|
| 32 |
-
<a href="javascript:void(0);" class="rta_error_link rta_hidden"
|
| 33 |
<div class="listContainer rta_error_box row rta_hidden">
|
| 34 |
<div class="statuslist col-sm-6">
|
| 35 |
-
<h4 class="listTitle"
|
| 36 |
<ul class="list-group">
|
| 37 |
</ul>
|
| 38 |
</div>
|
| 39 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
</div> <!-- container -->
|
| 41 |
</section>
|
| 1 |
|
|
|
|
|
|
|
| 2 |
<section class='regenerate'>
|
| 3 |
<div class='container'>
|
| 4 |
+
<div class="rta_wait_loader"><?php _e('Please wait...','regenerate-thumbnails-advanced'); ?></div>
|
| 5 |
|
| 6 |
<div class="cpbParent rta_progress rta_hidden">
|
| 7 |
<svg class="CircularProgressbar " viewBox="0 0 100 100">
|
| 22 |
<text class="CircularProgressbar-text" x="50" y="50">0%</text>
|
| 23 |
</svg>
|
| 24 |
<div class="images">
|
| 25 |
+
<h5><?php _e('Regenerated image:','regenerate-thumbnails-advanced'); ?></h5>
|
| 26 |
<img src="" alt="">
|
| 27 |
</div>
|
| 28 |
+
|
| 29 |
+
<button class='button stop-process rta_hidden'><?php _e('Stop Process', 'regenerate-thumbnails-advanced') ?></button>
|
| 30 |
+
|
| 31 |
</div>
|
| 32 |
|
| 33 |
+
<a href="javascript:void(0);" class="rta_error_link rta_hidden"><?php _e('There were some errors, click for details', 'regenerate-thumbnails-advanced'); ?></a>
|
| 34 |
<div class="listContainer rta_error_box row rta_hidden">
|
| 35 |
<div class="statuslist col-sm-6">
|
| 36 |
+
<h4 class="listTitle"><?php _e('Error(s)','regenerate-thumbnails-advanced'); ?></h4>
|
| 37 |
<ul class="list-group">
|
| 38 |
</ul>
|
| 39 |
</div>
|
| 40 |
</div>
|
| 41 |
+
|
| 42 |
+
<?php
|
| 43 |
+
#wp_nonce_field('enable-media-replace');
|
| 44 |
+
$plugins = get_plugins();
|
| 45 |
+
$spInstalled = isset($plugins['shortpixel-image-optimiser/wp-shortpixel.php']);
|
| 46 |
+
$spActive = is_plugin_active('shortpixel-image-optimiser/wp-shortpixel.php');
|
| 47 |
+
|
| 48 |
+
?>
|
| 49 |
+
|
| 50 |
+
<?php if(!$spInstalled): ?>
|
| 51 |
+
<div class='shortpixel-notice rta_hidden'>
|
| 52 |
+
<h3 class="" style="margin-top: 0;text-align: center;">
|
| 53 |
+
<a href="https://shortpixel.com/otp/af/TFXUHHC28044" target="_blank">
|
| 54 |
+
<?php echo esc_html__("Optimize your images with ShortPixel, get +50% credits!", "enable-media-replace"); ?>
|
| 55 |
+
</a>
|
| 56 |
+
</h3>
|
| 57 |
+
<div class="" style="text-align: center;">
|
| 58 |
+
<a href="https://shortpixel.com/otp/af/TFXUHHC28044" target="_blank">
|
| 59 |
+
<img src="https://optimizingmattersblog.files.wordpress.com/2016/10/shortpixel.png">
|
| 60 |
+
</a>
|
| 61 |
+
</div>
|
| 62 |
+
<div class="" style="margin-bottom: 10px;">
|
| 63 |
+
<?php echo esc_html__("Get more Google love by compressing your site's images! Check out how much ShortPixel can save your site and get +50% credits when signing up as an Enable Media Replace user! Forever!", "enable-media-replace"); ?>
|
| 64 |
+
</div>
|
| 65 |
+
<div class=""><div style="text-align: <?php echo (is_rtl()) ? 'left' : 'right' ?>;">
|
| 66 |
+
<a class="button button-primary" id="shortpixel-image-optimiser-info" href="https://shortpixel.com/otp/af/TFXUHHC28044" target="_blank">
|
| 67 |
+
<?php echo esc_html__("More info", "enable-media-replace"); ?></p>
|
| 68 |
+
</a>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
</div>
|
| 72 |
+
<?php
|
| 73 |
+
else:
|
| 74 |
+
?>
|
| 75 |
+
<div class='shortpixel-bulk-notice rta_hidden'>
|
| 76 |
+
<?php if ($spActive): ?>
|
| 77 |
+
<p class='gotobulk'><?php printf(__('Thumbnails successfully regenerated. Go to %s ShortPixel Bulk page %s to optimize the updated thumbnails.'), '<a href="' . admin_url('upload.php?page=wp-short-pixel-bulk') . '">', '</a>'); ?></p>
|
| 78 |
+
<?php else:
|
| 79 |
+
$path = 'shortpixel-image-optimiser/wp-shortpixel.php';
|
| 80 |
+
$activate_url = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$path), 'activate-plugin_'.$path);
|
| 81 |
+
?>
|
| 82 |
+
<p class='gotobulk'><?php printf(__('%s Activate ShortPixel %s to optimize your newly generated thumbnails.'), '<a href="' . $activate_url . '">', '</a>'); ?></p>
|
| 83 |
+
<?php endif; ?>
|
| 84 |
+
</div>
|
| 85 |
+
<?php endif ?>
|
| 86 |
</div> <!-- container -->
|
| 87 |
</section>
|
templates/admin/view_rta_regenerate.php
CHANGED
|
@@ -28,12 +28,12 @@
|
|
| 28 |
<h4><?php _e('Clean-up options', 'regenerate-thumbnails-advanced') ?></h4>
|
| 29 |
<div class='option'>
|
| 30 |
<label for="del_associated_thumbs"><?php _e('Delete Unused Thumbnails','regenerate-thumbnails-advanced'); ?></label>
|
| 31 |
-
<span><input type="checkbox" name="del_associated_thumbs" id="del_associated_thumbs" value="
|
| 32 |
<span class='note'><?php _e('This option will remove thumbnails not selected in the settings. Good for stale thumbnails, but be sure they are not in use. ','regenerate-thumbnails-advanced'); ?></span>
|
| 33 |
</div>
|
| 34 |
<div class='option'>
|
| 35 |
<label for="del_leftover_metadata"><?php _e('Delete Leftover Image Metadata','regenerate-thumbnails-advanced'); ?></label>
|
| 36 |
-
<span><input type="checkbox" name="del_leftover_metadata" id="del_leftover_metadata" value="
|
| 37 |
<span class='note'><?php _e('Delete all the metadata associated with missing (non-existing) images. Keep in mind there is no undo!','regenerate-thumbnails-advanced'); ?></span>
|
| 38 |
</div>
|
| 39 |
</div>
|
|
@@ -42,7 +42,8 @@
|
|
| 42 |
|
| 43 |
<section class='form_controls'>
|
| 44 |
<div class='container'>
|
| 45 |
-
<button type='submit' disabled class='rta_regenerate disabled'
|
|
|
|
| 46 |
</div>
|
| 47 |
</section>
|
| 48 |
</form>
|
| 28 |
<h4><?php _e('Clean-up options', 'regenerate-thumbnails-advanced') ?></h4>
|
| 29 |
<div class='option'>
|
| 30 |
<label for="del_associated_thumbs"><?php _e('Delete Unused Thumbnails','regenerate-thumbnails-advanced'); ?></label>
|
| 31 |
+
<span><input type="checkbox" name="del_associated_thumbs" id="del_associated_thumbs" value="1" /> </span>
|
| 32 |
<span class='note'><?php _e('This option will remove thumbnails not selected in the settings. Good for stale thumbnails, but be sure they are not in use. ','regenerate-thumbnails-advanced'); ?></span>
|
| 33 |
</div>
|
| 34 |
<div class='option'>
|
| 35 |
<label for="del_leftover_metadata"><?php _e('Delete Leftover Image Metadata','regenerate-thumbnails-advanced'); ?></label>
|
| 36 |
+
<span><input type="checkbox" name="del_leftover_metadata" id="del_leftover_metadata" value="1" /> </span>
|
| 37 |
<span class='note'><?php _e('Delete all the metadata associated with missing (non-existing) images. Keep in mind there is no undo!','regenerate-thumbnails-advanced'); ?></span>
|
| 38 |
</div>
|
| 39 |
</div>
|
| 42 |
|
| 43 |
<section class='form_controls'>
|
| 44 |
<div class='container'>
|
| 45 |
+
<button type='submit' disabled class='rta_regenerate disabled'><?php _e('Regenerate', 'regenerate-thumbnails-advanced'); ?></button>
|
| 46 |
+
<p class='save_note rta_hidden'><?php _e('Save your settings first','regenerate-thumbnails-advanced'); ?></p>
|
| 47 |
</div>
|
| 48 |
</section>
|
| 49 |
</form>
|
templates/admin/view_rta_settings.php
CHANGED
|
@@ -73,12 +73,12 @@
|
|
| 73 |
<div class='container'>
|
| 74 |
|
| 75 |
<div class='option'>
|
| 76 |
-
<label><?php _e('Use selected thumbnails:') ?></label>
|
| 77 |
<div class='checkbox-list'>
|
| 78 |
<?php echo $view->generateImageSizeOptions($view->process_image_sizes); ?>
|
| 79 |
</div>
|
| 80 |
-
<div class='select-options'><span class='select' data-action='select' data-target='regenerate_sizes'
|
| 81 |
-
<span class='deselect' data-action='deselect' data-target='regenerate_sizes'
|
| 82 |
<div class='note'>
|
| 83 |
<ul>
|
| 84 |
<li><?php _e('Select the thumbnails you want to have available in your system. ', 'regenerate-thumbnails-advanced') ?></li>
|
| 73 |
<div class='container'>
|
| 74 |
|
| 75 |
<div class='option'>
|
| 76 |
+
<label><?php _e('Use selected thumbnails:', 'regenerate-thumbnails-advanced') ?></label>
|
| 77 |
<div class='checkbox-list'>
|
| 78 |
<?php echo $view->generateImageSizeOptions($view->process_image_sizes); ?>
|
| 79 |
</div>
|
| 80 |
+
<div class='select-options'><span class='select' data-action='select' data-target='regenerate_sizes'><?php _e('Select All', 'regenerate-thumbnails-advanced'); ?></span>
|
| 81 |
+
<span class='deselect' data-action='deselect' data-target='regenerate_sizes'><?php _e('Deselect All', 'regenerate-thumbnails-advanced'); ?></span>
|
| 82 |
<div class='note'>
|
| 83 |
<ul>
|
| 84 |
<li><?php _e('Select the thumbnails you want to have available in your system. ', 'regenerate-thumbnails-advanced') ?></li>
|
