PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.3.3
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.3.3
1.3.3 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 All 29 releases
xspeed / includes / modules / Mcp / wp-cli-shim-class.php

wp-cli-shim-class.php in xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN 1.3.3, at includes/modules/Mcp/wp-cli-shim-class.php

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Global \WP_CLI shim class for the MCP CLI bridge.
4 *
5 * Loaded ONLY when the real WP_CLI is absent (i.e. a web/MCP request, not
6 * actual wp-cli). Provides the four static methods xSpeed's CLI callbacks
7 * use — log/line/success/warning forward to the active output buffer;
8 * error() throws a controlled signal Cli_Bridge catches. See Cli_Shim.
9 *
10 * This lives in the global namespace on purpose: callbacks reference
11 * `\WP_CLI`. It is required conditionally by Cli_Shim::ensure_class(),
12 * never on a real wp-cli run, so it can't collide with the genuine class.
13 *
14 * @package XSpeed
15 */
16
17 defined( 'ABSPATH' ) || exit;
18
19 if ( ! class_exists( 'WP_CLI', false ) ) {
20
21 /**
22 * Minimal drop-in for xSpeed's MCP CLI bridge. NOT a general WP-CLI
23 * replacement — only the methods our command callbacks call.
24 */
25 class WP_CLI {
26
27 public static function log( $message ) {
28 \XSpeed\Modules\Mcp\Cli_Shim::emit( '', (string) $message );
29 }
30
31 public static function line( $message = '' ) {
32 \XSpeed\Modules\Mcp\Cli_Shim::emit( '', (string) $message );
33 }
34
35 public static function success( $message ) {
36 \XSpeed\Modules\Mcp\Cli_Shim::emit( 'Success: ', (string) $message );
37 }
38
39 public static function warning( $message ) {
40 \XSpeed\Modules\Mcp\Cli_Shim::emit( 'Warning: ', (string) $message );
41 }
42
43 public static function error( $message ) {
44 throw new \XSpeed\Modules\Mcp\Cli_Error_Signal( (string) $message );
45 }
46 }
47 }
48