storage = new Storage(); $this->client = new Api_Client(); $this->lifecycle = new Lifecycle_Manager( $this->storage, $this->client ); $diagnostics = new Runtime_Diagnostics( $this->storage ); $this->management_diagnostics = new Management_Diagnostics( $this->storage, $this->client ); $this->ownership = new Ownership( $this->storage, $this->client ); $this->releases = new Release_Manager( $this->storage, $this->client, new Release_Verifier() ); $placement = new Placement( $this->storage, $this->releases, $this->lifecycle, $diagnostics ); ( new Rest_Controller( $this->ownership, $placement, $this->releases, $this->storage, $this->lifecycle, $diagnostics, $this->management_diagnostics ) )->register(); ( new Admin( $this->storage, $this->ownership ) )->register(); $placement->register(); } public function register() { add_action( 'init', array( '\\AchlaAI\\Lifecycle', 'maybe_upgrade' ), 1 ); add_action( Lifecycle::CRON_HOOK, array( $this, 'refresh_release' ) ); add_action( Lifecycle::HEARTBEAT_CRON_HOOK, array( $this, 'heartbeat' ) ); add_action( Lifecycle::DNS_RECOVERY_CRON_HOOK, array( $this, 'dns_recovery' ) ); add_action( Lifecycle::DIAGNOSTICS_CRON_HOOK, array( $this, 'flush_diagnostics' ) ); add_action( 'load-settings_page_achlaai-settings', array( $this, 'admin_maintenance' ) ); add_action( 'admin_init', array( $this, 'privacy_policy' ) ); add_action( 'wp_initialize_site', array( $this, 'initialize_site' ), 20, 1 ); } public function refresh_release() { return $this->releases->maybe_refresh( 'cron', false ); } /** @return array|\WP_Error */ public function heartbeat() { return $this->lifecycle->request_maintenance( 'cron' ); } /** @return array|\WP_Error */ public function dns_recovery() { return $this->ownership->poll_dns_recovery( true ); } /** @return array|\WP_Error */ public function flush_diagnostics() { $result = $this->management_diagnostics->flush(); $next = $this->management_diagnostics->next_flush_at(); if ( false !== $next ) { Lifecycle::schedule_diagnostics( $next ); } return $result; } public function admin_maintenance() { if ( current_user_can( 'manage_options' ) ) { Lifecycle::schedule_maintenance( $this->storage ); } } public function initialize_site( $site ) { if ( ! is_multisite() || ! isset( $site->blog_id ) ) { return; } switch_to_blog( $site->blog_id ); Lifecycle::activate_site(); restore_current_blog(); } public function privacy_policy() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( __( 'Achla AI Search', 'achlaai' ), wp_kses_post( '

' . __( 'When a visitor uses Achla AI Search, their search question and the page origin are sent to Achla AI Search so it can return an answer and citations. The connector does not use cookies, localStorage, advertising identifiers, or page-content telemetry. Review Achla\'s current privacy policy and subprocessors before publishing this text.', 'achlaai' ) . '

' ) ); } }