Skip to content

Commit

Permalink
WP Super Cache: check for the advanced-cache.php created by Boost Cac…
Browse files Browse the repository at this point in the history
…he (#36027)

* Check for Jetpack Boost when creating advanced-cache.php

* changelog

* Fix the link to the Plugins page so it's not escaped

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8097117840
  • Loading branch information
dilirity authored and matticbot committed Feb 29, 2024
1 parent f8534f5 commit 3d486dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This is an alpha version! The changes listed here are not final.
- General: updated PHP requirement to PHP 7.0+
- General: update WordPress version requirements to WordPress 6.3.
- Updated package dependencies.
- WP Super Cache: check for Boost Cache when creating advanced-cache.php
- WP Super Cache: remove notifications that preload started working again.

### Fixed
Expand Down
22 changes: 13 additions & 9 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2289,28 +2289,32 @@ function wp_cache_create_advanced_cache() {
function wpsc_check_advanced_cache() {
global $wpsc_advanced_cache_filename;

$ret = true;
$boost_advanced_cache = false;
$ret = false;
$other_advanced_cache = false;
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
$file = file_get_contents( $wpsc_advanced_cache_filename );
if ( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
return true;
} elseif ( strpos( $file, 'Boost Cache Plugin' ) ) {
$boost_advanced_cache = true;
$ret = false;
} elseif ( strpos( $file, 'Boost Cache Plugin' ) !== false ) {
$other_advanced_cache = 'BOOST';
} else {
$other_advanced_cache = true;
$ret = wp_cache_create_advanced_cache();
}
} else {
$ret = wp_cache_create_advanced_cache();
}

if ( false == $ret ) {
if ( $boost_advanced_cache ) {
echo '<div style="width: 50%" class="notice notice-error"><h2>' . esc_html__( 'You are using Page Caching on Jetpack Boost', 'wp-super-cache' ) . '</h2>';
echo '<p>' . esc_html__( 'It appears that Jetpack Boost Cache is currently enabled. If you wish to use WP Super Cache, please deactivate Jetpack Boost first, activate caching with WP Super Cache, and then reactivate Jetpack Boost.', 'wp-super-cache' ) . '</p>';
if ( $other_advanced_cache === 'BOOST' ) {
echo '<div style="width: 50%" class="notice notice-error"><h2>' . esc_html__( 'Warning! Jetpack Boost Cache Detected', 'wp-super-cache' ) . '</h2>';
// translators: %s is the filename of the advanced-cache.php file
echo '<p>' . sprintf( esc_html__( 'The file %s was created by the Jetpack Boost plugin.', 'wp-super-cache' ), esc_html( $wpsc_advanced_cache_filename ) ) . '</p>';
echo '<p>' . esc_html__( 'You can use Jetpack Boost and WP Super Cache at the same time but only if the Cache Site Pages module in Boost is disabled. To use WP Super Cache for caching:', 'wp-super-cache' ) . '</p>';
// translators: %s is a html link to the plugins page
echo '<ol><li>' . sprintf( esc_html__( 'Deactivate Jetpack Boost on the %s page.', 'wp-super-cache' ), '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">' . esc_html__( 'Plugins', 'wp-super-cache' ) . '</a>' ) . '</li>';
echo '<li>' . esc_html__( 'Reload this page to configure WP Super Cache.', 'wp-super-cache' ) . '</li>';
echo '<li>' . esc_html__( 'Activate the Jetpack Boost plugin again.', 'wp-super-cache' ) . '</li>';
echo '</ol>';
} elseif ( $other_advanced_cache ) {
echo '<div style="width: 50%" class="notice notice-error"><h2>' . __( 'Warning! You may not be allowed to use this plugin on your site.', 'wp-super-cache' ) . "</h2>";
echo '<p>' .
Expand Down

0 comments on commit 3d486dc

Please sign in to comment.