From 2646c4d50579c40b64ef4078adea484cad528ca6 Mon Sep 17 00:00:00 2001
From: Hardeep Asrani
Date: Sat, 18 Apr 2026 06:35:13 +0530
Subject: [PATCH] feat: add Super Page Cache option to the onboarding wizard
---
.github/workflows/test-php.yml | 5 ++--
assets/css/style-wizard.css | 1 +
assets/js/scripts-admin.js | 19 +++++++++++-
.../classes/wp-maintenance-mode-admin.php | 13 +++++++++
tests/bootstrap.php | 6 ++++
views/wizard.php | 29 +++++++++++++++++++
6 files changed, 69 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml
index 71dfac9f..03801ea8 100644
--- a/.github/workflows/test-php.yml
+++ b/.github/workflows/test-php.yml
@@ -53,7 +53,7 @@ jobs:
with:
php-version: '7.2'
extensions: simplexml, mysql
- tools: phpunit-polyfills
+ tools: phpunit:7.5.20, phpunit-polyfills
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Subversion
@@ -73,7 +73,6 @@ jobs:
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
- run: composer install --prefer-dist --no-progress --no-suggest --no-dev
+ run: composer install --prefer-dist --no-progress --no-suggest
- name: Run phpunit
run: composer run-script phpunit
-
diff --git a/assets/css/style-wizard.css b/assets/css/style-wizard.css
index b57b63bc..5a2b6eb5 100644
--- a/assets/css/style-wizard.css
+++ b/assets/css/style-wizard.css
@@ -107,6 +107,7 @@ h2.wpmm-title span img {
.step.import-step {
margin: min(10%, 65px) min(12%, 195px);
width: 1090px;
+ outline: 0;
}
.import-step .header {
diff --git a/assets/js/scripts-admin.js b/assets/js/scripts-admin.js
index 42b7ef8d..e2877531 100644
--- a/assets/js/scripts-admin.js
+++ b/assets/js/scripts-admin.js
@@ -601,6 +601,7 @@ jQuery( function( $ ) {
*/
function handlePlugins() {
const optimoleCheckbox = $( '#wizard-optimole-checkbox' );
+ const wpscCheckbox = $( '#wizard-wpsc-checkbox' );
const otterBlockCheckbox = $( '#wizard-otter-block-checkbox' );
let promiseChain = Promise.resolve();
@@ -617,6 +618,19 @@ jQuery( function( $ ) {
});
}
+ if ( wpscCheckbox.length && wpscCheckbox.is( ':checked' ) ) {
+ promiseChain = promiseChain
+ .then( () => {
+ if ( ! wpmmVars.isWPSCInstalled ) {
+ return installPlugin( 'wp-cloudflare-page-cache' ).then( () => activatePlugin( 'wp-cloudflare-page-cache' ) );
+ }
+
+ if ( ! wpmmVars.isWPSCActive ) {
+ return activatePlugin( wpmmVars.isWPSCProInstalled ? 'wp-super-page-cache-pro' : 'wp-cloudflare-page-cache' );
+ }
+ } );
+ }
+
if ( otterBlockCheckbox.length && otterBlockCheckbox.is( ':checked' ) ) {
promiseChain = promiseChain
.then(() => handleOtter());
@@ -637,7 +651,7 @@ jQuery( function( $ ) {
updateSDKOptions();
return activatePlugin( 'otter-blocks' );
} );
- } else if ( ! wpmmVars.isOtterActivated ) {
+ } else if ( ! wpmmVars.isOtterActive ) {
return activatePlugin( 'otter-blocks' );
}
@@ -689,6 +703,9 @@ jQuery( function( $ ) {
return $.get( wpmmVars.otterActivationLink );
case 'optimole-wp':
return $.get( wpmmVars.optimoleActivationLink );
+ case 'wp-super-page-cache-pro':
+ case 'wp-cloudflare-page-cache':
+ return $.get( wpmmVars.wpscActivationLink );
default:
break;
}
diff --git a/includes/classes/wp-maintenance-mode-admin.php b/includes/classes/wp-maintenance-mode-admin.php
index b9ff3043..1f36a031 100644
--- a/includes/classes/wp-maintenance-mode-admin.php
+++ b/includes/classes/wp-maintenance-mode-admin.php
@@ -168,6 +168,9 @@ public function enqueue_admin_scripts() {
'isOtterActive' => is_plugin_active( 'otter-blocks/otter-blocks.php' ),
'isOptimoleInstalled' => file_exists( ABSPATH . 'wp-content/plugins/optimole-wp/optimole-wp.php' ),
'isOptimoleActive' => is_plugin_active( 'optimole-wp/optimole-wp.php' ),
+ 'isWPSCInstalled' => file_exists( ABSPATH . 'wp-content/plugins/wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ) || file_exists( ABSPATH . 'wp-content/plugins/wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' ),
+ 'isWPSCActive' => is_plugin_active( 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ) || is_plugin_active( 'wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' ),
+ 'isWPSCProInstalled' => file_exists( ABSPATH . 'wp-content/plugins/wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' ),
'errorString' => __( 'Something went wrong, please try again.', 'wp-maintenance-mode' ),
'loadingString' => __( 'Doing some magic...', 'wp-maintenance-mode' ),
'importingText' => __( 'Importing', 'wp-maintenance-mode' ),
@@ -198,6 +201,16 @@ public function enqueue_admin_scripts() {
),
esc_url( network_admin_url( 'plugins.php' ) )
),
+ 'wpscActivationLink' => add_query_arg(
+ array(
+ 'action' => 'activate',
+ 'plugin' => rawurlencode( file_exists( ABSPATH . 'wp-content/plugins/wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' ) ? 'wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' : 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
+ 'plugin_status' => 'all',
+ 'paged' => '1',
+ '_wpnonce' => wp_create_nonce( file_exists( ABSPATH . 'wp-content/plugins/wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' ) ? 'activate-plugin_wp-super-page-cache-pro/wp-cloudflare-super-page-cache-pro.php' : 'activate-plugin_wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
+ ),
+ esc_url( network_admin_url( 'plugins.php' ) )
+ ),
'modalTexts' => array(
'title' => __( 'The template has been imported!', 'wp-maintenance-mode' ),
'description' => __( 'The template has been imported to a new draft page. You can take a look and enable it from plugin settings.', 'wp-maintenance-mode' ),
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 0407d0b2..99fdedc8 100755
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -9,6 +9,12 @@
error_log( var_export ( $_tests_dir, true) );
+$polyfills_path = dirname( dirname( __FILE__ ) ) . '/vendor/yoast/phpunit-polyfills';
+
+if ( file_exists( $polyfills_path . '/phpunitpolyfills-autoload.php' ) && ! defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) {
+ define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $polyfills_path );
+}
+
if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
}
diff --git a/views/wizard.php b/views/wizard.php
index 90a30b2e..07516db8 100644
--- a/views/wizard.php
+++ b/views/wizard.php
@@ -98,6 +98,35 @@
wpmm_translated_string_allowed_html(),
);
?>
+
+
+
+
+
+
+
+ %3$s %4$s',
+ __( 'Speed up your pages by 60-80% with intelligent caching. Achieve faster load times and better search rankings automatically, with', 'wp-maintenance-mode' ),
+ esc_url( 'https://wordpress.org/plugins/wp-cloudflare-page-cache/' ),
+ __( 'Super Page Cache', 'wp-maintenance-mode' ),
+ __( 'plugin installed and activated automatically.', 'wp-maintenance-mode' ),
+ ),
+ wpmm_translated_string_allowed_html(),
+ );
+ ?>
+