• I am extending WP-CLI Fatal error: Uncaught Error: Class ‘WP_CLI’ not found in WP_CLI.

    This is a MAMP installation running localhost.

    The code is only this much and I still get the error:

    	WP_CLI::add_command('twelve','Twelve_Command');
    
    	class Twelve_Command extends WP_CLI_Command{
    
    	}	

    Can someone please help fix this?

    Thank you,
    Bruce

    • This topic was modified 8 years, 2 months ago by hotwebideas.
Viewing 1 replies (of 1 total)
  • In this similar StackExchange question wp-cli maintainer Daniel Bachhuber suggests wrapping your statement within a class_exists() check. So that the command is only registered when WP-CLI class is available when WP-CLI is running.

    if ( class_exists( 'WP_CLI' ) ) {
        WP_CLI::add_command( 'twelve', 'Twelve_Command' );
    }
Viewing 1 replies (of 1 total)

The topic ‘In WP_CLI, Fatal error: Uncaught Error: Class ‘WP_CLI’ not found inside plugin’ is closed to new replies.