Version Description
- Fix: Corrected handling of robots.txt (file and filter)
Download this release
Release Info
Developer | joemoto |
Plugin | W3 Total Cache |
Version | 2.1.8 |
Comparing to | |
See all releases |
Code changes from version 2.1.7 to 2.1.8
- ConfigKeys.php +4 -1
- Generic_Environment.php +43 -27
- Generic_Plugin.php +13 -1
- Util_WpFile.php +22 -0
- inc/options/general.php +14 -7
- readme.txt +4 -1
- w3-total-cache-api.php +1 -1
- w3-total-cache.php +1 -1
ConfigKeys.php
CHANGED
@@ -2323,7 +2323,10 @@ $keys = array(
|
|
2323 |
)
|
2324 |
),
|
2325 |
|
2326 |
-
|
|
|
|
|
|
|
2327 |
'common.track_usage' => array(
|
2328 |
'type' => 'boolean',
|
2329 |
'default' => false
|
2323 |
)
|
2324 |
),
|
2325 |
|
2326 |
+
'robots_block.enable' => array(
|
2327 |
+
'type' => 'boolean',
|
2328 |
+
'default' => false
|
2329 |
+
),
|
2330 |
'common.track_usage' => array(
|
2331 |
'type' => 'boolean',
|
2332 |
'default' => false
|
Generic_Environment.php
CHANGED
@@ -4,7 +4,6 @@ namespace W3TC;
|
|
4 |
|
5 |
|
6 |
class Generic_Environment {
|
7 |
-
|
8 |
/**
|
9 |
* Fixes environment
|
10 |
*
|
@@ -16,7 +15,14 @@ class Generic_Environment {
|
|
16 |
$exs = new Util_Environment_Exceptions();
|
17 |
// create add-ins
|
18 |
$this->create_required_files( $config, $exs );
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
// create folders
|
22 |
$this->create_required_folders( $exs );
|
@@ -59,8 +65,9 @@ class Generic_Environment {
|
|
59 |
$exs = new Util_Environment_Exceptions();
|
60 |
|
61 |
$this->delete_required_files( $exs );
|
62 |
-
$this->robots_rules_remove( $exs );
|
63 |
|
|
|
|
|
64 |
if ( count( $exs->exceptions() ) > 0 )
|
65 |
throw $exs;
|
66 |
}
|
@@ -213,22 +220,22 @@ class Generic_Environment {
|
|
213 |
/**
|
214 |
* Write robots.txt directives to prevent crawl of cache directory.
|
215 |
*
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
}
|
233 |
|
234 |
/**
|
@@ -238,8 +245,8 @@ class Generic_Environment {
|
|
238 |
*
|
239 |
* @return string
|
240 |
*/
|
241 |
-
|
242 |
-
|
243 |
# BEGIN W3TC ROBOTS
|
244 |
User-agent: *
|
245 |
Disallow: /wp-content/cache/
|
@@ -257,11 +264,20 @@ Disallow: /wp-content/cache/
|
|
257 |
* @throws Util_WpFile_FilesystemOperationException with S/FTP form if it can't get the required filesystem credentials.
|
258 |
*/
|
259 |
private function robots_rules_remove( $exs ) {
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
}
|
4 |
|
5 |
|
6 |
class Generic_Environment {
|
|
|
7 |
/**
|
8 |
* Fixes environment
|
9 |
*
|
15 |
$exs = new Util_Environment_Exceptions();
|
16 |
// create add-ins
|
17 |
$this->create_required_files( $config, $exs );
|
18 |
+
|
19 |
+
if ( Util_WpFile::file_exists( Util_Environment::site_path() . 'robots.txt' ) ) {
|
20 |
+
if ( $config->get_boolean( 'robots_block.enable' ) ) {
|
21 |
+
$this->robots_rules_add( $config, $exs );
|
22 |
+
} else {
|
23 |
+
$this->robots_rules_remove( $exs );
|
24 |
+
}
|
25 |
+
}
|
26 |
|
27 |
// create folders
|
28 |
$this->create_required_folders( $exs );
|
65 |
$exs = new Util_Environment_Exceptions();
|
66 |
|
67 |
$this->delete_required_files( $exs );
|
|
|
68 |
|
69 |
+
$this->robots_rules_remove( $exs );
|
70 |
+
|
71 |
if ( count( $exs->exceptions() ) > 0 )
|
72 |
throw $exs;
|
73 |
}
|
220 |
/**
|
221 |
* Write robots.txt directives to prevent crawl of cache directory.
|
222 |
*
|
223 |
+
* @since 2.1.7
|
224 |
+
*
|
225 |
+
* @param Config $config Configuration.
|
226 |
+
* @param Util_Environment_Exceptions $exs Exceptions.
|
227 |
+
*
|
228 |
+
* @throws Util_WpFile_FilesystemOperationException with S/FTP form if it can't get the required filesystem credentials.
|
229 |
+
*/
|
230 |
+
private function robots_rules_add( $config, $exs ) {
|
231 |
+
Util_Rule::add_rules(
|
232 |
+
$exs,
|
233 |
+
Util_Rule::get_robots_rules_path(),
|
234 |
+
$this->robots_rules_generate(),
|
235 |
+
W3TC_MARKER_BEGIN_ROBOTS,
|
236 |
+
W3TC_MARKER_END_ROBOTS,
|
237 |
+
array()
|
238 |
+
);
|
239 |
}
|
240 |
|
241 |
/**
|
245 |
*
|
246 |
* @return string
|
247 |
*/
|
248 |
+
public static function robots_rules_generate() {
|
249 |
+
return '
|
250 |
# BEGIN W3TC ROBOTS
|
251 |
User-agent: *
|
252 |
Disallow: /wp-content/cache/
|
264 |
* @throws Util_WpFile_FilesystemOperationException with S/FTP form if it can't get the required filesystem credentials.
|
265 |
*/
|
266 |
private function robots_rules_remove( $exs ) {
|
267 |
+
$robots_path = Util_Environment::site_path() . 'robots.txt';
|
268 |
+
|
269 |
+
Util_Rule::remove_rules(
|
270 |
+
$exs,
|
271 |
+
$robots_path,
|
272 |
+
W3TC_MARKER_BEGIN_ROBOTS,
|
273 |
+
W3TC_MARKER_END_ROBOTS
|
274 |
+
);
|
275 |
+
|
276 |
+
WP_Filesystem();
|
277 |
+
global $wp_filesystem;
|
278 |
+
|
279 |
+
if ( empty( trim( $wp_filesystem->get_contents( $robots_path ) ) ) ) {
|
280 |
+
Util_WpFile::delete_file( $robots_path );
|
281 |
+
}
|
282 |
}
|
283 |
}
|
Generic_Plugin.php
CHANGED
@@ -84,6 +84,14 @@ class Generic_Plugin {
|
|
84 |
'ob_callback'
|
85 |
) );
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
/**
|
@@ -213,7 +221,6 @@ class Generic_Plugin {
|
|
213 |
add_action( 'wp_print_scripts', array( $this, 'popup_script' ) );
|
214 |
}
|
215 |
|
216 |
-
|
217 |
// dont add system stuff to search results
|
218 |
if ( ( isset( $_GET['repeat'] ) && $_GET['repeat'] == 'w3tc' ) ||
|
219 |
Util_Environment::is_preview_mode() ) {
|
@@ -669,4 +676,9 @@ class Generic_Plugin {
|
|
669 |
public function pro_dev_mode() {
|
670 |
echo '<!-- W3 Total Cache is currently running in Pro version Development mode. --><div style="border:2px solid red;text-align:center;font-size:1.2em;color:red"><p><strong>W3 Total Cache is currently running in Pro version Development mode.</strong></p></div>';
|
671 |
}
|
|
|
|
|
|
|
|
|
|
|
672 |
}
|
84 |
'ob_callback'
|
85 |
) );
|
86 |
}
|
87 |
+
|
88 |
+
/*
|
89 |
+
* @link https://developer.wordpress.org/reference/hooks/robots_txt/
|
90 |
+
* if robots_block is enabled modify robots.txt
|
91 |
+
*/
|
92 |
+
if ( $this->_config->get_boolean( 'robots_block.enable' ) && !Util_WpFile::file_exists( Util_Environment::site_path() . 'robots.txt' ) ) {
|
93 |
+
add_filter( 'robots_txt', array( $this, 'robots_rules_generate' ) );
|
94 |
+
}
|
95 |
}
|
96 |
|
97 |
/**
|
221 |
add_action( 'wp_print_scripts', array( $this, 'popup_script' ) );
|
222 |
}
|
223 |
|
|
|
224 |
// dont add system stuff to search results
|
225 |
if ( ( isset( $_GET['repeat'] ) && $_GET['repeat'] == 'w3tc' ) ||
|
226 |
Util_Environment::is_preview_mode() ) {
|
676 |
public function pro_dev_mode() {
|
677 |
echo '<!-- W3 Total Cache is currently running in Pro version Development mode. --><div style="border:2px solid red;text-align:center;font-size:1.2em;color:red"><p><strong>W3 Total Cache is currently running in Pro version Development mode.</strong></p></div>';
|
678 |
}
|
679 |
+
|
680 |
+
public function robots_rules_generate( $content ) {
|
681 |
+
$content .= Generic_Environment::robots_rules_generate();
|
682 |
+
return $content;
|
683 |
+
}
|
684 |
}
|
Util_WpFile.php
CHANGED
@@ -226,6 +226,28 @@ class Util_WpFile {
|
|
226 |
}
|
227 |
}
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
/**
|
230 |
* Get WordPress filesystems credentials. Required for WP filesystem usage.
|
231 |
*
|
226 |
}
|
227 |
}
|
228 |
|
229 |
+
/**
|
230 |
+
* Checks if file exists
|
231 |
+
*
|
232 |
+
* @since 2.1.8
|
233 |
+
*
|
234 |
+
* @param string $filename path to file
|
235 |
+
* @throws Util_WpFile_FilesystemOperationException
|
236 |
+
* @return boolean
|
237 |
+
*/
|
238 |
+
static public function file_exists( $filename ) {
|
239 |
+
try {
|
240 |
+
self::request_filesystem_credentials();
|
241 |
+
} catch ( Util_WpFile_FilesystemOperationException $ex ) {
|
242 |
+
throw new Util_WpFile_FilesystemOperationException( $ex->getMessage(),
|
243 |
+
$ex->credentials_form() );
|
244 |
+
}
|
245 |
+
|
246 |
+
global $wp_filesystem;
|
247 |
+
|
248 |
+
return $wp_filesystem->exists( $filename );
|
249 |
+
}
|
250 |
+
|
251 |
/**
|
252 |
* Get WordPress filesystems credentials. Required for WP filesystem usage.
|
253 |
*
|
inc/options/general.php
CHANGED
@@ -524,13 +524,20 @@ Util_Ui::config_item( array(
|
|
524 |
)
|
525 |
);
|
526 |
|
527 |
-
Util_Ui::config_item( array(
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
</table>
|
535 |
|
536 |
<?php Util_Ui::button_config_save( 'general_misc' ); ?>
|
524 |
)
|
525 |
);
|
526 |
|
527 |
+
Util_Ui::config_item( array(
|
528 |
+
'key' => 'common.track_usage',
|
529 |
+
'control' => 'checkbox',
|
530 |
+
'checkbox_label' => __( 'Anonymously track usage to improve product quality', 'w3-total-cache' ),
|
531 |
+
'label_class' => 'w3tc_single_column'
|
532 |
+
) );
|
533 |
+
|
534 |
+
Util_Ui::config_item( array(
|
535 |
+
'key' => 'robots_block.enable',
|
536 |
+
'control' => 'checkbox',
|
537 |
+
'checkbox_label' => __( 'Enable robots.txt blocking for cache directory', 'w3-total-cache' ),
|
538 |
+
'label_class' => 'w3tc_single_column'
|
539 |
+
) );
|
540 |
+
?>
|
541 |
</table>
|
542 |
|
543 |
<?php Util_Ui::button_config_save( 'general_misc' ); ?>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: boldgrid, fredericktownes, maxicusc, gidomanders, bwmarkle, harryj
|
|
3 |
Tags: seo, cache, optimize, pagespeed, performance, caching, compression, maxcdn, nginx, varnish, redis, new relic, aws, amazon web services, s3, cloudfront, rackspace, cloudflare, azure, apache
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 5.8
|
6 |
-
Stable tag: 2.1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -275,6 +275,9 @@ Please reach out to all of these people and support their projects if you're so
|
|
275 |
|
276 |
== Changelog ==
|
277 |
|
|
|
|
|
|
|
278 |
= 2.1.7 =
|
279 |
* Fix: Corrected relative paths used in the JS minify YUI Compressor
|
280 |
* Fix: Disallow crawling of cache directory
|
3 |
Tags: seo, cache, optimize, pagespeed, performance, caching, compression, maxcdn, nginx, varnish, redis, new relic, aws, amazon web services, s3, cloudfront, rackspace, cloudflare, azure, apache
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 5.8
|
6 |
+
Stable tag: 2.1.8
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
275 |
|
276 |
== Changelog ==
|
277 |
|
278 |
+
= 2.1.8 =
|
279 |
+
* Fix: Corrected handling of robots.txt (file and filter)
|
280 |
+
|
281 |
= 2.1.7 =
|
282 |
* Fix: Corrected relative paths used in the JS minify YUI Compressor
|
283 |
* Fix: Disallow crawling of cache directory
|
w3-total-cache-api.php
CHANGED
@@ -5,7 +5,7 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
5 |
}
|
6 |
|
7 |
define( 'W3TC', true );
|
8 |
-
define( 'W3TC_VERSION', '2.1.
|
9 |
define( 'W3TC_POWERED_BY', 'W3 Total Cache' );
|
10 |
define( 'W3TC_EMAIL', 'w3tc@w3-edge.com' );
|
11 |
define( 'W3TC_TEXT_DOMAIN', 'w3-total-cache' );
|
5 |
}
|
6 |
|
7 |
define( 'W3TC', true );
|
8 |
+
define( 'W3TC_VERSION', '2.1.8' );
|
9 |
define( 'W3TC_POWERED_BY', 'W3 Total Cache' );
|
10 |
define( 'W3TC_EMAIL', 'w3tc@w3-edge.com' );
|
11 |
define( 'W3TC_TEXT_DOMAIN', 'w3-total-cache' );
|
w3-total-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: W3 Total Cache
|
4 |
* Plugin URI: https://www.boldgrid.com/totalcache/
|
5 |
* Description: The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
|
6 |
-
* Version: 2.1.
|
7 |
* Requires at least: 3.8
|
8 |
* Requires PHP: 5.6
|
9 |
* Author: BoldGrid
|
3 |
* Plugin Name: W3 Total Cache
|
4 |
* Plugin URI: https://www.boldgrid.com/totalcache/
|
5 |
* Description: The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
|
6 |
+
* Version: 2.1.8
|
7 |
* Requires at least: 3.8
|
8 |
* Requires PHP: 5.6
|
9 |
* Author: BoldGrid
|