Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger new 'cli_init' hook during WordPress plugins_loaded action. #4861

Update test scenario - remove additional class import per feedback fr…

…om Alain.
  • Loading branch information...
jmichaelward committed Jul 20, 2018
commit 630089bf5f643bbf98c88e46edf73526222f5d10
Copy path View file
@@ -1675,23 +1675,13 @@ Feature: WP-CLI Commands
// Plugin Name: Custom Command
add_action( 'cli_init', function() {
require_once plugin_dir_path( __FILE__ ) . '/class-custom-command.php';
$command = new Custom_Command();
WP_CLI::add_command( 'custom', array( $command, 'do_custom_command' ) );
WP_CLI::add_command( 'custom', 'do_custom_command' );
} );
"""
And a wp-content/plugins/custom-command/class-custom-command.php file:
"""
<?php
class Custom_Command extends WP_CLI_Command {
/**
* Tell the whole world!
*/
public function do_custom_command() {
WP_CLI::success( "This command doesn't really do much, does it?" );
function do_custom_command() {
WP_CLI::success( 'Triggered the callback for the custom command.' );
}
}
"""
"""
And I run `wp plugin activate custom-command`
When I run `wp custom --help`
Then STDOUT should contain:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.