在php/wp-cli.php 我们发现以下几行:
// Can be used by plugins/themes to check if WP-CLI is running or not
define( \'WP_CLI\', true );
define( \'WP_CLI_VERSION\', trim( file_get_contents( WP_CLI_ROOT . \'/VERSION\' ) ) );
define( \'WP_CLI_START_MICROTIME\', microtime( true ) );
所以你可以检查一下
WP_CLI 或
WP_CLI_VERSION 已定义。