Skip to content

Commit

Permalink
Automatically enable Page Cache when migrating from WP Super Cache. (…
Browse files Browse the repository at this point in the history
…#37963)

* Automatically enable Page Cache when migrating from WP Super Cache.

* Add plugins/boost changelog entry.

* lintfix

* Automatically enable Page Cache when migrating from WP Super Cache.

* lintfix v2

* Fix: #37747 - "Try Jetpack" button

* Check if we can migrate to boost

* Add WPSC Migration tracks

* Update the upgrade to boost banner image

* Update the banner design

* fix lints

* Add plugins/super-cache changelog entry.

* phpcs

* phpcs fixes

* Bump the min version of boost

* Replace dash with a non-breaking hyphen in this title.

Avoids line breaking in the wrong place.

* Update projects/plugins/super-cache/partials/easy.php

Co-authored-by: Adnan Haque <[email protected]>

* Update projects/plugins/boost/compatibility/wp-super-cache-migration.php

Co-authored-by: Adnan Haque <[email protected]>

* Allow the admin notice to go full width

---------

Co-authored-by: Donncha O Caoimh <[email protected]>
Co-authored-by: Adnan Haque <[email protected]>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9597651405

Upstream-Ref: Automattic/jetpack@06252e4
  • Loading branch information
pyronaur authored and matticbot committed Jun 20, 2024
1 parent 24ac2f9 commit c8b70ed
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This is an alpha version! The changes listed here are not final.
- General: indicate compatibility with the upcoming version of WordPress - 6.6.
- Super Cache: tell user that Cache module of Boost must be deactivated to use WPSC
- Updated package dependencies.
- WP Super Cache: Updated banner designs, added auto-install Jetpack Boost buttons

### Fixed
- Super Cache: Align detection of Boost installs with activation of that plugin
Expand Down
Binary file modified assets/boost-install-card-main-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/boost-install-card-main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion inc/boost.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Minimum version of Jetpack Boost required for compatibility.
if ( ! defined( 'MINIMUM_BOOST_VERSION' ) ) {
define( 'MINIMUM_BOOST_VERSION', '3.4.0' );
define( 'MINIMUM_BOOST_VERSION', '3.4.5' );
}

/**
Expand Down
22 changes: 21 additions & 1 deletion partials/easy.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,27 @@
echo '<p><strong>' . esc_html__( 'Notice: Simple caching enabled but Supercache mod_rewrite rules from expert mode detected. Cached files will be served using those rules. If your site is working ok, please ignore this message. Otherwise, you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
}
}
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" /></div></form>';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" />';
if ( wpsc_is_boost_current() ) {
$config = wpsc_get_boost_migration_config();
$button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url'];
$button_class = $config['is_installed'] ? 'wpsc-activate-boost-button' : 'wpsc-install-boost-button';
$button_label = esc_html__( 'Try Jetpack Boost', 'wp-super-cache' );
if ( wpsc_is_boost_active() && wpsc_is_boost_installed() ) {
$button_url = esc_url( admin_url( 'admin.php?page=jetpack-boost' ) );
$button_class = '';
$button_label = esc_html__( 'Jetpack Boost Dashboard', 'wp-super-cache' );
}
echo "<a style='margin-left: 12px;' data-source='try_button' class='button button-secondary " . esc_attr( $button_class ) . " wpsc-boost-migration-button' href='" . esc_url( $button_url ) . "'>";
echo '<div class="spinner" style="display:none;"></div>';
echo '<label>';
echo esc_html( $button_label );
echo '</label>';
echo '</a>';
}

echo '</div></form>';
echo '</div>';
if ( $cache_enabled ) {
echo '<div class="wpsc-card">';
Expand Down
17 changes: 8 additions & 9 deletions styling/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Cantarell,
"Helvetica Neue",
sans-serif;
--max-container-width: 1128px;
--max-container-width: 1128px;
background-color: var(--jp-white);
}

Expand All @@ -50,12 +50,12 @@

#wpsc-callout ul,
#wpsc-callout ol,
#wpsc-callout > p:last-child {
#wpsc-callout>p:last-child {
font-size: var(--font-body-small);
}

#wpsc-dashboard > .header,
#wpsc-dashboard > .footer,
#wpsc-dashboard>.header,
#wpsc-dashboard>.footer,
#wpsc-dashboard .wpsc-body-content,
#wpsc-dashboard .wpsc-nav {
max-width: var(--max-container-width);
Expand All @@ -75,6 +75,7 @@
height: var(--icon-height);
border-radius: 7px;
}

.header .wpsc-name {
color: var(--jp-black);
font-family: var(--wpsc-header-font);
Expand Down Expand Up @@ -142,7 +143,7 @@

.footer {
--icon-height: 16px;

display: flex;
margin-top: 1em;
margin-bottom: 1em;
Expand All @@ -169,18 +170,16 @@
text-align: right;
}

.footer .automattic-airline img {
.footer .automattic-airline img {
width: 190px;
height: auto;
}

#wpsc-notice-boost-migrate {
width: 80%;
margin: 0 auto;
margin-top: 10px;

a.button.button-primary {
background-color: var(--jp-black);
color: var(--jp-white);
}
}
}
32 changes: 21 additions & 11 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ function wpsc_ajax_activate_boost() {
* Show a Jetpack Boost installation banner (unless dismissed or installed)
*/
function wpsc_jetpack_boost_install_banner() {
if ( ! wpsc_is_boost_current() ) {
return;
}
// Don't show the banner if Boost is installed, or the banner has been dismissed.
$is_dismissed = '1' === get_user_option( 'wpsc_dismissed_boost_banner' );
if ( wpsc_is_boost_active() || $is_dismissed ) {
Expand All @@ -400,7 +403,7 @@ function wpsc_jetpack_boost_install_banner() {

$config = wpsc_get_boost_migration_config();
$button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url'];
$button_label = $config['is_installed'] ? __( 'Activate Jetpack Boost', 'wp-super-cache' ) : __( 'Install Jetpack Boost', 'wp-super-cache' );
$button_label = $config['is_installed'] ? __( 'Set up Jetpack Boost', 'wp-super-cache' ) : __( 'Install Jetpack Boost', 'wp-super-cache' );
$button_class = $config['is_installed'] ? 'wpsc-activate-boost-button' : 'wpsc-install-boost-button';
$plugin_url = plugin_dir_url( __FILE__ );

Expand All @@ -411,33 +414,40 @@ function wpsc_jetpack_boost_install_banner() {
<img style="width:282px" src="<?php echo esc_url( $plugin_url . '/assets/jetpack-logo.svg' ); ?>" height="36" />

<h3>
<?php esc_html_e( 'Find out how much Super Cache speeds up your site', 'wp-super-cache' ); ?>
<?php esc_html_e( 'Speed up your site with our top&#8209;rated performance tool', 'wp-super-cache' ); ?>
</h3>

<p id="wpsc-install-invitation">
<?php
esc_html_e(
'Caching is a great start, but there is more to maximize your site speed. Find out how much your cache speeds up your site and make it blazing fast with Jetpack Boost, the easiest WordPress speed optimization plugin developed by Super Cache engineers.',
'Caching is a great start, but there is more to maximize your site speed. Find out how much your cache speeds up your site and make it blazing fast with Jetpack Boost, the easiest WordPress speed optimization plugin developed by WP Super Cache engineers.',
'wp-super-cache'
);
?>
</p>

<div class="wpsc-boost-migration-error" style="display:none; color:red; margin-bottom: 20px;"></div>

<a data-source='banner' href="<?php echo esc_url( $button_url ); ?>" class="wpsc-boost-migration-button button button-primary <?php echo esc_attr( $button_class ); ?>">
<div class="spinner" style="display:none; margin-top: 8px"></div>
<label><?php echo esc_html( $button_label ); ?></label>
</a>
<div style="display: flex; gap: 24px;">
<a style="font-weight: 500; line-height: 1; padding: 10px 20px 15px;" data-source='banner' href="<?php echo esc_url( $button_url ); ?>" class="wpsc-boost-migration-button button button-primary <?php echo esc_attr( $button_class ); ?>">
<div class='spinner' style='display:none; margin-top: 8px'></div>
<label><?php echo esc_html( $button_label ); ?></label>
</a>
<a style="display: flex; align-items: center; font-weight: 500; color: #000; " href="https://jetpack.com/blog/discover-how-to-improve-your-site-performance-with-jetpack-boost/">
Learn More
</a>
</div>
</div>

<div class="wpsc-boost-banner-image-container">
<img
src="<?php echo esc_url( $plugin_url . '/assets/boost-install-card-main.png' ); ?>"
width="350"
height="452"
src="<?php echo esc_url( $plugin_url . 'assets/boost-install-card-main.png' ); ?>"
title="<?php esc_attr_e( 'Check how your web site performance scores for desktop and mobile.', 'wp-super-cache' ); ?>"
alt="<?php esc_attr_e( 'An image showing a space shuttle. In the foreground are two graphs in yellow and green', 'wp-super-cache' ); ?>"
srcset="<?php echo esc_url( $plugin_url . '/assets/boost-install-card-main.png' ); ?> 352w <?php echo esc_url( $plugin_url . '/assets/boost-install-card-main-2x.png' ); ?> 730w"
sizes="(max-width: 782px) 352px, 730px"
alt="<?php esc_attr_e( 'An image showing the Jetpack Boost dashboard.', 'wp-super-cache' ); ?>"
srcset="<?php echo esc_url( $plugin_url . 'assets/boost-install-card-main.png' ); ?> 400w, <?php echo esc_url( $plugin_url . 'assets/boost-install-card-main-2x.png' ); ?> 800w"
sizes="(max-width: 782px) 350px, 700px"
>
</div>
</div>
Expand Down

0 comments on commit c8b70ed

Please sign in to comment.