/home/websdxuk/dannymattinezllc.com/wp-content/plugins/litespeed-cache/cli/database.cls.php
<?php
/**
 * LiteSpeed CLI - database cleanup
 *
 * Add CLI database cleanup commands.
 *
 * @package LiteSpeed
 * @since 7.3
 */

namespace LiteSpeed\CLI;

defined('WPINC') || exit();

use LiteSpeed\Debug2;
use LiteSpeed\DB_Optm;
use WP_CLI;

/**
 * LiteSpeed Cache Database CLI
 */
class Database {
	/**
	 * Current blog id the optimization is working on.
	 *
	 * @var int|false $current_blog Current blog id.
	 */
	private $current_blog = false;
	/**
	 * Database class.
	 *
	 * @var DB_Optim $db Database class.
	 */
	private $db;

	/**
	 * Class constructor.
	 */
	public function __construct() {
		Debug2::debug('CLI_Database init');

		$this->db = DB_Optm::cls();
	}

	/**
	 * List all site domains and ids on the network.
	 */
	public function network_list() {
		if ( !is_multisite() ) {
			WP_CLI::error('This is not a multisite installation!');

			return;
		}
		$buf = WP_CLI::colorize("%CThe list of installs:%n\n");

		$sites = get_sites();
		foreach ( $sites as $site ) {
			$buf .= WP_CLI::colorize( '%Y' . $site->domain . $site->path . ':%n ID ' . $site->blog_id ) . "\n";
		}

		WP_CLI::line($buf);
	}

	/**
	 * Change to blog sent as param.
	 *
	 * @param array $args Description.
	 */
	private function change_to_blog( $args ) {
		if ( !isset( $args[0] ) || 'blog' !== $args[0] ) {
			return;
		}

		$this->current_blog = get_current_blog_id();
		$blogid             = $args[1];
		if ( !is_numeric( $blogid ) ) {
			$error = WP_CLI::colorize( '%RError: invalid blog id entered.%n' );
			WP_CLI::line( $error );
			$this->network_list( $args );
			return;
		}
		$site = get_blog_details( $blogid );
		if ( false === $site ) {
			$error = WP_CLI::colorize( '%RError: invalid blog id entered.%n' );
			WP_CLI::line( $error );
			$this->network_list( $args );
			return;
		}
		switch_to_blog( $blogid );
	}

	/**
	 * Change to previous blog.
	 */
	private function change_to_default() {
		// Check if previous blog set.
		if ( $this->current_blog ) {
			switch_to_blog( $this->current_blog );
			// Switched to previous blog.
			$this->current_blog = false;
		}
	}

	/**
	 * Show CLI response.
	 *
	 * @param boolean $result Flag if result is success or failure.
	 * @param string  $action Action name.
	 */
	private function show_response( $result, $action ) {
		if ($result) {
			WP_CLI::success( $result );
		} else {
			WP_CLI::error( 'Error running optimization: ' . $action );
		}
	}

	/**
	 * Clean actions function.
	 *
	 * @param int   $args Action arguments.
	 * @param array $types What data to clean.
	 */
	private function clean_action( $args, $types ) {
		$this->change_to_blog( $args );
		foreach ( $types as $type ) {
			$result = $this->db->handler_clean_db_cli( $type );
			$this->show_response( $result, $type );
		}
		$this->change_to_default();
	}

	/**
	 * Clear posts data(revisions, orphaned, auto drafts, trashed posts).
	 *     # Start clearing posts data.
	 *     $ wp litespeed-database clear_posts
	 *     $ wp litespeed-database clear_posts blog 2
	 *
	 * @param string $args Action arguments.
	 */
	public function clear_posts( $args ) {
		$types = array(
			'revision',
			'orphaned_post_meta',
			'auto_draft',
			'trash_post',
		);
		$this->clean_action( $args, $types );
	}

	/**
	 * Clear comments(spam and trash comments).
	 *     # Start clearing comments.
	 *     $ wp litespeed-database clear_comments
	 *     $ wp litespeed-database clear_comments blog 2
	 *
	 * @param string $args Action arguments.
	 */
	public function clear_comments( $args ) {
		$types = array(
			'spam_comment',
			'trash_comment',
		);
		$this->clean_action( $args, $types );
	}

