Version Description
- Rewrite URLs filtering the_content so that rendered HTML in REST API use CDN
Download this release
Release Info
Developer | keycdn |
Plugin | CDN Enabler – WordPress CDN Plugin |
Version | 1.0.9 |
Comparing to | |
See all releases |
Code changes from version 1.0.8 to 1.0.9
- cdn-enabler.php +1 -1
- inc/cdn_enabler.class.php +49 -11
- readme.txt +7 -4
cdn-enabler.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
Author: KeyCDN
|
7 |
Author URI: https://www.keycdn.com
|
8 |
License: GPLv2 or later
|
9 |
-
Version: 1.0.
|
10 |
*/
|
11 |
|
12 |
/*
|
6 |
Author: KeyCDN
|
7 |
Author URI: https://www.keycdn.com
|
8 |
License: GPLv2 or later
|
9 |
+
Version: 1.0.9
|
10 |
*/
|
11 |
|
12 |
/*
|
inc/cdn_enabler.class.php
CHANGED
@@ -26,7 +26,7 @@ class CDN_Enabler
|
|
26 |
* constructor
|
27 |
*
|
28 |
* @since 0.0.1
|
29 |
-
* @change 1.0.
|
30 |
*/
|
31 |
|
32 |
public function __construct() {
|
@@ -39,6 +39,16 @@ class CDN_Enabler
|
|
39 |
]
|
40 |
);
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/* Hooks */
|
43 |
add_action(
|
44 |
'admin_init',
|
@@ -422,23 +432,19 @@ class CDN_Enabler
|
|
422 |
|
423 |
|
424 |
/**
|
425 |
-
*
|
|
|
|
|
|
|
426 |
*
|
427 |
-
* @since 0.0.1
|
428 |
-
* @change 1.0.5
|
429 |
*/
|
430 |
|
431 |
-
public static function
|
432 |
$options = self::get_options();
|
433 |
|
434 |
-
// check if origin equals cdn url
|
435 |
-
if (get_option('home') == $options['url']) {
|
436 |
-
return;
|
437 |
-
}
|
438 |
-
|
439 |
$excludes = array_map('trim', explode(',', $options['excludes']));
|
440 |
|
441 |
-
|
442 |
get_option('home'),
|
443 |
$options['url'],
|
444 |
$options['dirs'],
|
@@ -448,7 +454,39 @@ class CDN_Enabler
|
|
448 |
$options['keycdn_api_key'],
|
449 |
$options['keycdn_zone_id']
|
450 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
ob_start(array(&$rewriter, 'rewrite'));
|
452 |
}
|
453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
}
|
26 |
* constructor
|
27 |
*
|
28 |
* @since 0.0.1
|
29 |
+
* @change 1.0.9
|
30 |
*/
|
31 |
|
32 |
public function __construct() {
|
39 |
]
|
40 |
);
|
41 |
|
42 |
+
/* Rewrite rendered content in REST API */
|
43 |
+
add_filter(
|
44 |
+
'the_content',
|
45 |
+
[
|
46 |
+
__CLASS__,
|
47 |
+
'rewrite_the_content',
|
48 |
+
],
|
49 |
+
100
|
50 |
+
);
|
51 |
+
|
52 |
/* Hooks */
|
53 |
add_action(
|
54 |
'admin_init',
|
432 |
|
433 |
|
434 |
/**
|
435 |
+
* return new rewriter
|
436 |
+
*
|
437 |
+
* @since 1.0.9
|
438 |
+
* @change 1.0.9
|
439 |
*
|
|
|
|
|
440 |
*/
|
441 |
|
442 |
+
public static function get_rewriter() {
|
443 |
$options = self::get_options();
|
444 |
|
|
|
|
|
|
|
|
|
|
|
445 |
$excludes = array_map('trim', explode(',', $options['excludes']));
|
446 |
|
447 |
+
return new CDN_Enabler_Rewriter(
|
448 |
get_option('home'),
|
449 |
$options['url'],
|
450 |
$options['dirs'],
|
454 |
$options['keycdn_api_key'],
|
455 |
$options['keycdn_zone_id']
|
456 |
);
|
457 |
+
}
|
458 |
+
|
459 |
+
|
460 |
+
/**
|
461 |
+
* run rewrite hook
|
462 |
+
*
|
463 |
+
* @since 0.0.1
|
464 |
+
* @change 1.0.9
|
465 |
+
*/
|
466 |
+
|
467 |
+
public static function handle_rewrite_hook() {
|
468 |
+
$options = self::get_options();
|
469 |
+
|
470 |
+
// check if origin equals cdn url
|
471 |
+
if (get_option('home') == $options['url']) {
|
472 |
+
return;
|
473 |
+
}
|
474 |
+
|
475 |
+
$rewriter = self::get_rewriter();
|
476 |
ob_start(array(&$rewriter, 'rewrite'));
|
477 |
}
|
478 |
|
479 |
+
|
480 |
+
/**
|
481 |
+
* rewrite html content
|
482 |
+
*
|
483 |
+
* @since 1.0.9
|
484 |
+
* @change 1.0.9
|
485 |
+
*/
|
486 |
+
|
487 |
+
public static function rewrite_the_content($html) {
|
488 |
+
$rewriter = self::get_rewriter();
|
489 |
+
return $rewriter->rewrite($html);
|
490 |
+
}
|
491 |
+
|
492 |
}
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: keycdn
|
3 |
Tags: cdn, content delivery network, content distribution network
|
4 |
Requires at least: 4.6
|
5 |
-
Tested up to:
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -31,7 +31,7 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
|
|
31 |
|
32 |
|
33 |
= System Requirements =
|
34 |
-
* PHP >=5.
|
35 |
* WordPress >=4.6
|
36 |
|
37 |
|
@@ -47,10 +47,13 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
50 |
= 1.0.8 =
|
51 |
* Purge CDN redirects to admin dashboard to avoid error messages
|
52 |
-
*
|
53 |
-
*
|
54 |
|
55 |
= 1.0.7 =
|
56 |
* Minor bug fixes (pass-by-reference)
|
2 |
Contributors: keycdn
|
3 |
Tags: cdn, content delivery network, content distribution network
|
4 |
Requires at least: 4.6
|
5 |
+
Tested up to: 5.1
|
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.6
|
35 |
* WordPress >=4.6
|
36 |
|
37 |
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
= 1.0.9 =
|
51 |
+
* Rewrite URLs filtering the_content so that rendered HTML in REST API use CDN
|
52 |
+
|
53 |
= 1.0.8 =
|
54 |
* Purge CDN redirects to admin dashboard to avoid error messages
|
55 |
+
* Better error messages
|
56 |
+
* Do not display nag notice when KeyCDN API credentials are set
|
57 |
|
58 |
= 1.0.7 =
|
59 |
* Minor bug fixes (pass-by-reference)
|