'class-aieo-content-cli.php', 'AIEO_Content_CLI_Menu' => 'class-aieo-content-cli.php', 'AIEO_Content_CLI_Form' => 'class-aieo-content-cli.php', ); private static $autoload = false; public static function autoload() { if ( self::$autoload ) { return; } self::$autoload = true; spl_autoload_register( static function ( $class ) { if ( 0 !== strpos( $class, 'AIEO_Content_' ) ) { return; } $file = __DIR__ . '/' . ( self::FILES[ $class ] ?? 'class-' . strtolower( str_replace( '_', '-', $class ) ) . '.php' ); if ( is_file( $file ) ) { require_once $file; } } ); } const CLI_COMMANDS = array( 'aieo page apply' => array( 'AIEO_Content_CLI_Page', 'apply', 'Apply page specs: draft (an autosave with a preview link) or apply (a revision).', ' [--mode=] [--status=] [--force[=]] [--media-dir=] [--wp-content-dir=] [--strict] [--dry-run] [--format=]' ), 'aieo page diff' => array( 'AIEO_Content_CLI_Page', 'diff', 'What a run would do, per section: create, update, keep, conflict, remove.', ' [--media-dir=] [--wp-content-dir=] [--strict] [--format=]' ), 'aieo page export' => array( 'AIEO_Content_CLI_Page', 'export', 'A page back to a spec.', ' [--out=]' ), 'aieo page validate' => array( 'AIEO_Content_CLI_Page', 'validate', 'Validate one spec or a folder of them.', ' [--media-dir=] [--wp-content-dir=] [--strict]' ), 'aieo menu apply' => array( 'AIEO_Content_CLI_Menu', 'apply', 'Write a rooster-menus@1 file\'s menus as navigation posts (adopted by slug).', ' [--mode=] [--strict] [--dry-run] [--format=]' ), 'aieo form apply' => array( 'AIEO_Content_CLI_Form', 'apply', 'Create or update the forms of a *.form.json file or of a folder of them.', ' [--dry-run] [--format=]' ), ); public static function cli() { if ( ! class_exists( 'WP_CLI' ) ) { return; } self::autoload(); WP_CLI::add_command( 'aieo page', 'AIEO_Content_CLI_Page' ); WP_CLI::add_command( 'aieo menu', 'AIEO_Content_CLI_Menu' ); WP_CLI::add_command( 'aieo form', 'AIEO_Content_CLI_Form' ); $objects = array(); foreach ( self::CLI_COMMANDS as $name => [ $class, $method, $summary, $synopsis ] ) { $objects[ $class ] = $objects[ $class ] ?? new $class(); WP_CLI::add_command( $name, array( $objects[ $class ], $method ), array( 'shortdesc' => $summary, 'synopsis' => $synopsis ) ); } } public static function category() { self::autoload(); AIEO_Content_Abilities::category(); } public static function abilities() { self::autoload(); AIEO_Content_Abilities::register(); } public static function recipe( $key ) { return self::RECIPE_PREFIX . (string) $key; } } }