Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-super.../inc
File: boost.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Code to handle migration from WP Super Cache to Jetpack Boost.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WP_Super_Cache
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
// Minimum version of Jetpack Boost required for compatibility.
[7] Fix | Delete
if ( ! defined( 'MINIMUM_BOOST_VERSION' ) ) {
[8] Fix | Delete
define( 'MINIMUM_BOOST_VERSION', '3.4.5' );
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Get shared configuration for each migration button.
[13] Fix | Delete
*/
[14] Fix | Delete
function wpsc_get_boost_migration_config() {
[15] Fix | Delete
return array(
[16] Fix | Delete
'install_url' => wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=jetpack-boost' ), 'install-plugin_jetpack-boost' ),
[17] Fix | Delete
'activate_url' => admin_url( 'plugins.php' ),
[18] Fix | Delete
'is_installed' => wpsc_is_boost_installed(),
[19] Fix | Delete
);
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Display an admin notice to install Jetpack Boost.
[24] Fix | Delete
*/
[25] Fix | Delete
function wpsc_jetpack_boost_notice() {
[26] Fix | Delete
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpsupercache' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[27] Fix | Delete
return;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
// hide the admin notice if Jetpack Boost Cache is already used.
[31] Fix | Delete
if ( 'BOOST' === wpsc_identify_advanced_cache() ) {
[32] Fix | Delete
return;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
// Don't show the banner if the banner has been dismissed.
[36] Fix | Delete
$is_dismissed = '1' === get_user_option( 'wpsc_dismissed_boost_admin_notice' );
[37] Fix | Delete
if ( $is_dismissed ) {
[38] Fix | Delete
return;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
// Don't show the admin notice if Jetpack Boost is too old.
[42] Fix | Delete
if ( ! wpsc_is_boost_current() ) {
[43] Fix | Delete
return;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
// Don't show the banner if Super Cache is using features that Boost doesn't support.
[47] Fix | Delete
if ( ! wpsc_is_boost_compatible() ) {
[48] Fix | Delete
return;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
$config = wpsc_get_boost_migration_config();
[52] Fix | Delete
$button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url'];
[53] Fix | Delete
$button_class = $config['is_installed'] ? 'wpsc-activate-boost-button' : 'wpsc-install-boost-button';
[54] Fix | Delete
[55] Fix | Delete
?>
[56] Fix | Delete
<div id="wpsc-notice-boost-migrate" class="notice boost-notice notice-success is-dismissible">
[57] Fix | Delete
<h3>
[58] Fix | Delete
<?php esc_html_e( 'Migrate to Jetpack Boost', 'wp-super-cache' ); ?>
[59] Fix | Delete
</h3>
[60] Fix | Delete
<p>
[61] Fix | Delete
<?php esc_html_e( 'Your WP Super Cache setup is compatible with Boost\'s new caching feature. Continue to cache as you currently do and enhance your site\'s speed using our highly-rated performance solutions.', 'wp-super-cache' ); ?>
[62] Fix | Delete
</p>
[63] Fix | Delete
[64] Fix | Delete
<p>
[65] Fix | Delete
<div class="wpsc-boost-migration-error" style="display:none; color:red; margin-bottom: 20px;"></div>
[66] Fix | Delete
<a data-source='notice' class='wpsc-boost-migration-button button button-primary <?php echo esc_attr( $button_class ); ?>' href="<?php echo esc_url( $button_url ); ?>">
[67] Fix | Delete
<div class="spinner" style="display:none; margin-top: 8px"></div>
[68] Fix | Delete
<label><?php esc_html_e( 'Migrate now', 'wp-super-cache' ); ?></label>
[69] Fix | Delete
</a>
[70] Fix | Delete
</p>
[71] Fix | Delete
</div>
[72] Fix | Delete
<?php
[73] Fix | Delete
}
[74] Fix | Delete
add_action( 'admin_notices', 'wpsc_jetpack_boost_notice' );
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Dismiss the migration admin notice by setting a user option flag.
[78] Fix | Delete
*/
[79] Fix | Delete
function wpsc_dismiss_boost_notice() {
[80] Fix | Delete
update_user_option( get_current_user_id(), 'wpsc_dismissed_boost_admin_notice', '1' );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Handler called by AJAX to dismiss the admin notice.
[85] Fix | Delete
*/
[86] Fix | Delete
function wpsc_dismiss_boost_notice_ajax_handler() {
[87] Fix | Delete
check_ajax_referer( 'wpsc_dismiss_boost_notice', 'nonce' );
[88] Fix | Delete
wpsc_dismiss_boost_notice();
[89] Fix | Delete
wp_die();
[90] Fix | Delete
}
[91] Fix | Delete
add_action( 'wp_ajax_wpsc_dismiss_boost_notice', 'wpsc_dismiss_boost_notice_ajax_handler' );
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Dismiss the admin notice if the Jetpack Boost plugin is activated.
[95] Fix | Delete
*/
[96] Fix | Delete
function wpsc_dismiss_notice_on_activation() {
[97] Fix | Delete
if ( ! current_user_can( 'activate_plugins' ) ) {
[98] Fix | Delete
return;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
wpsc_dismiss_boost_notice();
[102] Fix | Delete
}
[103] Fix | Delete
add_action( 'wp_ajax_wpsc_activate_boost', 'wpsc_dismiss_notice_on_activation' );
[104] Fix | Delete
/**
[105] Fix | Delete
* Add a notice to the settings page if the Jetpack Boost cache module is detected.
[106] Fix | Delete
* The notice contains instructions on how to disable the Boost Cache module.
[107] Fix | Delete
*/
[108] Fix | Delete
function wpsc_deactivate_boost_cache_notice() {
[109] Fix | Delete
global $wpsc_advanced_cache_filename;
[110] Fix | Delete
?>
[111] Fix | Delete
<div style="width: 50%" class="notice notice-error"><h2><?php esc_html_e( 'Warning! Jetpack Boost Cache Detected', 'wp-super-cache' ); ?></h2>
[112] Fix | Delete
<?php // translators: %s is the filename of the advanced-cache.php file ?>
[113] Fix | Delete
<p><?php printf( esc_html__( 'The file %s was created by the Jetpack Boost plugin.', 'wp-super-cache' ), esc_html( $wpsc_advanced_cache_filename ) ); ?></p>
[114] Fix | Delete
<p><?php esc_html_e( '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>
[115] Fix | Delete
<ol>
[116] Fix | Delete
<?php // translators: %s is a html link to the Boost settings page ?>
[117] Fix | Delete
<li><?php printf( esc_html__( 'Deactivate the "Cache Site Pages" module of Jetpack Boost on the %s page.', 'wp-super-cache' ), '<a href="' . esc_url( admin_url( 'admin.php?page=jetpack-boost' ) ) . '">' . esc_html__( 'Boost Settings', 'wp-super-cache' ) . '</a>' ); ?></li>
[118] Fix | Delete
<li><?php esc_html_e( 'Reload this page to configure WP Super Cache.', 'wp-super-cache' ); ?></li>
[119] Fix | Delete
<li><?php esc_html_e( 'You can continue to use the other features of Jetpack Boost.', 'wp-super-cache' ); ?></li>
[120] Fix | Delete
</ol>
[121] Fix | Delete
</div>
[122] Fix | Delete
<?php
[123] Fix | Delete
set_transient( 'wpsc_boost_cache_notice_displayed', true, WEEK_IN_SECONDS );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Tell Jetpack when the cache is moved from Jetpack Boost to WP Super Cache.
[128] Fix | Delete
*/
[129] Fix | Delete
function wpsc_track_move_from_boost() {
[130] Fix | Delete
if ( ! get_transient( 'wpsc_boost_cache_notice_displayed' ) ) {
[131] Fix | Delete
return;
[132] Fix | Delete
}
[133] Fix | Delete
delete_transient( 'wpsc_boost_cache_notice_displayed' );
[134] Fix | Delete
[135] Fix | Delete
do_action( 'jb_cache_moved_to_wpsc' );
[136] Fix | Delete
}
[137] Fix | Delete
add_action( 'wpsc_created_advanced_cache', 'wpsc_track_move_from_boost' );
[138] Fix | Delete
[139] Fix | Delete
/**
[140] Fix | Delete
* Notify Jetpack Boost that Boost Cache will be used instead of WP Super Cache.
[141] Fix | Delete
*
[142] Fix | Delete
* @param string $source The source of the migration: 'notice', 'banner', 'try_button'.
[143] Fix | Delete
*/
[144] Fix | Delete
function wpsc_notify_migration_to_boost( $source ) {
[145] Fix | Delete
if ( ! in_array( $source, array( 'notice', 'banner', 'try_button' ), true ) ) {
[146] Fix | Delete
return;
[147] Fix | Delete
}
[148] Fix | Delete
set_transient( 'jb_cache_moved_to_boost', $source, WEEK_IN_SECONDS );
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Check if Jetpack Boost is compatible with WP Super Cache.
[153] Fix | Delete
*
[154] Fix | Delete
* @return bool
[155] Fix | Delete
*/
[156] Fix | Delete
function wpsc_is_boost_compatible() {
[157] Fix | Delete
if ( ! empty( $GLOBALS['wp_cache_mobile_enabled'] ) ) {
[158] Fix | Delete
return false;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
if ( isset( $GLOBALS['wp_super_cache_late_init'] ) && $GLOBALS['wp_super_cache_late_init'] === 1 ) {
[162] Fix | Delete
return false;
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
if ( ! empty( $GLOBALS['wpsc_rejected_cookies'] ) ) {
[166] Fix | Delete
return false;
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if ( isset( $GLOBALS['wp_cache_not_logged_in'] ) && $GLOBALS['wp_cache_not_logged_in'] !== 2 ) {
[170] Fix | Delete
return false;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
if ( isset( $GLOBALS['wp_cache_preload_on'] ) && $GLOBALS['wp_cache_preload_on'] === 1 ) {
[174] Fix | Delete
return false;
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
if ( ! empty( $GLOBALS['wp_cache_no_cache_for_get'] ) ) {
[178] Fix | Delete
return false;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
if ( ! empty( $GLOBALS['wpsc_save_headers'] ) ) {
[182] Fix | Delete
return false;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
if ( isset( $GLOBALS['wp_cache_make_known_anon'] ) && $GLOBALS['wp_cache_make_known_anon'] === 1 ) {
[186] Fix | Delete
return false;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
if ( ! empty( $GLOBALS['wp_cache_mfunc_enabled'] ) ) {
[190] Fix | Delete
return false;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
if ( isset( $GLOBALS['wp_cache_clear_on_post_edit'] ) && $GLOBALS['wp_cache_clear_on_post_edit'] === 1 ) {
[194] Fix | Delete
return false;
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
if ( ! empty( $GLOBALS['wp_cache_front_page_checks'] ) ) {
[198] Fix | Delete
return false;
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
if ( is_array( $GLOBALS['wp_cache_pages'] ) && array_sum( $GLOBALS['wp_cache_pages'] ) ) {
[202] Fix | Delete
return false;
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
$default_cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
[206] Fix | Delete
if ( is_array( $GLOBALS['cache_acceptable_files'] ) && array_diff( $GLOBALS['cache_acceptable_files'], $default_cache_acceptable_files ) ) {
[207] Fix | Delete
return false;
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
$default_cache_rejected_uri = array( 'wp-.*\\.php', 'index\\.php' );
[211] Fix | Delete
if ( is_array( $GLOBALS['cache_rejected_uri'] ) && array_diff( $GLOBALS['cache_rejected_uri'], $default_cache_rejected_uri ) ) {
[212] Fix | Delete
return false;
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
if ( is_array( $GLOBALS['cache_rejected_user_agent'] ) && array_diff( $GLOBALS['cache_rejected_user_agent'], array( '' ) ) ) {
[216] Fix | Delete
return false;
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
return true;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Check if the Jetpack Boost that is installed is current.
[224] Fix | Delete
*
[225] Fix | Delete
* @return bool True if Jetpack Boost is same as or newer than version 3.4.0
[226] Fix | Delete
*/
[227] Fix | Delete
function wpsc_is_boost_current() {
[228] Fix | Delete
if ( defined( 'JETPACK_BOOST_VERSION' ) ) {
[229] Fix | Delete
return version_compare( (string) JETPACK_BOOST_VERSION, MINIMUM_BOOST_VERSION, '>=' );
[230] Fix | Delete
} else {
[231] Fix | Delete
return true; // don't care if Boost is not installed
[232] Fix | Delete
}
[233] Fix | Delete
}
[234] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function