Changeset 62032 for trunk/src/wp-includes/class-wp-connector-registry.php
- Timestamp:
- 03/16/2026 08:18:21 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-connector-registry.php
r61983 r62032 1 1 <?php 2 2 /** 3 * Connectors API 4 * 5 * Defines WP_Connector_Registry class. 3 * Connectors API: WP_Connector_Registry class. 6 4 * 7 5 * @package WordPress … … 13 11 * Manages the registration and lookup of connectors. 14 12 * 13 * This is an internal class. Use the public API functions to interact with connectors: 14 * 15 * - `wp_is_connector_registered()` — check if a connector exists. 16 * - `wp_get_connector()` — retrieve a single connector's data. 17 * - `wp_get_connectors()` — retrieve all registered connectors. 18 * 19 * Plugins receive the registry instance via the `wp_connectors_init` action 20 * to register or override connectors directly. 21 * 15 22 * @since 7.0.0 16 23 * @access private 24 * 25 * @see wp_is_connector_registered() 26 * @see wp_get_connector() 27 * @see wp_get_connectors() 28 * @see _wp_connectors_init() 17 29 * 18 30 * @phpstan-type Connector array{ … … 54 66 * Registers a new connector. 55 67 * 56 * @since 7.0.0 57 * 58 * @param string $id The unique connector identifier. Must contain only lowercase 59 * alphanumeric characters and underscores. 68 * Validates the provided arguments and stores the connector in the registry. 69 * For connectors with `api_key` authentication, a `setting_name` is automatically 70 * generated using the pattern `connectors_ai_{$id}_api_key` (e.g., connector ID 71 * `openai` produces `connectors_ai_openai_api_key`). This setting name is used 72 * for the Settings API registration and REST API exposure. 73 * 74 * Registering a connector with an ID that is already registered will trigger a 75 * `_doing_it_wrong()` notice and return `null`. To override an existing connector, 76 * call `unregister()` first. 77 * 78 * @since 7.0.0 79 * 80 * @see WP_Connector_Registry::unregister() 81 * 82 * @param string $id The unique connector identifier. Must match the pattern 83 * `/^[a-z0-9_]+$/` (lowercase alphanumeric and underscores only). 60 84 * @param array $args { 61 85 * An associative array of arguments for the connector. … … 176 200 * Unregisters a connector. 177 201 * 178 * @since 7.0.0 202 * Returns the connector data on success, which can be modified and passed 203 * back to `register()` to override a connector's metadata. 204 * 205 * Triggers a `_doing_it_wrong()` notice if the connector is not registered. 206 * Use `is_registered()` to check first when the connector may not exist. 207 * 208 * @since 7.0.0 209 * 210 * @see WP_Connector_Registry::register() 211 * @see WP_Connector_Registry::is_registered() 179 212 * 180 213 * @param string $id The connector identifier. … … 237 270 * 238 271 * Do not use this method directly. Instead, use the `wp_get_connector()` function. 272 * 273 * Triggers a `_doing_it_wrong()` notice if the connector is not registered. 274 * Use `is_registered()` to check first when the connector may not exist. 239 275 * 240 276 * @since 7.0.0 … … 273 309 * Sets the main instance of the registry class. 274 310 * 311 * Called by `_wp_connectors_init()` during the `init` action. Must not be 312 * called outside of that context. 313 * 275 314 * @since 7.0.0 276 315 * @access private 316 * 317 * @see _wp_connectors_init() 277 318 * 278 319 * @param WP_Connector_Registry $registry The registry instance.
Note:
See TracChangeset
for help on using the changeset viewer.