Skip to content

Commit d3b23cd

Browse files
authored
Merge pull request #364 from wp-media/branch-2.9.8
2.9.8
2 parents 514d6a4 + e242354 commit d3b23cd

File tree

7 files changed

+142
-16
lines changed

7 files changed

+142
-16
lines changed

inc/admin/options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ function rocket_settings_callback( $inputs ) {
954954
$checked = rocket_check_key();
955955
}
956956

957-
if ( is_array( $checked ) ) {
957+
if ( isset( $checked ) && is_array( $checked ) ) {
958958
$inputs['consumer_key'] = $checked['consumer_key'];
959959
$inputs['consumer_email'] = $checked['consumer_email'];
960960
$inputs['secret_key'] = $checked['secret_key'];

inc/compat.php

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,131 @@ function apply_filters_deprecated( $tag, $args, $version, $replacement = false,
8787

8888
return apply_filters_ref_array( $tag, $args );
8989
}
90-
}
90+
}
91+
92+
93+
/**
94+
* Copied from core for compatibility with WP < 4.4
95+
* A wrapper for PHP's parse_url() function that handles consistency in the return
96+
* values across PHP versions.
97+
*
98+
* PHP 5.4.7 expanded parse_url()'s ability to handle non-absolute url's, including
99+
* schemeless and relative url's with :// in the path. This function works around
100+
* those limitations providing a standard output on PHP 5.2~5.4+.
101+
*
102+
* Secondly, across various PHP versions, schemeless URLs starting containing a ":"
103+
* in the query are being handled inconsistently. This function works around those
104+
* differences as well.
105+
*
106+
* Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated
107+
* when URL parsing failed.
108+
*
109+
* @since 4.4.0
110+
* @since 4.7.0 The $component parameter was added for parity with PHP's parse_url().
111+
*
112+
* @param string $url The URL to parse.
113+
* @param int $component The specific component to retrieve. Use one of the PHP
114+
* predefined constants to specify which one.
115+
* Defaults to -1 (= return all parts as an array).
116+
* @see http://php.net/manual/en/function.parse-url.php
117+
* @return mixed False on parse failure; Array of URL components on success;
118+
* When a specific component has been requested: null if the component
119+
* doesn't exist in the given URL; a sting or - in the case of
120+
* PHP_URL_PORT - integer when it does. See parse_url()'s return values.
121+
*/
122+
if ( ! function_exists( 'wp_parse_url' ) ) {
123+
function wp_parse_url( $url, $component = -1 ) {
124+
$to_unset = array();
125+
$url = strval( $url );
126+
127+
if ( '//' === substr( $url, 0, 2 ) ) {
128+
$to_unset[] = 'scheme';
129+
$url = 'placeholder:' . $url;
130+
} elseif ( '/' === substr( $url, 0, 1 ) ) {
131+
$to_unset[] = 'scheme';
132+
$to_unset[] = 'host';
133+
$url = 'placeholder://placeholder' . $url;
134+
}
135+
136+
$parts = @parse_url( $url );
137+
138+
if ( false === $parts ) {
139+
// Parsing failure.
140+
return $parts;
141+
}
142+
143+
// Remove the placeholder values.
144+
foreach ( $to_unset as $key ) {
145+
unset( $parts[ $key ] );
146+
}
147+
148+
return _get_component_from_parsed_url_array( $parts, $component );
149+
}
150+
}
151+
152+
/**
153+
* Copied from core for compatibility with WP < 4.7
154+
* Retrieve a specific component from a parsed URL array.
155+
*
156+
* @internal
157+
*
158+
* @since 4.7.0
159+
*
160+
* @param array|false $url_parts The parsed URL. Can be false if the URL failed to parse.
161+
* @param int $component The specific component to retrieve. Use one of the PHP
162+
* predefined constants to specify which one.
163+
* Defaults to -1 (= return all parts as an array).
164+
* @see http://php.net/manual/en/function.parse-url.php
165+
* @return mixed False on parse failure; Array of URL components on success;
166+
* When a specific component has been requested: null if the component
167+
* doesn't exist in the given URL; a sting or - in the case of
168+
* PHP_URL_PORT - integer when it does. See parse_url()'s return values.
169+
*/
170+
if ( ! function_exists( '_get_component_from_parsed_url_array') ) {
171+
function _get_component_from_parsed_url_array( $url_parts, $component = -1 ) {
172+
if ( -1 === $component ) {
173+
return $url_parts;
174+
}
175+
176+
$key = _wp_translate_php_url_constant_to_key( $component );
177+
if ( false !== $key && is_array( $url_parts ) && isset( $url_parts[ $key ] ) ) {
178+
return $url_parts[ $key ];
179+
} else {
180+
return null;
181+
}
182+
}
183+
}
184+
185+
/**
186+
* Copied from core for compatibility with WP < 4.7
187+
* Translate a PHP_URL_* constant to the named array keys PHP uses.
188+
*
189+
* @internal
190+
*
191+
* @since 4.7.0
192+
*
193+
* @see http://php.net/manual/en/url.constants.php
194+
*
195+
* @param int $constant PHP_URL_* constant.
196+
* @return string|bool The named key or false.
197+
*/
198+
if ( ! function_exists( '_wp_translate_php_url_constant_to_key') ) {
199+
function _wp_translate_php_url_constant_to_key( $constant ) {
200+
$translation = array(
201+
PHP_URL_SCHEME => 'scheme',
202+
PHP_URL_HOST => 'host',
203+
PHP_URL_PORT => 'port',
204+
PHP_URL_USER => 'user',
205+
PHP_URL_PASS => 'pass',
206+
PHP_URL_PATH => 'path',
207+
PHP_URL_QUERY => 'query',
208+
PHP_URL_FRAGMENT => 'fragment',
209+
);
210+
211+
if ( isset( $translation[ $constant ] ) ) {
212+
return $translation[ $constant ];
213+
} else {
214+
return false;
215+
}
216+
}
217+
}

