* Presets CLI for LiteSpeed Cache.
defined( 'WPINC' ) || exit();
* Constructor for Presets CLI.
public function __construct() {
Debug2::debug( 'CLI_Presets init' );
$this->preset = Preset::cls();
* Applies a standard preset's settings.
* : The preset name to apply (e.g., basic).
* # Apply the preset called "basic"
* $ wp litespeed-presets apply basic
* @param array $args Positional arguments (preset).
public function apply( $args ) {
if ( empty( $preset ) ) {
WP_CLI::error( 'Please specify a preset to apply.' );
return $this->preset->apply( $preset );
* Returns sorted backup names.
* $ wp litespeed-presets get_backups
public function get_backups() {
$backups = $this->preset->get_backups();
foreach ( $backups as $backup ) {
* Restores settings from the backup file with the given timestamp, then deletes the file.
* : The timestamp of the backup to restore.
* # Restore the backup with the timestamp 1667485245
* $ wp litespeed-presets restore 1667485245
* @param array $args Positional arguments (timestamp).
public function restore( $args ) {
if ( empty( $timestamp ) ) {
WP_CLI::error( 'Please specify a timestamp to restore.' );
return $this->preset->restore( $timestamp );