+ { __(
+ 'You need to add at least one Brand Site and configure your Algolia credentials before you can set up indices and search.',
+ 'onesearch'
+ ) }
+
+
+
+ ) }
+ >
) }
>
);
diff --git a/assets/src/components/SiteSearchSettings.tsx b/assets/src/components/SiteSearchSettings.tsx
index 4b83a37a..d66ef69f 100644
--- a/assets/src/components/SiteSearchSettings.tsx
+++ b/assets/src/components/SiteSearchSettings.tsx
@@ -7,22 +7,22 @@ import {
Card,
CardBody,
CardHeader,
- ToggleControl,
- Spinner,
Notice,
+ Spinner,
+ ToggleControl,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
/**
* External dependencies
*/
-import { useState, useEffect, useCallback, useRef } from 'react';
+import { useCallback, useEffect, useRef, useState } from 'react';
/**
* Internal dependencies
*/
-import { NONCE, withTrailingSlash } from '../js/utils';
import type { NoticeType } from '@/admin/settings/page';
+import { NONCE, withTrailingSlash } from '../js/utils';
/**
* Create NONCE middleware for apiFetch
@@ -468,8 +468,9 @@ const SiteSearchSettings = ( {
+
+ { /* Notice for warnings */ }
- { /* Notice for warnings */ }
{ localNotice && (
;
+ hasAlgoliaCredentials?: boolean;
}
export interface OneSearchOnboarding {
diff --git a/inc/Modules/Core/Assets.php b/inc/Modules/Core/Assets.php
index 84ca8191..14e061e7 100644
--- a/inc/Modules/Core/Assets.php
+++ b/inc/Modules/Core/Assets.php
@@ -64,17 +64,20 @@ final class Assets implements Registrable {
* @return array
*/
public static function get_localized_data(): array {
+ $algolia_creds = Search_Settings::get_algolia_credentials();
+
if ( empty( self::$localized_data ) ) {
self::$localized_data = [
- 'currentSiteUrl' => esc_url( home_url( '/' ) ),
- 'indexableEntities' => Search_Settings::get_indexable_entities(),
- 'nonce' => wp_create_nonce( 'wp_rest' ),
- 'api_key' => Settings::get_api_key(),
- 'restNamespace' => Abstract_REST_Controller::NAMESPACE,
- 'restUrl' => esc_url( home_url( '/wp-json/' ) ),
- 'setupUrl' => admin_url( 'admin.php?page=onesearch-settings' ),
- 'sharedSites' => array_values( Settings::get_shared_sites() ),
- 'siteType' => Settings::get_site_type(),
+ 'currentSiteUrl' => esc_url( home_url( '/' ) ),
+ 'hasAlgoliaCredentials' => ! empty( $algolia_creds['app_id'] ) && ! empty( $algolia_creds['write_key'] ),
+ 'indexableEntities' => Search_Settings::get_indexable_entities(),
+ 'nonce' => wp_create_nonce( 'wp_rest' ),
+ 'api_key' => Settings::get_api_key(),
+ 'restNamespace' => Abstract_REST_Controller::NAMESPACE,
+ 'restUrl' => esc_url( home_url( '/wp-json/' ) ),
+ 'setupUrl' => admin_url( 'admin.php?page=onesearch-settings' ),
+ 'sharedSites' => array_values( Settings::get_shared_sites() ),
+ 'siteType' => Settings::get_site_type(),
];
}
diff --git a/inc/Modules/Search/Admin.php b/inc/Modules/Search/Admin.php
index 06ac2def..74229154 100644
--- a/inc/Modules/Search/Admin.php
+++ b/inc/Modules/Search/Admin.php
@@ -11,7 +11,6 @@
use OneSearch\Contracts\Interfaces\Registrable;
use OneSearch\Modules\Core\Assets;
-use OneSearch\Modules\Search\Settings as Search_Settings;
use OneSearch\Modules\Settings\Settings;
/**
@@ -34,7 +33,7 @@ final class Admin implements Registrable {
* {@inheritDoc}
*/
public function register_hooks(): void {
- if ( ! Settings::is_governing_site() || empty( Search_Settings::get_algolia_credentials() ) ) {
+ if ( ! Settings::is_governing_site() ) {
return;
}
add_action( 'admin_menu', [ $this, 'add_submenu' ] );
@@ -45,7 +44,7 @@ public function register_hooks(): void {
* Register the settings page.
*/
public function add_submenu(): void {
- // Register the "Indices and Search" submenu only for governing sites with Algolia credentials.
+ // Register the "Indices and Search" submenu for governing sites.
add_submenu_page(
self::MENU_SLUG,
__( 'Indices and Search', 'onesearch' ),
diff --git a/inc/Modules/Settings/Admin.php b/inc/Modules/Settings/Admin.php
index 4e852ea4..b0ed4acd 100644
--- a/inc/Modules/Settings/Admin.php
+++ b/inc/Modules/Settings/Admin.php
@@ -85,7 +85,7 @@ public function add_submenu(): void {
* Remove the default submenu added by WordPress.
*/
public function remove_default_submenu(): void {
- if ( Settings::is_governing_site() && ! empty( Settings::get_shared_sites() ) ) {
+ if ( Settings::is_governing_site() ) {
return;
}
remove_submenu_page( self::MENU_SLUG, self::MENU_SLUG );