Skip to content

Add WordPress action to initialize plugin commands on #4818

@schlessera

Description

@schlessera

Right now, when a plugin wants to add WP-CLI actions, they need to do something like the following:

if ( defined( 'WP_CLI' ) && WP_CLI ) {
	add_action( 'plugins_loaded', 'my_plugin_cli_init' );
}

We should have WP-CLI add an action 'cli_init' that matches 'init' and 'admin_init' and allows for easier hooking of commands:

add_action( 'cli_init', 'my_plugin_cli_init' );

If WP-CLI is not loaded, the action will not be triggered. No other checks are needed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions