← All changes
|
extensions/plugins/ai-assistant-plugin/reader-chat/class-jetpack-reader-chat.php
+12
-2
16.2-beta
→
16.3-beta
View file →
| @@ -17,13 +17,18 @@ | ||
| 17 | 17 | |
| 18 | 18 | namespace Automattic\Jetpack\Extensions\AiAssistantPlugin; |
| 19 | 19 | |
| 20 | 20 | use Automattic\Jetpack\Connection\Manager as Connection_Manager; |
| 21 | +use Automattic\Jetpack\Search\Helper as Search_Helper; | |
| 21 | 22 | use Automattic\Jetpack\Search\Plan; |
| 22 | 23 | use Automattic\Jetpack\Status; |
| 23 | 24 | use Automattic\Jetpack\Status\Host; |
| 24 | 25 | use Jetpack_Options; |
| 25 | 26 | |
| 27 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 28 | + exit( 0 ); | |
| 29 | +} | |
| 30 | + | |
| 26 | 31 | const READER_CHAT_JS_URL = 'https://widgets.wp.com/agents-manager/reader-chat.min.js'; |
| 27 | 32 | const READER_CHAT_ASSET_TRANSIENT = 'jetpack_reader_chat_asset'; |
| 28 | 33 | const READER_CHAT_ASSET_FAILURE_CACHE_TTL = 5 * MINUTE_IN_SECONDS; |
| 29 | 34 | |
| @@ -439,9 +444,12 @@ | ||
| 439 | 444 | |
| 440 | 445 | $wpcom_plan_info_class = '\Jetpack\Search\Plan_Info'; |
| 441 | 446 | if ( class_exists( $wpcom_plan_info_class ) ) { |
| 442 | 447 | $plan_info = new $wpcom_plan_info_class( $blog_id ); |
| 443 | - return $plan_info->supports_search() && ! $plan_info->is_disabled_due_to_overage(); | |
| 448 | + return $plan_info->supports_search() | |
| 449 | + && method_exists( $plan_info, 'is_free_search_plan' ) | |
| 450 | + && ! $plan_info->is_free_search_plan() | |
| 451 | + && ! $plan_info->is_disabled_due_to_overage(); | |
| 444 | 452 | } |
| 445 | 453 | } |
| 446 | 454 | |
| 447 | 455 | if ( ! class_exists( Plan::class ) ) { |
| @@ -452,9 +460,11 @@ | ||
| 452 | 460 | if ( ! is_array( $plan_info ) ) { |
| 453 | 461 | return false; |
| 454 | 462 | } |
| 455 | 463 | |
| 456 | - return ! empty( $plan_info['supports_search'] ) | |
| 464 | + return ! Search_Helper::is_forced_free_plan() | |
| 465 | + && ! empty( $plan_info['supports_search'] ) | |
| 466 | + && ( $plan_info['effective_subscription']['product_slug'] ?? null ) !== Plan::JETPACK_SEARCH_FREE_PRODUCT_SLUG | |
| 457 | 467 | && empty( $plan_info['plan_usage']['must_upgrade'] ); |
| 458 | 468 | } |
| 459 | 469 | |
| 460 | 470 | /** |