Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/litespee...
File: litespeed-cache.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Plugin Name: LiteSpeed Cache
[3] Fix | Delete
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
[4] Fix | Delete
* Description: High-performance page caching and site optimization from LiteSpeed
[5] Fix | Delete
* Version: 6.4.1
[6] Fix | Delete
* Author: LiteSpeed Technologies
[7] Fix | Delete
* Author URI: https://www.litespeedtech.com
[8] Fix | Delete
* License: GPLv3
[9] Fix | Delete
* License URI: http://www.gnu.org/licenses/gpl.html
[10] Fix | Delete
* Text Domain: litespeed-cache
[11] Fix | Delete
* Domain Path: /lang
[12] Fix | Delete
*
[13] Fix | Delete
* Copyright (C) 2015-2024 LiteSpeed Technologies, Inc.
[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 3 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, see <http://www.gnu.org/licenses/>.
[27] Fix | Delete
[28] Fix | Delete
*/
[29] Fix | Delete
defined('WPINC') || exit();
[30] Fix | Delete
[31] Fix | Delete
if (defined('LSCWP_V')) {
[32] Fix | Delete
return;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
!defined('LSCWP_V') && define('LSCWP_V', '6.4.1');
[36] Fix | Delete
[37] Fix | Delete
!defined('LSCWP_CONTENT_DIR') && define('LSCWP_CONTENT_DIR', WP_CONTENT_DIR);
[38] Fix | Delete
!defined('LSCWP_DIR') && define('LSCWP_DIR', __DIR__ . '/'); // Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
[39] Fix | Delete
!defined('LSCWP_BASENAME') && define('LSCWP_BASENAME', 'litespeed-cache/litespeed-cache.php'); //LSCWP_BASENAME='litespeed-cache/litespeed-cache.php'
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* This needs to be before activation because admin-rules.class.php need const `LSCWP_CONTENT_FOLDER`
[43] Fix | Delete
* This also needs to be before cfg.cls init because default cdn_included_dir needs `LSCWP_CONTENT_FOLDER`
[44] Fix | Delete
* @since 5.2 Auto correct protocol for CONTENT URL
[45] Fix | Delete
*/
[46] Fix | Delete
$WP_CONTENT_URL = WP_CONTENT_URL;
[47] Fix | Delete
$home_url = home_url('/');
[48] Fix | Delete
if (substr($WP_CONTENT_URL, 0, 5) == 'http:' && substr($home_url, 0, 5) == 'https') {
[49] Fix | Delete
$WP_CONTENT_URL = str_replace('http://', 'https://', $WP_CONTENT_URL);
[50] Fix | Delete
}
[51] Fix | Delete
!defined('LSCWP_CONTENT_FOLDER') && define('LSCWP_CONTENT_FOLDER', str_replace($home_url, '', $WP_CONTENT_URL)); // `wp-content`
[52] Fix | Delete
!defined('LSWCP_PLUGIN_URL') && define('LSWCP_PLUGIN_URL', plugin_dir_url(__FILE__)); // Full URL path '//example.com/wp-content/plugins/litespeed-cache/'
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Static cache files consts
[56] Fix | Delete
* @since 3.0
[57] Fix | Delete
*/
[58] Fix | Delete
!defined('LITESPEED_DATA_FOLDER') && define('LITESPEED_DATA_FOLDER', 'litespeed');
[59] Fix | Delete
!defined('LITESPEED_STATIC_URL') && define('LITESPEED_STATIC_URL', $WP_CONTENT_URL . '/' . LITESPEED_DATA_FOLDER); // Full static cache folder URL '//example.com/wp-content/litespeed'
[60] Fix | Delete
!defined('LITESPEED_STATIC_DIR') && define('LITESPEED_STATIC_DIR', LSCWP_CONTENT_DIR . '/' . LITESPEED_DATA_FOLDER); // Full static cache folder path '/var/www/html/***/wp-content/litespeed'
[61] Fix | Delete
[62] Fix | Delete
!defined('LITESPEED_TIME_OFFSET') && define('LITESPEED_TIME_OFFSET', get_option('gmt_offset') * 60 * 60);
[63] Fix | Delete
[64] Fix | Delete
// Placeholder for lazyload img
[65] Fix | Delete
!defined('LITESPEED_PLACEHOLDER') && define('LITESPEED_PLACEHOLDER', 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=');
[66] Fix | Delete
[67] Fix | Delete
// Auto register LiteSpeed classes
[68] Fix | Delete
require_once LSCWP_DIR . 'autoload.php';
[69] Fix | Delete
[70] Fix | Delete
// Define CLI
[71] Fix | Delete
if ((defined('WP_CLI') && WP_CLI) || PHP_SAPI == 'cli') {
[72] Fix | Delete
!defined('LITESPEED_CLI') && define('LITESPEED_CLI', true);
[73] Fix | Delete
[74] Fix | Delete
// Register CLI cmd
[75] Fix | Delete
if (method_exists('WP_CLI', 'add_command')) {
[76] Fix | Delete
WP_CLI::add_command('litespeed-option', 'LiteSpeed\CLI\Option');
[77] Fix | Delete
WP_CLI::add_command('litespeed-purge', 'LiteSpeed\CLI\Purge');
[78] Fix | Delete
WP_CLI::add_command('litespeed-online', 'LiteSpeed\CLI\Online');
[79] Fix | Delete
WP_CLI::add_command('litespeed-image', 'LiteSpeed\CLI\Image');
[80] Fix | Delete
WP_CLI::add_command('litespeed-debug', 'LiteSpeed\CLI\Debug');
[81] Fix | Delete
WP_CLI::add_command('litespeed-presets', 'LiteSpeed\CLI\Presets');
[82] Fix | Delete
WP_CLI::add_command('litespeed-crawler', 'LiteSpeed\CLI\Crawler');
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
// Server type
[87] Fix | Delete
if (!defined('LITESPEED_SERVER_TYPE')) {
[88] Fix | Delete
if (isset($_SERVER['HTTP_X_LSCACHE']) && $_SERVER['HTTP_X_LSCACHE']) {
[89] Fix | Delete
define('LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ADC');
[90] Fix | Delete
} elseif (isset($_SERVER['LSWS_EDITION']) && strpos($_SERVER['LSWS_EDITION'], 'Openlitespeed') === 0) {
[91] Fix | Delete
define('LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_OLS');
[92] Fix | Delete
} elseif (isset($_SERVER['SERVER_SOFTWARE']) && $_SERVER['SERVER_SOFTWARE'] == 'LiteSpeed') {
[93] Fix | Delete
define('LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ENT');
[94] Fix | Delete
} else {
[95] Fix | Delete
define('LITESPEED_SERVER_TYPE', 'NONE');
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
// Checks if caching is allowed via server variable
[100] Fix | Delete
if (!empty($_SERVER['X-LSCACHE']) || LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_ADC' || defined('LITESPEED_CLI')) {
[101] Fix | Delete
!defined('LITESPEED_ALLOWED') && define('LITESPEED_ALLOWED', true);
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
// ESI const definition
[105] Fix | Delete
if (!defined('LSWCP_ESI_SUPPORT')) {
[106] Fix | Delete
define('LSWCP_ESI_SUPPORT', LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ? true : false);
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
if (!defined('LSWCP_TAG_PREFIX')) {
[110] Fix | Delete
define('LSWCP_TAG_PREFIX', substr(md5(LSCWP_DIR), -3));
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* Handle exception
[115] Fix | Delete
*/
[116] Fix | Delete
if (!function_exists('litespeed_exception_handler')) {
[117] Fix | Delete
function litespeed_exception_handler($errno, $errstr, $errfile, $errline)
[118] Fix | Delete
{
[119] Fix | Delete
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Overwrite the WP nonce funcs outside of LiteSpeed namespace
[125] Fix | Delete
* @since 3.0
[126] Fix | Delete
*/
[127] Fix | Delete
if (!function_exists('litespeed_define_nonce_func')) {
[128] Fix | Delete
function litespeed_define_nonce_func()
[129] Fix | Delete
{
[130] Fix | Delete
/**
[131] Fix | Delete
* If the nonce is in none_actions filter, convert it to ESI
[132] Fix | Delete
*/
[133] Fix | Delete
function wp_create_nonce($action = -1)
[134] Fix | Delete
{
[135] Fix | Delete
if (!defined('LITESPEED_DISABLE_ALL')) {
[136] Fix | Delete
$control = \LiteSpeed\ESI::cls()->is_nonce_action($action);
[137] Fix | Delete
if ($control !== null) {
[138] Fix | Delete
$params = array(
[139] Fix | Delete
'action' => $action,
[140] Fix | Delete
);
[141] Fix | Delete
return \LiteSpeed\ESI::cls()->sub_esi_block('nonce', 'wp_create_nonce ' . $action, $params, $control, true, true, true);
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
return wp_create_nonce_litespeed_esi($action);
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Ori WP wp_create_nonce
[150] Fix | Delete
*/
[151] Fix | Delete
function wp_create_nonce_litespeed_esi($action = -1)
[152] Fix | Delete
{
[153] Fix | Delete
$uid = get_current_user_id();
[154] Fix | Delete
if (!$uid) {
[155] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[156] Fix | Delete
$uid = apply_filters('nonce_user_logged_out', $uid, $action);
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
$token = wp_get_session_token();
[160] Fix | Delete
$i = wp_nonce_tick();
[161] Fix | Delete
[162] Fix | Delete
return substr(wp_hash($i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
/**
[168] Fix | Delete
* Begins execution of the plugin.
[169] Fix | Delete
*
[170] Fix | Delete
* @since 1.0.0
[171] Fix | Delete
*/
[172] Fix | Delete
if (!function_exists('run_litespeed_cache')) {
[173] Fix | Delete
function run_litespeed_cache()
[174] Fix | Delete
{
[175] Fix | Delete
//Check minimum PHP requirements, which is 5.3 at the moment.
[176] Fix | Delete
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
[177] Fix | Delete
return;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
//Check minimum WP requirements, which is 4.9 at the moment.
[181] Fix | Delete
if (version_compare($GLOBALS['wp_version'], '4.9', '<')) {
[182] Fix | Delete
return;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
\LiteSpeed\Core::cls();
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
run_litespeed_cache();
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function