container = $container; $this->pluginFile = $pluginFile; } /** * Boot the plugin. * * Initializes all plugin components and registers WordPress hooks. * * @return void */ public function boot(): void { // Get services from container $altTextService = $this->container->get(AltTextService::class); $mediaLibrary = $this->container->get(MediaLibrary::class); $contentAltTextEnricher = $this->container->get(ContentAltTextEnricher::class); $schema = $this->container->get(ErrorLogSchema::class); if (defined('WP_CLI') && WP_CLI) { \WP_CLI::add_command('auto-alt-text', new AutoAltTextCommand($altTextService)); } // Create plugin lifecycle handler $lifecycle = new PluginLifecycle($schema); // Create and configure bulk action handler $bulkActionHandler = $this->createBulkActionHandler($altTextService); // Create hooks registrar and register all hooks $hooksRegistrar = new HooksRegistrar( $altTextService, $bulkActionHandler, $lifecycle, $mediaLibrary, $contentAltTextEnricher, $this->pluginFile ); $hooksRegistrar->register(); } /** * Create and configure the bulk action handler. * * @param AltTextService $altTextService The alt text service * @return BulkActionHandler Configured bulk action handler */ private function createBulkActionHandler(AltTextService $altTextService): BulkActionHandler { $handler = new BulkActionHandler(); // Register the generate alt text bulk action $generateAltTextAction = new GenerateAltTextBulkAction($altTextService); $handler->register($generateAltTextAction); return $handler; } /** * Static factory method for easy plugin initialization. * * Usage in main plugin file: * ```php * PluginBootstrap::init(__FILE__); * ``` * * @param string $pluginFile Path to the main plugin file * @return void */ public static function init(string $pluginFile): void { $container = Container::make(); $bootstrap = new self($container, $pluginFile); $bootstrap->boot(); } }