Commit 7f7f2ea
Connectors: Dynamically register providers from WP AI Client registry (#76014)
* Connectors: Dynamically register providers from WP AI Client registry
Polyfills WordPress/wordpress-develop#11080 for the Gutenberg plugin:
- Expand `_gutenberg_get_provider_settings()` to dynamically fetch
registered providers from the AI Client registry, in addition to the
three hardcoded featured providers (Gemini, OpenAI, Claude).
- Restructure the return value to be keyed by provider ID with `name`,
`description`, `credentials_url` at the top level and `settings` as a
nested array.
- Filter out providers whose authentication method is not `api_key`.
- Update all consumer functions to use the new structure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Expose provider settings to the script module
Pass provider data (name, description, credentials URL, setting keys)
to the `connectors-wp-admin` script module via the
`script_module_data` filter, making it available as inline JSON for
the frontend to consume.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Register connectors dynamically from server-provided data
Replace hardcoded per-provider connector components with a single
dynamic loop that reads provider data from the script module data
JSON tag. Known providers retain their SVG logos via a client-side
map; third-party providers from the registry render without a logo.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Connectors: Use ucwords fallback for empty provider name
When a third-party provider from the AI Client registry has no name,
fall back to ucwords( $provider_id ) for a reasonable display label.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Add authentication_method to provider data structure
Expose authentication_method ('api_key' or 'none') in provider settings
instead of silently filtering out non-API-key providers. This makes the
public-facing interfaces extensible for future authentication methods
while still only implementing api_key support for now.
- Include all registered providers regardless of auth method
- Conditionally generate settings sub-array only for api_key providers
- Expose authenticationMethod in script module data for the frontend
- Skip non-api_key providers in the frontend registration loop
- Rename ProviderConnector to ApiKeyProviderConnector for clarity
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Add type field to distinguish AI providers from other connectors
Add a 'type' field ('ai_provider') to the provider data structure so
credentials are only passed to the WP AI Client for AI providers. The
frontend also filters by type, only rendering connectors for AI
providers. This separates AI providers from future non-AI connectors
and makes the intent of the API explicit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Group authentication fields into sub-object and eliminate settings duplication
Restructure provider data so credentials_url, setting_name, and method
live together in an authentication sub-object rather than as flat
top-level fields. Remove the redundant settings array from
_gutenberg_get_provider_settings() and move register_setting logic
(label, description, sanitize) into the consumer function. Update all
PHP consumers to read from authentication directly. On the frontend,
change ProviderAuthentication to a discriminated union type for
type-safe access after narrowing on method.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Rename _gutenberg_get_provider_settings to _gutenberg_get_connector_settings
Use the domain term "connector" consistently with the rest of the
codebase (settings group, option names, script module filter).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Clarify authentication docblock for none method
Document that credentials_url and setting_name are only present when
method is 'api_key' and absent when method is 'none'.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Use URL hostname for help label instead of regex stripping
Replace manual regex URL stripping with new URL().hostname for a
cleaner, more robust extraction of the domain name used as the help
link label.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Use type-based namespace for connector names
Derive the connector name namespace from data.type instead of
hardcoding 'core/'. Sanitize both parts to only allow letters, numbers,
and hyphens. This produces names like 'ai-provider/google'.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Rename ApiKeyProviderConnector and derive helpLabel internally
Rename ApiKeyProviderConnector to ApiKeyConnector and move helpLabel
derivation from the registration loop into the component itself, since
it already receives helpUrl.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Update lib/experimental/connectors/default-connectors.php
Co-authored-by: Felix Arntz <flixos90@gmail.com>
* Connectors: Rename _gutenberg_is_api_key_valid to _gutenberg_is_ai_api_key_valid
The function is AI-provider-specific, so the name should reflect that.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Move sanitize helper outside the loop
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Pass plugin data from server instead of deriving slug client-side
Hardcode plugin slugs for the three featured AI providers in PHP within
a `plugin` sub-object and pass them to the client via script module data.
When no plugin data is provided (e.g. dynamically registered providers),
the install/activate UI is skipped and the connector assumes the plugin
is already active.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add backport changelog entry for Core PR #11080
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Connectors: Add remove_filter for Core script module data function
Ensures the Gutenberg version overrides the equivalent Core function
(_wp_connectors_get_connector_script_module_data), consistent with the
pattern used by the other connector functions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Felix Arntz <flixos90@gmail.com>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: raftaar1191 <raftaar1191@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>1 parent f167589 commit 7f7f2ea
File tree
4 files changed
+296
-119
lines changed- backport-changelog/7.0
- lib/experimental/connectors
- routes/connectors-home
4 files changed
+296
-119
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
86 | 107 | | |
87 | | - | |
88 | | - | |
| 108 | + | |
| 109 | + | |
89 | 110 | | |
90 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
91 | 121 | | |
92 | 122 | | |
93 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
94 | 133 | | |
95 | 134 | | |
96 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
97 | 145 | | |
98 | 146 | | |
99 | 147 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 148 | + | |
103 | 149 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
127 | 191 | | |
128 | 192 | | |
129 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
130 | 201 | | |
131 | 202 | | |
132 | 203 | | |
| |||
169 | 240 | | |
170 | 241 | | |
171 | 242 | | |
172 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
173 | 250 | | |
174 | 251 | | |
175 | 252 | | |
176 | 253 | | |
177 | | - | |
| 254 | + | |
178 | 255 | | |
179 | 256 | | |
180 | 257 | | |
181 | 258 | | |
182 | | - | |
| 259 | + | |
183 | 260 | | |
184 | 261 | | |
185 | 262 | | |
| |||
200 | 277 | | |
201 | 278 | | |
202 | 279 | | |
203 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
204 | 287 | | |
205 | 288 | | |
206 | 289 | | |
207 | 290 | | |
208 | 291 | | |
209 | | - | |
210 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
211 | 302 | | |
212 | 303 | | |
213 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
214 | 313 | | |
215 | 314 | | |
216 | | - | |
| 315 | + | |
217 | 316 | | |
218 | 317 | | |
219 | 318 | | |
| |||
231 | 330 | | |
232 | 331 | | |
233 | 332 | | |
234 | | - | |
235 | | - | |
236 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
237 | 345 | | |
238 | 346 | | |
239 | 347 | | |
240 | 348 | | |
241 | | - | |
| 349 | + | |
242 | 350 | | |
243 | 351 | | |
244 | 352 | | |
| |||
248 | 356 | | |
249 | 357 | | |
250 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
0 commit comments