inc/front/cdn.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ function rocket_cdn_images( $html ) {
135135

136136
list( $host, $path, $scheme, $query ) = get_rocket_parse_url( $image_url );
137137

138+
if ( empty( trim( $path ) ) || '{href}' === $path ) {
139+
continue;
140+
}
141+
138142
if ( isset( $cnames[ $host ] ) ) {
139143
continue;
140144
}

inc/front/process.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
}
131131

132132
// Don't cache page with these user agents
133-
if ( isset( $rocket_cache_reject_ua, $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '#(' . $rocket_cache_reject_ua . ')#', $_SERVER['HTTP_USER_AGENT'] ) ) {
133+
if ( isset( $rocket_cache_reject_ua, $_SERVER['HTTP_USER_AGENT'] ) && ! empty( trim( $rocket_cache_reject_ua ) ) && preg_match( '#(' . $rocket_cache_reject_ua . ')#', $_SERVER['HTTP_USER_AGENT'] ) ) {
134134
rocket_define_donotminify_constants( true );
135135
return;
136136
}
@@ -410,4 +410,4 @@ function rocket_get_ip() {
410410
}
411411

412412
return '0.0.0.0';
413-
}
413+
}

inc/functions/formatting.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function get_rocket_parse_url( $url ) {
157157
return;
158158
}
159159

160-
$url = parse_url( $url );
160+
$url = wp_parse_url( $url );
161161
$host = isset( $url['host'] ) ? strtolower( $url['host'] ) : '';
162162
$path = isset( $url['path'] ) ? $url['path'] : '';
163163
$scheme = isset( $url['scheme'] ) ? $url['scheme'] : '';
@@ -206,4 +206,4 @@ function rocket_get_cache_busting_paths( $filename, $extension ) {
206206
'filepath' => $cache_busting_filepath,
207207
'url' => $cache_busting_url
208208
);
209-
}
209+
}

min/.htaccess

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
<FilesMatch "index.php">
2-
<IfModule !mod_authz_core.c>
3-
Allow from all
4-
</IfModule>
5-
<IfModule mod_authz_core.c>
6-
Require all granted
7-
</IfModule>
8-
</FilesMatch>
1+
<Files index.php>
2+
Allow from all
3+
</Files>
94

105
<IfModule mod_rewrite.c>
116
RewriteEngine on

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.7
6+
Version: 2.9.8
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.7' );
22+
define( 'WP_ROCKET_VERSION' , '2.9.8' );
2323
define( 'WP_ROCKET_PRIVATE_KEY' , false );
2424
define( 'WP_ROCKET_SLUG' , 'wp_rocket_settings' );
2525
define( 'WP_ROCKET_WEB_MAIN' , false );

0 commit comments

Comments
 (0)