Resize Image After Upload - Version 1.8.4

Version Description

Release date: 14th April 2018

  • Add recommended plugins
Download this release

Release Info

Developer ShortPixel
Plugin Icon 128x128 Resize Image After Upload
Version 1.8.4
Comparing to
See all releases

Code changes from version 1.8.3 to 1.8.4

class-riau-smart-notification.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class RIAU_Smart_Notification {
4
+
5
+ private static $_instance = null;
6
+ private $plugins;
7
+ private $options;
8
+ private $plugin_dir;
9
+
10
+ function __construct( $args ) {
11
+
12
+ if ( defined( WP_PLUGIN_DIR ) ) {
13
+ $this->plugin_dir = WP_PLUGIN_DIR . '/';
14
+ }else{
15
+ $this->plugin_dir = WP_CONTENT_DIR . '/plugins/';
16
+ }
17
+
18
+ $this->container_id = 'riau-smart-notification';
19
+ $this->options = get_option( 'sp-recommended-plugin', array() );
20
+ $this->plugins = $this->parse_plugins( $args['plugins'] );
21
+
22
+ if ( is_admin() && $this->show_notice() ) {
23
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
24
+ add_action( 'admin_notices', array( $this, 'notification' ) );
25
+ add_action( 'wp_ajax_riau_smart_notitification', array( $this, 'ajax' ) );
26
+ add_action('admin_footer', array( $this, 'riau_script' ) );
27
+ }
28
+
29
+ }
30
+
31
+ private function parse_plugins( $need_check ) {
32
+ $plugins = array();
33
+
34
+ foreach ( $need_check as $slug => $plugin ) {
35
+
36
+ if ( in_array( $slug, $this->options ) ) {
37
+ continue;
38
+ }
39
+
40
+ $plugin_info = $this->check_plugin( $slug );
41
+ if ( 'deactivate' == $plugin_info['needs'] ) {
42
+ continue;
43
+ }
44
+
45
+ $plugins[ $slug ] = array_merge( $plugin, $plugin_info );
46
+ }
47
+
48
+ return $plugins;
49
+
50
+ }
51
+
52
+ private function show_notice() {
53
+
54
+ if ( ! empty( $this->plugins ) ) {
55
+ return true;
56
+ }
57
+
58
+ return false;
59
+
60
+ }
61
+
62
+ /**
63
+ * @since 1.0.0
64
+ * @return riau_Smart_Notification
65
+ */
66
+ public static function get_instance( $args ) {
67
+ if ( is_null( self::$_instance ) ) {
68
+ self::$_instance = new self( $args );
69
+ }
70
+ return self::$_instance;
71
+ }
72
+
73
+ public function notification() {
74
+ $notice_html = '';
75
+
76
+ foreach ( $this->plugins as $slug => $plugin ) {
77
+ $notice_html .= '<div class="riau-plugin-card">';
78
+ $url = $this->create_plugin_link( $plugin['needs'], $slug );
79
+ if ( '' != $plugin['image'] ) {
80
+ $notice_html .= '<div style="padding-right: 10px;">';
81
+ $notice_html .= '<img src="' . esc_url( $plugin['image'] ) . '" width="75" height="75">';
82
+ $notice_html .= '</div>';
83
+ }
84
+ $notice_html .= '<div style="align-self: center;flex-grow: 1;">';
85
+ $notice_html .= '<h3 style="margin:0;">' . $plugin['name'] . '</h3>';
86
+ $notice_html .= '<p>' . $plugin['description'] . '</p>';
87
+ $notice_html .= '</div>';
88
+ $notice_html .= '<div>';
89
+ $notice_html .= '<a href="#" class="riau-dismiss" data-dismiss="' . esc_attr( $slug ) . '"><span class="screen-reader-text">Dismiss this notice.</span></a>';
90
+ $notice_html .= '<span class="plugin-card-' . esc_attr( $slug ) . ' action_button ' . $plugin['needs'] . '">';
91
+ $notice_html .= '<a data-slug="' . esc_attr( $slug ) . '" data-action="' . esc_attr( $plugin['needs'] ) . '" class="riau-plugin-button ' . esc_attr( $plugin['class'] ) . '" href="' . esc_url( $url ) . '">' . esc_attr( $plugin['label'] ) . '</a>';
92
+ $notice_html .= '</span>';
93
+ $notice_html .= '</div>';
94
+ $notice_html .= '</div>';
95
+ }
96
+
97
+ $class = "riau-one-column";
98
+ if ( count( $this->plugins ) > 1 ) {
99
+ $class = "riau-two-column";
100
+ }
101
+ echo '<div id="' . $this->container_id . '" class="riau-custom-notice notice ' . $class . '" style="background:transparent;border: 0 none;box-shadow: none;padding: 0;display: flex;">';
102
+ echo $notice_html;
103
+ echo '<style>.riau-plugin-card {display: flex;background: #fff;border-left: 4px solid #46b450;padding: .5em 12px;box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);position:relative;align-items:center;}.riau-one-column .riau-plugin-card{ width:100%; }.riau-two-column .riau-plugin-card{width:49%;}.riau-two-column .riau-plugin-card:nth-child( 2n + 1 ){margin-right:2%;}.riau-dismiss { position: absolute;top: 0;right: 1px;border: none;margin: 0;padding: 9px;background: 0 0;color: #72777c;cursor: pointer;text-decoration:none; }.riau-dismiss:before { background: 0 0;color: #72777c;content: "\f153";display: block;font: 400 16px/20px dashicons; speak: none;height: 20px;text-align: center;width: 20px;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale; }.riau-dismiss:active:before, .riau-dismiss:focus:before, .riau-dismiss:hover:before { color: #c00; }</style>';
104
+ echo '</div>';
105
+
106
+
107
+ }
108
+
109
+ public function ajax() {
110
+
111
+ check_ajax_referer( 'riau-smart-notitification', 'security' );
112
+
113
+ if ( isset( $_POST['slug'] ) ) {
114
+ $this->options[] = sanitize_text_field( $_POST['slug'] );
115
+ update_option( 'sp-recommended-plugin', $this->options );
116
+ }
117
+
118
+ wp_die( 'ok' );
119
+
120
+ }
121
+
122
+ public function enqueue() {
123
+ wp_enqueue_script( 'updates' );
124
+ wp_enqueue_script( 'jquery' );
125
+ }
126
+
127
+ private function get_plugins( $plugin_folder = '' ) {
128
+ if ( ! function_exists( 'get_plugins' ) ) {
129
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
130
+ }
131
+
132
+ return get_plugins( $plugin_folder );
133
+ }
134
+
135
+ private function _get_plugin_basename_from_slug( $slug ) {
136
+ $keys = array_keys( $this->get_plugins() );
137
+
138
+ foreach ( $keys as $key ) {
139
+ if ( preg_match( '|^' . $slug . '/|', $key ) ) {
140
+ return $key;
141
+ }
142
+ }
143
+
144
+ return $slug;
145
+ }
146
+
147
+ /**
148
+ * @return bool
149
+ */
150
+ private function check_plugin_is_installed( $slug ) {
151
+
152
+ $plugin_path = $this->_get_plugin_basename_from_slug( $slug );
153
+
154
+ if ( file_exists( $this->plugin_dir . $plugin_path ) ) {
155
+ return true;
156
+ }
157
+
158
+ return false;
159
+ }
160
+
161
+ /**
162
+ * @return bool
163
+ */
164
+ private function check_plugin_is_active( $slug ) {
165
+ $plugin_path = $this->_get_plugin_basename_from_slug( $slug );
166
+ if ( file_exists( $this->plugin_dir . $plugin_path ) ) {
167
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
168
+
169
+ return is_plugin_active( $plugin_path );
170
+ }
171
+ }
172
+
173
+ private function create_plugin_link( $state, $slug ) {
174
+ $string = '';
175
+
176
+ switch ( $state ) {
177
+ case 'install':
178
+ $string = wp_nonce_url(
179
+ add_query_arg(
180
+ array(
181
+ 'action' => 'install-plugin',
182
+ 'plugin' => $this->_get_plugin_basename_from_slug( $slug ),
183
+ ),
184
+ network_admin_url( 'update.php' )
185
+ ),
186
+ 'install-plugin_' . $slug
187
+ );
188
+ break;
189
+ case 'deactivate':
190
+ $string = add_query_arg(
191
+ array(
192
+ 'action' => 'deactivate',
193
+ 'plugin' => rawurlencode( $this->_get_plugin_basename_from_slug( $slug ) ),
194
+ 'plugin_status' => 'all',
195
+ 'paged' => '1',
196
+ '_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $this->_get_plugin_basename_from_slug( $slug ) ),
197
+ ),
198
+ admin_url( 'plugins.php' )
199
+ );
200
+ break;
201
+ case 'activate':
202
+ $string = add_query_arg(
203
+ array(
204
+ 'action' => 'activate',
205
+ 'plugin' => rawurlencode( $this->_get_plugin_basename_from_slug( $slug ) ),
206
+ 'plugin_status' => 'all',
207
+ 'paged' => '1',
208
+ '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $this->_get_plugin_basename_from_slug( $slug ) ),
209
+ ),
210
+ admin_url( 'plugins.php' )
211
+ );
212
+ break;
213
+ default:
214
+ $string = '';
215
+ break;
216
+ }// End switch().
217
+
218
+ return $string;
219
+ }
220
+
221
+ private function check_plugin( $slug = '' ) {
222
+ $arr = array(
223
+ 'installed' => $this->check_plugin_is_installed( $slug ),
224
+ 'active' => $this->check_plugin_is_active( $slug ),
225
+ 'needs' => 'install',
226
+ 'class' => 'button button-primary',
227
+ 'label' => __( 'Install and Activate', 'enable-media-replace' ),
228
+ );
229
+
230
+ if ( $arr['installed'] ) {
231
+ $arr['needs'] = 'activate';
232
+ $arr['class'] = 'button button-primary';
233
+ $arr['label'] = __( 'Activate now', 'enable-media-replace' );
234
+ }
235
+
236
+ if ( $arr['active'] ) {
237
+ $arr['needs'] = 'deactivate';
238
+ $arr['class'] = 'deactivate-now button';
239
+ $arr['label'] = __( 'Deactivate now', 'enable-media-replace' );
240
+ }
241
+
242
+ return $arr;
243
+ }
244
+
245
+ public function riau_script() {
246
+
247
+ $ajax_nonce = wp_create_nonce( 'riau-smart-notitification' );
248
+
249
+ ?>
250
+ <script type="text/javascript">
251
+
252
+
253
+ function riauActivatePlugin( url, el ) {
254
+
255
+ jQuery.ajax( {
256
+ async: true,
257
+ type: 'GET',
258
+ dataType: 'html',
259
+ url: url,
260
+ success: function() {
261
+ location.reload();
262
+ }
263
+ } );
264
+ }
265
+
266
+ var riauContainer = jQuery( '#<?php echo $this->container_id ?>' );
267
+ riauContainer.on( 'click', '.riau-plugin-button', function( event ) {
268
+ var action = jQuery( this ).data( 'action' ),
269
+ url = jQuery( this ).attr( 'href' ),
270
+ slug = jQuery( this ).data( 'slug' );
271
+
272
+ jQuery(this).addClass( 'updating-message' );
273
+ jQuery(this).attr( 'disabled', 'disabled' );
274
+
275
+ event.preventDefault();
276
+
277
+ if ( 'install' === action ) {
278
+
279
+ wp.updates.installPlugin( {
280
+ slug: slug
281
+ } );
282
+
283
+ } else if ( 'activate' === action ) {
284
+
285
+ riauActivatePlugin( url, jQuery( this ) );
286
+
287
+ }
288
+
289
+ } );
290
+
291
+ riauContainer.on( 'click', '.riau-dismiss', function( event ) {
292
+ var container = jQuery(this).parents( '.riau-plugin-card' ),
293
+ data = jQuery(this).data(),
294
+ ajaxData = {
295
+ action: 'riau_smart_notitification',
296
+ security: '<?php echo $ajax_nonce; ?>',
297
+ };
298
+
299
+ event.preventDefault();
300
+
301
+ ajaxData.slug = data.dismiss;
302
+
303
+ jQuery.post( '<?php echo admin_url( 'admin-ajax.php' ) ?>', ajaxData, function( response ) {
304
+ container.slideUp( 'fast', function() {
305
+ jQuery( this ).remove();
306
+ } );
307
+ });
308
+
309
+ });
310
+
311
+ jQuery( document ).on( 'wp-plugin-install-success', function( response, data ) {
312
+ var el = riauContainer.find( '.riau-plugin-button[data-slug="' + data.slug + '"]' );
313
+ event.preventDefault();
314
+ riauActivatePlugin( data.activateUrl, el );
315
+ } );
316
+
317
+ </script>
318
+
319
+ <?php
320
+ }
321
+
322
+ }
img/shortpixel.png ADDED
Binary file
img/sp.png CHANGED
Binary file
img/wp-modula.jpg ADDED
Binary file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/resizeImage
4
  Tags: image, resize, rescale, bulk resize, bulk rescale, downsize,
