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

Register a CLI command per importer #80

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions inc/classes/class-master.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Manages
* - Getting/setting of importer and validator instances
* - Initialisation of CLI command instances
* - Initialization of CLI command instances
*
* @package HMCI
*/
Expand Down Expand Up @@ -39,7 +39,7 @@ class Master {
/**
* Get the master class instance
*
* @return bool
* @return static
*/
public static function get_instance() {

Expand Down Expand Up @@ -70,7 +70,7 @@ public static function add_importer( $key, $class_name ) {
*
* Returns assoc array of importer ID -> class name
*
* @return array
* @return array<string, class-string>
*/
public static function get_importers() {
return self::$importers;
Expand Down Expand Up @@ -153,12 +153,13 @@ public static function get_validator_instance( $key, $args = [] ) {
}

/**
* Initialise WP CLI command
* Initialize WP CLI command
*/
protected function init_cli() {

if ( defined( 'WP_CLI' ) && 'WP_CLI' ) {
\WP_CLI::add_command( 'hmci', apply_filters( 'hmci_wp_cli_class_name', __NAMESPACE__ . '\\CLI\\HMCI' ) );
$class = apply_filters( 'hmci_wp_cli_class_name', __NAMESPACE__ . '\\CLI\\HMCI' );
$class = new $class();
$class->register_commands();
}
}

Expand Down
Loading