array( 'GF_CLI_Bootstrap', 'before_invoke' ) ); // Adds WP-CLI commands, and maps them to the appropriate class. WP_CLI::add_command( 'gf', 'GF_CLI_Root' ); WP_CLI::add_command( 'gf form', 'GF_CLI_Form', $command_args ); WP_CLI::add_command( 'gf form notification', 'GF_CLI_Form_Notification', $command_args ); WP_CLI::add_command( 'gf notification', 'GF_CLI_Form_Notification', $command_args ); WP_CLI::add_command( 'gf form field', 'GF_CLI_Form_Field', $command_args ); WP_CLI::add_command( 'gf field', 'GF_CLI_Form_Field', $command_args ); WP_CLI::add_command( 'gf entry', 'GF_CLI_Entry', $command_args ); WP_CLI::add_command( 'gf license', 'GF_CLI_License', $command_args ); WP_CLI::add_command( 'gf entry notification', 'GF_CLI_Entry_Notification', $command_args ); WP_CLI::add_command( 'gf tool', 'GF_CLI_Tool', $command_args ); } } public static function before_invoke() { if ( ! class_exists( 'GFForms' ) ) { WP_CLI::error( 'Gravity Forms is not installed. Use the "wp gf install" command to install Gravity Forms.' ); } if ( version_compare( GFForms::$version, GF_CLI_MIN_GF_VERSION, '<' ) ) { WP_CLI::error( 'The minimum required version of Gravity Forms is ' . GF_CLI_MIN_GF_VERSION . '. The version installed is ' . GFForms::$version . '. Please upgrade Gravity Forms to the latest version.' ); } } } GF_CLI_Bootstrap::load_cli(); /** * Returns an instance of the GF_CLI class * * @since 1.0-beta-1 * @return object|null An instance of the GF_CLI class, or null if not available. */ function gf_cli() { if ( class_exists( 'GF_CLI' ) ) { return GF_CLI::get_instance(); } return null; }