storage = $storage; $this->ownership = $ownership; } public function register() { add_action( 'admin_menu', array( $this, 'menu' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); add_filter( 'plugin_action_links_' . plugin_basename( ACHLAAI_FILE ), array( $this, 'settings_link' ) ); } public function menu() { $this->hook = add_options_page( __( 'Achla AI Search', 'achlaai' ), __( 'Achla AI Search', 'achlaai' ), 'manage_options', self::PAGE_SLUG, array( $this, 'render' ) ); } /** @return string */ public static function settings_url() { return admin_url( 'options-general.php?page=' . self::PAGE_SLUG ); } public function assets( $hook ) { if ( $hook !== $this->hook ) { return; } wp_enqueue_style( 'achlaai-admin', ACHLAAI_URL . 'assets/admin.css', array(), ACHLAAI_VERSION ); wp_enqueue_script( 'achlaai-admin', ACHLAAI_URL . 'assets/admin.js', array(), ACHLAAI_VERSION, true ); wp_localize_script( 'achlaai-admin', 'AchlaAIAdmin', array( 'restRoot' => esc_url_raw( rest_url( 'achla/v1/' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'pluginVersion' => ACHLAAI_VERSION, 'wpVersion' => get_bloginfo( 'version' ), 'phpVersion' => PHP_VERSION, ) ); } public function render() { if ( ! current_user_can( 'manage_options' ) ) { return; } Lifecycle::schedule_maintenance( $this->storage ); $settings = $this->storage->get(); $status = $this->ownership->status(); $current = Protocol::canonical_site( home_url( '/' ) ); $is_http = $current && 'limited_http' === $current['security_level']; $verified_origin = $status['siteOrigin'] ? $status['siteOrigin'] : __( 'Not verified', 'achlaai' ); $last_error = $settings['release']['error_code'] ? $settings['release']['error_code'] : $status['lastError']; $last_error = $last_error ? $last_error : __( 'None', 'achlaai' ); ?>