Skip to content

Commit 3466dbd

Browse files
committed
Register WP-CLI command on cli_init
Replace direct CLI setup call in the constructor with an action hook: the constructor now hooks a new cli_init() method to the 'cli_init' action instead of calling cli() directly. The private method was renamed from cli() to cli_init() and the explicit WP_CLI runtime check was removed (registration now occurs on cli_init, which only runs under WP-CLI). The WP_CLI::add_command() registration remains unchanged.
1 parent b03006f commit 3466dbd

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/Subscriptions/SubscriptionsFollowUpPaymentsController.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function setup() {
3333

3434
\add_action( 'pronamic_pay_create_subscription_follow_up_payment', $this->action_create_subscription_follow_up_payment( ... ) );
3535

36-
$this->cli();
36+
\add_action( 'cli_init', $this->cli_init( ... ) );
3737
}
3838

3939
/**
@@ -44,11 +44,7 @@ public function setup() {
4444
* @link https://make.wordpress.org/cli/handbook/commands-cookbook/
4545
* @return void
4646
*/
47-
private function cli() {
48-
if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
49-
return;
50-
}
51-
47+
private function cli_init() {
5248
WP_CLI::add_command(
5349
'pay subscription list',
5450
function (): void {

0 commit comments

Comments
 (0)