@@ -60,12 +60,12 @@ Feature: Bootstrap WP-CLI
6060 return;
6161 }
6262 // Override bundled command.
63- WP_CLI::add_command( 'eval', 'Eval_Command ', array( 'when' => 'before_wp_load' ) );
63+ WP_CLI::add_command( 'eval', 'Custom_Eval_Command ', array( 'when' => 'before_wp_load' ) );
6464 """
65- And a override/src/Eval_Command .php file:
65+ And a override/src/Custom_Eval_Command .php file:
6666 """
6767 <?php
68- class Eval_Command extends WP_CLI_Command {
68+ class Custom_Eval_Command extends WP_CLI_Command {
6969 public function __invoke() {
7070 WP_CLI::success( "WP-Override-Eval" );
7171 }
@@ -105,27 +105,36 @@ Feature: Bootstrap WP-CLI
105105 return;
106106 }
107107 $autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
108- if ( file_exists( $autoload ) && ! class_exists( 'CLI_Command ' ) ) {
108+ if ( file_exists( $autoload ) && ! class_exists( 'Custom_CLI_Command ' ) ) {
109109 require_once $autoload;
110110 }
111111 // Override framework command.
112- WP_CLI::add_command( 'cli', 'CLI_Command ', array( 'when' => 'before_wp_load' ) );
112+ WP_CLI::add_command( 'cli', 'Custom_CLI_Command ', array( 'when' => 'before_wp_load' ) );
113113 // Override bundled command.
114- WP_CLI::add_command( 'eval', 'Eval_Command', array( 'when' => 'before_wp_load' ) );
114+ WP_CLI::add_hook(
115+ 'after_add_command:eval',
116+ static function () {
117+ static $added = false;
118+ if ( ! $added ) {
119+ $added = true;
120+ WP_CLI::add_command( 'eval', 'Custom_Eval_Command', array( 'when' => 'before_wp_load' ) );
121+ }
122+ }
123+ );
115124 """
116- And a override/src/CLI_Command .php file:
125+ And a override/src/Custom_CLI_Command .php file:
117126 """
118127 <?php
119- class CLI_Command extends WP_CLI_Command {
128+ class Custom_CLI_Command extends WP_CLI_Command {
120129 public function version() {
121130 WP_CLI::success( "WP-Override-CLI" );
122131 }
123132 }
124133 """
125- And a override/src/Eval_Command .php file:
134+ And a override/src/Custom_Eval_Command .php file:
126135 """
127136 <?php
128- class Eval_Command extends WP_CLI_Command {
137+ class Custom_Eval_Command extends WP_CLI_Command {
129138 public function __invoke() {
130139 WP_CLI::success( "WP-Override-Eval" );
131140 }
@@ -184,27 +193,36 @@ Feature: Bootstrap WP-CLI
184193 return;
185194 }
186195 $autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
187- if ( file_exists( $autoload ) && ! class_exists( 'CLI_Command ' ) ) {
196+ if ( file_exists( $autoload ) && ! class_exists( 'Custom_CLI_Command ' ) ) {
188197 require_once $autoload;
189198 }
190199 // Override framework command.
191- WP_CLI::add_command( 'cli', 'CLI_Command ', array( 'when' => 'before_wp_load' ) );
200+ WP_CLI::add_command( 'cli', 'Custom_CLI_Command ', array( 'when' => 'before_wp_load' ) );
192201 // Override bundled command.
193- WP_CLI::add_command( 'eval', 'Eval_Command', array( 'when' => 'before_wp_load' ) );
202+ WP_CLI::add_hook(
203+ 'after_add_command:eval',
204+ static function () {
205+ static $added = false;
206+ if ( ! $added ) {
207+ $added = true;
208+ WP_CLI::add_command( 'eval', 'Custom_Eval_Command', array( 'when' => 'before_wp_load' ) );
209+ }
210+ }
211+ );
194212 """
195- And a override/src/CLI_Command .php file:
213+ And a override/src/Custom_CLI_Command .php file:
196214 """
197215 <?php
198- class CLI_Command extends WP_CLI_Command {
216+ class Custom_CLI_Command extends WP_CLI_Command {
199217 public function version() {
200218 WP_CLI::success( "WP-Override-CLI" );
201219 }
202220 }
203221 """
204- And a override/src/Eval_Command .php file:
222+ And a override/src/Custom_Eval_Command .php file:
205223 """
206224 <?php
207- class Eval_Command extends WP_CLI_Command {
225+ class Custom_Eval_Command extends WP_CLI_Command {
208226 public function __invoke() {
209227 WP_CLI::success( "WP-Override-Eval" );
210228 }
0 commit comments