Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/litespee...
File: litespeed-cache.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Plugin Name: LiteSpeed Cache
[2] Fix | Delete
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
[3] Fix | Delete
* Description: High-performance page caching and site optimization from LiteSpeed
[4] Fix | Delete
* Version: 7.7
[5] Fix | Delete
* Author: LiteSpeed Technologies
[6] Fix | Delete
* Author URI: https://www.litespeedtech.com
[7] Fix | Delete
* License: GPLv3
[8] Fix | Delete
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
[9] Fix | Delete
* Text Domain: litespeed-cache
[10] Fix | Delete
* Domain Path: /lang
[11] Fix | Delete
*
[12] Fix | Delete
* @package LiteSpeed
[13] Fix | Delete
*
[14] Fix | Delete
* Copyright (C) 2015-2025 LiteSpeed Technologies, Inc.
[15] Fix | Delete
*
[16] Fix | Delete
* This program is free software: you can redistribute it and/or modify
[17] Fix | Delete
* it under the terms of the GNU General Public License as published by
[18] Fix | Delete
* the Free Software Foundation, either version 3 of the License, or
[19] Fix | Delete
* (at your option) any later version.
[20] Fix | Delete
*
[21] Fix | Delete
* This program is distributed in the hope that it will be useful,
[22] Fix | Delete
* but WITHOUT ANY WARRANTY; without even the implied warranty of
[23] Fix | Delete
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[24] Fix | Delete
* GNU General Public License for more details.
[25] Fix | Delete
*
[26] Fix | Delete
* You should have received a copy of the GNU General Public License
[27] Fix | Delete
* along with this program. If not, see <http://www.gnu.org/licenses/>.
[28] Fix | Delete
*/
[29] Fix | Delete
[30] Fix | Delete
defined( 'WPINC' ) || exit();
[31] Fix | Delete
[32] Fix | Delete
if ( defined( 'LSCWP_V' ) ) {
[33] Fix | Delete
return;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '7.7' );
[37] Fix | Delete
[38] Fix | Delete
! defined( 'LSCWP_CONTENT_DIR' ) && define( 'LSCWP_CONTENT_DIR', WP_CONTENT_DIR );
[39] Fix | Delete
! defined( 'LSCWP_DIR' ) && define( 'LSCWP_DIR', __DIR__ . '/' ); // Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
[40] Fix | Delete
! defined( 'LSCWP_BASENAME' ) && define( 'LSCWP_BASENAME', 'litespeed-cache/litespeed-cache.php' ); // LSCWP_BASENAME='litespeed-cache/litespeed-cache.php'
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* This needs to be before activation because admin-rules.class.php need const `LSCWP_CONTENT_FOLDER`
[44] Fix | Delete
* This also needs to be before cfg.cls init because default cdn_included_dir needs `LSCWP_CONTENT_FOLDER`
[45] Fix | Delete
*
[46] Fix | Delete
* @since 5.2 Auto correct protocol for CONTENT URL
[47] Fix | Delete
*/
[48] Fix | Delete
$wp_content_url = WP_CONTENT_URL;
[49] Fix | Delete
$site_url = site_url( '/' );
[50] Fix | Delete
if ( 'http:' === substr( $wp_content_url, 0, 5 ) && 'https' === substr( $site_url, 0, 5 ) ) {
[51] Fix | Delete
$wp_content_url = str_replace( 'http://', 'https://', $wp_content_url );
[52] Fix | Delete
}
[53] Fix | Delete
! defined( 'LSCWP_CONTENT_FOLDER' ) && define( 'LSCWP_CONTENT_FOLDER', str_replace( $site_url, '', $wp_content_url ) ); // `wp-content`
[54] Fix | Delete
unset( $site_url );
[55] Fix | Delete
! defined( 'LSWCP_PLUGIN_URL' ) && define( 'LSWCP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); // Full URL path '//example.com/wp-content/plugins/litespeed-cache/'
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Static cache files consts
[59] Fix | Delete
*
[60] Fix | Delete
* @since 3.0
[61] Fix | Delete
*/
[62] Fix | Delete
! defined( 'LITESPEED_DATA_FOLDER' ) && define( 'LITESPEED_DATA_FOLDER', 'litespeed' );
[63] 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'
[64] Fix | Delete
unset( $wp_content_url );
[65] 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'
[66] Fix | Delete
[67] Fix | Delete
! defined( 'LITESPEED_TIME_OFFSET' ) && define( 'LITESPEED_TIME_OFFSET', get_option( 'gmt_offset' ) * 60 * 60 );
[68] Fix | Delete
[69] Fix | Delete
// Placeholder for lazyload img
[70] Fix | Delete
! defined( 'LITESPEED_PLACEHOLDER' ) && define( 'LITESPEED_PLACEHOLDER', 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' );
[71] Fix | Delete
[72] Fix | Delete
// Auto register LiteSpeed classes
[73] Fix | Delete
require_once LSCWP_DIR . 'autoload.php';
[74] Fix | Delete
[75] Fix | Delete
// Define CLI
[76] Fix | Delete
if ( ( defined( 'WP_CLI' ) && constant('WP_CLI') ) || 'cli' === PHP_SAPI ) {
[77] Fix | Delete
! defined( 'LITESPEED_CLI' ) && define( 'LITESPEED_CLI', true );
[78] Fix | Delete
[79] Fix | Delete
// Register CLI cmd
[80] Fix | Delete
if ( method_exists( 'WP_CLI', 'add_command' ) ) {
[81] Fix | Delete
WP_CLI::add_command( 'litespeed-option', 'LiteSpeed\CLI\Option' );
[82] Fix | Delete
WP_CLI::add_command( 'litespeed-purge', 'LiteSpeed\CLI\Purge' );
[83] Fix | Delete
WP_CLI::add_command( 'litespeed-online', 'LiteSpeed\CLI\Online' );
[84] Fix | Delete
WP_CLI::add_command( 'litespeed-image', 'LiteSpeed\CLI\Image' );
[85] Fix | Delete
WP_CLI::add_command( 'litespeed-debug', 'LiteSpeed\CLI\Debug' );
[86] Fix | Delete
WP_CLI::add_command( 'litespeed-presets', 'LiteSpeed\CLI\Presets' );
[87] Fix | Delete
WP_CLI::add_command( 'litespeed-crawler', 'LiteSpeed\CLI\Crawler' );
[88] Fix | Delete
WP_CLI::add_command( 'litespeed-database', 'LiteSpeed\CLI\Database' );
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
// Server type
[93] Fix | Delete
if ( ! defined( 'LITESPEED_SERVER_TYPE' ) ) {
[94] Fix | Delete
$http_x_lscache = isset( $_SERVER['HTTP_X_LSCACHE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_LSCACHE'] ) ) : '';
[95] Fix | Delete
$lsws_edition = isset( $_SERVER['LSWS_EDITION'] ) ? sanitize_text_field( wp_unslash( $_SERVER['LSWS_EDITION'] ) ) : '';
[96] Fix | Delete
$server_software = isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '';
[97] Fix | Delete
[98] Fix | Delete
if ( $http_x_lscache ) {
[99] Fix | Delete
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ADC' );
[100] Fix | Delete
} elseif ( 0 === strpos( $lsws_edition, 'Openlitespeed' ) ) {
[101] Fix | Delete
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_OLS' );
[102] Fix | Delete
} elseif ( 'LiteSpeed' === $server_software ) {
[103] Fix | Delete
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ENT' );
[104] Fix | Delete
} else {
[105] Fix | Delete
define( 'LITESPEED_SERVER_TYPE', 'NONE' );
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
// Checks if caching is allowed via server variable
[110] Fix | Delete
if ( ! empty( $_SERVER['X-LSCACHE'] ) || 'LITESPEED_SERVER_ADC' === LITESPEED_SERVER_TYPE || defined( 'LITESPEED_CLI' ) ) {
[111] Fix | Delete
! defined( 'LITESPEED_ALLOWED' ) && define( 'LITESPEED_ALLOWED', true );
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
// ESI const definition
[115] Fix | Delete
if ( ! defined( 'LSWCP_ESI_SUPPORT' ) ) {
[116] Fix | Delete
define( 'LSWCP_ESI_SUPPORT', LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' );
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
if ( ! defined( 'LSWCP_TAG_PREFIX' ) ) {
[120] Fix | Delete
define( 'LSWCP_TAG_PREFIX', substr( md5( LSCWP_DIR ), -3 ) );
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
if ( ! function_exists( 'litespeed_exception_handler' ) ) {
[124] Fix | Delete
/**
[125] Fix | Delete
* Handle exception
[126] Fix | Delete
*
[127] Fix | Delete
* @param int $errno Error number.
[128] Fix | Delete
* @param string $errstr Error string.
[129] Fix | Delete
* @param string $errfile Error file.
[130] Fix | Delete
* @param int $errline Error line.
[131] Fix | Delete
* @throws \ErrorException When an error is encountered.
[132] Fix | Delete
*/
[133] Fix | Delete
function litespeed_exception_handler( $errno, $errstr, $errfile, $errline ) {
[134] Fix | Delete
throw new \ErrorException(
[135] Fix | Delete
esc_html( $errstr ),
[136] Fix | Delete
0,
[137] Fix | Delete
absint( $errno ),
[138] Fix | Delete
esc_html( $errfile ),
[139] Fix | Delete
absint( $errline )
[140] Fix | Delete
);
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
if ( ! function_exists( 'litespeed_define_nonce_func' ) ) {
[145] Fix | Delete
/**
[146] Fix | Delete
* Overwrite the WP nonce funcs outside of LiteSpeed namespace
[147] Fix | Delete
*
[148] Fix | Delete
* @since 3.0
[149] Fix | Delete
*/
[150] Fix | Delete
function litespeed_define_nonce_func() {
[151] Fix | Delete
/**
[152] Fix | Delete
* If the nonce is in none_actions filter, convert it to ESI
[153] Fix | Delete
*
[154] Fix | Delete
* @param mixed $action Action name or -1.
[155] Fix | Delete
* @return string
[156] Fix | Delete
*/
[157] Fix | Delete
function wp_create_nonce( $action = -1 ) {
[158] Fix | Delete
if ( ! defined( 'LITESPEED_DISABLE_ALL' ) || ! LITESPEED_DISABLE_ALL ) {
[159] Fix | Delete
$control = \LiteSpeed\ESI::cls()->is_nonce_action( $action );
[160] Fix | Delete
if ( null !== $control ) {
[161] Fix | Delete
$params = array(
[162] Fix | Delete
'action' => $action,
[163] Fix | Delete
);
[164] Fix | Delete
return \LiteSpeed\ESI::cls()->sub_esi_block( 'nonce', 'wp_create_nonce ' . $action, $params, $control, true, true, true );
[165] Fix | Delete
}
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
return wp_create_nonce_litespeed_esi( $action );
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Ori WP wp_create_nonce
[173] Fix | Delete
*
[174] Fix | Delete
* @param mixed $action Action name or -1.
[175] Fix | Delete
* @return string
[176] Fix | Delete
*/
[177] Fix | Delete
function wp_create_nonce_litespeed_esi( $action = -1 ) {
[178] Fix | Delete
$uid = get_current_user_id();
[179] Fix | Delete
if ( ! $uid ) {
[180] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[181] Fix | Delete
$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
$token = wp_get_session_token();
[185] Fix | Delete
$i = wp_nonce_tick();
[186] Fix | Delete
[187] Fix | Delete
return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
[188] Fix | Delete
}
[189] Fix | Delete
}
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
if ( ! function_exists( 'run_litespeed_cache' ) ) {
[193] Fix | Delete
/**
[194] Fix | Delete
* Begins execution of the plugin.
[195] Fix | Delete
*
[196] Fix | Delete
* @since 1.0.0
[197] Fix | Delete
*/
[198] Fix | Delete
function run_litespeed_cache() {
[199] Fix | Delete
// Check minimum PHP requirements, which is 7.2 at the moment.
[200] Fix | Delete
if ( version_compare( PHP_VERSION, '7.2.0', '<' ) ) {
[201] Fix | Delete
return;
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
// Check minimum WP requirements, which is 5.3 at the moment.
[205] Fix | Delete
if ( version_compare( $GLOBALS['wp_version'], '5.3', '<' ) ) {
[206] Fix | Delete
return;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
\LiteSpeed\Core::cls();
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
run_litespeed_cache();
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function