boot(); } return self::$instance; } /** * Create services and register hooks. */ private function boot() { Installer::maybe_upgrade(); $this->settings = new Settings(); $this->terms = new Terms(); $this->scanner = new Scanner( $this->settings ); $this->report = new Report( $this->settings, $this->scanner ); $this->traffic = new Store(); ( new Cron( $this->scanner, $this->report, $this->traffic ) )->register(); ( new Rest( $this ) )->register(); LocalFonts::register(); \GoConsent\Policies\Tags::register(); $consent_log = new ConsentLog(); $consent_log->register_admin(); if ( is_admin() ) { ( new Admin( $this ) )->register(); } // Visitor-facing protection runs only after an admin accepts the terms. if ( $this->terms->accepted() && $this->settings->get( 'enabled' ) ) { ( new Consent( $this->settings ) )->register(); ( new OutputFilter( $this->settings, $this->scanner ) )->register(); ( new Collector( $this->settings, $this->traffic ) )->register(); $consent_log->register_public(); } /** * Fires after GoConsent has booted. Integrations (e.g. hosting plugins) hook here. * * @param Plugin $plugin The plugin instance. */ do_action( 'goconsent_loaded', $this ); } /** * Whether visitor-facing protection is running on this request. * * @return bool */ public function is_protecting() { return $this->terms->accepted() && (bool) $this->settings->get( 'enabled' ); } }