45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace PluginNamespace;
 | |
| 
 | |
| use WP_CLI;
 | |
| 
 | |
| if ( ! defined( 'ABSPATH' ) ) {
 | |
|     exit; // Exit if accessed directly
 | |
| }
 | |
| 
 | |
| class NmspCli {
 | |
| 
 | |
|     /**
 | |
|      * Class constructor. Can add commands here.
 | |
|      *
 | |
|      * @since 1.0.0
 | |
|      *
 | |
|      * @return void
 | |
|      */
 | |
|     public function __construct() {
 | |
|         WP_CLI::add_command(
 | |
|             'nmsp-plugin do',
 | |
|             array( $this, 'do_the_thing' ),
 | |
|             array(
 | |
|                 'shortdesc' => __( 'The short description.', 'nmsp-plugin-name-text-domain' ),
 | |
|                 'longdesc'  => __( "This is the super long description that will go on and on my friend. Some people started writing it not knowing what it was, and we'll continue writing it forever just because this is the description that never ends...", 'nmsp-plugin-name-text-domain' ),
 | |
|             ),
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * A sample method where something is done.
 | |
|      *
 | |
|      * @since 1.0.0
 | |
|      *
 | |
|      * @return void
 | |
|      */
 | |
|     public function do_the_thing(): void {
 | |
|         WP_CLI::success( __( 'Congradulations, it is working.', 'nmsp-plugin-name-text-domain' ) );
 | |
|     }
 | |
| 
 | |
| }
 | |
| 
 | |
| new NmspCli();
 |