Skip to content

Commit

Permalink
Display error notice if EP is not install and active.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Sep 17, 2024
1 parent 5d5de9a commit 713dc42
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
14 changes: 8 additions & 6 deletions includes/Classifai/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use function Classifai\get_plugin;
use function Classifai\get_services_menu;
use function Classifai\get_post_statuses_for_language_settings;
use function Classifai\is_elasticpress_installed;

class Settings {

Expand Down Expand Up @@ -83,12 +84,13 @@ public function admin_enqueue_scripts( $hook_suffix ) {
wp_set_script_translations( 'classifai-settings', 'classifai' );

$data = array(
'features' => $this->get_features(),
'services' => get_services_menu(),
'settings' => $this->get_settings(),
'dashboardUrl' => admin_url( '/' ),
'nonce' => wp_create_nonce( 'classifai-previewer-action' ),
'postStatuses' => get_post_statuses_for_language_settings(),
'features' => $this->get_features(),
'services' => get_services_menu(),
'settings' => $this->get_settings(),
'dashboardUrl' => admin_url( '/' ),
'nonce' => wp_create_nonce( 'classifai-previewer-action' ),
'postStatuses' => get_post_statuses_for_language_settings(),
'isEPinstalled' => is_elasticpress_installed(),
);

wp_add_inline_script(
Expand Down
23 changes: 23 additions & 0 deletions src/js/settings/components/feature-settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ const PersonalizerDeprecationNotice = () => (
</Notice>
);

const ElasticPressRequiredNotice = () => (
<Notice
status="error"
isDismissible={ false }
className="elasticpress-required-notice"
>
<p>
{ __(
'The Smart 404 Feature requires the ElasticPress plugin to be installed and active prior to use.',
'classifai'
) }
</p>
</Notice>
);

/**
* Feature Settings component.
*
Expand Down Expand Up @@ -83,6 +98,14 @@ export const FeatureSettings = ( { onSaveSuccess = () => {} } ) => {
);
}

// Show ElasticPress required notice if the feature is Smart 404 and ElasticPress is not active.
if (
'feature_smart_404' === featureName &&
! window.classifAISettings?.isEPinstalled
) {
return <ElasticPressRequiredNotice />;
}

return (
<>
{ 'feature_recommended_content' === featureName && (
Expand Down

0 comments on commit 713dc42

Please sign in to comment.