Skip to content

Commit 1aec060

Browse files
gzioloclaude
andcommitted
Connectors: Sort providers alphabetically and scope settings to AI type.
Addresses review feedback: - Reorder default providers alphabetically (Anthropic, Google, OpenAI). - Sort all registered providers with `ksort()` for neutral ordering. - Add `ai_provider` type check in settings registration to prevent AI-specific sanitize/description logic from applying to other types. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 20ca4e7 commit 1aec060

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/wp-includes/connectors.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ function _wp_connectors_get_real_api_key( string $option_name, callable $mask_ca
139139
*/
140140
function _wp_connectors_get_connector_settings(): array {
141141
$connectors = array(
142+
'anthropic' => array(
143+
'name' => 'Anthropic',
144+
'description' => __( 'Text generation with Claude.' ),
145+
'type' => 'ai_provider',
146+
'plugin' => array(
147+
'slug' => 'ai-provider-for-anthropic',
148+
),
149+
'authentication' => array(
150+
'method' => 'api_key',
151+
'credentials_url' => 'https://platform.claude.com/settings/keys',
152+
),
153+
),
142154
'google' => array(
143155
'name' => 'Google',
144156
'description' => __( 'Text and image generation with Gemini and Imagen.' ),
@@ -163,18 +175,6 @@ function _wp_connectors_get_connector_settings(): array {
163175
'credentials_url' => 'https://platform.openai.com/api-keys',
164176
),
165177
),
166-
'anthropic' => array(
167-
'name' => 'Anthropic',
168-
'description' => __( 'Text generation with Claude.' ),
169-
'type' => 'ai_provider',
170-
'plugin' => array(
171-
'slug' => 'ai-provider-for-anthropic',
172-
),
173-
'authentication' => array(
174-
'method' => 'api_key',
175-
'credentials_url' => 'https://platform.claude.com/settings/keys',
176-
),
177-
),
178178
);
179179

180180
$registry = AiClient::defaultRegistry();
@@ -222,6 +222,8 @@ function _wp_connectors_get_connector_settings(): array {
222222
}
223223
}
224224

225+
ksort( $connectors );
226+
225227
// Add setting_name for connectors that use API key authentication.
226228
foreach ( $connectors as $connector_id => $connector ) {
227229
if ( 'api_key' === $connector['authentication']['method'] ) {
@@ -304,7 +306,7 @@ function _wp_connectors_validate_keys_in_rest( WP_REST_Response $response, WP_RE
304306
function _wp_register_default_connector_settings(): void {
305307
foreach ( _wp_connectors_get_connector_settings() as $connector_id => $connector_data ) {
306308
$auth = $connector_data['authentication'];
307-
if ( 'api_key' !== $auth['method'] || empty( $auth['setting_name'] ) ) {
309+
if ( 'ai_provider' !== $connector_data['type'] || 'api_key' !== $auth['method'] || empty( $auth['setting_name'] ) ) {
308310
continue;
309311
}
310312

0 commit comments

Comments
 (0)