From 2cefca315be55104968158c73037a053d8a99cdf Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 13 Apr 2026 17:36:19 +0100 Subject: [PATCH 1/2] Connectors: Gate non-AI default setting auto-registration --- .../connectors/default-connectors.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/experimental/connectors/default-connectors.php b/lib/experimental/connectors/default-connectors.php index 2d08f162738004..5cf91391f93000 100644 --- a/lib/experimental/connectors/default-connectors.php +++ b/lib/experimental/connectors/default-connectors.php @@ -387,9 +387,19 @@ function _gutenberg_register_default_connector_settings(): void { continue; } - // For AI providers, skip if the provider is not in the AI Client registry. - if ( 'ai_provider' === $connector_data['type'] && ! $ai_registry->hasProvider( $connector_id ) ) { - continue; + if ( 'ai_provider' === $connector_data['type'] ) { + // For AI providers, skip if the provider is not in the AI Client registry. + if ( ! $ai_registry->hasProvider( $connector_id ) ) { + continue; + } + } else { + if ( ! isset( $connector_data['plugin']['is_active'] ) || ! is_callable( $connector_data['plugin']['is_active'] ) ) { + continue; + } + + if ( ! call_user_func( $connector_data['plugin']['is_active'] ) ) { + continue; + } } register_setting( From be86d4243d20fbe71db55f50dbcd62f24e3b0fa3 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 4 May 2026 18:04:19 +0100 Subject: [PATCH 2/2] Connectors: Unify default setting auto-registration gate Replace the AI/non-AI branch in _gutenberg_register_default_connector_settings() with a single plugin.is_active check, matching core's _wp_register_default_connector_settings() (wordpress-develop PR 11564, commit d141ecb7a7). Drop the now-unused $ai_registry local; iterate values only since $connector_id is no longer referenced. Depends on the registry/AI-provider is_active wiring in WordPress/gutenberg#77897 (backport of wordpress-develop PR 11565): without that, default AI providers have no plugin.is_active and would be silently skipped here. Add backport-changelog/7.0/11564.md. --- backport-changelog/7.0/11564.md | 1 + .../connectors/default-connectors.php | 20 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) create mode 100644 backport-changelog/7.0/11564.md diff --git a/backport-changelog/7.0/11564.md b/backport-changelog/7.0/11564.md new file mode 100644 index 00000000000000..c3438675ef56e4 --- /dev/null +++ b/backport-changelog/7.0/11564.md @@ -0,0 +1 @@ +https://github.com/WordPress/wordpress-develop/pull/11564 diff --git a/lib/experimental/connectors/default-connectors.php b/lib/experimental/connectors/default-connectors.php index 5cf91391f93000..e0a40f7d4509d0 100644 --- a/lib/experimental/connectors/default-connectors.php +++ b/lib/experimental/connectors/default-connectors.php @@ -373,10 +373,9 @@ function _gutenberg_connectors_rest_settings_dispatch( WP_REST_Response $respons * @access private */ function _gutenberg_register_default_connector_settings(): void { - $ai_registry = \WordPress\AiClient\AiClient::defaultRegistry(); $existing_settings = get_registered_settings(); - foreach ( wp_get_connectors() as $connector_id => $connector_data ) { + foreach ( wp_get_connectors() as $connector_data ) { $auth = $connector_data['authentication']; if ( 'api_key' !== $auth['method'] || empty( $auth['setting_name'] ) ) { continue; @@ -387,19 +386,12 @@ function _gutenberg_register_default_connector_settings(): void { continue; } - if ( 'ai_provider' === $connector_data['type'] ) { - // For AI providers, skip if the provider is not in the AI Client registry. - if ( ! $ai_registry->hasProvider( $connector_id ) ) { - continue; - } - } else { - if ( ! isset( $connector_data['plugin']['is_active'] ) || ! is_callable( $connector_data['plugin']['is_active'] ) ) { - continue; - } + if ( ! isset( $connector_data['plugin']['is_active'] ) || ! is_callable( $connector_data['plugin']['is_active'] ) ) { + continue; + } - if ( ! call_user_func( $connector_data['plugin']['is_active'] ) ) { - continue; - } + if ( ! call_user_func( $connector_data['plugin']['is_active'] ) ) { + continue; } register_setting(