CDN Enabler – WordPress CDN Plugin - Version 1.0.5

Version Description

  • Multiprotocol CDN rewriting
  • Add purging through KeyCDN API
  • Don't rewrite if in admin preview mode
  • Rewrite to HTTPS if enabled and client connects through HTTP
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.0.5

cdn-enabler.php CHANGED
@@ -1,32 +1,31 @@
1
  <?php
2
  /*
3
- Plugin Name: CDN Enabler
4
- Text Domain: cdn-enabler
5
- Description: Simply integrate a Content Delivery Network (CDN) into your WordPress site.
6
- Author: KeyCDN
7
- Author URI: https://www.keycdn.com
8
- License: GPLv2 or later
9
- Version: 1.0.4
10
- */
11
 
12
  /*
13
- Copyright (C) 2017 KeyCDN
14
 
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License as published by
17
- the Free Software Foundation; either version 2 of the License, or
18
- (at your option) any later version.
19
 
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License along
26
- with this program; if not, write to the Free Software Foundation, Inc.,
27
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
- */
29
 
 
 
 
 
30
 
31
  /* Check & Quit */
32
  defined('ABSPATH') OR exit;
@@ -41,31 +40,31 @@ define('CDN_ENABLER_MIN_WP', '3.8');
41
 
42
  /* loader */
43
  add_action(
44
- 'plugins_loaded',
45
- array(
46
- 'CDN_Enabler',
47
- 'instance'
48
- )
49
  );
50
 
51
 
52
  /* uninstall */
53
  register_uninstall_hook(
54
- __FILE__,
55
- array(
56
- 'CDN_Enabler',
57
- 'handle_uninstall_hook'
58
- )
59
  );
60
 
61
 
62
  /* activation */
63
  register_activation_hook(
64
- __FILE__,
65
- array(
66
- 'CDN_Enabler',
67
- 'handle_activation_hook'
68
- )
69
  );
70
 
71
 
@@ -74,13 +73,13 @@ spl_autoload_register('CDN_ENABLER_autoload');
74
 
75
  /* autoload funktion */
76
  function CDN_ENABLER_autoload($class) {
77
- if ( in_array($class, array('CDN_Enabler', 'CDN_Enabler_Rewriter', 'CDN_Enabler_Settings')) ) {
78
- require_once(
79
- sprintf(
80
- '%s/inc/%s.class.php',
81
- CDN_ENABLER_DIR,
82
- strtolower($class)
83
- )
84
- );
85
- }
86
  }
1
  <?php
2
  /*
3
+ Plugin Name: CDN Enabler
4
+ Text Domain: cdn-enabler
5
+ Description: Simply integrate a Content Delivery Network (CDN) into your WordPress site.
6
+ Author: KeyCDN
7
+ Author URI: https://www.keycdn.com
8
+ License: GPLv2 or later
9
+ Version: 1.0.5
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2017 KeyCDN
14
 
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License as published by
17
+ the Free Software Foundation; either version 2 of the License, or
18
+ (at your option) any later version.
19
 
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
 
 
 
 
 
24
 
25
+ You should have received a copy of the GNU General Public License along
26
+ with this program; if not, write to the Free Software Foundation, Inc.,
27
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
+ */
29
 
30
  /* Check & Quit */
31
  defined('ABSPATH') OR exit;
40
 
41
  /* loader */
42
  add_action(
43
+ 'plugins_loaded',
44
+ [
45
+ 'CDN_Enabler',
46
+ 'instance',
47
+ ]
48
  );
49
 
50
 
51
  /* uninstall */
52
  register_uninstall_hook(
53
+ __FILE__,
54
+ [
55
+ 'CDN_Enabler',
56
+ 'handle_uninstall_hook',
57
+ ]
58
  );
59
 
60
 
61
  /* activation */
62
  register_activation_hook(
63
+ __FILE__,
64
+ [
65
+ 'CDN_Enabler',
66
+ 'handle_activation_hook',
67
+ ]
68
  );
69
 
70
 
73
 
74
  /* autoload funktion */
75
  function CDN_ENABLER_autoload($class) {
76
+ if ( in_array($class, ['CDN_Enabler', 'CDN_Enabler_Rewriter', 'CDN_Enabler_Settings']) ) {
77
+ require_once(
78
+ sprintf(
79
+ '%s/inc/%s.class.php',
80
+ CDN_ENABLER_DIR,
81
+ strtolower($class)
82
+ )
83
+ );
84
+ }
85
  }
inc/cdn_enabler.class.php CHANGED
@@ -1,246 +1,402 @@
1
  <?php
2
 
3
  /**
4
- * CDN_Enabler
5
- *
6
- * @since 0.0.1
7
- */
8
 
9
  class CDN_Enabler
