PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.3.0
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.3.0
1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2.0 All 28 releases
xspeed / includes / class-cli-manager.php

class-cli-manager.php in xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN 1.3.0, at includes/class-cli-manager.php

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CLI_Manager — registers a module's WP-CLI commands under the
4 * `wp xspeed <module> ...` namespace.
5 *
6 * Loaded only when WP_CLI is defined and truthy (Module_Registry guards
7 * the call). Modules declare commands via Module::cli_commands().
8 *
9 * The full xSpeed CLI surface is enumerated in FEATURES.md → "xSpeed CLI"
10 * section (24 planned commands across all modules). Each handler shares
11 * its core function with the matching REST callback — no duplicated
12 * validation paths.
13 *
14 * @package XSpeed
15 */
16
17 namespace XSpeed;
18
19 defined( 'ABSPATH' ) || exit;
20
21 final class Cli_Manager {
22
23 public static function register_module( Module $module ): void {
24 if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
25 return;
26 }
27 foreach ( $module->cli_commands() as $cmd ) {
28 $name = $cmd['name'] ?? '';
29 $callback = $cmd['callback'] ?? null;
30 if ( '' === $name || ! is_callable( $callback ) ) {
31 continue;
32 }
33 $args = array();
34 if ( isset( $cmd['synopsis'] ) ) {
35 $args['synopsis'] = $cmd['synopsis'];
36 }
37 if ( isset( $cmd['shortdesc'] ) ) {
38 $args['shortdesc'] = $cmd['shortdesc'];
39 }
40 \WP_CLI::add_command( $name, $callback, $args );
41 }
42 }
43 }
44