class-wppo-cli-command.php

WP-CLI integration for Performance Optimisation plugin.

Source includes/Admin/class-wppo-cli-command.php7 min readPart of Performance Optimisation

includes/Admin/class-wppo-cli-command.php

WP-CLI integration for Performance Optimisation plugin.

Namespace: PerformanceOptimise\\Inc · Lines: 2297

Class WPPO_CLI_Command

Manages Performance Optimisation features via WP-CLI.

Source: includes/Admin/class-wppo-cli-command.php, line 42

class WPPO_CLI_Command extends WP_CLI_Command

Tags: @since 1.9.0

public cache()

public function cache(array $args, array $assoc_args): void

Manage static HTML cache.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand cache

Source: includes/Admin/class-wppo-cli-command.php, line 82

public database()

public function database(array $args, array $assoc_args): void

Perform database cleanup and optimization routines.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand database

Source: includes/Admin/class-wppo-cli-command.php, line 206

public image()

public function image(array $args, array $assoc_args): void

Manage image conversion.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand image

Source: includes/Admin/class-wppo-cli-command.php, line 366

privatestatic get_default_settings()

private static function get_default_settings(): array

Get default settings structure for fresh installs.

Return: array<string, — array<string, mixed>> Default settings keyed by tab.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 449

privatestatic log_json()

private static function log_json($data): void

Log data as JSON, warning loudly when encoding fails.

ParameterTypeDefaultDescription
$datamixed—Data to encode and log.

Return: void.

Tags: @since 2.2.0

Source: includes/Admin/class-wppo-cli-command.php, line 464

public settings()

public function settings(array $args, array $assoc_args): void

View, update, export, or import plugin settings.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand settings

Source: includes/Admin/class-wppo-cli-command.php, line 530

public object_cache()

public function object_cache(array $args, array $assoc_args): void

Manage Redis Object Cache.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand object-cache

Source: includes/Admin/class-wppo-cli-command.php, line 834

privatestatic get_redis_config_from_assoc()

private static function get_redis_config_from_assoc(array $assoc_args): array

Build a Redis config array from CLI associative arguments.

ParameterTypeDefaultDescription
$assoc_argsarray—The associative arguments from the command.

Return: array<string, — mixed> Redis connection configuration.

Tags: @since 2.0.0 · @since NEXT Delegates construction to Redis_Config_Policy::build().

Source: includes/Admin/class-wppo-cli-command.php, line 919

public pagespeed()

public function pagespeed(array $args, array $assoc_args): void

Manage Google PageSpeed scans.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @since NEXT Reads PageSpeed results through Insight_Query. · @when after_wp_load · @subcommand pagespeed

Source: includes/Admin/class-wppo-cli-command.php, line 958

public system_info()

public function system_info(array $args, array $assoc_args): void

Show system information.

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand system-info

Source: includes/Admin/class-wppo-cli-command.php, line 1021

public verify()

public function verify(array $args, array $assoc_args): void

Verify live site state (self-verification gate for the autonomous maintenance loop).

ParameterTypeDefaultDescription
$argsarray—Command positional arguments.
$assoc_argsarray—Command associative arguments.

Return: void.

Tags: @when after_wp_load · @subcommand verify · @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1097

publicstatic get_verify_check_names()

public static function get_verify_check_names(): array

Canonical verify check names (single source for –check validation).

Return: string[].

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1230

publicstatic resolve_verify_domain()

public static function resolve_verify_domain(string $home_url): string

Resolve the static-cache domain for a home URL (Cache::__construct convention).

ParameterTypeDefaultDescription
$home_urlstring—Home URL.

Return: string — Sanitized domain, or \’\’ when unresolvable.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1246

publicstatic build_redis_config_from_settings()

public static function build_redis_config_from_settings(array $stored): array

Build a Redis config array from stored settings.

ParameterTypeDefaultDescription
$storedarray—Raw wppo_settings array.

Return: array<string, — mixed> Redis connection configuration.

Tags: @since 2.0.0 · @since NEXT Delegates construction to Redis_Config_Policy::build().

Source: includes/Admin/class-wppo-cli-command.php, line 1293

publicstatic validate_settings_schema()

public static function validate_settings_schema(array $stored, ?array=null $allowed, ?array=null $schema): array