5
  Requires at least: 3.5
6
  Tested up to: 4.9
7
- Stable tag: 1.8.3
8
 
9
  Automatically resize your images after upload using this plugin. Specify height&width, the plugin will do the rest quickly and transparently.
10
 
@@ -43,6 +43,12 @@ Is that simple, just give it a try, it is safe and free! :-)
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
 
46
  = 1.8.3 =
47
 
48
  Release date: 20th December 2017
4
  Tags: image, resize, rescale, bulk resize, bulk rescale, downsize,
5
  Requires at least: 3.5
6
  Tested up to: 4.9
7
+ Stable tag: 1.8.4
8
 
9
  Automatically resize your images after upload using this plugin. Specify height&width, the plugin will do the rest quickly and transparently.
10
 
43
 
44
  == Changelog ==
45
 
46
+ = 1.8.4 =
47
+
48
+ Release date: 14th April 2018
49
+
50
+ * Add recommended plugins
51
+
52
  = 1.8.3 =
53
 
54
  Release date: 20th December 2017
resize-image-after-upload.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Resize Image After Upload
4
  Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/
5
  Description: Automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options found under <a href="options-general.php?page=resize-after-upload">Settings > Resize Image Upload</a>
6
  Author: ShortPixel
7
- Version: 1.8.3
8
  Author URI: https://shortpixel.com
