* Auto registration for LiteSpeed classes
defined('WPINC') || exit();
// Force define for object cache usage before plugin init
!defined('LSCWP_DIR') && define('LSCWP_DIR', __DIR__ . '/'); // Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
// Load all classes instead of autoload for direct conf update purpose when upgrade to new version.
// NOTE: These files need to load exactly in order
$litespeed_php_files = array(
'src/activation.cls.php',
'src/admin-display.cls.php',
'src/admin-settings.cls.php',
'src/crawler-map.cls.php',
'src/import.preset.cls.php',
'src/localization.cls.php',
'src/object-cache.cls.php',
'src/placeholder.cls.php',
'src/cdn/cloudflare.cls.php',
'lib/css_js_min/pathconverter/converter.cls.php',
'lib/css_js_min/minify/exception.cls.php',
'lib/css_js_min/minify/minify.cls.php',
'lib/css_js_min/minify/css.cls.php',
'lib/css_js_min/minify/js.cls.php',
'lib/urirewriter.cls.php',
// 'lib/object-cache.php',
// 'lib/php-compatibility.func.php',
// upgrade purpose delay loaded funcs
// 'src/data.upgrade.func.php',
foreach ($litespeed_php_files as $class) {
$file = LSCWP_DIR . $class;
if (!function_exists('litespeed_autoload')) {
* Autoload function for LiteSpeed classes
* @param string $cls The class name to autoload.
function litespeed_autoload( $cls ) {
if (strpos($cls, '.') !== false) {
if (strpos($cls, 'LiteSpeed') !== 0) {
$file = explode('\\', $cls);
$file = implode('/', $file);
$file = str_replace('_', '-', strtolower($file));
// if (strpos($file, 'lib/') === 0 || strpos($file, 'cli/') === 0 || strpos($file, 'thirdparty/') === 0) {
// $file = LSCWP_DIR . $file . '.cls.php';
// $file = LSCWP_DIR . 'src/' . $file . '.cls.php';
if (strpos($file, 'thirdparty/') !== 0) {
$file = LSCWP_DIR . $file . '.cls.php';
if (file_exists($file)) {
spl_autoload_register('litespeed_autoload');