Validate stored settings against the canonical schema (read-only).

ParameterTypeDefaultDescription
$storedarray—Raw wppo_settings array (live get_option).
$allowed?array=null—Optional allowlist override (testing).
$schema?array=null—Optional schema override (testing).

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1315

publicstatic find_orphan_cron_hooks()

public static function find_orphan_cron_hooks(array $found_hooks): array

Split found wppo_* cron hooks into orphans vs known-legacy (pure helper).

ParameterTypeDefaultDescription
$found_hooksarray—Hook names discovered in WP-Cron.

Return: array{orphans:string[],legacy:string[]} — Orphan and legacy lists.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1408

publicstatic evaluate_litespeed_state()

public static function evaluate_litespeed_state(string $raw_mode, string $effective, bool $server_ls, bool $lscache, bool $esi_enabled, bool $esi_available): array

Evaluate LiteSpeed coherence from live inputs (pure helper, no I/O).

ParameterTypeDefaultDescription
$raw_modestring—Raw configured mode string (unvalidated).
$effectivestring—Resolved effective mode.
$server_lsbool—Whether the server is LiteSpeed.
$lscachebool—Whether the LSCache plugin is active.
$esi_enabledbool—Whether the ESI bridge setting is on.
$esi_availablebool—Whether native ESI is available (Enterprise).

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1441

publicstatic find_unknown_wppo_options()

public static function find_unknown_wppo_options(array $found_names): array

Find wppo_* options without a known live owner (pure helper).

ParameterTypeDefaultDescription
$found_namesarray—Option names from the options table.

Return: string[] — Unknown option names.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1507

publicstatic build_verify_payload()

public static function build_verify_payload(array $rows, string=\'fail\' $severity): array

Build the machine-readable verify payload (pure helper).

ParameterTypeDefaultDescription
$rowsarray—Verify rows.
$severitystring=\'fail\'—Exit-code gate (\’fail\’ or \’warn\’).

Return: array{overall:string,checks:array} — Payload for –format=json.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1557

private check_verify_cache_dirs()

private function check_verify_cache_dirs(): array

Check 1 — cache directories live (writable + consistent).

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1589

publicstatic classify_unwritable_cache_root()

public static function classify_unwritable_cache_root($euid, $stat, string $root): array

Classify a cache root that is not writable by the current process.

ParameterTypeDefaultDescription
$euidint|null—Effective UID of the current process (null when posix is unavailable).
$statarray|false—stat() result for the directory (false when stat failed).
$rootstring—Absolute cache root path, used in the detail message.

Return: array{status:string,detail:string} — \’warn\’ when a foreign owner can write; \’fail\’ otherwise.

Tags: @since 2.2.0

Source: includes/Admin/class-wppo-cli-command.php, line 1714

private check_verify_dropins()

private function check_verify_dropins(array $stored): array

Check 2 — drop-ins present & intended (incl. foreign).

ParameterTypeDefaultDescription
$storedarray—Raw wppo_settings array.

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1762

private check_verify_redis()

private function check_verify_redis(array $stored): array

Check 3 — Redis reachable when enabled (live probe).

ParameterTypeDefaultDescription
$storedarray—Raw wppo_settings array.

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1904

private check_verify_litespeed()

private function check_verify_litespeed(array $stored): array

Check 4 — LiteSpeed mode coherent.

ParameterTypeDefaultDescription
$storedarray—Raw wppo_settings array.

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 1977

private check_verify_cron()

private function check_verify_cron(array $stored): array

Check 6 — orphaned cron / Action Scheduler events.

ParameterTypeDefaultDescription
$storedarray—Raw wppo_settings array.

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 2037

private check_verify_uninstall_spot()

private function check_verify_uninstall_spot(): array

Check 7 — uninstall-completeness spot check (read-only).

Return: array{check:string,status:string,detail:string} — Verify row.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 2185

private read_small_file()

private function read_small_file(string $path): ?string

Read a small file via WP_Filesystem with a native fallback (size-guarded).

ParameterTypeDefaultDescription
$pathstring—Absolute path.

Return: string|null — Contents, or null when missing/unreadable/too large.

Tags: @since 2.0.0

Source: includes/Admin/class-wppo-cli-command.php, line 2268