Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Automattic\Jetpack\Connection\Manager;
use Automattic\Jetpack\Current_Plan;
use Automattic\Jetpack\Modules;
use Automattic\Jetpack\Search\Plan as Search_Plan;
use Automattic\Jetpack\Status\Host;

Expand Down Expand Up @@ -203,7 +204,10 @@ private function build_settings_response() {
),
),
'feature_clip' => array( 'enabled' => $stored['feature_clip'] ),
'seo_enhancer' => array( 'enabled' => $stored['seo_enhancer'] ),
'seo_enhancer' => array(
'enabled' => $stored['seo_enhancer'],
'available' => $this->is_seo_enhancer_available(),
),
'ai_search' => array(
'enabled' => $stored['ai_search'],
'requires_upgrade' => ! $supports_search,
Expand All @@ -212,6 +216,28 @@ private function build_settings_response() {
);
}

/**
* Whether the AI SEO enhancer is available on this site, so the settings
* page can hide its row where the feature can't run.
*
* Mirrors the legacy Traffic page's gate: the feature filter, the
* seo-tools module (always active on WordPress.com Simple, where
* Modules::is_active() short-circuits), and the plan feature.
*
* @return bool
*/
private function is_seo_enhancer_available() {
$filter_on = (bool) apply_filters( 'ai_seo_enhancer_enabled', true );

$module_active = class_exists( Modules::class )
&& ( new Modules() )->is_active( 'seo-tools' );

$plan_supports = class_exists( Current_Plan::class )
&& Current_Plan::supports( 'ai-seo-enhancer' );

return $filter_on && $module_active && $plan_supports;
}

/**
* Whether the site can know its plan: Simple sites always can; elsewhere a
* connected owner is required. Mirrors the connection predicate the AI
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

AI settings: report SEO enhancer availability in the feature-settings endpoint.
Loading