wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=jetpack-boost' ), 'install-plugin_jetpack-boost' ), 'activate_url' => admin_url( 'plugins.php' ), 'is_installed' => wpsc_is_boost_installed(), ); } /** * Display an admin notice to install Jetpack Boost. */ function wpsc_jetpack_boost_notice() { if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpsupercache' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } // hide the admin notice if Jetpack Boost Cache is already used. if ( 'BOOST' === wpsc_identify_advanced_cache() ) { return; } // Don't show the banner if the banner has been dismissed. $is_dismissed = '1' === get_user_option( 'wpsc_dismissed_boost_admin_notice' ); if ( $is_dismissed ) { return; } // Don't show the admin notice if Jetpack Boost is too old. if ( ! wpsc_is_boost_current() ) { return; } // Don't show the banner if Super Cache is using features that Boost doesn't support. if ( ! wpsc_is_boost_compatible() ) { return; } $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'; ?>

  1. ' . esc_html__( 'Boost Settings', 'wp-super-cache' ) . '' ); ?>
=' ); } else { return true; // don't care if Boost is not installed } } /** * Check if Jetpack Boost has been installed. */ function wpsc_is_boost_installed() { $plugins = array_keys( get_plugins() ); foreach ( $plugins as $plugin ) { if ( str_contains( $plugin, 'jetpack-boost/jetpack-boost.php' ) ) { return true; } } return false; } /** * Check if Jetpack Boost is active. */ function wpsc_is_boost_active() { return class_exists( '\Automattic\Jetpack_Boost\Jetpack_Boost' ); } /** * Admin ajax action: hide the Boost Banner. */ function wpsc_hide_boost_banner() { check_ajax_referer( 'wpsc_dismiss_boost_banner', 'nonce' ); update_user_option( get_current_user_id(), 'wpsc_dismissed_boost_banner', '1' ); wp_die(); } add_action( 'wp_ajax_wpsc-hide-boost-banner', 'wpsc_hide_boost_banner' ); /** * Admin ajax action: activate Jetpack Boost. */ function wpsc_ajax_activate_boost() { check_ajax_referer( 'activate-boost' ); if ( ! isset( $_POST['source'] ) ) { wp_send_json_error( 'no source specified', null, JSON_UNESCAPED_SLASHES ); } $source = sanitize_text_field( wp_unslash( $_POST['source'] ) ); $result = activate_plugin( 'jetpack-boost/jetpack-boost.php' ); if ( is_wp_error( $result ) ) { wp_send_json_error( $result->get_error_message(), null, JSON_UNESCAPED_SLASHES ); } wpsc_notify_migration_to_boost( $source ); wp_send_json_success( null, null, JSON_UNESCAPED_SLASHES ); } add_action( 'wp_ajax_wpsc_activate_boost', '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 ) { return; } $config = wpsc_get_boost_migration_config(); $button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url']; $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( dirname( __DIR__ ) . '/wp-cache.php' ); ?>
<?php esc_attr_e( 'An image showing the Jetpack Boost dashboard.', 'wp-super-cache' ); ?>