Skip to content

Connectors: Add connectors registry for extensibility#76364

Merged
gziolo merged 6 commits intotrunkfrom
add/connectors-registry
Mar 11, 2026
Merged

Connectors: Add connectors registry for extensibility#76364
gziolo merged 6 commits intotrunkfrom
add/connectors-registry

Conversation

@gziolo
Copy link
Copy Markdown
Member

@gziolo gziolo commented Mar 10, 2026

Summary

Ports the connectors registry from WordPress core (wordpress-develop#11175) to Gutenberg.

  • Introduces WP_Connector_Registry class (singleton) in lib/compat/wordpress-7.0/ managing connector registration with validation for IDs, required fields, and authentication methods
  • Polyfills public query functions with function_exists guards: wp_is_connector_registered(), wp_get_connector(), wp_get_connectors()
  • Polyfills _wp_connectors_resolve_ai_provider_logo_url() to convert plugin file paths to URLs for provider logos
  • Adds _gutenberg_connectors_init() that creates the registry, registers built-in connectors (merged with AI Client data), and fires wp_connectors_init action for plugin extensibility
  • Refactors _gutenberg_get_connector_settings() to build on wp_get_connectors() and enrich with logo URLs and plugin status
  • Core polyfills placed in lib/compat/wordpress-7.0/ following the standard pattern, with class_exists/function_exists guards to avoid double declarations

Test plan

  • PHP unit tests pass (1376 tests)
  • Connector E2E tests pass (6 tests)
  • PHPCS passes clean
  • Verify built-in connectors (openai, google, anthropic) are registered via the registry
  • Verify wp_is_connector_registered(), wp_get_connector(), wp_get_connectors() return expected data
  • Verify the wp_connectors_init action fires and allows plugins to register custom connectors
  • Verify calling WP_Connector_Registry::set_instance() outside init triggers _doing_it_wrong
  • Verify the Connectors settings page still works correctly

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

Flaky tests detected in d54af13.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22946168903
📝 Reported issues:

gziolo and others added 3 commits March 11, 2026 09:39
Ports the connectors registry from WordPress core (wordpress-develop#11175)
to Gutenberg. Introduces WP_Connector_Registry class and wp_connectors_init
action hook so plugins can register their own connectors alongside the
built-in defaults (Anthropic, Google, OpenAI).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…_get_connectors

Uses function_exists guards so plugins can use the wp_* names now and
seamlessly switch to core's implementation once WordPress 7.0 ships.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Move WP_Connector_Registry class and wp_* helper functions to
lib/compat/wordpress-7.0/ where other core polyfills live. This
aligns with the existing PHPCS exclude pattern for the default
text domain and keeps core-ported code in the standard location.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gziolo gziolo force-pushed the add/connectors-registry branch from 6aa9067 to 462a198 Compare March 11, 2026 08:39
@gziolo gziolo self-assigned this Mar 11, 2026
@gziolo gziolo added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience Connectors screen Tracks connectors screen related tasks Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Mar 11, 2026
@gziolo gziolo marked this pull request as ready for review March 11, 2026 08:44
@gziolo gziolo requested a review from spacedmonkey as a code owner March 11, 2026 08:44
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 11, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: gziolo <[email protected]>
Co-authored-by: felixarntz <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Extend WP_Connector_Registry to persist logo_url, removing the need
for a separate enrichment step. Resolve logo URLs from AI Client
metadata alongside name and description in _gutenberg_connectors_init.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
… core

Move the logo URL resolver to lib/compat/wordpress-7.0/connectors.php as
a polyfill for the _wp_connectors_resolve_ai_provider_logo_url function
being added to WP core. Remove the Gutenberg-prefixed version and its
unit tests, which will be covered by core.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gziolo
Copy link
Copy Markdown
Member Author

gziolo commented Mar 11, 2026

The latest commit polyfills _wp_connectors_resolve_ai_provider_logo_url from WP core instead of using a Gutenberg-prefixed version. Unit tests for this function are dropped since they'll live in core.


$name = $provider_metadata->getName();
$description = $provider_metadata->getDescription();
$logo_url = method_exists( $provider_metadata, 'getLogoPath' ) && $provider_metadata->getLogoPath()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should remove the method_exists check soon. At least in Core it should be removed as soon as that new php-ai-client version update has been committed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We need to commit PHP AI client update first.

@gziolo gziolo merged commit 4b5606b into trunk Mar 11, 2026
43 of 45 checks passed
@gziolo gziolo deleted the add/connectors-registry branch March 11, 2026 15:32
@github-actions github-actions bot added this to the Gutenberg 22.8 milestone Mar 11, 2026
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Mar 11, 2026
gutenbergplugin pushed a commit that referenced this pull request Mar 11, 2026
* Connectors: Add connectors registry for extensibility

Ports the connectors registry from WordPress core (wordpress-develop#11175)
to Gutenberg. Introduces WP_Connector_Registry class and wp_connectors_init
action hook so plugins can register their own connectors alongside the
built-in defaults (Anthropic, Google, OpenAI).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* Connectors: Polyfill wp_is_connector_registered, wp_get_connector, wp_get_connectors

Uses function_exists guards so plugins can use the wp_* names now and
seamlessly switch to core's implementation once WordPress 7.0 ships.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* Connectors: Move core polyfills to lib/compat/wordpress-7.0

Move WP_Connector_Registry class and wp_* helper functions to
lib/compat/wordpress-7.0/ where other core polyfills live. This
aligns with the existing PHPCS exclude pattern for the default
text domain and keeps core-ported code in the standard location.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* Connectors: Add backport changelog entry for wordpress-develop#11175

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* Connectors: Add logo_url support to registry and resolve during init

Extend WP_Connector_Registry to persist logo_url, removing the need
for a separate enrichment step. Resolve logo URLs from AI Client
metadata alongside name and description in _gutenberg_connectors_init.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* Connectors: Polyfill _wp_connectors_resolve_ai_provider_logo_url from core

Move the logo URL resolver to lib/compat/wordpress-7.0/connectors.php as
a polyfill for the _wp_connectors_resolve_ai_provider_logo_url function
being added to WP core. Remove the Gutenberg-prefixed version and its
unit tests, which will be covered by core.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>

Co-authored-by: gziolo <[email protected]>
Co-authored-by: felixarntz <[email protected]>
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Mar 11, 2026
@github-actions
Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: 53ebecf

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Mar 12, 2026
This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`.

The following changes are included:

- Navigation Editor: Allow any blocks to be inserted by gating contentOnly insertion rules to section blocks (WordPress/gutenberg#76189)
- Add `fetchpriority=low` to `IMG` tags in collapsed Details blocks (WordPress/gutenberg#76269)
- Connectors: Add logo URL support for custom AI providers (WordPress/gutenberg#76190)
- Cover Block: Add a playlist parameter to loop YouTube background videos. (WordPress/gutenberg#76004)
- Connectors: Memoize getConnectors selector (WordPress/gutenberg#76339)
- HTML Block: Fix broken layout (WordPress/gutenberg#76278)
- Tests: Skip connector logo URL tests when AI Client is unavailable (WordPress/gutenberg#76343)
- Navigation Overlay: Explicitly set fetchpriority for images (WordPress/gutenberg#76208)
- Connectors: Show API key source for env vars and wp-config constants (WordPress/gutenberg#76355)
- Connectors: Move API key validation and masking to REST dispatch level (WordPress/gutenberg#76327)
- Connectors: Replace apiFetch with core-data store selectors (WordPress/gutenberg#76333)
- Do not sync local attributes (WordPress/gutenberg#76267)
- Add `fetchpriority=low` to `IMG` tags in collapsed Accordion Item blocks (WordPress/gutenberg#76336)
- Implement disconnection debounce after initial connection (WordPress/gutenberg#76114)
- Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part (WordPress/gutenberg#76305)
- Fix: Document Bar: Back button flickers (WordPress/gutenberg#76320)
- RTC: Move event hooks from editor to core-data (WordPress/gutenberg#76358)
- fix(navigation): prevent right-justified submenu overflow in custom overlays (WordPress/gutenberg#76360)
- Connectors: Add connectors registry for extensibility (WordPress/gutenberg#76364)
- Connectors: Add empty state when no connectors are registered (WordPress/gutenberg#76375)
- Temp: Disable RTC in the site editor (WordPress/gutenberg#76223)
- Connectors: Add AI Experiments plugin callout with install/activate functionality (WordPress/gutenberg#76379)
- Editor: Polish real-time collaboration presence UI and move Avatar to editor package (WordPress/gutenberg#75652) (WordPress/gutenberg#76365)
- RTC: Add collaborator selection highlighting in rich text (WordPress/gutenberg#76107)
- Sync changes from `wp_enqueue_global_styles()` to Gutenberg override (WordPress/gutenberg#76127)
- [RTC] Fix performance regression on post save (WordPress/gutenberg#76370)
- Media: Enable AVIF support for client-side uploads (WordPress/gutenberg#76371)
- Connectors: Move plugin status computation to script module data (WordPress/gutenberg#76409)
- Revisions: Skip rendered fields in REST API responses (WordPress/gutenberg#76347)
- E2E Tests: Add connector setup flow tests with test AI provider (WordPress/gutenberg#76433)
- RTC: Place sync connection modal in front of popover (WordPress/gutenberg#76431)
- Connectors: Sync PHP code with WordPress Core (WordPress/gutenberg#76443)
- Editor: Show own presence in collaborative editing sessions (WordPress/gutenberg#76413) (WordPress/gutenberg#76445)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/9b8144036fa5faf75de43d4502ff9809fcf689ad…8c78d87453509661a9f28f978ba2c242d515563b.

Log created with:

git log --reverse --format="- %s" 9b8144036fa5faf75de43d4502ff9809fcf689ad..8c78d87453509661a9f28f978ba2c242d515563b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.


git-svn-id: https://develop.svn.wordpress.org/trunk@61988 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Mar 12, 2026
This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`.

The following changes are included:

- Navigation Editor: Allow any blocks to be inserted by gating contentOnly insertion rules to section blocks (WordPress/gutenberg#76189)
- Add `fetchpriority=low` to `IMG` tags in collapsed Details blocks (WordPress/gutenberg#76269)
- Connectors: Add logo URL support for custom AI providers (WordPress/gutenberg#76190)
- Cover Block: Add a playlist parameter to loop YouTube background videos. (WordPress/gutenberg#76004)
- Connectors: Memoize getConnectors selector (WordPress/gutenberg#76339)
- HTML Block: Fix broken layout (WordPress/gutenberg#76278)
- Tests: Skip connector logo URL tests when AI Client is unavailable (WordPress/gutenberg#76343)
- Navigation Overlay: Explicitly set fetchpriority for images (WordPress/gutenberg#76208)
- Connectors: Show API key source for env vars and wp-config constants (WordPress/gutenberg#76355)
- Connectors: Move API key validation and masking to REST dispatch level (WordPress/gutenberg#76327)
- Connectors: Replace apiFetch with core-data store selectors (WordPress/gutenberg#76333)
- Do not sync local attributes (WordPress/gutenberg#76267)
- Add `fetchpriority=low` to `IMG` tags in collapsed Accordion Item blocks (WordPress/gutenberg#76336)
- Implement disconnection debounce after initial connection (WordPress/gutenberg#76114)
- Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part (WordPress/gutenberg#76305)
- Fix: Document Bar: Back button flickers (WordPress/gutenberg#76320)
- RTC: Move event hooks from editor to core-data (WordPress/gutenberg#76358)
- fix(navigation): prevent right-justified submenu overflow in custom overlays (WordPress/gutenberg#76360)
- Connectors: Add connectors registry for extensibility (WordPress/gutenberg#76364)
- Connectors: Add empty state when no connectors are registered (WordPress/gutenberg#76375)
- Temp: Disable RTC in the site editor (WordPress/gutenberg#76223)
- Connectors: Add AI Experiments plugin callout with install/activate functionality (WordPress/gutenberg#76379)
- Editor: Polish real-time collaboration presence UI and move Avatar to editor package (WordPress/gutenberg#75652) (WordPress/gutenberg#76365)
- RTC: Add collaborator selection highlighting in rich text (WordPress/gutenberg#76107)
- Sync changes from `wp_enqueue_global_styles()` to Gutenberg override (WordPress/gutenberg#76127)
- [RTC] Fix performance regression on post save (WordPress/gutenberg#76370)
- Media: Enable AVIF support for client-side uploads (WordPress/gutenberg#76371)
- Connectors: Move plugin status computation to script module data (WordPress/gutenberg#76409)
- Revisions: Skip rendered fields in REST API responses (WordPress/gutenberg#76347)
- E2E Tests: Add connector setup flow tests with test AI provider (WordPress/gutenberg#76433)
- RTC: Place sync connection modal in front of popover (WordPress/gutenberg#76431)
- Connectors: Sync PHP code with WordPress Core (WordPress/gutenberg#76443)
- Editor: Show own presence in collaborative editing sessions (WordPress/gutenberg#76413) (WordPress/gutenberg#76445)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/9b8144036fa5faf75de43d4502ff9809fcf689ad…8c78d87453509661a9f28f978ba2c242d515563b.

Log created with:

git log --reverse --format="- %s" 9b8144036fa5faf75de43d4502ff9809fcf689ad..8c78d87453509661a9f28f978ba2c242d515563b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.

Built from https://develop.svn.wordpress.org/trunk@61988


git-svn-id: http://core.svn.wordpress.org/trunk@61270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core Connectors screen Tracks connectors screen related tasks [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants