Connectors: Improve PHPDoc for developer documentation#11244
Connectors: Improve PHPDoc for developer documentation#11244gziolo wants to merge 15 commits intoWordPress:trunkfrom
Conversation
Add detailed documentation covering the Connectors API overview, working with connectors, initialization lifecycle, and authentication methods to improve developer discoverability and understanding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Example blocks to wp_is_connector_registered(), wp_get_connector(), and wp_get_connectors() to match the documentation style used in the Abilities API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add consistent @see tags linking related public functions (wp_is_connector_registered, wp_get_connector, wp_get_connectors) to each other, improving navigability for developers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… sequence. Document the full initialization lifecycle including registry creation, built-in connector defaults, AI Client metadata merging, and the wp_connectors_init action firing order. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…PHPDoc. Document that AI provider plugins registered with the WP AI Client get automatic connector integration without explicit registration. Add new sections covering admin UI integration scope (ai_provider + api_key only), the auto-generated setting_name convention, and that other configurations require client-side JS for frontend UI with plans to extend support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rride. The previous examples showed registering a new ai_provider connector manually, which contradicts the auto-discovery model. Replace with examples showing the realistic use case: overriding metadata on an existing auto-discovered connector. Add forward-looking note about future connector types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The registry rejects duplicate IDs with _doing_it_wrong(), so overriding an existing connector requires unregistering first. Guard with is_registered() to avoid warnings when the connector is absent, then use unregister() return value to get the data, modify, and re-register. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… limitations. Add @see reference to WordPress\AiClient\Providers\ProviderRegistry so developers know where to start for AI provider integration. Rework the Custom Connectors section to explicitly state that non-AI-provider connector types are not yet fully supported and only ai_provider with api_key auth receives automatic admin UI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…ctor_Registry. Add public API function references and @see tags to guide developers toward the correct entry points. Clarify that this is an internal class and plugins interact via wp_connectors_init action. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…havior in register().
Explain that api_key connectors get an auto-generated setting_name
using the pattern connectors_ai_{id}_api_key. Document that duplicate
IDs are rejected with _doing_it_wrong() and add @see to unregister().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
references. Document that unregister() returns connector data for the override pattern, warn about _doing_it_wrong() on missing IDs, and add @see to register() and is_registered(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Warn developers that calling get_registered() with an unregistered ID triggers a _doing_it_wrong() notice, and suggest using is_registered() to check first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clarify that set_instance() is called by _wp_connectors_init() during init and must not be called outside of that context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expands the "Admin UI Integration" section in the file-level docblock to explain what the Settings → Connectors screen renders for each registry field (name, logo, plugin install/activate, credentials URL, key source). Also enriches the `_wp_connectors_get_connector_script_module_data()` docblock to describe its role bridging the PHP registry and the frontend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Aligns Overview, Initialization Lifecycle, and _wp_connectors_init() to reflect that the wp_connectors_init action is primarily for overriding metadata on existing connectors, not just registering new ones. Expands _wp_register_default_connector_settings() to document its scope. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dev NoteIntroducing the Connectors API in WordPress 7.0WordPress 7.0 introduces the Connectors API — a new framework for registering and managing connections to external services. The initial focus is on AI providers, giving WordPress a standardized way to handle API key management, provider discovery, and admin UI for configuring AI services. This post walks through what the Connectors API does, how it works under the hood, and what plugin developers need to know. Table of Contents
What is a connector?A connector represents a connection to an external service. Each connector carries standardized metadata — a display name, description, logo, authentication configuration, and an optional association with a WordPress.org plugin. The system currently focuses on AI providers, but the architecture is designed to support additional connector types in future releases. WordPress 7.0 ships with three built-in connectors: Anthropic, Google, and OpenAI. These are registered automatically during initialization and appear on the new Settings > Connectors admin screen. Each connector is stored as an associative array with the following shape: array(
'name' => 'Anthropic',
'description' => 'Text generation with Claude.',
'logo_url' => 'https://example.com/anthropic-logo.svg',
'type' => 'ai_provider',
'authentication' => array(
'method' => 'api_key',
'credentials_url' => 'https://platform.claude.com/settings/keys',
'setting_name' => 'connectors_ai_anthropic_api_key',
),
'plugin' => array(
'slug' => 'ai-provider-for-anthropic',
),
)How AI providers are auto-discoveredIf you're building an AI provider plugin that integrates with the WP AI Client, you don't need to register a connector manually. The Connectors API automatically discovers providers from the WP AI Client's Here's what happens during initialization:
The authentication method ( In short: if your AI provider plugin registers with the WP AI Client, the connector is created for you. No additional code is needed. The Settings > Connectors admin screenRegistered
Connectors with other authentication methods or types are stored in the PHP registry and exposed via the script module data, but currently require a client-side JavaScript registration for custom frontend UI. Authentication and API key managementConnectors support two authentication methods:
API key source priorityFor
The naming convention follows the pattern Public API functionsThe Connectors API provides three public functions for querying the registry. These are available after
|
| Method | Description |
|---|---|
register( $id, $args ) |
Register a new connector. Returns the connector data or null on failure. |
unregister( $id ) |
Remove a connector and return its data. Returns null if not found. |
is_registered( $id ) |
Check if a connector exists. |
get_registered( $id ) |
Retrieve a single connector's data. |
get_all_registered() |
Retrieve all registered connectors. |
Outside of the wp_connectors_init callback, use the public API functions (wp_get_connector(), wp_get_connectors(), wp_is_connector_registered()) instead of accessing the registry directly.
The initialization lifecycle
Understanding the initialization sequence helps when deciding where to hook in:
During the init action, _wp_connectors_init() runs and:
- Creates the
WP_Connector_Registrysingleton. - Registers built-in connectors (Anthropic, Google, OpenAI) with hardcoded defaults.
- Auto-discovers providers from the WP AI Client registry and merges their metadata on top of defaults.
- Fires the
wp_connectors_initaction — this is where plugins override metadata or register additional connectors.
The wp_connectors_init action is the only supported entry point for modifying the registry. Attempting to set the registry instance outside of init triggers a _doing_it_wrong() notice.
Looking ahead
The Connectors API in WordPress 7.0 is scoped to AI providers, but the underlying architecture is designed to grow. Currently, only ai_provider connectors with api_key authentication receive the full admin UI treatment. The PHP registry already accepts any connector type — what's missing is the frontend integration for non-AI connector types.
Future releases are expected to:
- Expand support for additional authentication methods beyond
api_keyandnone. - Lift the
ai_providertype restriction for the admin screen. - Provide a client-side JavaScript registration API for custom connector UI.
When those capabilities land, the wp_connectors_init action will be the primary hook for registering new connector types.
Props to @jorgefilipecosta, @shaunandrews, @felixarntz, @Jameswlepage, @gziolo and others for contributing to the Connectors API.
#7-0, #dev-notes
Trac ticket: https://core.trac.wordpress.org/ticket/64791
Follow-up for #11175
Summary
connectors.phpcovering overview, AI provider auto-discovery, admin UI integration, custom connectors, initialization lifecycle, and authentication.plugin.slug,credentials_url,logo_url, key source) map to the Settings → Connectors admin screen.@seecross-references to public API functions (wp_get_connector(),wp_get_connectors(),wp_is_connector_registered()).WP_Connector_Registryforregister(),unregister(),get_registered(), andset_instance()with behavior details,@seereferences, and override patterns._wp_connectors_get_connector_script_module_data()as the bridge between the PHP registry and the frontend admin UI.Test plan
🤖 Generated with Claude Code