build_blackout( $settings, $providers, $resolver, $call_log ); $badge = new Badge( $settings, $policy, $tdmrep ); $terms = new TermsClause( $signals ); $nginx = new NginxSnippet( $matcher ); $auditor = $this->build_auditor( $registry, $policy, $matcher, $server, $robots, $htaccess, $cache, $loopback ); $auditor->add( new DeclarationsCheck( $tdmrep, $signals, $meta, $history ) ); $auditor->add( new BlackoutCheck( $blackout, $settings ) ); $protection_record = new ProtectionRecord( $auditor, $history, $registry, $policy ); $upgrade = new Upgrade(); $notes = new ReleaseNotes(); $onboarding = new Onboarding( $settings, $policy, $registry ); $decl_admin = new DeclarationsPanel( $settings, $tdmrep, $signals, $meta, $terms, $history, $badge ); $table = new CrawlerTable( $registry, $policy, $matcher, $settings ); $main_admin = new MainScreen( $registry, $policy, $server, $htaccess, $nginx, $publisher, $onboarding, $table, $decl_admin, $auditor, $protection_record ); $this->services = array( 'settings' => $settings, 'registry' => $registry, 'policy' => $policy, 'matcher' => $matcher, 'server' => $server, 'files' => $files, 'robots' => $robots, 'htaccess' => $htaccess, 'php_gate' => new PhpGate( $matcher ), 'publisher' => $publisher, 'suspension' => $suspend, 'nginx' => $nginx, 'cache' => $cache, 'loopback' => $loopback, 'auditor' => $auditor, 'protection_record' => $protection_record, 'history' => $history, 'signals' => $signals, 'tdmrep' => $tdmrep, 'meta' => $meta, 'terms' => $terms, 'badge' => $badge, 'upgrade' => $upgrade, 'release_notes' => $notes, 'assets' => new Assets(), 'onboarding' => $onboarding, 'review_request' => new ReviewRequest( $settings ), 'whats_new' => new WhatsNewScreen( $notes, $upgrade ), 'rating_footer' => new RatingFooter(), 'dashboard_widget' => new DashboardWidget( $protection_record ), 'admin_bar_status' => new AdminBarStatus( $protection_record ), 'plugin_row_status' => new PluginRowStatus( $protection_record ), 'crawler_table' => $table, 'main_admin' => $main_admin, 'decl_admin' => $decl_admin, 'providers' => $providers, 'resolver' => $resolver, 'call_log' => $call_log, 'blackout' => $blackout, 'blackout_admin' => new BlackoutScreen( $blackout, $settings, $providers, $resolver ), ); } /** * Assembles the AI Blackout module. * * @param Settings $settings Plugin settings. * @param ProviderRegistry $providers Bundled AI provider list. * @param CallerResolver $resolver Caller attribution. * @param BlockedCalls $call_log Outbound call log. * @return Blackout The configured module. */ private function build_blackout( Settings $settings, ProviderRegistry $providers, CallerResolver $resolver, BlockedCalls $call_log ): Blackout { $blackout = new Blackout( $settings, new CoreAi( $settings ), new AdminUi( $settings ), new OutboundFirewall( $providers, $settings, $resolver, $call_log ), $call_log ); $blackout->add_integration( new ElementorAi() ); $blackout->add_integration( new YoastAi() ); return $blackout; } /** * Assembles the Truth Audit. * * @param Registry $registry Crawler registry. * @param Policy $policy Policy resolver. * @param UserAgentMatcher $matcher User-agent matcher. * @param ServerProfile $server Server profile. * @param RobotsTxt $robots robots.txt layer. * @param Htaccess $htaccess .htaccess layer. * @param PageCache $cache Page cache detector. * @param Loopback $loopback Loopback client. * @return Auditor The configured auditor. */ private function build_auditor( Registry $registry, Policy $policy, UserAgentMatcher $matcher, ServerProfile $server, RobotsTxt $robots, Htaccess $htaccess, PageCache $cache, Loopback $loopback ): Auditor { $auditor = new Auditor(); $auditor->add( new RobotsTxtCheck( $robots ) ); $auditor->add( new HtaccessCheck( $htaccess, $server ) ); $auditor->add( new PhpGateCheck( $cache, $server, $htaccess, $matcher ) ); $auditor->add( new PageCacheCheck( $cache, $server, $htaccess ) ); $auditor->add( new CloudflareCheck() ); $auditor->add( new ServedRobotsCheck( $loopback, $robots ) ); $auditor->add( new HostBlockingCheck( $loopback, $registry, $policy ) ); return $auditor; } /** * Registers everything that hooks into WordPress. * * @return void */ public function register(): void { $this->robots()->register(); $this->php_gate()->register(); $this->history()->register(); $this->tdmrep()->register(); $this->meta_tags()->register(); $this->blackout()->register(); $this->badge()->register(); $this->protection_record()->register(); if ( is_admin() ) { $this->upgrade()->register(); $this->assets()->register(); $this->onboarding()->register(); $this->suspension()->register(); $this->review_request()->register(); $this->whats_new()->register(); $this->rating_footer()->register(); $this->dashboard_widget()->register(); $this->admin_bar_status()->register(); $this->plugin_row_status()->register(); $this->main_admin()->register(); $this->decl_admin()->register(); $this->blackout_admin()->register(); } } /** * Returns a service by name. * * @param string $name Service name. * @return mixed|null The service, or null when unknown. */ public function get( string $name ) { return isset( $this->services[ $name ] ) ? $this->services[ $name ] : null; } /** * Version tracking across updates. * * @return Upgrade */ public function upgrade(): Upgrade { return $this->services['upgrade']; } /** * The bundled release notes. * * @return ReleaseNotes */ public function release_notes(): ReleaseNotes { return $this->services['release_notes']; } /** * The What's new screen. * * @return WhatsNewScreen */ public function whats_new(): WhatsNewScreen { return $this->services['whats_new']; } /** * Settings service. * * @return Settings */ public function settings(): Settings { return $this->services['settings']; } /** * Crawler registry service. * * @return Registry */ public function registry(): Registry { return $this->services['registry']; } /** * Policy service. * * @return Policy */ public function policy(): Policy { return $this->services['policy']; } /** * User-agent matcher service. * * @return UserAgentMatcher */ public function matcher(): UserAgentMatcher { return $this->services['matcher']; } /** * Server profile service. * * @return ServerProfile */ public function server(): ServerProfile { return $this->services['server']; } /** * Layer for robots.txt. * * @return RobotsTxt */ public function robots(): RobotsTxt { return $this->services['robots']; } /** * .htaccess layer. * * @return Htaccess */ public function htaccess(): Htaccess { return $this->services['htaccess']; } /** * PHP gate layer. * * @return PhpGate */ public function php_gate(): PhpGate { return $this->services['php_gate']; } /** * Record of what the last deactivation reverted. * * @return Suspension */ public function suspension(): Suspension { return $this->services['suspension']; } /** * The ask for a review. * * @return ReviewRequest */ public function review_request(): ReviewRequest { return $this->services['review_request']; } /** * The rating ask in the admin footer. * * @return RatingFooter */ public function rating_footer(): RatingFooter { return $this->services['rating_footer']; } /** * Generator for the nginx snippet. * * @return NginxSnippet */ public function nginx(): NginxSnippet { return $this->services['nginx']; } /** * Page cache detector. * * @return PageCache */ public function cache(): PageCache { return $this->services['cache']; } /** * Loopback client for user-initiated self-tests. * * @return Loopback */ public function loopback(): Loopback { return $this->services['loopback']; } /** * Writes the enforcement layers to disk. * * @return Publisher */ public function publisher(): Publisher { return $this->services['publisher']; } /** * Truth Audit. * * @return Auditor */ public function auditor(): Auditor { return $this->services['auditor']; } /** * The ambient protection record. * * @return ProtectionRecord */ public function protection_record(): ProtectionRecord { return $this->services['protection_record']; } /** * The "is this working" dashboard widget. * * @return DashboardWidget */ public function dashboard_widget(): DashboardWidget { return $this->services['dashboard_widget']; } /** * The persistent admin bar status. * * @return AdminBarStatus */ public function admin_bar_status(): AdminBarStatus { return $this->services['admin_bar_status']; } /** * The status line on the Plugins list screen. * * @return PluginRowStatus */ public function plugin_row_status(): PluginRowStatus { return $this->services['plugin_row_status']; } /** * Declaration history. * * @return History */ public function history(): History { return $this->services['history']; } /** * Content Signals declaration. * * @return ContentSignals */ public function content_signals(): ContentSignals { return $this->services['signals']; } /** * TDM reservation. * * @return Tdmrep */ public function tdmrep(): Tdmrep { return $this->services['tdmrep']; } /** * The noai and noimageai directives. * * @return MetaTags */ public function meta_tags(): MetaTags { return $this->services['meta']; } /** * Terms clause generator. * * @return TermsClause */ public function terms(): TermsClause { return $this->services['terms']; } /** * AI Blackout module. * * @return Blackout */ public function blackout(): Blackout { return $this->services['blackout']; } /** * Bundled AI provider list. * * @return ProviderRegistry */ public function providers(): ProviderRegistry { return $this->services['providers']; } /** * Outbound call log. * * @return BlockedCalls */ public function call_log(): BlockedCalls { return $this->services['call_log']; } /** * AI Blackout admin screen. * * @return BlackoutScreen */ public function blackout_admin(): BlackoutScreen { return $this->services['blackout_admin']; } /** * The optional front-end badge. * * @return Badge */ public function badge(): Badge { return $this->services['badge']; } /** * Admin stylesheet loader. * * @return Assets */ public function assets(): Assets { return $this->services['assets']; } /** * First-run setup screen. * * @return Onboarding */ public function onboarding(): Onboarding { return $this->services['onboarding']; } /** * The plugin's one screen. * * @return MainScreen */ public function main_admin(): MainScreen { return $this->services['main_admin']; } /** * The per-crawler override table. * * @return CrawlerTable */ public function crawler_table(): CrawlerTable { return $this->services['crawler_table']; } /** * Declarations screen. * * @return DeclarationsPanel */ public function decl_admin(): DeclarationsPanel { return $this->services['decl_admin']; } }