9
 
10
  Copyright (C) 2017 ShortPixel
@@ -24,7 +24,7 @@ along with this program; if not, write to the Free Software
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
- $PLUGIN_VERSION = '1.8.3';
28
  $DEBUG_LOGGER = false;
29
 
30
 
@@ -52,8 +52,8 @@ add_action('wp_handle_upload', 'jr_uploadresize_resize');
52
 
53
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'jr_generate_plugin_links');//for plugin settings page
54
 
55
- add_action('admin_notices', 'jr_display_notices');
56
- add_action('wp_ajax_jr_dismiss_notices', 'jr_dismiss_notices');
57
 
58
  /**
59
  * Add ths link to Settings in Plugins Page
@@ -606,3 +606,22 @@ function jr_error_log($message) {
606
  error_log(print_r($message, true));
607
  }
608
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  Plugin URI: https://wordpress.org/plugins/resize-image-after-upload/
5
  Description: Automatically resize uploaded images to within specified maximum width and height. Also has option to force recompression of JPEGs. Configuration options found under <a href="options-general.php?page=resize-after-upload">Settings > Resize Image Upload</a>
6
  Author: ShortPixel
7
+ Version: 1.8.4
8
  Author URI: https://shortpixel.com
9
 
10
  Copyright (C) 2017 ShortPixel
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
+ $PLUGIN_VERSION = '1.8.4';
28
  $DEBUG_LOGGER = false;
29
 
30
 
52
 
53
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'jr_generate_plugin_links');//for plugin settings page
54
 
55
+ //add_action('admin_notices', 'jr_display_notices');
56
+ //add_action('wp_ajax_jr_dismiss_notices', 'jr_dismiss_notices');
57
 
58
  /**
59
  * Add ths link to Settings in Plugins Page
606
  error_log(print_r($message, true));
607
  }
608
  }
609
+
610
+
611
+ // Add Smart Notification
612
+ require_once 'class-riau-smart-notification.php';
613
+ RIAU_Smart_Notification::get_instance( array(
614
+ 'plugins' => array(
615
+ 'shortpixel-image-optimiser' => array(
616
+ 'name' => __( 'ShortPixel Image Optimizer', 'resize-image-after-upload' ),
617
+ 'description' => __( 'A freemium easy to use, comprehensive, stable and frequently updated image compression plugin supported by the friendly team that created it.', 'resize-image-after-upload' ),
618
+ 'image' => plugins_url('/img/shortpixel.png',__FILE__),
619
+ ),
620
+ 'modula-best-grid-gallery' => array(
621
+ 'name' => __( 'Modula WordPress Photo Gallery', 'resize-image-after-upload' ),
622
+ 'description' => __( 'Modula is currently the easiest and fastest photo gallery plugin for WordPress. With its wizard you are able to build an image gallery in a few seconds, unlike many other WordPress gallery plugins.', 'resize-image-after-upload' ),
623
+ 'image' => plugins_url('/img/wp-modula.jpg',__FILE__),
624
+ ),
625
+ ),
626
+
627
+ ) );