From f66571d3af861b0656ef35a3771639df08ec8074 Mon Sep 17 00:00:00 2001 From: Ariana Kataoka Date: Tue, 14 Jul 2026 20:42:08 +1000 Subject: [PATCH] AI settings: report SEO enhancer availability The feature-settings endpoint gains seo_enhancer.available so the settings page can hide the row where the enhancer can't run. Mirrors the legacy Traffic gate: the ai_seo_enhancer_enabled filter, the seo-tools module (always active on Simple), and the ai-seo-enhancer plan feature. Co-Authored-By: Claude Fable 5 --- ...st-api-v2-endpoint-ai-feature-settings.php | 28 ++++++++++++++++++- .../add-jetpack-ai-seo-enhancer-availability | 4 +++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/add-jetpack-ai-seo-enhancer-availability diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-ai-feature-settings.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-ai-feature-settings.php index f37360a6c30f..661851ef67bb 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-ai-feature-settings.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-ai-feature-settings.php @@ -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; @@ -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, @@ -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 diff --git a/projects/plugins/jetpack/changelog/add-jetpack-ai-seo-enhancer-availability b/projects/plugins/jetpack/changelog/add-jetpack-ai-seo-enhancer-availability new file mode 100644 index 000000000000..587193904bef --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-jetpack-ai-seo-enhancer-availability @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +AI settings: report SEO enhancer availability in the feature-settings endpoint.