Created
January 31, 2022 17:41
-
-
Save pbiron/3d4f5fea0a1c8667e5e01a764008d88e to your computer and use it in GitHub Desktop.
This simple plugin demonstrates a problem I'm having creating a sub-command * of `wp db`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: DB Sub-Comannd Test | |
* Description: Demonstrate problem creating a sub-command of `wp db`. | |
* Version: 0.1.0 | |
* Author: Paul V. Biron/Sparrow Hawk Computing | |
* Author URI: http://sparrowhawkcomputing.com/ | |
* | |
* This simple plugin demonstrates a problem I'm having creating a sub-command | |
* of `wp db`. See https://wordpress.slack.com/archives/C02RP4T41/p1643579809090159. | |
*/ | |
namespace SHC\DB_SUBCOMMAND_TEST; | |
use WP_CLI; | |
use WP_CLI_Command; | |
defined( 'ABSPATH' ) || die; | |
add_action( | |
'cli_init', | |
function() { | |
WP_CLI::add_command( 'db connection', __NAMESPACE__ . '\\Connection_Command' ); | |
} | |
); | |
if ( class_exists( 'WP_CLI_Command' ) ) { | |
/** | |
* Display info about the DB connection. | |
*/ | |
class Connection_Command extends WP_CLI_Command { | |
/** | |
* Display the DB connection status. | |
*/ | |
public function status() { | |
WP_CLI::line( 'this is a test' ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment