Skip to content

Commit 1d08210

Browse files
committed
feat: add Super Page Cache option to the onboarding wizard
1 parent f4b9554 commit 1d08210

5 files changed

Lines changed: 60 additions & 3 deletions

File tree

.github/workflows/test-php.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
with:
5454
php-version: '7.2'
5555
extensions: simplexml, mysql
56-
tools: phpunit-polyfills
56+
tools: phpunit:7.5.20, phpunit-polyfills
5757
- name: Checkout source code
5858
uses: actions/checkout@v2
5959
- name: Install Subversion
@@ -76,4 +76,3 @@ jobs:
7676
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
7777
- name: Run phpunit
7878
run: composer run-script phpunit
79-

assets/css/style-wizard.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ h2.wpmm-title span img {
107107
.step.import-step {
108108
margin: min(10%, 65px) min(12%, 195px);
109109
width: 1090px;
110+
outline: 0;
110111
}
111112

112113
.import-step .header {

assets/js/scripts-admin.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ jQuery( function( $ ) {
601601
*/
602602
function handlePlugins() {
603603
const optimoleCheckbox = $( '#wizard-optimole-checkbox' );
604+
const wpscCheckbox = $( '#wizard-wpsc-checkbox' );
604605
const otterBlockCheckbox = $( '#wizard-otter-block-checkbox' );
605606
let promiseChain = Promise.resolve();
606607

@@ -617,6 +618,19 @@ jQuery( function( $ ) {
617618
});
618619
}
619620

621+
if ( wpscCheckbox.length && wpscCheckbox.is( ':checked' ) ) {
622+
promiseChain = promiseChain
623+
.then( () => {
624+
if ( ! wpmmVars.isWPSCInstalled ) {
625+
return installPlugin( 'wp-cloudflare-page-cache' ).then( () => activatePlugin( 'wp-cloudflare-page-cache' ) );
626+
}
627+
628+
if ( ! wpmmVars.isWPSCActive ) {
629+
return activatePlugin( 'wp-cloudflare-page-cache' );
630+
}
631+
} );
632+
}
633+
620634
if ( otterBlockCheckbox.length && otterBlockCheckbox.is( ':checked' ) ) {
621635
promiseChain = promiseChain
622636
.then(() => handleOtter());
@@ -637,7 +651,7 @@ jQuery( function( $ ) {
637651
updateSDKOptions();
638652
return activatePlugin( 'otter-blocks' );
639653
} );
640-
} else if ( ! wpmmVars.isOtterActivated ) {
654+
} else if ( ! wpmmVars.isOtterActive ) {
641655
return activatePlugin( 'otter-blocks' );
642656
}
643657

@@ -689,6 +703,8 @@ jQuery( function( $ ) {
689703
return $.get( wpmmVars.otterActivationLink );
690704
case 'optimole-wp':
691705
return $.get( wpmmVars.optimoleActivationLink );
706+
case 'wp-cloudflare-page-cache':
707+
return $.get( wpmmVars.wpscActivationLink );
692708
default:
693709
break;
694710
}

includes/classes/wp-maintenance-mode-admin.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function enqueue_admin_scripts() {
168168
'isOtterActive' => is_plugin_active( 'otter-blocks/otter-blocks.php' ),
169169
'isOptimoleInstalled' => file_exists( ABSPATH . 'wp-content/plugins/optimole-wp/optimole-wp.php' ),
170170
'isOptimoleActive' => is_plugin_active( 'optimole-wp/optimole-wp.php' ),
171+
'isWPSCInstalled' => file_exists( ABSPATH . 'wp-content/plugins/wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
172+
'isWPSCActive' => is_plugin_active( 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
171173
'errorString' => __( 'Something went wrong, please try again.', 'wp-maintenance-mode' ),
172174
'loadingString' => __( 'Doing some magic...', 'wp-maintenance-mode' ),
173175
'importingText' => __( 'Importing', 'wp-maintenance-mode' ),
@@ -198,6 +200,16 @@ public function enqueue_admin_scripts() {
198200
),
199201
esc_url( network_admin_url( 'plugins.php' ) )
200202
),
203+
'wpscActivationLink' => add_query_arg(
204+
array(
205+
'action' => 'activate',
206+
'plugin' => rawurlencode( 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
207+
'plugin_status' => 'all',
208+
'paged' => '1',
209+
'_wpnonce' => wp_create_nonce( 'activate-plugin_wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
210+
),
211+
esc_url( network_admin_url( 'plugins.php' ) )
212+
),
201213
'modalTexts' => array(
202214
'title' => __( 'The template has been imported!', 'wp-maintenance-mode' ),
203215
'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' ),

views/wizard.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,35 @@
9898
wpmm_translated_string_allowed_html(),
9999
);
100100
?>
101+
</p>
102+
</div>
103+
<?php } ?>
104+
<?php if ( ! is_plugin_active( 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ) ) { ?>
105+
<div class="optimole-upsell">
106+
<div class="optimole-upsell-container">
107+
<span class="components-checkbox-control__input-container">
108+
<input id="wizard-wpsc-checkbox" type="checkbox" class="components-checkbox-control__input" checked>
109+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="presentation" class="components-checkbox-control__checked" aria-hidden="true" focusable="false"><path d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"></path></svg>
110+
</span>
111+
<label for="wizard-wpsc-checkbox">
112+
<?php esc_html_e( 'Accelerate your website performance', 'wp-maintenance-mode' ); ?>
113+
</label>
114+
</div>
115+
<p class="description">
116+
<?php
117+
echo wp_kses(
118+
sprintf(
119+
// translators: %1$s is a description, %2$s is the Super Page Cache URL, %3$s is the plugin name, %4$s is description text.
120+
'%1$s <a href="%2$s" target="_blank">%3$s</a> %4$s',
121+
__( 'Speed up your pages by 60-80% with intelligent caching. Achieve faster load times and better search rankings automatically, with', 'wp-maintenance-mode' ),
122+
esc_url( 'https://wordpress.org/plugins/wp-cloudflare-page-cache/' ),
123+
__( 'Super Page Cache', 'wp-maintenance-mode' ),
124+
__( 'plugin installed and activated automatically.', 'wp-maintenance-mode' ),
125+
),
126+
wpmm_translated_string_allowed_html(),
127+
);
128+
?>
129+
</p>
101130
</div>
102131
<?php } ?>
103132

0 commit comments

Comments
 (0)