@@ -60,7 +60,7 @@ function _wp_connectors_mask_api_key( string $key ): string {
6060 * @param string $provider_id The WP AI client provider ID.
6161 * @return bool|null True if valid, false if invalid, null if unable to determine.
6262 */
63- function _wp_connectors_is_api_key_valid ( string $ key , string $ provider_id ): ?bool {
63+ function _wp_connectors_is_ai_api_key_valid ( string $ key , string $ provider_id ): ?bool {
6464 try {
6565 $ registry = AiClient::defaultRegistry ();
6666
@@ -122,7 +122,10 @@ function _wp_connectors_get_real_api_key( string $option_name, callable $mask_ca
122122 *
123123 * @type string $name The connector's display name.
124124 * @type string $description The connector's description.
125- * @type string $type The connector type: 'ai_provider'.
125+ * @type string $type The connector type. Currently, only 'ai_provider' is supported.
126+ * @type array $plugin Optional. Plugin data for install/activate UI.
127+ * @type string $slug The WordPress.org plugin slug.
128+ * }
126129 * @type array $authentication {
127130 * Authentication configuration. When method is 'api_key', includes
128131 * credentials_url and setting_name. When 'none', only method is present.
@@ -137,27 +140,36 @@ function _wp_connectors_get_real_api_key( string $option_name, callable $mask_ca
137140function _wp_connectors_get_connector_settings (): array {
138141 $ connectors = array (
139142 'google ' => array (
140- 'name ' => 'Gemini ' ,
141- 'description ' => __ ( 'Content generation, translation, and vision with Google \' s Gemini. ' ),
143+ 'name ' => 'Google ' ,
144+ 'description ' => __ ( 'Text and image generation with Gemini and Imagen . ' ),
142145 'type ' => 'ai_provider ' ,
146+ 'plugin ' => array (
147+ 'slug ' => 'ai-provider-for-google ' ,
148+ ),
143149 'authentication ' => array (
144150 'method ' => 'api_key ' ,
145151 'credentials_url ' => 'https://aistudio.google.com/api-keys ' ,
146152 ),
147153 ),
148154 'openai ' => array (
149155 'name ' => 'OpenAI ' ,
150- 'description ' => __ ( 'Text, image, and code generation with GPT and DALL -E. ' ),
156+ 'description ' => __ ( 'Text and image generation with GPT and Dall -E. ' ),
151157 'type ' => 'ai_provider ' ,
158+ 'plugin ' => array (
159+ 'slug ' => 'ai-provider-for-openai ' ,
160+ ),
152161 'authentication ' => array (
153162 'method ' => 'api_key ' ,
154163 'credentials_url ' => 'https://platform.openai.com/api-keys ' ,
155164 ),
156165 ),
157166 'anthropic ' => array (
158- 'name ' => 'Claude ' ,
159- 'description ' => __ ( 'Writing, research, and analysis with Claude. ' ),
167+ 'name ' => 'Anthropic ' ,
168+ 'description ' => __ ( 'Text generation with Claude. ' ),
160169 'type ' => 'ai_provider ' ,
170+ 'plugin ' => array (
171+ 'slug ' => 'ai-provider-for-anthropic ' ,
172+ ),
161173 'authentication ' => array (
162174 'method ' => 'api_key ' ,
163175 'credentials_url ' => 'https://platform.claude.com/settings/keys ' ,
@@ -259,7 +271,7 @@ function _wp_connectors_validate_keys_in_rest( WP_REST_Response $response, WP_RE
259271
260272 foreach ( _wp_connectors_get_connector_settings () as $ connector_id => $ connector_data ) {
261273 $ auth = $ connector_data ['authentication ' ];
262- if ( 'api_key ' !== $ auth ['method ' ] || empty ( $ auth ['setting_name ' ] ) ) {
274+ if ( 'ai_provider ' !== $ connector_data [ ' type ' ] || ' api_key ' !== $ auth ['method ' ] || empty ( $ auth ['setting_name ' ] ) ) {
263275 continue ;
264276 }
265277
@@ -273,7 +285,7 @@ function _wp_connectors_validate_keys_in_rest( WP_REST_Response $response, WP_RE
273285 continue ;
274286 }
275287
276- if ( true !== _wp_connectors_is_api_key_valid ( $ real_key , $ connector_id ) ) {
288+ if ( true !== _wp_connectors_is_ai_api_key_valid ( $ real_key , $ connector_id ) ) {
277289 $ data [ $ setting_name ] = 'invalid_key ' ;
278290 }
279291 }
@@ -320,7 +332,7 @@ function _wp_register_default_connector_settings(): void {
320332 return $ value ;
321333 }
322334
323- $ valid = _wp_connectors_is_api_key_valid ( $ value , $ connector_id );
335+ $ valid = _wp_connectors_is_ai_api_key_valid ( $ value , $ connector_id );
324336 return true === $ valid ? $ value : '' ;
325337 },
326338 )
@@ -385,12 +397,18 @@ function _wp_connectors_get_connector_script_module_data( array $data ): array {
385397 $ auth_out ['credentialsUrl ' ] = $ auth ['credentials_url ' ] ?? null ;
386398 }
387399
388- $ connectors [ $ connector_id ] = array (
400+ $ connector_out = array (
389401 'name ' => $ connector_data ['name ' ],
390402 'description ' => $ connector_data ['description ' ],
391403 'type ' => $ connector_data ['type ' ],
392404 'authentication ' => $ auth_out ,
393405 );
406+
407+ if ( ! empty ( $ connector_data ['plugin ' ] ) ) {
408+ $ connector_out ['plugin ' ] = $ connector_data ['plugin ' ];
409+ }
410+
411+ $ connectors [ $ connector_id ] = $ connector_out ;
394412 }
395413 $ data ['connectors ' ] = $ connectors ;
396414 return $ data ;
0 commit comments