Changeset 62056 for trunk/src/wp-includes/class-wp-connector-registry.php
- Timestamp:
- 03/19/2026 06:50:08 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-connector-registry.php
r62032 r62056 68 68 * Validates the provided arguments and stores the connector in the registry. 69 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. 70 * generated using the pattern `connectors_ai_{$id}_api_key`, with hyphens in the ID 71 * normalized to underscores (e.g., connector ID `openai` produces 72 * `connectors_ai_openai_api_key`, and `azure-openai` produces 73 * `connectors_ai_azure_openai_api_key`). This setting name is used for the Settings 74 * API registration and REST API exposure. 73 75 * 74 76 * Registering a connector with an ID that is already registered will trigger a … … 81 83 * 82 84 * @param string $id The unique connector identifier. Must match the pattern 83 * `/^[a-z0-9_ ]+$/` (lowercase alphanumericand underscores only).85 * `/^[a-z0-9_-]+$/` (lowercase alphanumeric, hyphens, and underscores only). 84 86 * @param array $args { 85 87 * An associative array of arguments for the connector. … … 107 109 */ 108 110 public function register( string $id, array $args ): ?array { 109 if ( ! preg_match( '/^[a-z0-9_ ]+$/', $id ) ) {111 if ( ! preg_match( '/^[a-z0-9_-]+$/', $id ) ) { 110 112 _doing_it_wrong( 111 113 __METHOD__, 112 114 __( 113 'Connector ID must contain only lowercase alphanumeric characters and underscores.'115 'Connector ID must contain only lowercase alphanumeric characters, hyphens, and underscores.' 114 116 ), 115 117 '7.0.0' … … 186 188 $connector['authentication']['credentials_url'] = $args['authentication']['credentials_url']; 187 189 } 188 $connector['authentication']['setting_name'] = "connectors_ai_{$id}_api_key";190 $connector['authentication']['setting_name'] = 'connectors_ai_' . str_replace( '-', '_', $id ) . '_api_key'; 189 191 } 190 192
Note:
See TracChangeset
for help on using the changeset viewer.