	/**
	 * Clear trackbacks/pingbacks.
	 *     # Start clearing trackbacks/pingbacks.
	 *     $ wp litespeed-database clear_trackbacks
	 *     $ wp litespeed-database clear_trackbacks blog 2
	 *
	 * @param string $args Action arguments.
	 */
	public function clear_trackbacks( $args ) {
		$types = array(
			'trackback-pingback',
		);
		$this->clean_action( $args, $types );
	}

	/**
	 * Clear transients.
	 *     # Start clearing transients.
	 *     $ wp litespeed-database clear_transients
	 *     $ wp litespeed-database clear_transients blog 2
	 *
	 * @param string $args Action arguments.
	 */
	public function clear_transients( $args ) {
		$types = array(
			'expired_transient',
			'all_transients',
		);
		$this->clean_action( $args, $types );
	}

	/**
	 * Optimize tables.
	 *     # Start optimizing tables.
	 *     $ wp litespeed-database optimize_tables
	 *     $ wp litespeed-database optimize_tables blog 2
	 *
	 * @param string $args Action arguments.
	 */
	public function optimize_tables( $args ) {
		$types = array(
			'optimize_tables',
		);
		$this->clean_action( $args, $types );
	}

	/**
	 * Optimize database by running all possible operations.
	 *     # Start optimizing all.
	 *     $ wp litespeed-database optimize_all
	 *     $ wp litespeed-database optimize_all blog 2
	 *
	 * @param string $args Action arguments.
	 */
	public function optimize_all( $args ) {
		$types = array(
			'all',
		);
		$this->clean_action( $args, $types );
	}
}
My Blog – My WordPress Blog

Navigating Your Journey, Relocating Your World

Elevate Your Move, Experience Seamless Relocations.

A leading innovator in orchestrating top-notch Moving Solutions and Ensuring Seamless Relocations across the USA.

Booked Your Movement

Goods Packing Service

Goods Unpacking Service

Moving Goods Service

Goods Unloading Service

Service

Choose Your Movement Service

Start From 10 USD/Hour

Complete Goods Packing Service for House

All aspects of your software assets including purchasing, deployment & maintenance.

Start From 15 USD/Hour

Complete Goods Unpacking Service for House

All aspects of your software assets including purchasing, deployment & maintenance.

Start From 100 USD/Month

Complete Storage Solution For Your Goods

All aspects of your software assets including purchasing, deployment & maintenance.

Start From 100 USD/Month

Complete Unloading Solution For Your Goods

All aspects of your software assets including purchasing, deployment & maintenance.

Get 10% Discount For Every First of Order. 

View All Our Service Here

WHY CHOOSE US

Explore Why Our Company is Preferable

At [Your Company Name], we pride ourselves on delivering exceptional value, unparalleled service, and innovative solutions tailored to meet your needs.

No Hidden Price

Free Unloading

Clean No Trash

Warehouse

Fast Truck

About Us

Swift Your Transitions With Unmatched Service

At [Your Company Name], we are more than just a business—we are a team of passionate professionals dedicated to delivering excellence. With [X] years of experience in [your industry], we’ve built a reputation for [key strengths, e.g., innovation, reliability, customer-centric solutions].

Thinking insights, verified driven research, and metrics data help you make the right decisions!

Achievments

Moving You Forward By Moving with Care

At [Your Company Name], we take pride in our milestones and the impact we’ve made. Our journey is marked by dedication, innovation, and a relentless pursuit of excellence. Here’s a glimpse of what we’ve accomplished:

Every achievement reflects our commitment to excellence and the trust our clients and partners place in us. We’re not just celebrating the past—we’re building an even brighter future.

0 +

Clients

0 +

Miles

0 +

Movers

Study Case

Learn Our Successfull Study Cases

Urban, Relocations

From City to Suburbs: A Smooth Urban Relocation

Corporate, Precision

Corporate Precision: Streamlining Office Moves

Senior, Transitions

Senior Transitions: Compassionate Moves for Aging Loved Onesz

Cross, Country

Cross-Country Adventure: A Transcontinental Move

Booked Form

Don't Let Your Back Hurt, Let Us Move Your Things!

Our easy-to-use booking form ensures a seamless experience, allowing you to choose your preferred date, time, and options without any hassle.

Why book with us?
✓ Instant Confirmation – Receive immediate booking details via email/SMS.
✓ Flexible Scheduling – Pick a slot that fits your schedule.
✓ 100% Secure – Your information is safe with us.

Booked Your Movement

Booked Your Movement