singleton( AddonRegistry::class, function () use ( $container ) { $registry = AddonRegistry::getInstance(); if ( $container->has( LoggerInterface::class ) ) { $registry->setLogger( $container->get( LoggerInterface::class ) ); } return $registry; } ); } /** * {@inheritdoc} */ public function boot( Container $container ): void { $registry = $container->get( AddonRegistry::class ); /* * Decoupling rationale: boot() itself runs during Container::boot(), * which fires at plugins_loaded priority 10 while the main plugin is * being instantiated. Addon plugins that hook on plugins_loaded:10 * may not have loaded yet, so we defer the registration window by * one priority step. Late-registering addons after priority 20 will * still be picked up by the register() method's late-boot path. */ add_action( 'plugins_loaded', function () use ( $registry, $container ) { /** * Fires once per request, giving addon plugins the opportunity * to register themselves with the AddonRegistry. * * @since 4.3.0 * * @param AddonRegistry $registry The addon registry. * @param Container $container The core DI container, for * addons that need it at * registration time (rare — * prefer AddonInterface::boot()). */ do_action( 'f12_cf7_doubleoptin_register_addons', $registry, $container ); $registry->bootAll( $container ); }, 20 ); } }