Skip to content

Commit b13d1d7

Browse files
authored
Merge pull request #4861 from jmichaelward/issue-4818-add-wordpress-action-to-initialize-plugin-commands
Trigger new 'cli_init' hook during WordPress plugins_loaded action.
2 parents b765a24 + 7a50370 commit b13d1d7

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎features/command.feature‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,3 +1666,21 @@ Feature: WP-CLI Commands
16661666
"""
16671667
core custom-subcommand
16681668
"""
1669+
1670+
Scenario: An activated plugin should successfully add custom commands when hooked on the cli_init action
1671+
Given a WP installation
1672+
And a wp-content/plugins/custom-command/custom-cmd.php file:
1673+
"""
1674+
<?php
1675+
// Plugin Name: Custom Command
1676+
1677+
add_action( 'cli_init', function() {
1678+
WP_CLI::add_command( 'custom', function () {} );
1679+
} );
1680+
"""
1681+
And I run `wp plugin activate custom-command`
1682+
When I run `wp custom --help`
1683+
Then STDOUT should contain:
1684+
"""
1685+
wp custom
1686+
"""

0 commit comments

Comments
 (0)