| 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 |
|