CDN Enabler – WordPress CDN Plugin - Version 2.0.2

Version Description

  • Update URL matcher in rewriter (#28)
  • Update full URL rewrite (#28)
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.2

cdn-enabler.php CHANGED
@@ -6,7 +6,7 @@ Description: Simple and fast WordPress content delivery network (CDN) integratio
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
- Version: 2.0.1
10
  */
11
 
12
  /*
@@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
32
  }
33
 
34
  // constants
35
- define( 'CDN_ENABLER_VERSION', '2.0.1' );
36
  define( 'CDN_ENABLER_MIN_PHP', '5.6' );
37
  define( 'CDN_ENABLER_MIN_WP', '5.1' );
38
  define( 'CDN_ENABLER_FILE', __FILE__ );
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
+ Version: 2.0.2
10
  */
11
 
12
  /*
32
  }
33
 
34
  // constants
35
+ define( 'CDN_ENABLER_VERSION', '2.0.2' );
36
  define( 'CDN_ENABLER_MIN_PHP', '5.6' );
37
  define( 'CDN_ENABLER_MIN_WP', '5.1' );
38
  define( 'CDN_ENABLER_FILE', __FILE__ );
inc/cdn_enabler_engine.class.php CHANGED
@@ -172,7 +172,7 @@ final class CDN_Enabler_Engine {
172
  * rewrite URL to use CDN hostname
173
  *
174
  * @since 0.0.1
175
- * @change 2.0.0
176
  *
177
  * @param array $matches pattern matches from parsed contents
178
  * @return string $file_url rewritten file URL if applicable, unchanged otherwise
@@ -192,8 +192,8 @@ final class CDN_Enabler_Engine {
192
 
193
  // rewrite full URL (e.g. https://www.example.com/wp..., https:\/\/www.example.com\/wp..., or //www.example.com/wp...)
194
  foreach ( $site_hostnames as $site_hostname ) {
195
- if ( stripos( $file_url, '/' . $site_hostname ) !== false ) {
196
- return str_replace( $site_hostname, $cdn_hostname, $file_url );
197
  }
198
  }
199
 
@@ -235,7 +235,7 @@ final class CDN_Enabler_Engine {
235
 
236
  $included_file_extensions_regex = quotemeta( implode( '|', explode( PHP_EOL, self::$settings['included_file_extensions'] ) ) );
237
 
238
- $urls_regex = '#(?:(?:[\"\'\s=>,]|url\()\K|^)[^\"\'\s(=>,]+(' . $included_file_extensions_regex . ')(\?[^?\\\"\'\s)>,]+)?(?:(?=\/?[?\\\"\'\s)>,])|$)#i';
239
 
240
  $rewritten_contents = apply_filters( 'cdn_enabler_contents_after_rewrite', preg_replace_callback( $urls_regex, 'self::rewrite_url', $contents ) );
241
 
172
  * rewrite URL to use CDN hostname
173
  *
174
  * @since 0.0.1
175
+ * @change 2.0.2
176
  *
177
  * @param array $matches pattern matches from parsed contents
178
  * @return string $file_url rewritten file URL if applicable, unchanged otherwise
192
 
193
  // rewrite full URL (e.g. https://www.example.com/wp..., https:\/\/www.example.com\/wp..., or //www.example.com/wp...)
194
  foreach ( $site_hostnames as $site_hostname ) {
195
+ if ( stripos( $file_url, '//' . $site_hostname ) !== false || stripos( $file_url, '\/\/' . $site_hostname ) !== false ) {
196
+ return substr_replace( $file_url, $cdn_hostname, stripos( $file_url, $site_hostname ), strlen( $site_hostname ) );
197
  }
198
  }
199
 
235
 
236
  $included_file_extensions_regex = quotemeta( implode( '|', explode( PHP_EOL, self::$settings['included_file_extensions'] ) ) );
237
 
238
+ $urls_regex = '#(?:(?:[\"\'\s=>,]|url\()\K|^)[^\"\'\s(=>,]+(' . $included_file_extensions_regex . ')(\?[^\/?\\\"\'\s)>,]+)?(?:(?=\/?[?\\\"\'\s)>,])|$)#i';
239
 
240
  $rewritten_contents = apply_filters( 'cdn_enabler_contents_after_rewrite', preg_replace_callback( $urls_regex, 'self::rewrite_url', $contents ) );
241
 
readme.txt CHANGED
@@ -47,6 +47,10 @@ CDN Enabler captures page contents and rewrites URLs to be served by the designa
47
 
48
  == Changelog ==
49
 
 
 
 
 
50
  = 2.0.1 =
51
  * Update URL matcher in rewriter (#25)
52
  * Update settings conversion (#26)
47
 
48
  == Changelog ==
49
 
50
+ = 2.0.2 =
51
+ * Update URL matcher in rewriter (#28)
52
+ * Update full URL rewrite (#28)
53
+
54
  = 2.0.1 =
55
  * Update URL matcher in rewriter (#25)
56
  * Update settings conversion (#26)