Version Description
- Improved exclusions for directories and extensions
Download this release
Release Info
Developer | keycdn |
Plugin | CDN Enabler – WordPress CDN Plugin |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- cdn-enabler.php +2 -2
- inc/cdn_enabler.class.php +34 -16
- inc/cdn_enabler_rewriter.class.php +5 -4
- inc/cdn_enabler_settings.class.php +19 -24
- readme.txt +5 -2
cdn-enabler.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: CDN Enabler
|
4 |
-
Text Domain: cdn
|
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.
|
10 |
*/
|
11 |
|
12 |
/*
|
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.3
|
10 |
*/
|
11 |
|
12 |
/*
|
inc/cdn_enabler.class.php
CHANGED
@@ -17,8 +17,7 @@ class CDN_Enabler
|
|
17 |
* @change 0.0.1
|
18 |
*/
|
19 |
|
20 |
-
public static function instance()
|
21 |
-
{
|
22 |
new self();
|
23 |
}
|
24 |
|
@@ -30,8 +29,7 @@ class CDN_Enabler
|
|
30 |
* @change 0.0.1
|
31 |
*/
|
32 |
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
|
36 |
/* CDN rewriter hook */
|
37 |
add_action(
|
@@ -53,6 +51,13 @@ class CDN_Enabler
|
|
53 |
}
|
54 |
|
55 |
/* Hooks */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
add_action(
|
57 |
'admin_init',
|
58 |
array(
|
@@ -98,8 +103,7 @@ class CDN_Enabler
|
|
98 |
* @return array $data extended array with links
|
99 |
*/
|
100 |
|
101 |
-
public static function add_action_link($data)
|
102 |
-
{
|
103 |
// check permission
|
104 |
if ( ! current_user_can('manage_options') ) {
|
105 |
return $data;
|
@@ -130,8 +134,7 @@ class CDN_Enabler
|
|
130 |
* @change 0.0.1
|
131 |
*/
|
132 |
|
133 |
-
public static function handle_uninstall_hook()
|
134 |
-
{
|
135 |
delete_option('cdn_enabler');
|
136 |
}
|
137 |
|
@@ -140,7 +143,7 @@ class CDN_Enabler
|
|
140 |
* run activation hook
|
141 |
*
|
142 |
* @since 0.0.1
|
143 |
-
* @change 1.0.
|
144 |
*/
|
145 |
|
146 |
public static function handle_activation_hook() {
|
@@ -171,7 +174,7 @@ class CDN_Enabler
|
|
171 |
sprintf(
|
172 |
'<div class="error"><p>%s</p></div>',
|
173 |
sprintf(
|
174 |
-
__("CDN Enabler is optimized for WordPress %s. Please disable the plugin or upgrade your WordPress installation (recommended).", "cdn"),
|
175 |
CDN_ENABLER_MIN_WP
|
176 |
)
|
177 |
)
|
@@ -180,17 +183,33 @@ class CDN_Enabler
|
|
180 |
}
|
181 |
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
/**
|
184 |
* return plugin options
|
185 |
*
|
186 |
* @since 0.0.1
|
187 |
-
* @change 1.0.
|
188 |
*
|
189 |
* @return array $diff data pairs
|
190 |
*/
|
191 |
|
192 |
-
public static function get_options()
|
193 |
-
{
|
194 |
return wp_parse_args(
|
195 |
get_option('cdn_enabler'),
|
196 |
array(
|
@@ -208,11 +227,10 @@ class CDN_Enabler
|
|
208 |
* run rewrite hook
|
209 |
*
|
210 |
* @since 0.0.1
|
211 |
-
* @change 1.0.
|
212 |
*/
|
213 |
|
214 |
-
public static function handle_rewrite_hook()
|
215 |
-
{
|
216 |
$options = self::get_options();
|
217 |
|
218 |
// check if origin equals cdn url
|
17 |
* @change 0.0.1
|
18 |
*/
|
19 |
|
20 |
+
public static function instance() {
|
|
|
21 |
new self();
|
22 |
}
|
23 |
|
29 |
* @change 0.0.1
|
30 |
*/
|
31 |
|
32 |
+
public function __construct() {
|
|
|
33 |
|
34 |
/* CDN rewriter hook */
|
35 |
add_action(
|
51 |
}
|
52 |
|
53 |
/* Hooks */
|
54 |
+
add_action(
|
55 |
+
'admin_init',
|
56 |
+
array(
|
57 |
+
__CLASS__,
|
58 |
+
'register_textdomain'
|
59 |
+
)
|
60 |
+
);
|
61 |
add_action(
|
62 |
'admin_init',
|
63 |
array(
|
103 |
* @return array $data extended array with links
|
104 |
*/
|
105 |
|
106 |
+
public static function add_action_link($data) {
|
|
|
107 |
// check permission
|
108 |
if ( ! current_user_can('manage_options') ) {
|
109 |
return $data;
|
134 |
* @change 0.0.1
|
135 |
*/
|
136 |
|
137 |
+
public static function handle_uninstall_hook() {
|
|
|
138 |
delete_option('cdn_enabler');
|
139 |
}
|
140 |
|
143 |
* run activation hook
|
144 |
*
|
145 |
* @since 0.0.1
|
146 |
+
* @change 1.0.3
|
147 |
*/
|
148 |
|
149 |
public static function handle_activation_hook() {
|
174 |
sprintf(
|
175 |
'<div class="error"><p>%s</p></div>',
|
176 |
sprintf(
|
177 |
+
__("CDN Enabler is optimized for WordPress %s. Please disable the plugin or upgrade your WordPress installation (recommended).", "cdn-enabler"),
|
178 |
CDN_ENABLER_MIN_WP
|
179 |
)
|
180 |
)
|
183 |
}
|
184 |
|
185 |
|
186 |
+
/**
|
187 |
+
* register textdomain
|
188 |
+
*
|
189 |
+
* @since 1.0.3
|
190 |
+
* @change 1.0.3
|
191 |
+
*/
|
192 |
+
|
193 |
+
public static function register_textdomain() {
|
194 |
+
|
195 |
+
load_plugin_textdomain(
|
196 |
+
'cdn-enabler',
|
197 |
+
false,
|
198 |
+
'cdn-enabler/lang'
|
199 |
+
);
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
/**
|
204 |
* return plugin options
|
205 |
*
|
206 |
* @since 0.0.1
|
207 |
+
* @change 1.0.3
|
208 |
*
|
209 |
* @return array $diff data pairs
|
210 |
*/
|
211 |
|
212 |
+
public static function get_options() {
|
|
|
213 |
return wp_parse_args(
|
214 |
get_option('cdn_enabler'),
|
215 |
array(
|
227 |
* run rewrite hook
|
228 |
*
|
229 |
* @since 0.0.1
|
230 |
+
* @change 1.0.3
|
231 |
*/
|
232 |
|
233 |
+
public static function handle_rewrite_hook() {
|
|
|
234 |
$options = self::get_options();
|
235 |
|
236 |
// check if origin equals cdn url
|
inc/cdn_enabler_rewriter.class.php
CHANGED
@@ -12,7 +12,7 @@ class CDN_Enabler_Rewriter
|
|
12 |
var $cdn_url = null; // CDN URL
|
13 |
|
14 |
var $dirs = null; // included directories
|
15 |
-
var $excludes = array(); //
|
16 |
var $relative = false; // use CDN on relative paths
|
17 |
var $https = false; // use CDN on HTTPS
|
18 |
|
@@ -20,7 +20,7 @@ class CDN_Enabler_Rewriter
|
|
20 |
* constructor
|
21 |
*
|
22 |
* @since 0.0.1
|
23 |
-
* @change
|
24 |
*/
|
25 |
|
26 |
function __construct($blog_url, $cdn_url, $dirs, array $excludes, $relative, $https) {
|
@@ -34,16 +34,17 @@ class CDN_Enabler_Rewriter
|
|
34 |
|
35 |
|
36 |
/**
|
37 |
-
*
|
38 |
*
|
39 |
* @since 0.0.1
|
40 |
-
* @change
|
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 |
foreach ($this->excludes as $exclude) {
|
48 |
if (!!$exclude && stristr($asset, $exclude) != false) {
|
49 |
return true;
|
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 |
|
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) {
|
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;
|
inc/cdn_enabler_settings.class.php
CHANGED
@@ -34,7 +34,7 @@ class CDN_Enabler_Settings
|
|
34 |
* validation of settings
|
35 |
*
|
36 |
* @since 0.0.1
|
37 |
-
* @change
|
38 |
*
|
39 |
* @param array $data array with form data
|
40 |
* @return array array with validated values
|
@@ -78,7 +78,7 @@ class CDN_Enabler_Settings
|
|
78 |
* settings page
|
79 |
*
|
80 |
* @since 0.0.1
|
81 |
-
* @change
|
82 |
*
|
83 |
* @return void
|
84 |
*/
|
@@ -87,9 +87,13 @@ class CDN_Enabler_Settings
|
|
87 |
{ ?>
|
88 |
<div class="wrap">
|
89 |
<h2>
|
90 |
-
<?php _e("CDN Enabler Settings", "cdn"); ?>
|
91 |
</h2>
|
92 |
|
|
|
|
|
|
|
|
|
93 |
<form method="post" action="options.php">
|
94 |
<?php settings_fields('cdn_enabler') ?>
|
95 |
|
@@ -99,17 +103,16 @@ class CDN_Enabler_Settings
|
|
99 |
|
100 |
<tr valign="top">
|
101 |
<th scope="row">
|
102 |
-
<?php _e("CDN URL", "cdn"); ?>
|
103 |
</th>
|
104 |
<td>
|
105 |
<fieldset>
|
106 |
<label for="cdn_enabler_url">
|
107 |
<input type="text" name="cdn_enabler[url]" id="cdn_enabler_url" value="<?php echo $options['url']; ?>" size="64" class="regular-text code" />
|
108 |
-
<?php _e("", "cdn"); ?>
|
109 |
</label>
|
110 |
|
111 |
<p class="description">
|
112 |
-
<?php _e("Enter the CDN URL without trailing", "cdn"); ?> <code>/</code>
|
113 |
</p>
|
114 |
</fieldset>
|
115 |
</td>
|
@@ -117,17 +120,17 @@ class CDN_Enabler_Settings
|
|
117 |
|
118 |
<tr valign="top">
|
119 |
<th scope="row">
|
120 |
-
<?php _e("Included Directories", "cdn"); ?>
|
121 |
</th>
|
122 |
<td>
|
123 |
<fieldset>
|
124 |
<label for="cdn_enabler_dirs">
|
125 |
<input type="text" name="cdn_enabler[dirs]" id="cdn_enabler_dirs" value="<?php echo $options['dirs']; ?>" size="64" class="regular-text code" />
|
126 |
-
<?php _e("Default: <code>wp-content,wp-includes</code>", "cdn"); ?>
|
127 |
</label>
|
128 |
|
129 |
<p class="description">
|
130 |
-
<?php _e("Assets in these directories will be pointed to the CDN URL. Enter the directories separated by", "cdn"); ?> <code>,</code>
|
131 |
</p>
|
132 |
</fieldset>
|
133 |
</td>
|
@@ -135,17 +138,17 @@ class CDN_Enabler_Settings
|
|
135 |
|
136 |
<tr valign="top">
|
137 |
<th scope="row">
|
138 |
-
<?php _e("
|
139 |
</th>
|
140 |
<td>
|
141 |
<fieldset>
|
142 |
<label for="cdn_enabler_excludes">
|
143 |
<input type="text" name="cdn_enabler[excludes]" id="cdn_enabler_excludes" value="<?php echo $options['excludes']; ?>" size="64" class="regular-text code" />
|
144 |
-
<?php _e("Default: <code>.php</code>", "cdn"); ?>
|
145 |
</label>
|
146 |
|
147 |
<p class="description">
|
148 |
-
<?php _e("Enter the exclusions separated by", "cdn"); ?> <code>,</code>
|
149 |
</p>
|
150 |
</fieldset>
|
151 |
</td>
|
@@ -153,36 +156,28 @@ class CDN_Enabler_Settings
|
|
153 |
|
154 |
<tr valign="top">
|
155 |
<th scope="row">
|
156 |
-
<?php _e("Relative Path", "cdn"); ?>
|
157 |
</th>
|
158 |
<td>
|
159 |
<fieldset>
|
160 |
<label for="cdn_enabler_relative">
|
161 |
<input type="checkbox" name="cdn_enabler[relative]" id="cdn_enabler_relative" value="1" <?php checked(1, $options['relative']) ?> />
|
162 |
-
<?php _e("Enable CDN for relative paths (default: enabled).", "cdn"); ?>
|
163 |
</label>
|
164 |
-
|
165 |
-
<p class="description">
|
166 |
-
<?php _e("", "cdn"); ?>
|
167 |
-
</p>
|
168 |
</fieldset>
|
169 |
</td>
|
170 |
</tr>
|
171 |
|
172 |
<tr valign="top">
|
173 |
<th scope="row">
|
174 |
-
<?php _e("CDN HTTPS", "cdn"); ?>
|
175 |
</th>
|
176 |
<td>
|
177 |
<fieldset>
|
178 |
<label for="cdn_enabler_https">
|
179 |
<input type="checkbox" name="cdn_enabler[https]" id="cdn_enabler_https" value="1" <?php checked(1, $options['https']) ?> />
|
180 |
-
<?php _e("Enable CDN for HTTPS connections (default: disabled).", "cdn"); ?>
|
181 |
</label>
|
182 |
-
|
183 |
-
<p class="description">
|
184 |
-
<?php _e("", "cdn"); ?>
|
185 |
-
</p>
|
186 |
</fieldset>
|
187 |
</td>
|
188 |
</tr>
|
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
|
78 |
* settings page
|
79 |
*
|
80 |
* @since 0.0.1
|
81 |
+
* @change 1.0.3
|
82 |
*
|
83 |
* @return void
|
84 |
*/
|
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 |
|
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>
|
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>
|
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>
|
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>
|
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.
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -23,7 +23,7 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
|
|
23 |
= Features =
|
24 |
* Link assets to load from a CDN
|
25 |
* Set included directories
|
26 |
-
* Define exclusions
|
27 |
* Enable or disable for HTTPS
|
28 |
* Supports [Bedrock](https://roots.io/bedrock/ "Bedrock CDN")
|
29 |
|
@@ -42,6 +42,9 @@ The CDN Enabler plugin has been developed to link your content to the CDN URLs.
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
45 |
= 1.0.2 =
|
46 |
* Switched from siteurl to home (e.g. for bedrock support)
|
47 |
|
2 |
Contributors: keycdn
|
3 |
Tags: cdn, content delivery network, content distribution network
|
4 |
Requires at least: 3.8
|
5 |
+
Tested up to: 4.5
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
23 |
= Features =
|
24 |
* Link assets to load from a CDN
|
25 |
* Set included directories
|
26 |
+
* Define exclusions (directories or extensions)
|
27 |
* Enable or disable for HTTPS
|
28 |
* Supports [Bedrock](https://roots.io/bedrock/ "Bedrock CDN")
|
29 |
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 1.0.3 =
|
46 |
+
* Improved exclusions for directories and extensions
|
47 |
+
|
48 |
= 1.0.2 =
|
49 |
* Switched from siteurl to home (e.g. for bedrock support)
|
50 |
|