register( AdminNotices::class, static fn (ServiceContainer $c): AdminNotices => new AdminNotices( $c->resolve(PublishedSet::class) ) ); $container->register( AdminMenu::class, static fn (ServiceContainer $c): AdminMenu => new AdminMenu( $c->resolve(AdminNotices::class) ) ); // Tools → Site Health → Info → WConvert, which the Help page points // support requests at instead of drawing a report of its own. $container->register( SiteHealthInfo::class, static function (ServiceContainer $c): SiteHealthInfo { $manifest = TierManifest::load(); return new SiteHealthInfo($c->resolve(OptinRepository::class), new WpProPresence(), $manifest); } ); // The door into the eligibility inspector, on the page it explains. // It adds one node to the admin bar, linking the URL the merchant is // already on — once something is published to ask about (ADR 0147). $container->register( InspectorBar::class, static fn (ServiceContainer $c): InspectorBar => new InspectorBar($c->resolve(PublishedSet::class)) ); // The CSV download is an `admin-post.php` action rather than a REST // route: a download is a navigation, and the browser has to be handed // a `Content-Disposition` it can act on. $container->register( LeadExport::class, static fn (ServiceContainer $c): LeadExport => new LeadExport( $c->resolve(LeadRepository::class), $c->resolve(OptinRepository::class), $c->resolve(LeadCsv::class) ) ); } public function boot(ServiceContainer $container): void { // **Registered before the `is_admin()` return, deliberately.** Every // other admin surface belongs inside wp-admin; the inspector's door is // an admin-bar node on the FRONT END, which is the only place the page // it explains exists. `admin_bar_menu` fires on both sides and // {@see InspectorBar} returns on `is_admin()` itself, so a merchant in // wp-admin is offered nothing. $container->resolve(InspectorBar::class)->hooks(); if (!is_admin()) { return; } $container->resolve(AdminNotices::class)->hooks(); $container->resolve(AdminMenu::class)->hooks(); $container->resolve(LeadExport::class)->hooks(); (new PluginRowMeta(plugin_basename(WCONVERT_MAIN_FILE)))->hooks(); // Built only when Site Health asks, since it reads the tier manifest // and the campaigns table; every other admin request skips both. add_filter('debug_information', static fn ($info): array => $container->resolve(SiteHealthInfo::class)->addSection($info)); } }