← All changes
|
extensions/plugins/ai-content-lens/ai-content-lens.php
+18
-4
12.9.5
→
16.3
View file →
| @@ -10,8 +10,17 @@ | ||
| 10 | 10 | use Automattic\Jetpack\Connection\Manager as Connection_Manager; |
| 11 | 11 | use Automattic\Jetpack\Status; |
| 12 | 12 | use Automattic\Jetpack\Status\Host; |
| 13 | 13 | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit( 0 ); | |
| 16 | +} | |
| 17 | + | |
| 18 | +// Required directly rather than relying on the plugin bootstrap: on | |
| 19 | +// WordPress.com Simple the extension files load through wpcom's own loader | |
| 20 | +// and load-jetpack.php never runs. | |
| 21 | +require_once __DIR__ . '/../../../_inc/lib/class-jetpack-ai-settings.php'; | |
| 22 | + | |
| 14 | 23 | // Feature name. |
| 15 | 24 | const FEATURE_NAME = 'ai-content-lens'; |
| 16 | 25 | |
| 17 | 26 | /** |
| @@ -21,12 +30,17 @@ | ||
| 21 | 30 | * |
| 22 | 31 | * @return void |
| 23 | 32 | */ |
| 24 | 33 | function register_plugin() { |
| 25 | - // Connection check. | |
| 34 | + // Connection check, plus the AI master switch and the writing toggle that | |
| 35 | + // owns the excerpt generator on the AI settings page. | |
| 26 | 36 | if ( |
| 27 | - ( new Host() )->is_wpcom_simple() | |
| 28 | - || ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() ) | |
| 37 | + ( | |
| 38 | + ( new Host() )->is_wpcom_simple() | |
| 39 | + || ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() ) | |
| 40 | + ) | |
| 41 | + && \Jetpack_AI_Settings::is_ai_enabled() | |
| 42 | + && \Jetpack_AI_Settings::is_feature_enabled( 'writing_assistant' ) | |
| 29 | 43 | ) { |
| 30 | 44 | // Register AI Content lens plugin. |
| 31 | 45 | \Jetpack_Gutenberg::set_extension_available( FEATURE_NAME ); |
| 32 | 46 | } |
| @@ -37,9 +51,9 @@ | ||
| 37 | 51 | add_filter( |
| 38 | 52 | 'jetpack_set_available_extensions', |
| 39 | 53 | function ( $extensions ) { |
| 40 | 54 | return array_merge( |
| 41 | - $extensions, | |
| 55 | + (array) $extensions, | |
| 42 | 56 | array( |
| 43 | 57 | FEATURE_NAME, |
| 44 | 58 | ) |
| 45 | 59 | ); |