CDN Enabler – WordPress CDN Plugin - Version 1.0.6

Version Description

Download this release

Release Info

Developer keycdn
Plugin Icon 128x128 CDN Enabler – WordPress CDN Plugin
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

inc/cdn_enabler.class.php CHANGED
@@ -102,7 +102,7 @@ class CDN_Enabler
102
  * add Zone purge link
103
  *
104
  * @since 1.0.5
105
- * @change 1.0.5
106
  *
107
  * @hook mixed
108
  *
@@ -113,7 +113,7 @@ class CDN_Enabler
113
  $options = self::get_options();
114
 
115
  // check user role
116
- if ( ! is_admin_bar_showing()) {
117
  return;
118
  }
119
 
@@ -157,7 +157,7 @@ class CDN_Enabler
157
  * process purge request
158
  *
159
  * @since 1.0.5
160
- * @change 1.0.5
161
  *
162
  * @param array $data array of metadata
163
  */
@@ -209,17 +209,30 @@ class CDN_Enabler
209
  $json = json_decode($response['body'], true);
210
 
211
  // success
212
- if ( wp_remote_retrieve_response_code( $response ) == 200 ) {
 
 
 
213
  printf(
214
  '<div class="notice notice-success is-dismissible"><p>%s</p></div>',
215
  esc_html__($json['description'], 'cdn-enabler')
216
  );
217
 
 
 
 
 
 
 
 
 
218
  return;
219
  }
220
 
221
  // API call returned != 200 and also a status message
222
- if ( array_key_exists('status', $json) and $json['status'] != "" ) {
 
 
223
  printf(
224
  '<div class="notice notice-error is-dismissible"><p>%s</p></div>',
225
  esc_html__('HTTP returned '. wp_remote_retrieve_response_code( $response ) .': '.$json['description'], 'cdn-enabler')
@@ -228,10 +241,22 @@ class CDN_Enabler
228
  // Something else went wrong - show HTTP error code
229
  printf(
230
  '<div class="notice notice-error is-dismissible"><p>%s</p></div>',
231
- esc_html__('HTTP returned '. wp_remote_retrieve_response_code( $response ) .':')
232
  );
233
  }
234
  }
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
 
237
 
102
  * add Zone purge link
103
  *
104
  * @since 1.0.5
105
+ * @change 1.0.6
106
  *
107
  * @hook mixed
108
  *
113
  $options = self::get_options();
114
 
115
  // check user role
116
+ if ( ! is_admin_bar_showing() or ! apply_filters('user_can_clear_cache', current_user_can('manage_options')) ) {
117
  return;
118
  }
119
 
157
  * process purge request
158
  *
159
  * @since 1.0.5
160
+ * @change 1.0.6
161
  *
162
  * @param array $data array of metadata
163
  */
209
  $json = json_decode($response['body'], true);
210
 
211
  // success
212
+ if ( wp_remote_retrieve_response_code( $response ) == 200
213
+ and is_array($json)
214
+ and array_key_exists('description', $json) )
215
+ {
216
  printf(
217
  '<div class="notice notice-success is-dismissible"><p>%s</p></div>',
218
  esc_html__($json['description'], 'cdn-enabler')
219
  );
220
 
221
+ return;
222
+ } elseif ( wp_remote_retrieve_response_code( $response ) == 200 ) {
223
+ // return code 200 but no message
224
+ printf(
225
+ '<div class="notice notice-warning is-dismissible"><p>%s</p></div>',
226
+ esc_html__('HTTP returned 200 but no message received.')
227
+ );
228
+
229
  return;
230
  }
231
 
232
  // API call returned != 200 and also a status message
233
+ if ( is_array($json)
234
+ and array_key_exists('status', $json)
235
+ and $json['status'] != "" ) {
236
  printf(
237
  '<div class="notice notice-error is-dismissible"><p>%s</p></div>',
238
  esc_html__('HTTP returned '. wp_remote_retrieve_response_code( $response ) .': '.$json['description'], 'cdn-enabler')
241
  // Something else went wrong - show HTTP error code
242
  printf(
243
  '<div class="notice notice-error is-dismissible"><p>%s</p></div>',
244
+ esc_html__('HTTP returned '. wp_remote_retrieve_response_code( $response ))
245
  );
246
  }
247
  }
248
+
249
+
250
+ if ( ! is_admin() ) {
251
+ wp_safe_redirect(
252
+ remove_query_arg(
253
+ '_cache',
254
+ wp_get_referer()
255
+ )
256
+ );
257
+
258
+ exit();
259
+ }
260
  }
261
 
262
 
inc/cdn_enabler_settings.class.php CHANGED
@@ -93,7 +93,7 @@ class CDN_Enabler_Settings
93
  * settings page
94
  *
95
  * @since 0.0.1
96
- * @change 1.0.5
97
  *
98
  * @return void
99
  */
@@ -204,7 +204,7 @@ class CDN_Enabler_Settings
204
  <td>
205
  <fieldset>
206
  <label for="cdn_enabler_api_key">
207
- <input type="text" name="cdn_enabler[keycdn_api_key]" id="cdn_enabler_api_key" value="<?php echo $options['keycdn_api_key']; ?>" size="64" class="regular-text code" />
208
  <p class="description">
209
  <?php _e("KeyCDN API key to purge zone on request", "cdn-enabler"); ?>
210
  </p>
93
  * settings page
94
  *
95
  * @since 0.0.1
96
+ * @change 1.0.6
97
  *
98
  * @return void
99
  */
204
  <td>
205
  <fieldset>
206
  <label for="cdn_enabler_api_key">
207
+ <input type="password" name="cdn_enabler[keycdn_api_key]" id="cdn_enabler_api_key" value="<?php echo $options['keycdn_api_key']; ?>" size="64" class="regular-text code" />
208
  <p class="description">
209
  <?php _e("KeyCDN API key to purge zone on request", "cdn-enabler"); ?>
210
  </p>
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === CDN Enabler - WordPress CDN Plugin ===
2
  Contributors: keycdn
3
  Tags: cdn, content delivery network, content distribution network
4
- Requires at least: 3.8
5
- Tested up to: 4.8
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -31,8 +31,8 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
31
 
32
 
33
  = System Requirements =
34
- * PHP >=5.3
35
- * WordPress >=3.8
36
 
37
 
38
  = Contribute =
1
  === CDN Enabler - WordPress CDN Plugin ===
2
  Contributors: keycdn
3
  Tags: cdn, content delivery network, content distribution network
4
+ Requires at least: 4.6
5
+ Tested up to: 4.9
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
31
 
32
 
33
  = System Requirements =
34
+ * PHP >=5.4
35
+ * WordPress >=4.6
36
 
37
 
38
  = Contribute =