Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"ENABLE_OTTER_PRO_DEV": true
},
"plugins": [
"."
".",
"https://downloads.wordpress.org/plugin/ai-provider-for-openai.zip"
],
"themes": [ "./test/emptytheme" ],
"mappings": {
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"phpunit/phpunit": "9.6.5",
"yoast/phpunit-polyfills": "^4.0",
"phpstan/phpstan": "^2.1",
"php-stubs/woocommerce-stubs": "^9.1",
"php-stubs/acf-pro-stubs": "^6.0",
"php-stubs/woocommerce-stubs": "^10.8",
"php-stubs/acf-pro-stubs": "^6.8",
"wpackagist-plugin/woocommerce": "*",
"szepeviktor/phpstan-wordpress": "^2.0",
"automattic/vipwpcs": "^3.0"
"automattic/vipwpcs": "^3.0",
"php-stubs/wordpress-stubs": "7.0.0 as 6.8.2"
},
"license": "GPL-2.0+",
"authors": [
Expand Down
117 changes: 31 additions & 86 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion inc/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ThemeIsle\GutenbergBlocks\Plugins\Dashboard;
use ThemeIsle\GutenbergBlocks\Plugins\LimitedOffers;
use ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud;
use ThemeIsle\GutenbergBlocks\Server\AI_Client_Adaptor;

/**
* Class Registration.
Expand Down Expand Up @@ -247,6 +248,9 @@ public function enqueue_block_editor_assets() {

global $wp_roles;

$is_wp_ai_backend = AI_Client_Adaptor::BACKEND_WP === AI_Client_Adaptor::resolve_backend();
$ai_provider_status = AI_Client_Adaptor::provider_status();

wp_localize_script(
'otter-blocks',
'themeisleGutenberg',
Expand Down Expand Up @@ -293,7 +297,10 @@ public function enqueue_block_editor_assets() {
'version' => OTTER_BLOCKS_VERSION,
'isRTL' => is_rtl(),
'highlightDynamicText' => get_option( 'themeisle_blocks_settings_highlight_dynamic', true ),
'hasOpenAiKey' => ! empty( get_option( 'themeisle_open_ai_api_key' ) ),
'hasOpenAiKey' => $is_wp_ai_backend || ! empty( get_option( 'themeisle_open_ai_api_key' ) ),
'aiClientActive' => $is_wp_ai_backend,
'hasAIProvider' => $ai_provider_status['hasAIProvider'],
'aiProviderSource' => $ai_provider_status['source'],
'hasPatternSources' => Template_Cloud::has_used_pattern_sources(),
)
);
Expand Down
5 changes: 5 additions & 0 deletions inc/plugins/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use ThemeIsle\GutenbergBlocks\Pro;
use ThemeIsle\GutenbergBlocks\Plugins\FSE_Onboarding;
use ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud;
use ThemeIsle\GutenbergBlocks\Server\AI_Client_Adaptor;

/**
* Class Dashboard
Expand Down Expand Up @@ -282,6 +283,10 @@ public function get_dashboard_data() {
),
'neveInstalled' => defined( 'NEVE_VERSION' ),
'hasPatternSources' => Template_Cloud::has_used_pattern_sources(),
'aiClientAvailable' => AI_Client_Adaptor::is_available(),
'aiClientSupported' => function_exists( 'wp_ai_client_prompt' ),
'aiBackendFallback' => AI_Client_Adaptor::is_fallback_active(),
'connectorsUrl' => esc_url( admin_url( 'options-connectors.php' ) ),
);

$global_data = apply_filters( 'otter_dashboard_data', $global_data );
Expand Down
14 changes: 14 additions & 0 deletions inc/plugins/class-options-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,20 @@ function ( $item ) {
)
);

register_setting(
'themeisle_blocks_settings',
'themeisle_otter_ai_backend',
array(
'type' => 'string',
'description' => __( 'The AI backend used by Otter AI features.', 'otter-blocks' ),
'sanitize_callback' => function ( $value ) {
return in_array( $value, array( 'auto', 'wp-ai-client', 'openai-key' ), true ) ? $value : 'auto';
},
'show_in_rest' => true,
'default' => 'auto',
)
);

register_setting(
'themeisle_blocks_settings',
'themeisle_otter_ai_usage',
Expand Down
Loading
Loading