Skip to content

Commit 0e092ad

Browse files
authored
Merge pull request #287 from wp-media/branch-2.9.2
2.9.2
2 parents ad45870 + 5c3692e commit 0e092ad

File tree

10 files changed

+71
-41
lines changed

10 files changed

+71
-41
lines changed

inc/common/purge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function rocket_clean_post( $post_id ) {
104104

105105
// Don't purge if post's post type is not public or not publicly queryable
106106
$post_type = get_post_type_object( $post->post_type );
107-
if ( $post_type->public !== true ) {
107+
if ( ! is_object( $post_type ) || $post_type->public !== true ) {
108108
return;
109109
}
110110

inc/front/cdn.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,33 @@ function rocket_cdn_file( $url ) {
5757
return $url;
5858
}
5959

60+
add_filter( 'wp_get_attachment_image_src', 'rocket_cdn_attachment_image_src', PHP_INT_MAX );
61+
/**
62+
* Replace URL by CDN of images displayed using wp_get_attachment_image_src
63+
*
64+
* @since 2.9.2
65+
* @author Remy Perona
66+
* @source https://github.com/wp-media/wp-rocket/issues/271#issuecomment-269849927
67+
*
68+
* @param array $image An array containing the src, width and height of the image.
69+
* @return array Array with updated src URL
70+
*/
71+
function rocket_cdn_attachment_image_src( $image ) {
72+
if ( ! (bool) $image ) {
73+
return $image;
74+
}
75+
76+
$zones = array( 'all', 'images' );
77+
78+
if ( ! (bool) get_rocket_cdn_cnames( $zones ) ) {
79+
return $image;
80+
}
81+
82+
$image[0] = get_rocket_cdn_url( $image[0], $zones );
83+
84+
return $image;
85+
}
86+
6087
/**
6188
* Replace srcset URLs by CDN URLs for WP responsive images
6289
*

inc/front/dns-prefetch.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,31 +76,3 @@ function __rocket_dns_prefetch_buffer( $buffer ) {
7676

7777
return $buffer;
7878
}
79-
80-
/**
81-
* Get the domain names to DNS prefetch from WP Rocket options
82-
*
83-
* @since 2.8.9
84-
* @author Remy Perona
85-
*
86-
* return Array An array of domain names to DNS prefetch
87-
*/
88-
function rocket_get_dns_prefetch_domains() {
89-
$cdn_cnames = get_rocket_cdn_cnames( array( 'all', 'images', 'css_and_js', 'css', 'js' ) );
90-
91-
// Don't add CNAMES if CDN is disabled HTTPS pages or on specific posts
92-
if ( ! is_rocket_cdn_on_ssl() || is_rocket_post_excluded_option( 'cdn' ) ) {
93-
$cdn_cnames = array();
94-
}
95-
96-
$domains = array_merge( $cdn_cnames, (array) get_rocket_option( 'dns_prefetch' ) );
97-
98-
/**
99-
* Filter list of domains to prefetch DNS
100-
*
101-
* @since 1.1.0
102-
*
103-
* @param array $domains List of domains to prefetch DNS
104-
*/
105-
return apply_filters( 'rocket_dns_prefetch', $domains );
106-
}

inc/front/enqueue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function rocket_browser_cache_busting( $src, $current_filter = '' ) {
8888
*
8989
* @param string $filename filename for the cache busting file
9090
*/
91-
$cache_busting_filename = apply_filters( 'rocket_cache_busting_filename', preg_replace( '/\.(js|css)\?ver=(.+)$/', '-$2.$1', rtrim( str_replace( '/', '-', $relative_src_path ) ) ) );
91+
$cache_busting_filename = apply_filters( 'rocket_cache_busting_filename', preg_replace( '/\.(js|css)\?ver=(.+)$/', '-$2.$1', rtrim( str_replace( array( '/', ' ', '%20' ), '-', $relative_src_path ) ) ) );
9292
$cache_busting_paths = rocket_get_cache_busting_paths( $cache_busting_filename, $extension );
9393

9494
if ( file_exists( $cache_busting_paths['filepath'] ) && is_readable( $cache_busting_paths['filepath'] ) ) {
@@ -178,7 +178,7 @@ function rocket_cache_dynamic_resource( $src ) {
178178
*
179179
* @param string $filename filename for the cache file
180180
*/
181-
$cache_dynamic_resource_filename = apply_filters( 'rocket_dynamic_resource_cache_filename', preg_replace( '/\.(php)$/', $extension, strtok( rtrim( str_replace( '/', '-', $relative_src_path ) ), '?' ) ) );
181+
$cache_dynamic_resource_filename = apply_filters( 'rocket_dynamic_resource_cache_filename', preg_replace( '/\.(php)$/', $extension, strtok( rtrim( str_replace( array( '/', ' ', '%20' ), '-', $relative_src_path ) ), '?' ) ) );
182182
$cache_busting_paths = rocket_get_cache_busting_paths( $cache_dynamic_resource_filename, $extension );
183183

184184
if ( file_exists( $cache_busting_paths['filepath'] ) && is_readable( $cache_busting_paths['filepath'] ) ) {

inc/front/process.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
// Don't cache without GET method
3333
if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || $_SERVER['REQUEST_METHOD'] != 'GET' ) {
34+
rocket_define_donotminify_constants( true );
3435
return;
3536
}
3637

inc/functions/cloudflare.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function set_rocket_cloudflare_browser_cache_ttl( $mode ) {
322322

323323
try {
324324
$cf_settings = new CloudFlare\Zone\Settings( $GLOBALS['rocket_cloudflare']->auth );
325-
$cf_return = $cf_settings->change_browser_cache_ttl( $GLOBALS['rocket_cloudflare']->zone_id, $mode );
325+
$cf_return = $cf_settings->change_browser_cache_ttl( $GLOBALS['rocket_cloudflare']->zone_id, (int) $mode );
326326

327327
if ( ! isset( $cf_return->success ) || empty( $cf_return->success ) ) {
328328
foreach( $cf_return->errors as $error ) {
@@ -429,6 +429,7 @@ function rocket_get_cloudflare_ips() {
429429
'2a06:98c0::/29',
430430
);
431431

432+
set_transient( 'rocket_cloudflare_ips', $cf_ips, 2 * WEEK_IN_SECONDS );
432433
return $cf_ips;
433434
}
434435
}

inc/functions/options.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,34 @@ function is_rocket_cdn_on_ssl() {
137137
return is_ssl() && get_rocket_option( 'cdn_ssl', 0 ) ? false : true;
138138
}
139139

140+
/**
141+
* Get the domain names to DNS prefetch from WP Rocket options
142+
*
143+
* @since 2.8.9
144+
* @author Remy Perona
145+
*
146+
* return Array An array of domain names to DNS prefetch
147+
*/
148+
function rocket_get_dns_prefetch_domains() {
149+
$cdn_cnames = get_rocket_cdn_cnames( array( 'all', 'images', 'css_and_js', 'css', 'js' ) );
150+
151+
// Don't add CNAMES if CDN is disabled HTTPS pages or on specific posts
152+
if ( ! is_rocket_cdn_on_ssl() || is_rocket_post_excluded_option( 'cdn' ) ) {
153+
$cdn_cnames = array();
154+
}
155+
156+
$domains = array_merge( $cdn_cnames, (array) get_rocket_option( 'dns_prefetch' ) );
157+
158+
/**
159+
* Filter list of domains to prefetch DNS
160+
*
161+
* @since 1.1.0
162+
*
163+
* @param array $domains List of domains to prefetch DNS
164+
*/
165+
return apply_filters( 'rocket_dns_prefetch', $domains );
166+
}
167+
140168
/**
141169
* Get the interval task cron purge in seconds
142170
* This setting can be changed from the options page of the plugin

min/lib/Minify/HTML.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function process()
162162

163163
protected function _commentCB($m)
164164
{
165-
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<![') || 0 === strpos($m[1], 'esi'))
165+
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<![') || 0 === strpos($m[1], 'esi') || 0 === strpos($m[1], 'noindex') || 0 === strpos($m[1], 'start_content') || 0 === strpos($m[1], 'end_content'))
166166
? $m[0]
167167
: '';
168168
}

uninstall.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
* Remove all cache files
2626
*
2727
* @since 1.2.0
28+
*
29+
* @param string $dir Directory path to remove.
2830
*/
29-
function __rocket_rrmdir( $dir )
30-
{
31+
function __rocket_rrmdir( $dir ) {
3132

32-
if( !is_dir( $dir ) )
33-
{
33+
if ( ! is_dir( $dir ) ) {
3434
@unlink( $dir );
3535
return;
3636
}
3737

38-
if( $globs = glob( $dir . '/*', GLOB_NOSORT ) ) {
39-
foreach( $globs as $file ) {
38+
if ( $globs = glob( $dir . '/*', GLOB_NOSORT ) ) {
39+
foreach ( $globs as $file ) {
4040
is_dir( $file ) ? __rocket_rrmdir($file) : @unlink( $file );
4141
}
4242
}
@@ -47,4 +47,5 @@ function __rocket_rrmdir( $dir )
4747

4848
__rocket_rrmdir( WP_CONTENT_DIR . '/cache/wp-rocket/' );
4949
__rocket_rrmdir( WP_CONTENT_DIR . '/cache/min/' );
50+
__rocket_rrmdir( WP_CONTENT_DIR . '/cache/busting/' );
5051
__rocket_rrmdir( WP_CONTENT_DIR . '/wp-rocket-config/' );

wp-rocket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: WP Rocket
44
Plugin URI: https://wp-rocket.me
55
Description: The best WordPress performance plugin.
6-
Version: 2.9.1
6+
Version: 2.9.2
77
Code Name: Iridonia
88
Author: WP Media
99
Contributors: Jonathan Buttigieg, Julio Potier, Remy Perona
@@ -19,7 +19,7 @@
1919
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
2020

2121
// Rocket defines
22-
define( 'WP_ROCKET_VERSION' , '2.9.1' );
22+
define( 'WP_ROCKET_VERSION' , '2.9.2' );
2323
define( 'WP_ROCKET_PRIVATE_KEY' , false );
2424
define( 'WP_ROCKET_SLUG' , 'wp_rocket_settings' );
2525
define( 'WP_ROCKET_WEB_MAIN' , 'http://support.wp-rocket.me/' );

0 commit comments

Comments
 (0)