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...
File: wp-cache.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* Plugin Name: WP Super Cache
[2] Fix | Delete
* Plugin URI: https://wordpress.org/plugins/wp-super-cache/
[3] Fix | Delete
* Description: Very fast caching plugin for WordPress.
[4] Fix | Delete
* Version: 1.12.4
[5] Fix | Delete
* Author: Automattic
[6] Fix | Delete
* Author URI: https://automattic.com/
[7] Fix | Delete
* License: GPL2+
[8] Fix | Delete
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
[9] Fix | Delete
* Text Domain: wp-super-cache
[10] Fix | Delete
*/
[11] Fix | Delete
[12] Fix | Delete
/*
[13] Fix | Delete
Copyright Automattic and many other contributors.
[14] Fix | Delete
[15] Fix | Delete
This program is free software; you can redistribute it and/or modify
[16] Fix | Delete
it under the terms of the GNU General Public License as published by
[17] Fix | Delete
the Free Software Foundation; either version 2 of the License, or
[18] Fix | Delete
(at your option) any later version.
[19] Fix | Delete
[20] Fix | Delete
This program is distributed in the hope that it will be useful,
[21] Fix | Delete
but WITHOUT ANY WARRANTY; without even the implied warranty of
[22] Fix | Delete
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[23] Fix | Delete
GNU General Public License for more details.
[24] Fix | Delete
[25] Fix | Delete
You should have received a copy of the GNU General Public License
[26] Fix | Delete
along with this program; if not, write to the Free Software
[27] Fix | Delete
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[28] Fix | Delete
*/
[29] Fix | Delete
[30] Fix | Delete
define( 'WPSC_VERSION_ID', '1.12.1' );
[31] Fix | Delete
[32] Fix | Delete
require_once( __DIR__. '/inc/delete-cache-button.php');
[33] Fix | Delete
require_once( __DIR__. '/inc/preload-notification.php');
[34] Fix | Delete
require_once __DIR__ . '/inc/boost.php';
[35] Fix | Delete
[36] Fix | Delete
if ( ! function_exists( 'wp_cache_phase2' ) ) {
[37] Fix | Delete
require_once( __DIR__. '/wp-cache-phase2.php');
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
if ( ! defined( 'PHP_VERSION_ID' ) ) {
[41] Fix | Delete
// For versions of PHP below 5.2.7, this constant doesn't exist.
[42] Fix | Delete
$wpsc_php_version = explode( '.', PHP_VERSION );
[43] Fix | Delete
define( 'PHP_VERSION_ID', intval( $wpsc_php_version[0] * 10000 + $wpsc_php_version[1] * 100 + $wpsc_php_version[2] ) );
[44] Fix | Delete
unset( $wpsc_php_version );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Defines how many posts to preload per loop.
[49] Fix | Delete
*/
[50] Fix | Delete
if ( ! defined( 'WPSC_PRELOAD_POST_COUNT' ) ) {
[51] Fix | Delete
define( 'WPSC_PRELOAD_POST_COUNT', 10 );
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Defines the interval in seconds between preloading pages.
[56] Fix | Delete
*/
[57] Fix | Delete
if ( ! defined( 'WPSC_PRELOAD_POST_INTERVAL' ) ) {
[58] Fix | Delete
define( 'WPSC_PRELOAD_POST_INTERVAL', 1 );
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Defines the interval in seconds between preloading loops.
[63] Fix | Delete
*/
[64] Fix | Delete
if ( ! defined( 'WPSC_PRELOAD_LOOP_INTERVAL' ) ) {
[65] Fix | Delete
define( 'WPSC_PRELOAD_LOOP_INTERVAL', 0 );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
function wpsc_init() {
[69] Fix | Delete
global $wp_cache_config_file, $wp_cache_config_file_sample, $wpsc_advanced_cache_dist_filename, $wp_cache_check_wp_config, $wpsc_advanced_cache_filename, $wpsc_promo_links;
[70] Fix | Delete
[71] Fix | Delete
if ( ! defined( 'WPCACHECONFIGPATH' ) ) {
[72] Fix | Delete
define( 'WPCACHECONFIGPATH', WP_CONTENT_DIR );
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
$wp_cache_config_file = WPCACHECONFIGPATH . '/wp-cache-config.php';
[76] Fix | Delete
[77] Fix | Delete
// Centralise the promotional links to other products
[78] Fix | Delete
$wpsc_promo_links = array(
[79] Fix | Delete
'boost' => 'https://jetpack.com/boost/?utm_source=wporg&utm_medium=plugin&utm_campaign=wp-super-cache&utm_id=wp-super-cache',
[80] Fix | Delete
'photon' => 'https://jetpack.com/features/design/content-delivery-network/?utm_source=wporg&utm_medium=plugin&utm_campaign=wp-super-cache&utm_id=wp-super-cache',
[81] Fix | Delete
'videopress' => 'https://jetpack.com/videopress/?utm_source=wporg&utm_medium=plugin&utm_campaign=wp-super-cache&utm_id=wp-super-cache',
[82] Fix | Delete
'crowdsignal' => 'https://crowdsignal.com/?utm_source=wporg&utm_medium=plugin&utm_campaign=wp-super-cache&utm_id=wp-super-cache',
[83] Fix | Delete
'jetpack' => 'https://jetpack.com/?utm_source=wporg&utm_medium=plugin&utm_campaign=wp-super-cache&utm_id=wp-super-cache',
[84] Fix | Delete
);
[85] Fix | Delete
[86] Fix | Delete
if ( !defined( 'WPCACHEHOME' ) ) {
[87] Fix | Delete
define( 'WPCACHEHOME', __DIR__ . '/' );
[88] Fix | Delete
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
[89] Fix | Delete
$wpsc_advanced_cache_dist_filename = WPCACHEHOME . 'advanced-cache.php';
[90] Fix | Delete
} elseif ( realpath( WPCACHEHOME ) != realpath( __DIR__ ) ) {
[91] Fix | Delete
$wp_cache_config_file_sample = __DIR__. '/wp-cache-config-sample.php';
[92] Fix | Delete
$wpsc_advanced_cache_dist_filename = __DIR__. '/advanced-cache.php';
[93] Fix | Delete
if ( ! defined( 'ADVANCEDCACHEPROBLEM' ) ) {
[94] Fix | Delete
define( 'ADVANCEDCACHEPROBLEM', 1 ); // force an update of WPCACHEHOME
[95] Fix | Delete
}
[96] Fix | Delete
} else {
[97] Fix | Delete
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
[98] Fix | Delete
$wpsc_advanced_cache_dist_filename = WPCACHEHOME . 'advanced-cache.php';
[99] Fix | Delete
}
[100] Fix | Delete
$wpsc_advanced_cache_filename = WP_CONTENT_DIR . '/advanced-cache.php';
[101] Fix | Delete
[102] Fix | Delete
if ( !defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) ) {
[103] Fix | Delete
$wp_cache_check_wp_config = true;
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
wpsc_init();
[108] Fix | Delete
[109] Fix | Delete
/**
[110] Fix | Delete
* WP-CLI requires explicit declaration of global variables.
[111] Fix | Delete
* It's minimal list of global variables.
[112] Fix | Delete
*/
[113] Fix | Delete
global $super_cache_enabled, $cache_enabled, $wp_cache_mod_rewrite, $wp_cache_home_path, $cache_path, $file_prefix;
[114] Fix | Delete
global $wp_cache_mutex_disabled, $mutex_filename, $sem_id, $wp_super_cache_late_init;
[115] Fix | Delete
global $cache_compression, $cache_max_time, $wp_cache_shutdown_gc, $cache_rebuild_files;
[116] Fix | Delete
global $wp_super_cache_debug, $wp_super_cache_advanced_debug, $wp_cache_debug_level, $wp_cache_debug_to_file;
[117] Fix | Delete
global $wp_cache_debug_log, $wp_cache_debug_ip, $wp_cache_debug_username, $wp_cache_debug_email;
[118] Fix | Delete
global $cache_time_interval, $cache_scheduled_time, $cache_schedule_interval, $cache_schedule_type, $cache_gc_email_me;
[119] Fix | Delete
global $wp_cache_preload_on, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_taxonomies;
[120] Fix | Delete
[121] Fix | Delete
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- these are used by various functions but the linter complains.
[122] Fix | Delete
global $wp_cache_preload_email_me, $wp_cache_preload_email_volume;
[123] Fix | Delete
global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
[124] Fix | Delete
global $wp_cache_config_file, $wp_cache_config_file_sample;
[125] Fix | Delete
[126] Fix | Delete
// Check is cache config already loaded.
[127] Fix | Delete
if ( ! isset( $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite, $cache_path ) &&
[128] Fix | Delete
empty( $wp_cache_phase1_loaded ) &&
[129] Fix | Delete
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
[130] Fix | Delete
! @include( $wp_cache_config_file )
[131] Fix | Delete
) {
[132] Fix | Delete
@include $wp_cache_config_file_sample; // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
include(WPCACHEHOME . 'wp-cache-base.php');
[136] Fix | Delete
if ( class_exists( 'WP_REST_Controller' ) ) {
[137] Fix | Delete
include( __DIR__. '/rest/load.php' );
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
function wp_super_cache_init_action() {
[141] Fix | Delete
[142] Fix | Delete
load_plugin_textdomain( 'wp-super-cache', false, basename( __DIR__ ) . '/languages' );
[143] Fix | Delete
[144] Fix | Delete
wpsc_register_post_hooks();
[145] Fix | Delete
}
[146] Fix | Delete
add_action( 'init', 'wp_super_cache_init_action' );
[147] Fix | Delete
[148] Fix | Delete
function wp_cache_set_home() {
[149] Fix | Delete
global $wp_cache_is_home;
[150] Fix | Delete
$wp_cache_is_home = ( is_front_page() || is_home() );
[151] Fix | Delete
if ( $wp_cache_is_home && is_paged() )
[152] Fix | Delete
$wp_cache_is_home = false;
[153] Fix | Delete
}
[154] Fix | Delete
add_action( 'template_redirect', 'wp_cache_set_home' );
[155] Fix | Delete
[156] Fix | Delete
function wpsc_enqueue_styles() {
[157] Fix | Delete
wp_enqueue_style(
[158] Fix | Delete
'wpsc_styles',
[159] Fix | Delete
plugins_url( 'styling/dashboard.css', __FILE__ ),
[160] Fix | Delete
array(),
[161] Fix | Delete
filemtime( plugin_dir_path( __FILE__ ) . 'styling/dashboard.css' )
[162] Fix | Delete
);
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
// Check for the page parameter to see if we're on a WPSC page.
[166] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[167] Fix | Delete
if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpsupercache' ) {
[168] Fix | Delete
add_action( 'admin_enqueue_scripts', 'wpsc_enqueue_styles' );
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
// OSSDL CDN plugin (https://wordpress.org/plugins/ossdl-cdn-off-linker/)
[172] Fix | Delete
include_once( WPCACHEHOME . 'ossdl-cdn.php' );
[173] Fix | Delete
[174] Fix | Delete
function get_wpcachehome() {
[175] Fix | Delete
if ( function_exists( '_deprecated_function' ) ) {
[176] Fix | Delete
_deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.5' );
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
if ( ! defined( 'WPCACHEHOME' ) ) {
[180] Fix | Delete
if ( is_file( __DIR__ . '/wp-cache-config-sample.php' ) ) {
[181] Fix | Delete
define( 'WPCACHEHOME', trailingslashit( __DIR__ ) );
[182] Fix | Delete
} elseif ( is_file( __DIR__ . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
[183] Fix | Delete
define( 'WPCACHEHOME', __DIR__ . '/wp-super-cache/' );
[184] Fix | Delete
} else {
[185] Fix | Delete
die( sprintf( esc_html__( 'Please create %s/wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), esc_attr( WPCACHECONFIGPATH ) ) );
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
function wpsc_remove_advanced_cache() {
[191] Fix | Delete
global $wpsc_advanced_cache_filename;
[192] Fix | Delete
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
[193] Fix | Delete
$file = file_get_contents( $wpsc_advanced_cache_filename );
[194] Fix | Delete
if (
[195] Fix | Delete
strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ||
[196] Fix | Delete
strpos( $file, "WP SUPER CACHE 1.2" )
[197] Fix | Delete
) {
[198] Fix | Delete
unlink( $wpsc_advanced_cache_filename );
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
function wpsupercache_uninstall() {
[204] Fix | Delete
global $wp_cache_config_file, $cache_path;
[205] Fix | Delete
[206] Fix | Delete
wpsc_remove_advanced_cache();
[207] Fix | Delete
[208] Fix | Delete
if ( file_exists( $wp_cache_config_file ) ) {
[209] Fix | Delete
unlink( $wp_cache_config_file );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
wp_cache_remove_index();
[213] Fix | Delete
[214] Fix | Delete
if ( ! empty( $cache_path ) ) {
[215] Fix | Delete
@unlink( $cache_path . '.htaccess' );
[216] Fix | Delete
@unlink( $cache_path . 'meta' );
[217] Fix | Delete
@unlink( $cache_path . 'supercache' );
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
[221] Fix | Delete
wp_clear_scheduled_hook( 'wp_cache_gc' );
[222] Fix | Delete
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
[223] Fix | Delete
wp_cache_disable_plugin();
[224] Fix | Delete
delete_site_option( 'wp_super_cache_index_detected' );
[225] Fix | Delete
}
[226] Fix | Delete
if ( is_admin() ) {
[227] Fix | Delete
register_uninstall_hook( __FILE__, 'wpsupercache_uninstall' );
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
function wpsupercache_deactivate() {
[231] Fix | Delete
global $wp_cache_config_file, $wpsc_advanced_cache_filename, $cache_path;
[232] Fix | Delete
[233] Fix | Delete
wpsc_remove_advanced_cache();
[234] Fix | Delete
[235] Fix | Delete
if ( ! empty( $cache_path ) ) {
[236] Fix | Delete
prune_super_cache( $cache_path, true );
[237] Fix | Delete
wp_cache_remove_index();
[238] Fix | Delete
@unlink( $cache_path . '.htaccess' );
[239] Fix | Delete
@unlink( $cache_path . 'meta' );
[240] Fix | Delete
@unlink( $cache_path . 'supercache' );
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
[244] Fix | Delete
wp_clear_scheduled_hook( 'wp_cache_gc' );
[245] Fix | Delete
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
[246] Fix | Delete
wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file);
[247] Fix | Delete
wp_cache_disable_plugin( false ); // don't delete configuration file
[248] Fix | Delete
delete_user_option( get_current_user_id(), 'wpsc_dismissed_boost_banner' );
[249] Fix | Delete
}
[250] Fix | Delete
register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' );
[251] Fix | Delete
[252] Fix | Delete
function wpsupercache_activate() {
[253] Fix | Delete
global $cache_path;
[254] Fix | Delete
if ( ! isset( $cache_path ) || $cache_path == '' )
[255] Fix | Delete
$cache_path = WP_CONTENT_DIR . '/cache/'; // from sample config file
[256] Fix | Delete
[257] Fix | Delete
ob_start();
[258] Fix | Delete
wpsc_init();
[259] Fix | Delete
[260] Fix | Delete
if (
[261] Fix | Delete
! wp_cache_verify_cache_dir() ||
[262] Fix | Delete
! wpsc_check_advanced_cache() ||
[263] Fix | Delete
! wp_cache_verify_config_file()
[264] Fix | Delete
) {
[265] Fix | Delete
$text = ob_get_contents();
[266] Fix | Delete
ob_end_clean();
[267] Fix | Delete
return false;
[268] Fix | Delete
}
[269] Fix | Delete
$text = ob_get_contents();
[270] Fix | Delete
wp_cache_check_global_config();
[271] Fix | Delete
ob_end_clean();
[272] Fix | Delete
wp_schedule_single_event( time() + 10, 'wp_cache_add_site_cache_index' );
[273] Fix | Delete
}
[274] Fix | Delete
register_activation_hook( __FILE__, 'wpsupercache_activate' );
[275] Fix | Delete
[276] Fix | Delete
function wpsupercache_site_admin() {
[277] Fix | Delete
global $wp_version;
[278] Fix | Delete
[279] Fix | Delete
if ( version_compare( $wp_version, '4.8', '>=' ) ) {
[280] Fix | Delete
return current_user_can( 'setup_network' );
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
return is_super_admin();
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
function wp_cache_add_pages() {
[287] Fix | Delete
if ( wpsupercache_site_admin() ) {
[288] Fix | Delete
// In single or MS mode add this menu item too, but only for superadmins in MS mode.
[289] Fix | Delete
add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
[290] Fix | Delete
}
[291] Fix | Delete
}
[292] Fix | Delete
add_action( 'admin_menu', 'wp_cache_add_pages' );
[293] Fix | Delete
[294] Fix | Delete
[295] Fix | Delete
function wp_cache_network_pages() {
[296] Fix | Delete
add_submenu_page( 'settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
[297] Fix | Delete
}
[298] Fix | Delete
add_action( 'network_admin_menu', 'wp_cache_network_pages' );
[299] Fix | Delete
[300] Fix | Delete
/**
[301] Fix | Delete
* Load JavaScript on admin pages.
[302] Fix | Delete
*/
[303] Fix | Delete
function wp_super_cache_admin_enqueue_scripts( $hook ) {
[304] Fix | Delete
if ( 'settings_page_wpsupercache' !== $hook ) {
[305] Fix | Delete
return;
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
wp_enqueue_script(
[309] Fix | Delete
'wp-super-cache-admin',
[310] Fix | Delete
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/admin.js',
[311] Fix | Delete
array( 'jquery' ),
[312] Fix | Delete
WPSC_VERSION_ID,
[313] Fix | Delete
false
[314] Fix | Delete
);
[315] Fix | Delete
[316] Fix | Delete
wp_localize_script(
[317] Fix | Delete
'wp-super-cache-admin',
[318] Fix | Delete
'wpscAdmin',
[319] Fix | Delete
array(
[320] Fix | Delete
'boostNoticeDismissNonce' => wp_create_nonce( 'wpsc_dismiss_boost_notice' ),
[321] Fix | Delete
'boostDismissNonce' => wp_create_nonce( 'wpsc_dismiss_boost_banner' ),
[322] Fix | Delete
'boostInstallNonce' => wp_create_nonce( 'updates' ),
[323] Fix | Delete
'boostActivateNonce' => wp_create_nonce( 'activate-boost' ),
[324] Fix | Delete
)
[325] Fix | Delete
);
[326] Fix | Delete
}
[327] Fix | Delete
add_action( 'admin_enqueue_scripts', 'wp_super_cache_admin_enqueue_scripts' );
[328] Fix | Delete
[329] Fix | Delete
/**
[330] Fix | Delete
* Use the standard WordPress plugin installation ajax handler.
[331] Fix | Delete
*/
[332] Fix | Delete
add_action( 'wp_ajax_wpsc_install_plugin', 'wp_ajax_install_plugin' );
[333] Fix | Delete
[334] Fix | Delete
/**
[335] Fix | Delete
* Check if Jetpack Boost has been installed.
[336] Fix | Delete
*/
[337] Fix | Delete
function wpsc_is_boost_installed() {
[338] Fix | Delete
$plugins = array_keys( get_plugins() );
[339] Fix | Delete
[340] Fix | Delete
foreach ( $plugins as $plugin ) {
[341] Fix | Delete
if ( str_contains( $plugin, 'jetpack-boost/jetpack-boost.php' ) ) {
[342] Fix | Delete
return true;
[343] Fix | Delete
}
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
return false;
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
/**
[350] Fix | Delete
* Check if Jetpack Boost is active.
[351] Fix | Delete
*/
[352] Fix | Delete
function wpsc_is_boost_active() {
[353] Fix | Delete
return class_exists( '\Automattic\Jetpack_Boost\Jetpack_Boost' );
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Admin ajax action: hide the Boost Banner.
[358] Fix | Delete
*/
[359] Fix | Delete
function wpsc_hide_boost_banner() {
[360] Fix | Delete
check_ajax_referer( 'wpsc_dismiss_boost_banner', 'nonce' );
[361] Fix | Delete
update_user_option( get_current_user_id(), 'wpsc_dismissed_boost_banner', '1' );
[362] Fix | Delete
[363] Fix | Delete
wp_die();
[364] Fix | Delete
}
[365] Fix | Delete
add_action( 'wp_ajax_wpsc-hide-boost-banner', 'wpsc_hide_boost_banner' );
[366] Fix | Delete
[367] Fix | Delete
/**
[368] Fix | Delete
* Admin ajax action: activate Jetpack Boost.
[369] Fix | Delete
*/
[370] Fix | Delete
function wpsc_ajax_activate_boost() {
[371] Fix | Delete
check_ajax_referer( 'activate-boost' );
[372] Fix | Delete
[373] Fix | Delete
if ( ! isset( $_POST['source'] ) ) {
[374] Fix | Delete
wp_send_json_error( 'no source specified' );
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
$source = sanitize_text_field( wp_unslash( $_POST['source'] ) );
[378] Fix | Delete
$result = activate_plugin( 'jetpack-boost/jetpack-boost.php' );
[379] Fix | Delete
if ( is_wp_error( $result ) ) {
[380] Fix | Delete
wp_send_json_error( $result->get_error_message() );
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
wpsc_notify_migration_to_boost( $source );
[384] Fix | Delete
[385] Fix | Delete
wp_send_json_success();
[386] Fix | Delete
}
[387] Fix | Delete
add_action( 'wp_ajax_wpsc_activate_boost', 'wpsc_ajax_activate_boost' );
[388] Fix | Delete
[389] Fix | Delete
/**
[390] Fix | Delete
* Show a Jetpack Boost installation banner (unless dismissed or installed)
[391] Fix | Delete
*/
[392] Fix | Delete
function wpsc_jetpack_boost_install_banner() {
[393] Fix | Delete
if ( ! wpsc_is_boost_current() ) {
[394] Fix | Delete
return;
[395] Fix | Delete
}
[396] Fix | Delete
// Don't show the banner if Boost is installed, or the banner has been dismissed.
[397] Fix | Delete
$is_dismissed = '1' === get_user_option( 'wpsc_dismissed_boost_banner' );
[398] Fix | Delete
if ( wpsc_is_boost_active() || $is_dismissed ) {
[399] Fix | Delete
return;
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
$config = wpsc_get_boost_migration_config();
[403] Fix | Delete
$button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url'];
[404] Fix | Delete
$button_label = $config['is_installed'] ? __( 'Set up Jetpack Boost', 'wp-super-cache' ) : __( 'Install Jetpack Boost', 'wp-super-cache' );
[405] Fix | Delete
$button_class = $config['is_installed'] ? 'wpsc-activate-boost-button' : 'wpsc-install-boost-button';
[406] Fix | Delete
$plugin_url = plugin_dir_url( __FILE__ );
[407] Fix | Delete
[408] Fix | Delete
?>
[409] Fix | Delete
<div class="wpsc-boost-banner">
[410] Fix | Delete
<div class="wpsc-boost-banner-inner">
[411] Fix | Delete
<div class="wpsc-boost-banner-content">
[412] Fix | Delete
<img style="width:282px" src="<?php echo esc_url( $plugin_url . '/assets/jetpack-logo.svg' ); ?>" height="36" />
[413] Fix | Delete
[414] Fix | Delete
<h3>
[415] Fix | Delete
<?php esc_html_e( 'Speed up your site with our top&#8209;rated performance tool', 'wp-super-cache' ); ?>
[416] Fix | Delete
</h3>
[417] Fix | Delete
[418] Fix | Delete
<p id="wpsc-install-invitation">
[419] Fix | Delete
<?php
[420] Fix | Delete
esc_html_e(
[421] Fix | Delete
'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.',
[422] Fix | Delete
'wp-super-cache'
[423] Fix | Delete
);
[424] Fix | Delete
?>
[425] Fix | Delete
</p>
[426] Fix | Delete
[427] Fix | Delete
<div class="wpsc-boost-migration-error" style="display:none; color:red; margin-bottom: 20px;"></div>
[428] Fix | Delete
[429] Fix | Delete
<div style="display: flex; gap: 24px;">
[430] Fix | Delete
<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 ); ?>">
[431] Fix | Delete
<div class='spinner' style='display:none; margin-top: 8px'></div>
[432] Fix | Delete
<label><?php echo esc_html( $button_label ); ?></label>
[433] Fix | Delete
</a>
[434] Fix | Delete
<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/">
[435] Fix | Delete
Learn More
[436] Fix | Delete
</a>
[437] Fix | Delete
</div>
[438] Fix | Delete
</div>
[439] Fix | Delete
[440] Fix | Delete
<div class="wpsc-boost-banner-image-container">
[441] Fix | Delete
<img
[442] Fix | Delete
width="350"
[443] Fix | Delete
height="452"
[444] Fix | Delete
src="<?php echo esc_url( $plugin_url . 'assets/boost-install-card-main.png' ); ?>"
[445] Fix | Delete
title="<?php esc_attr_e( 'Check how your web site performance scores for desktop and mobile.', 'wp-super-cache' ); ?>"
[446] Fix | Delete
alt="<?php esc_attr_e( 'An image showing the Jetpack Boost dashboard.', 'wp-super-cache' ); ?>"
[447] Fix | Delete
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"
[448] Fix | Delete
sizes="(max-width: 782px) 350px, 700px"
[449] Fix | Delete
>
[450] Fix | Delete
</div>
[451] Fix | Delete
</div>
[452] Fix | Delete
[453] Fix | Delete
<span class="wpsc-boost-dismiss dashicons dashicons-dismiss"></span>
[454] Fix | Delete
</div>
[455] Fix | Delete
<?php
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
function wp_cache_manager_error_checks() {
[459] Fix | Delete
global $wp_cache_debug, $wp_cache_cron_check, $cache_enabled, $super_cache_enabled, $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_mobile_enabled, $wp_cache_mod_rewrite;
[460] Fix | Delete
global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
[461] Fix | Delete
global $htaccess_path;
[462] Fix | Delete
[463] Fix | Delete
if ( ! wpsupercache_site_admin() ) {
[464] Fix | Delete
return false;
[465] Fix | Delete
}
[466] Fix | Delete
[467] Fix | Delete
if ( PHP_VERSION_ID < 50300 && ( ini_get( 'safe_mode' ) === '1' || strtolower( ini_get( 'safe_mode' ) ) === 'on' ) ) { // @codingStandardsIgnoreLine
[468] Fix | Delete
echo '<div class="notice notice-error"><h4>' . esc_html__( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h4>';
[469] Fix | Delete
echo '<p>' . esc_html__( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . '<br />';
[470] Fix | Delete
[471] Fix | Delete
if ( ! ini_get( 'safe_mode_gid' ) ) { // @codingStandardsIgnoreLine
[472] Fix | Delete
esc_html_e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' );
[473] Fix | Delete
echo '<br />';
[474] Fix | Delete
printf( __( 'You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) );
[475] Fix | Delete
} else {
[476] Fix | Delete
_e( 'You or an administrator must disable this. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.', 'wp-super-cache' );
[477] Fix | Delete
}
[478] Fix | Delete
echo '</p></div>';
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
if ( '' == get_option( 'permalink_structure' ) ) {
[482] Fix | Delete
echo '<div class="notice notice-error"><h4>' . __( 'Permlink Structure Error', 'wp-super-cache' ) . '</h4>';
[483] Fix | Delete
echo "<p>" . __( 'A custom url or permalink structure is required for this plugin to work correctly. Please go to the <a href="options-permalink.php">Permalinks Options Page</a> to configure your permalinks.', 'wp-super-cache' ) . "</p>";
[484] Fix | Delete
echo '</div>';
[485] Fix | Delete
return false;
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
if ( $wp_cache_debug || ! $wp_cache_cron_check ) {
[489] Fix | Delete
if ( defined( 'DISABLE_WP_CRON' ) && constant( 'DISABLE_WP_CRON' ) ) {
[490] Fix | Delete
?>
[491] Fix | Delete
<div class="notice notice-error"><h4><?php _e( 'CRON System Disabled', 'wp-super-cache' ); ?></h4>
[492] Fix | Delete
<p><?php _e( 'The WordPress CRON jobs system is disabled. This means the garbage collection system will not work unless you run the CRON system manually.', 'wp-super-cache' ); ?></p>
[493] Fix | Delete
</div>
[494] Fix | Delete
<?php
[495] Fix | Delete
} elseif ( function_exists( "wp_remote_get" ) == false ) {
[496] Fix | Delete
$hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) );
[497] Fix | Delete
if( strpos( $hostname, '/' ) )
[498] Fix | Delete
$hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function