10
  {
11
 
12
 
13
- /**
14
- * pseudo-constructor
15
- *
16
- * @since 0.0.1
17
- * @change 0.0.1
18
- */
19
-
20
- public static function instance() {
21
- new self();
22
- }
23
-
24
 
25
- /**
26
- * constructor
27
- *
28
- * @since 0.0.1
29
- * @change 1.0.4
30
- */
31
 
32
- public function __construct() {
 
 
 
 
 
33
 
 
34
  /* CDN rewriter hook */
35
  add_action(
36
  'template_redirect',
37
- array(
38
  __CLASS__,
39
- 'handle_rewrite_hook'
40
- )
41
  );
42
 
43
- /* Hooks */
44
- add_action(
45
- 'admin_init',
46
- array(
47
- __CLASS__,
48
- 'register_textdomain'
49
- )
50
- );
51
- add_action(
52
- 'admin_init',
53
- array(
54
- 'CDN_Enabler_Settings',
55
- 'register_settings'
56
- )
57
- );
58
- add_action(
59
- 'admin_menu',
60
- array(
61
- 'CDN_Enabler_Settings',
62
- 'add_settings_page'
63
- )
64
- );
65
  add_filter(
66
  'plugin_action_links_' .CDN_ENABLER_BASE,
67
- array(
68
  __CLASS__,
69
- 'add_action_link'
70
- )
71
  );
72
 
73
  /* admin notices */
74
  add_action(
75
  'all_admin_notices',
76
- array(
 
 
 
 
 
 
 
 
 
77
  __CLASS__,
78
- 'cdn_enabler_requirements_check'
79
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  );
 
 
81
 
82
- }
83
-
84
-
85
-
86
- /**
87
- * add action links
88
- *
89
- * @since 0.0.1
90
- * @change 0.0.1
91
- *
92
- * @param array $data alreay existing links
93
- * @return array $data extended array with links
94
- */
95
-
96
- public static function add_action_link($data) {
97
- // check permission
98
- if ( ! current_user_can('manage_options') ) {
99
- return $data;
100
- }
101
-
102
- return array_merge(
103
- $data,
104
- array(
105
- sprintf(
106
- '<a href="%s">%s</a>',
107
- add_query_arg(
108
- array(
109
- 'page' => 'cdn_enabler'
110
- ),
111
- admin_url('options-general.php')
112
- ),
113
- __("Settings")
114
- )
115
- )
116
- );
117
- }
118
-
119
-
120
- /**
121
- * run uninstall hook
122
- *
123
- * @since 0.0.1
124
- * @change 0.0.1
125
- */
126
-
127
- public static function handle_uninstall_hook() {
128
  delete_option('cdn_enabler');
129
- }
130
 
131
 
132
- /**
133
- * run activation hook
134
- *
135
- * @since 0.0.1
136
- * @change 1.0.3
137
- */
138
 
139
- public static function handle_activation_hook() {
140
  add_option(
141
  'cdn_enabler',
142
- array(
143
- 'url' => get_option('home'),
144
- 'dirs' => 'wp-content,wp-includes',
145
- 'excludes' => '.php',
146
- 'relative' => '1',
147
- 'https' => ''
148
- )
 
 
149
  );
150
- }
151
-
152
-
153
- /**
154
- * check plugin requirements
155
- *
156
- * @since 0.0.1
157
- * @change 0.0.1
158
- */
159
-
160
- public static function cdn_enabler_requirements_check() {
161
- // WordPress version check
162
- if ( version_compare($GLOBALS['wp_version'], CDN_ENABLER_MIN_WP.'alpha', '<') ) {
163
- show_message(
164
- sprintf(
165
- '<div class="error"><p>%s</p></div>',
166
- sprintf(
167
- __("CDN Enabler is optimized for WordPress %s. Please disable the plugin or upgrade your WordPress installation (recommended).", "cdn-enabler"),
168
- CDN_ENABLER_MIN_WP
169
- )
170
- )
171
- );
172
- }
173
- }
174
-
175
-
176
- /**
177
- * register textdomain
178
- *
179
- * @since 1.0.3
180
- * @change 1.0.3
181
- */
182
-
183
- public static function register_textdomain() {
184
-
185
- load_plugin_textdomain(
186
- 'cdn-enabler',
187
- false,
188
- 'cdn-enabler/lang'
189
- );
190
- }
191
-
192
-
193
- /**
194
- * return plugin options
195
- *
196
- * @since 0.0.1
197
- * @change 1.0.3
198
- *
199
- * @return array $diff data pairs
200
- */
201
-
202
- public static function get_options() {
203
- return wp_parse_args(
204
- get_option('cdn_enabler'),
205
- array(
206
- 'url' => get_option('home'),
207
- 'dirs' => 'wp-content,wp-includes',
208
- 'excludes' => '.php',
209
- 'relative' => 1,
210
- 'https' => 0
211
- )
212
- );
213
- }
 
214
 
215
 
216
  /**
217
- * run rewrite hook
218
- *
219
- * @since 0.0.1
220
- * @change 1.0.3
221
- */
222
 
223
  public static function handle_rewrite_hook() {
224
  $options = self::get_options();
225
 
226
  // check if origin equals cdn url
227
  if (get_option('home') == $options['url']) {
228
- return;
229
- }
230
 
231
  $excludes = array_map('trim', explode(',', $options['excludes']));
232
 
233
- $rewriter = new CDN_Enabler_Rewriter(
234
- get_option('home'),
235
- $options['url'],
236
- $options['dirs'],
237
- $excludes,
238
- $options['relative'],
239
- $options['https']
240
- );
241
- ob_start(
242
- array(&$rewriter, 'rewrite')
243
  );
 
244
  }
245
 
246
  }
1
  <?php
2
 
3
  /**
4
+ * CDN_Enabler
5
+ *
6
+ * @since 0.0.1
7
+ */
8
 
9
  class CDN_Enabler
10
  {
11
 
12
 
13
+ /**
14
+ * pseudo-constructor
15
+ *
16
+ * @since 0.0.1
17
+ * @change 0.0.1
18
+ */
19
+
20
+ public static function instance() {
21
+ new self();
22
+ }
 
23
 
 
 
 
 
 
 
24
 
25
+ /**
26
+ * constructor
27
+ *
28
+ * @since 0.0.1
29
+ * @change 1.0.4
30
+ */
31
 
32
+ public function __construct() {
33
  /* CDN rewriter hook */
34
  add_action(
35
  'template_redirect',
36
+ [
37
  __CLASS__,
38
+ 'handle_rewrite_hook',
39
+ ]
40
  );
41
 
42
+ /* Hooks */
43
+ add_action(
44
+ 'admin_init',
45
+ [
46
+ __CLASS__,
47
+ 'register_textdomain',
48
+ ]
49
+ );
50
+ add_action(
51
+ 'admin_init',
52
+ [
53
+ 'CDN_Enabler_Settings',
54
+ 'register_settings',
55
+ ]
56
+ );
57
+ add_action(
58
+ 'admin_menu',
59
+ [
60
+ 'CDN_Enabler_Settings',
61
+ 'add_settings_page',
62
+ ]
63
+ );
64
  add_filter(
65
  'plugin_action_links_' .CDN_ENABLER_BASE,
66
+ [
67
  __CLASS__,
68
+ 'add_action_link',
69
+ ]
70
  );
71
 
72
  /* admin notices */
73
  add_action(
74
  'all_admin_notices',
75
+ [
76
+ __CLASS__,
77
+ 'cdn_enabler_requirements_check',
78
+ ]
79
+ );
80
+
81
+ /* add admin purge link */
82
+ add_action(
83
+ 'admin_bar_menu',
84
+ [
85
  __CLASS__,
86
+ 'add_admin_links',
87
+ ],
88
+ 90
89
+ );
90
+ /* process purge request */
91
+ add_action(
92
+ 'init',
93
+ [
94
+ __CLASS__,
95
+ 'process_purge_request',
96
+ ]
97
+ );
98
+ }
99
+
100
+
101
+ /**
102
+ * add Zone purge link
103
+ *
104
+ * @since 1.0.5
105
+ * @change 1.0.5
106
+ *
107
+ * @hook mixed
108
+ *
109
+ * @param object menu properties
110
+ */
111
+
112
+ public static function add_admin_links($wp_admin_bar) {
113
+ $options = self::get_options();
114
+
115
+ // check user role
116
+ if ( ! is_admin_bar_showing()) {
117
+ return;
118
+ }
119
+
120
+ // verify Zone settings are set
121
+ if ( ! is_int($options['keycdn_zone_id'])
122
+ or $options['keycdn_zone_id'] <= 0 ) {
123
+ return;
124
+ }
125
+ if ( ! array_key_exists('keycdn_api_key', $options)
126
+ or strlen($options['keycdn_api_key']) < 20 ) {
127
+ return;
128
+ }
129
+
130
+ // add admin purge link
131
+ $wp_admin_bar->add_menu(
132
+ [
133
+ 'id' => 'purge-cdn',
134
+ 'href' => wp_nonce_url( add_query_arg('_cdn', 'purge'), '_cdn__purge_nonce'),
135
+ 'parent' => 'top-secondary',
136
+ 'title' => '<span class="ab-item">'.esc_html__('Purge CDN', 'cdn-enabler').'</span>',
137
+ 'meta' => ['title' => esc_html__('Purge CDN', 'cdn-enabler')],
138
+ ]
139
+ );
140
+
141
+ if ( ! is_admin() ) {
142
+ // add admin purge link
143
+ $wp_admin_bar->add_menu(
144
+ [
145
+ 'id' => 'purge-cdn',
146
+ 'href' => wp_nonce_url( add_query_arg('_cdn', 'purge'), '_cdn__purge_nonce'),
147
+ 'parent' => 'top-secondary',
148
+ 'title' => '<span class="ab-item">'.esc_html__('Purge CDN', 'cdn-enabler').'</span>',
149
+ 'meta' => ['title' => esc_html__('Purge CDN', 'cdn-enabler')],
150
+ ]
151
+ );
152
+ }
153
+ }
154
+
155
+
156
+ /**
157
+ * process purge request
158
+ *
159
+ * @since 1.0.5
160
+ * @change 1.0.5
161
+ *
162
+ * @param array $data array of metadata
163
+ */
164
+ public static function process_purge_request($data) {
165
+ $options = self::get_options();
166
+
167
+ // check if clear request
168
+ if ( empty($_GET['_cdn']) OR $_GET['_cdn'] !== 'purge' ) {
169
+ return;
170
+ }
171
+
172
+ // validate nonce
173
+ if ( empty($_GET['_wpnonce']) OR ! wp_verify_nonce($_GET['_wpnonce'], '_cdn__purge_nonce') ) {
174
+ return;
175
+ }
176
+
177
+ // check user role
178
+ if ( ! is_admin_bar_showing() ) {
179
+ return;
180
+ }
181
+
182
+ // load if network
183
+ if ( ! function_exists('is_plugin_active_for_network') ) {
184
+ require_once( ABSPATH. 'wp-admin/includes/plugin.php' );
185
+ }
186
+
187
+ // API call to purge zone
188
+ $response = wp_remote_get( 'https://api.keycdn.com/zones/purge/'. $options['keycdn_zone_id'] .'.json',
189
+ [
190
+ 'timeout' => 20,
191
+ 'headers' => [
192
+ 'Authorization' => 'Basic ' . base64_encode( $options['keycdn_api_key'] . ':' ),
193
+ ]
194
+ ]
195
+ );
196
+
197
+ // check results - error connecting
198
+ if ( is_wp_error( $response ) ) {
199
+ printf(
200
+ '<div class="notice notice-error is-dismissible"><p>%s</p></div>',
201
+ esc_html__('Error connecting to API - '. $response->get_error_message(), 'cdn-enabler')
202
+ );
203
+
204
+ return;
205
+ }
206
+
207
+ // check HTTP response
208
+ if ( is_array( $response ) and is_admin_bar_showing()) {
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')
226
+ );
227
+ } else {
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
+
238
+
239
+ /**
240
+ * add action links
241
+ *
242
+ * @since 0.0.1
243
+ * @change 0.0.1
244
+ *
245
+ * @param array $data alreay existing links
246
+ * @return array $data extended array with links
247
+ */
248
+
249
+ public static function add_action_link($data) {
250
+ // check permission
251
+ if ( ! current_user_can('manage_options') ) {
252
+ return $data;
253
+ }
254
+
255
+ return array_merge(
256
+ $data,
257
+ [
258
+ sprintf(
259
+ '<a href="%s">%s</a>',
260
+ add_query_arg(
261
+ [
262
+ 'page' => 'cdn_enabler',
263
+ ],
264
+ admin_url('options-general.php')
265
+ ),
266
+ __("Settings")
267
+ ),
268
+ ]
269
  );
270
+ }
271
+
272
 
273
+ /**
274
+ * run uninstall hook
275
+ *
276
+ * @since 0.0.1
277
+ * @change 0.0.1
278
+ */
279
+
280
+ public static function handle_uninstall_hook() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  delete_option('cdn_enabler');
282
+ }
283
 
284
 
285
+ /**
286
+ * run activation hook
287
+ *
288
+ * @since 0.0.1
289
+ * @change 1.0.5
290
+ */
291
 
292
+ public static function handle_activation_hook() {
293
  add_option(
294
  'cdn_enabler',
295
+ [
296
+ 'url' => get_option('home'),
297
+ 'dirs' => 'wp-content,wp-includes',
298
+ 'excludes' => '.php',
299
+ 'relative' => '1',
300
+ 'https' => '',
301
+ 'keycdn_api_key' => '',
302
+ 'keycdn_zone_id' => '',
303
+ ]
304
  );
305
+ }
306
+
307
+
308
+ /**
309
+ * check plugin requirements
310
+ *
311
+ * @since 0.0.1
312
+ * @change 0.0.1
313
+ */
314
+
315
+ public static function cdn_enabler_requirements_check() {
316
+ // WordPress version check
317
+ if ( version_compare($GLOBALS['wp_version'], CDN_ENABLER_MIN_WP.'alpha', '<') ) {
318
+ show_message(
319
+ sprintf(
320
+ '<div class="error"><p>%s</p></div>',
321
+ sprintf(
322
+ __("CDN Enabler is optimized for WordPress %s. Please disable the plugin or upgrade your WordPress installation (recommended).", "cdn-enabler"),
323
+ CDN_ENABLER_MIN_WP
324
+ )
325
+ )
326
+ );
327
+ }
328
+ }
329
+
330
+
331
+ /**
332
+ * register textdomain
333
+ *
334
+ * @since 1.0.3
335
+ * @change 1.0.3
336
+ */
337
+
338
+ public static function register_textdomain() {
339
+ load_plugin_textdomain(
340
+ 'cdn-enabler',
341
+ false,
342
+ 'cdn-enabler/lang'
343
+ );
344
+ }
345
+
346
+
347
+ /**
348
+ * return plugin options
349
+ *
350
+ * @since 0.0.1
351
+ * @change 1.0.5
352
+ *
353
+ * @return array $diff data pairs
354
+ */
355
+
356
+ public static function get_options() {
357
+ return wp_parse_args(
358
+ get_option('cdn_enabler'),
359
+ [
360
+ 'url' => get_option('home'),
361
+ 'dirs' => 'wp-content,wp-includes',
362
+ 'excludes' => '.php',
363
+ 'relative' => 1,
364
+ 'https' => 0,
365
+ 'keycdn_api_key' => '',
366
+ 'keycdn_zone_id' => '',
367
+ ]
368
+ );
369
+ }
370
 
371
 
372
  /**
373
+ * run rewrite hook
374
+ *
375
+ * @since 0.0.1
376
+ * @change 1.0.5
377
+ */
378
 
379
  public static function handle_rewrite_hook() {
380
  $options = self::get_options();
381
 
382
  // check if origin equals cdn url
383
  if (get_option('home') == $options['url']) {
384
+ return;
385
+ }
386
 
387
  $excludes = array_map('trim', explode(',', $options['excludes']));
388
 
389
+ $rewriter = new CDN_Enabler_Rewriter(
390
+ get_option('home'),
391
+ $options['url'],
392
+ $options['dirs'],
393
+ $excludes,
394
+ $options['relative'],
395
+ $options['https'],
396
+ $options['keycdn_api_key'],
397
+ $options['keycdn_zone_id']
 
398
  );
399
+ ob_start(array(&$rewriter, 'rewrite'));
400
  }
401
 
402
  }
inc/cdn_enabler_rewriter.class.php CHANGED
@@ -1,141 +1,194 @@
1
  <?php
2
 
3
  /**
4
- * CDN_Enabler_Rewriter
5
- *
6
- * @since 0.0.1
7
- */
8
 
9
  class CDN_Enabler_Rewriter
10
  {
11
- var $blog_url = null; // origin URL
12
- var $cdn_url = null; // CDN URL
13
 
14
- var $dirs = null; // included directories
15
- var $excludes = array(); // excludes
16
- var $relative = false; // use CDN on relative paths
17
- var $https = false; // use CDN on HTTPS
 
 
18
 
19
  /**
20
- * constructor
21
- *
22
- * @since 0.0.1
23
- * @change 1.0.3
24
- */
25
-
26
- function __construct($blog_url, $cdn_url, $dirs, array $excludes, $relative, $https) {
27
- $this->blog_url = $blog_url;
28
- $this->cdn_url = $cdn_url;
29
- $this->dirs = $dirs;
30
- $this->excludes = $excludes;
31
- $this->relative = $relative;
32
- $this->https = $https;
33
- }
 
 
 
 
 
 
 
 
 
 
 
34
 
35
 
36
  /**
37
- * exclude assets that should not be rewritten
38
- *
39
- * @since 0.0.1
40
- * @change 1.0.3
41
- *
42
- * @param string $asset current asset
43
- * @return boolean true if need to be excluded
44
- */
45
-
46
- protected function exclude_asset(&$asset) {
47
- // excludes
48
- foreach ($this->excludes as $exclude) {
49
- if (!!$exclude && stristr($asset, $exclude) != false) {
50
- return true;
51
- }
52
- }
53
- return false;
54
- }
55
 
56
 
57
  /**
58
- * rewrite url
59
- *
60
- * @since 0.0.1
61
- * @change 0.0.1
62
- *
63
- * @param string $asset current asset
64
- * @return string updated url if not excluded
65
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  protected function rewrite_url($asset) {
68
- if ($this->exclude_asset($asset[0])) {
69
- return $asset[0];
70
- }
71
- $blog_url = $this->blog_url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  // check if not a relative path
74
- if (!$this->relative || strstr($asset[0], $blog_url)) {
75
- return str_replace($blog_url, $this->cdn_url, $asset[0]);
76
- }
77
 
78
- return $this->cdn_url . $asset[0];
79
- }
 
80
 
81
 
82
  /**
83
- * get directory scope
84
- *
85
- * @since 0.0.1
86
- * @change 0.0.1
87
- *
88
- * @return string directory scope
89
- */
90
 
91
- protected function get_dir_scope() {
92
- $input = explode(',', $this->dirs);
93
 
94
  // default
95
- if ($this->dirs == '' || count($input) < 1) {
96
- return 'wp\-content|wp\-includes';
97
- }
98
 
99
- return implode('|', array_map('quotemeta', array_map('trim', $input)));
100
- }
101
 
102
 
103
  /**
104
- * rewrite url
105
- *
106
- * @since 0.0.1
107
- * @change 1.0.1
108
- *
109
- * @param string $html current raw HTML doc
110
- * @return string updated HTML doc with CDN links
111
- */
112
-
113
- public function rewrite($html) {
114
  // check if HTTPS and use CDN over HTTPS enabled
115
- if (!$this->https && isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') {
116
- return $html;
117
- }
118
 
119
  // get dir scope in regex format
120
- $dirs = $this->get_dir_scope();
121
- $blog_url = quotemeta($this->blog_url);
 
 
122
 
123
- // regex rule start
124
- $regex_rule = '#(?<=[(\"\'])';
125
 
126
  // check if relative paths
127
  if ($this->relative) {
128
  $regex_rule .= '(?:'.$blog_url.')?';
129
  } else {
130
- $regex_rule .= $blog_url;
131
- }
132
 
133
  // regex rule end
134
- $regex_rule .= '/(?:((?:'.$dirs.')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
135
 
136
  // call the cdn rewriter callback
137
- $cdn_html = preg_replace_callback($regex_rule, array(&$this, 'rewrite_url'), $html);
138
 
139
- return $cdn_html;
140
- }
141
  }
1
  <?php
2
 
3
  /**
4
+ * CDN_Enabler_Rewriter
5
+ *
6
+ * @since 0.0.1
7
+ */
8
 
9
  class CDN_Enabler_Rewriter
10
  {
11
+ var $blog_url = null; // origin URL
12
+ var $cdn_url = null; // CDN URL
13
 
14
+ var $dirs = null; // included directories
15
+ var $excludes = []; // excludes
16
+ var $relative = false; // use CDN on relative paths
17
+ var $https = false; // use CDN on HTTPS
18
+ var $keycdn_api_key = null; // optional API key for KeyCDN
19
+ var $keycdn_zone_id = null; // optional KeyCDN Zone ID
20
 
21
  /**
22
+ * constructor
23
+ *
24
+ * @since 0.0.1
25
+ * @change 1.0.5
26
+ */
27
+
28
+ function __construct(
29
+ $blog_url,
30
+ $cdn_url,
31
+ $dirs,
32
+ array $excludes,
33
+ $relative,
34
+ $https,
35
+ $keycdn_api_key,
36
+ $keycdn_zone_id
37
+ ) {
38
+ $this->blog_url = $blog_url;
39
+ $this->cdn_url = $cdn_url;
40
+ $this->dirs = $dirs;
41
+ $this->excludes = $excludes;
42
+ $this->relative = $relative;
43
+ $this->https = $https;
44
+ $this->keycdn_api_key = $keycdn_api_key;
45
+ $this->keycdn_zone_id = $keycdn_zone_id;
46
+ }
47
 
48
 
49
  /**
50
+ * exclude assets that should not be rewritten
51
+ *
52
+ * @since 0.0.1
53
+ * @change 1.0.3
54
+ *
55
+ * @param string $asset current asset
56
+ * @return boolean true if need to be excluded
57
+ */
58
+
59
+ protected function exclude_asset(&$asset) {
60
+ // excludes
61
+ foreach ($this->excludes as $exclude) {
62
+ if (!!$exclude && stristr($asset, $exclude) != false) {
63
+ return true;
64
+ }
65
+ }
66
+ return false;
67
+ }
68
 
69
 
70
  /**
71
+ * relative url
72
+ *
73
+ * @since 1.0.5
74
+ * @change 1.0.5
75
+ *
76
+ * @param string $url a full url
77
+ * @return string protocol relative url
78
+ */
79
+ protected function relative_url($url) {
80
+ return substr($url, strpos($url, '//'));
81
+ }
82
+
83
+
84
+ /**
85
+ * rewrite url
86
+ *
87
+ * @since 0.0.1
88
+ * @change 1.0.5
89
+ *
90
+ * @param string $asset current asset
91
+ * @return string updated url if not excluded
92
+ */
93
 
94
  protected function rewrite_url($asset) {
95
+ if ($this->exclude_asset($asset[0])) {
96
+ return $asset[0];
97
+ }
98
+
99
+ // Don't rewrite if in preview mode
100
+ if ( is_admin_bar_showing()
101
+ and array_key_exists('preview', $_GET)
102
+ and $_GET['preview'] == 'true' )
103
+ {
104
+ return $asset[0];
105
+ }
106
+
107
+ $blog_url = $this->relative_url($this->blog_url);
108
+ $subst_urls = [ 'http:'.$blog_url ];
109
+
110
+ // rewrite both http and https URLs if we ticked 'enable CDN for HTTPS connections'
111
+ if ($this->https) {
112
+ $subst_urls = [
113
+ 'http:'.$blog_url,
114
+ 'https:'.$blog_url,
115
+ ];
116
+ }
117
+
118
+ // is it a protocol independent URL?
119
+ if (strpos($asset[0], '//') === 0) {
120
+ return str_replace($blog_url, $this->cdn_url, $asset[0]);
121
+ }
122
 
123
  // check if not a relative path
124
+ if (!$this->relative || strstr($asset[0], $blog_url)) {
125
+ return str_replace($subst_urls, $this->cdn_url, $asset[0]);
126
+ }
127
 
128
+ // relative URL
129
+ return $this->cdn_url . $asset[0];
130
+ }
131
 
132
 
133
  /**
134
+ * get directory scope
135
+ *
136
+ * @since 0.0.1
137
+ * @change 0.0.1
138
+ *
139
+ * @return string directory scope
140
+ */
141
 
142
+ protected function get_dir_scope() {
143
+ $input = explode(',', $this->dirs);
144
 
145
  // default
146
+ if ($this->dirs == '' || count($input) < 1) {
147
+ return 'wp\-content|wp\-includes';
148
+ }
149
 
150
+ return implode('|', array_map('quotemeta', array_map('trim', $input)));
151
+ }
152
 
153
 
154
  /**
155
+ * rewrite url
156
+ *
157
+ * @since 0.0.1
158
+ * @change 1.0.5
159
+ *
160
+ * @param string $html current raw HTML doc
161
+ * @return string updated HTML doc with CDN links
162
+ */
163
+
164
+ public function rewrite($html) {
165
  // check if HTTPS and use CDN over HTTPS enabled
166
+ if (!$this->https && isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') {
167
+ return $html;
168
+ }
169
 
170
  // get dir scope in regex format
171
+ $dirs = $this->get_dir_scope();
172
+ $blog_url = $this->https
173
+ ? '(https?:|)'.$this->relative_url(quotemeta($this->blog_url))
174
+ : '(http:|)'.$this->relative_url(quotemeta($this->blog_url));
175
 
176
+ // regex rule start
177
+ $regex_rule = '#(?<=[(\"\'])';
178
 
179
  // check if relative paths
180
  if ($this->relative) {
181
  $regex_rule .= '(?:'.$blog_url.')?';
182
  } else {
183
+ $regex_rule .= $blog_url;
184
+ }
185
 
186
  // regex rule end
187
+ $regex_rule .= '/(?:((?:'.$dirs.')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
188
 
189
  // call the cdn rewriter callback
190
+ $cdn_html = preg_replace_callback($regex_rule, [&$this, 'rewrite_url'], $html);
191
 
192
+ return $cdn_html;
193
+ }
194
  }
inc/cdn_enabler_settings.class.php CHANGED
@@ -1,190 +1,237 @@
1
  <?php
2
 
3
  /**
4
- * CDN_Enabler_Settings
5
- *
6
- * @since 0.0.1
7
- */
8
 
9
  class CDN_Enabler_Settings
10
  {
11
 
12
 
13
- /**
14
- * register settings
15
- *
16
- * @since 0.0.1
17
- * @change 0.0.1
18
- */
19
-
20
- public static function register_settings()
21
- {
22
- register_setting(
23
- 'cdn_enabler',
24
- 'cdn_enabler',
25
- array(
26
- __CLASS__,
27
- 'validate_settings'
28
- )
29
- );
30
- }
31
-
32
-
33
- /**
34
- * validation of settings
35
- *
36
- * @since 0.0.1
37
- * @change 1.0.3
38
- *
39
- * @param array $data array with form data
40
- * @return array array with validated values
41
- */
42
-
43
- public static function validate_settings($data)
44
- {
45
- return array(
46
- 'url' => esc_url($data['url']),
47
- 'dirs' => esc_attr($data['dirs']),
48
- 'excludes' => esc_attr($data['excludes']),
49
- 'relative' => (int)($data['relative']),
50
- 'https' => (int)($data['https'])
51
- );
52
- }
53
-
54
-
55
- /**
56
- * add settings page
57
- *
58
- * @since 0.0.1
59
- * @change 0.0.1
60
- */
61
-
62
- public static function add_settings_page()
63
- {
64
- $page = add_options_page(
65
- 'CDN Enabler',
66
- 'CDN Enabler',
67
- 'manage_options',
68
- 'cdn_enabler',
69
- array(
70
- __CLASS__,
71
- 'settings_page'
72
- )
73
- );
74
- }
75
-
76
-
77
- /**
78
- * settings page
79
- *
80
- * @since 0.0.1
81
- * @change 1.0.3
82
- *
83
- * @return void
84
- */
85
-
86
- public static function settings_page()
87
- { ?>
88
- <div class="wrap">
89
- <h2>
90
- <?php _e("CDN Enabler Settings", "cdn-enabler"); ?>
91
- </h2>
92
-
93
- <div class="notice notice-info">
94
- <p><?php printf( __('Combine CDN Enabler with <b><a href="%s">%s</a></b> for even faster WordPress performance.', 'cdn-enabler'), 'https://www.keycdn.com?utm_source=wp-admin&utm_medium=plugins&utm_campaign=cdn-enabler', 'KeyCDN'); ?></p>
95
- </div>
96
-
97
- <form method="post" action="options.php">
98
- <?php settings_fields('cdn_enabler') ?>
99
-
100
- <?php $options = CDN_Enabler::get_options() ?>
101
-
102
- <table class="form-table">
103
-
104
- <tr valign="top">
105
- <th scope="row">
106
- <?php _e("CDN URL", "cdn-enabler"); ?>
107
- </th>
108
- <td>
109
- <fieldset>
110
- <label for="cdn_enabler_url">
111
- <input type="text" name="cdn_enabler[url]" id="cdn_enabler_url" value="<?php echo $options['url']; ?>" size="64" class="regular-text code" />
112
- </label>
113
-
114
- <p class="description">
115
- <?php _e("Enter the CDN URL without trailing", "cdn-enabler"); ?> <code>/</code>
116
- </p>
117
- </fieldset>
118
- </td>
119
- </tr>
120
-
121
- <tr valign="top">
122
- <th scope="row">
123
- <?php _e("Included Directories", "cdn-enabler"); ?>
124
- </th>
125
- <td>
126
- <fieldset>
127
- <label for="cdn_enabler_dirs">
128
- <input type="text" name="cdn_enabler[dirs]" id="cdn_enabler_dirs" value="<?php echo $options['dirs']; ?>" size="64" class="regular-text code" />
129
- <?php _e("Default: <code>wp-content,wp-includes</code>", "cdn-enabler"); ?>
130
- </label>
131
-
132
- <p class="description">
133
- <?php _e("Assets in these directories will be pointed to the CDN URL. Enter the directories separated by", "cdn-enabler"); ?> <code>,</code>
134
- </p>
135
- </fieldset>
136
- </td>
137
- </tr>
138
-
139
- <tr valign="top">
140
- <th scope="row">
141
- <?php _e("Exclusions", "cdn-enabler"); ?>
142
- </th>
143
- <td>
144
- <fieldset>
145
- <label for="cdn_enabler_excludes">
146
- <input type="text" name="cdn_enabler[excludes]" id="cdn_enabler_excludes" value="<?php echo $options['excludes']; ?>" size="64" class="regular-text code" />
147
- <?php _e("Default: <code>.php</code>", "cdn-enabler"); ?>
148
- </label>
149
-
150
- <p class="description">
151
- <?php _e("Enter the exclusions (directories or extensions) separated by", "cdn-enabler"); ?> <code>,</code>
152
- </p>
153
- </fieldset>
154
- </td>
155
- </tr>
156
-
157
- <tr valign="top">
158
- <th scope="row">
159
- <?php _e("Relative Path", "cdn-enabler"); ?>
160
- </th>
161
- <td>
162
- <fieldset>
163
- <label for="cdn_enabler_relative">
164
- <input type="checkbox" name="cdn_enabler[relative]" id="cdn_enabler_relative" value="1" <?php checked(1, $options['relative']) ?> />
165
- <?php _e("Enable CDN for relative paths (default: enabled).", "cdn-enabler"); ?>
166
- </label>
167
- </fieldset>
168
- </td>
169
- </tr>
170
-
171
- <tr valign="top">
172
- <th scope="row">
173
- <?php _e("CDN HTTPS", "cdn-enabler"); ?>
174
- </th>
175
- <td>
176
- <fieldset>
177
- <label for="cdn_enabler_https">
178
- <input type="checkbox" name="cdn_enabler[https]" id="cdn_enabler_https" value="1" <?php checked(1, $options['https']) ?> />
179
- <?php _e("Enable CDN for HTTPS connections (default: disabled).", "cdn-enabler"); ?>
180
- </label>
181
- </fieldset>
182
- </td>
183
- </tr>
184
- </table>
185
-
186
- <?php submit_button() ?>
187
- </form>
188
- </div><?php
189
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
1
  <?php
2
 
3
  /**
4
+ * CDN_Enabler_Settings
5
+ *
6
+ * @since 0.0.1
7
+ */
8
 
9
  class CDN_Enabler_Settings
10
  {
11
 
12
 
13
+ /**
14
+ * register settings
15
+ *
16
+ * @since 0.0.1
17
+ * @change 0.0.1
18
+ */
19
+
20
+ public static function register_settings()
21
+ {
22
+ register_setting(
23
+ 'cdn_enabler',
24
+ 'cdn_enabler',
25
+ [
26
+ __CLASS__,
27
+ 'validate_settings',
28
+ ]
29
+ );
30
+ }
31
+
32
+
33
+ /**
34
+ * validation of settings
35
+ *
36
+ * @since 0.0.1
37
+ * @change 1.0.5
38
+ *
39
+ * @param array $data array with form data
40
+ * @return array array with validated values
41
+ */
42
+
43
+ public static function validate_settings($data)
44
+ {
45
+ if (!isset($data['relative'])) {
46
+ $data['relative'] = 0;
47
+ }
48
+ if (!isset($data['https'])) {
49
+ $data['https'] = 0;
50
+ }
51
+ if (!isset($data['keycdn_api_key'])) {
52
+ $data['keycdn_api_key'] = "";
53
+ }
54
+ if (!isset($data['keycdn_zone_id'])) {
55
+ $data['keycdn_zone_id'] = "";
56
+ }
57
+
58
+ return [
59
+ 'url' => esc_url($data['url']),
60
+ 'dirs' => esc_attr($data['dirs']),
61
+ 'excludes' => esc_attr($data['excludes']),
62
+ 'relative' => (int)($data['relative']),
63
+ 'https' => (int)($data['https']),
64
+ 'keycdn_api_key' => esc_attr($data['keycdn_api_key']),
65
+ 'keycdn_zone_id' => (int)($data['keycdn_zone_id']),
66
+ ];
67
+ }
68
+
69
+
70
+ /**
71
+ * add settings page
72
+ *
73
+ * @since 0.0.1
74
+ * @change 0.0.1
75
+ */
76
+
77
+ public static function add_settings_page()
78
+ {
79
+ $page = add_options_page(
80
+ 'CDN Enabler',
81
+ 'CDN Enabler',
82
+ 'manage_options',
83
+ 'cdn_enabler',
84
+ [
85
+ __CLASS__,
86
+ 'settings_page',
87
+ ]
88
+ );
89
+ }
90
+
91
+
92
+ /**
93
+ * settings page
94
+ *
95
+ * @since 0.0.1
96
+ * @change 1.0.5
97
+ *
98
+ * @return void
99
+ */
100
+
101
+ public static function settings_page()
102
+ { ?>
103
+ <div class="wrap">
104
+ <h2>
105
+ <?php _e("CDN Enabler Settings", "cdn-enabler"); ?>
106
+ </h2>
107
+
108
+ <div class="notice notice-info">
109
+ <p><?php printf( __('Combine CDN Enabler with <b><a href="%s">%s</a></b> for even faster WordPress performance.', 'cdn-enabler'), 'https://www.keycdn.com?utm_source=wp-admin&utm_medium=plugins&utm_campaign=cdn-enabler', 'KeyCDN'); ?></p>
110
+ </div>
111
+
112
+ <form method="post" action="options.php">
113
+ <?php settings_fields('cdn_enabler') ?>
114
+
115
+ <?php $options = CDN_Enabler::get_options() ?>
116
+
117
+ <table class="form-table">
118
+
119
+ <tr valign="top">
120
+ <th scope="row">
121
+ <?php _e("CDN URL", "cdn-enabler"); ?>
122
+ </th>
123
+ <td>
124
+ <fieldset>
125
+ <label for="cdn_enabler_url">
126
+ <input type="text" name="cdn_enabler[url]" id="cdn_enabler_url" value="<?php echo $options['url']; ?>" size="64" class="regular-text code" />
127
+ </label>
128
+
129
+ <p class="description">
130
+ <?php _e("Enter the CDN URL without trailing", "cdn-enabler"); ?> <code>/</code>
131
+ </p>
132
+ </fieldset>
133
+ </td>
134
+ </tr>
135
+
136
+ <tr valign="top">
137
+ <th scope="row">
138
+ <?php _e("Included Directories", "cdn-enabler"); ?>
139
+ </th>
140
+ <td>
141
+ <fieldset>
142
+ <label for="cdn_enabler_dirs">
143
+ <input type="text" name="cdn_enabler[dirs]" id="cdn_enabler_dirs" value="<?php echo $options['dirs']; ?>" size="64" class="regular-text code" />
144
+ <?php _e("Default: <code>wp-content,wp-includes</code>", "cdn-enabler"); ?>
145
+ </label>
146
+
147
+ <p class="description">
148
+ <?php _e("Assets in these directories will be pointed to the CDN URL. Enter the directories separated by", "cdn-enabler"); ?> <code>,</code>
149
+ </p>
150
+ </fieldset>
151
+ </td>
152
+ </tr>
153
+
154
+ <tr valign="top">
155
+ <th scope="row">
156
+ <?php _e("Exclusions", "cdn-enabler"); ?>
157
+ </th>
158
+ <td>
159
+ <fieldset>
160
+ <label for="cdn_enabler_excludes">
161
+ <input type="text" name="cdn_enabler[excludes]" id="cdn_enabler_excludes" value="<?php echo $options['excludes']; ?>" size="64" class="regular-text code" />
162
+ <?php _e("Default: <code>.php</code>", "cdn-enabler"); ?>
163
+ </label>
164
+
165
+ <p class="description">
166
+ <?php _e("Enter the exclusions (directories or extensions) separated by", "cdn-enabler"); ?> <code>,</code>
167
+ </p>
168
+ </fieldset>
169
+ </td>
170
+ </tr>
171
+
172
+ <tr valign="top">
173
+ <th scope="row">
174
+ <?php _e("Relative Path", "cdn-enabler"); ?>
175
+ </th>
176
+ <td>
177
+ <fieldset>
178
+ <label for="cdn_enabler_relative">
179
+ <input type="checkbox" name="cdn_enabler[relative]" id="cdn_enabler_relative" value="1" <?php checked(1, $options['relative']) ?> />
180
+ <?php _e("Enable CDN for relative paths (default: enabled).", "cdn-enabler"); ?>
181
+ </label>
182
+ </fieldset>
183
+ </td>
184
+ </tr>
185
+
186
+ <tr valign="top">
187
+ <th scope="row">
188
+ <?php _e("CDN HTTPS", "cdn-enabler"); ?>
189
+ </th>
190
+ <td>
191
+ <fieldset>
192
+ <label for="cdn_enabler_https">
193
+ <input type="checkbox" name="cdn_enabler[https]" id="cdn_enabler_https" value="1" <?php checked(1, $options['https']) ?> />
194
+ <?php _e("Enable CDN for HTTPS connections (default: disabled).", "cdn-enabler"); ?>
195
+ </label>
196
+ </fieldset>
197
+ </td>
198
+ </tr>
199
+
200
+ <tr valign="top">
201
+ <th scope="row">
202
+ <?php _e("KeyCDN API Key", "cdn-enabler"); ?>
203
+ </th>
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>
211
+ </label>
212
+ </fieldset>
213
+ </td>
214
+ </tr>
215
+
216
+ <tr valign="top">
217
+ <th scope="row">
218
+ <?php _e("KeyCDN Zone ID", "cdn-enabler"); ?>
219
+ </th>
220
+ <td>
221
+ <fieldset>
222
+ <label for="cdn_enabler_zone_id">
223
+ <input type="text" name="cdn_enabler[keycdn_zone_id]" id="cdn_enabler_zone_id" value="<?php echo $options['keycdn_zone_id']; ?>" size="64" class="regular-text code" />
224
+ <p class="description">
225
+ <?php _e("KeyCDN Zone ID of the zone to purge on request", "cdn-enabler"); ?>
226
+ </p>
227
+ </label>
228
+ </fieldset>
229
+ </td>
230
+ </tr>
231
+ </table>
232
+
233
+ <?php submit_button() ?>
234
+ </form>
235
+ </div><?php
236
+ }
237
  }
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: keycdn
3
  Tags: cdn, content delivery network, content distribution network
4
  Requires at least: 3.8
5
- Tested up to: 4.7
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -35,6 +35,11 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
35
  * WordPress >=3.8
36
 
37
 
 
 
 
 
 
38
  = Author =
39
  * [KeyCDN](https://www.keycdn.com "KeyCDN")
40
 
@@ -42,6 +47,12 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
42
 
43
  == Changelog ==
44
 
 
 
 
 
 
 
45
  = 1.0.4 =
46
  * Removed unused code
47
 
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
35
  * WordPress >=3.8
36
 
37
 
38
+ = Contribute =
39
+ * Anyone is welcome to contribute to the plugin on [GitHub](https://github.com/keycdn/cdn-enabler).
40
+ * Please merge (squash) all your changes into a single commit before you open a pull request.
41
+
42
+
43
  = Author =
44
  * [KeyCDN](https://www.keycdn.com "KeyCDN")
45
 
47
 
48
  == Changelog ==
49
 
50
+ = 1.0.5 =
51
+ * Multiprotocol CDN rewriting
52
+ * Add purging through KeyCDN API
53
+ * Don't rewrite if in admin preview mode
54
+ * Rewrite to HTTPS if enabled and client connects through HTTP
55
+
56
  = 1.0.4 =
57
  * Removed unused code
58