Skip to content

Commit e2cf039

Browse files
Connectors: Respect custom setting_name in connector registration.
`WP_Connector_Registry::register()` always auto-generates the `setting_name` for connectors with `api_key` authentication, ignoring any caller-provided value. This prevents connectors from using existing WordPress options as their API key storage. This change checks for a non-empty `setting_name` in the provided args before falling back to the auto-generated name. Props jorgefilipecosta, gziolo. Fixes #64957. git-svn-id: https://develop.svn.wordpress.org/trunk@62116 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4d3b0b9 commit e2cf039

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/wp-includes/class-wp-connector-registry.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ public function register( string $id, array $args ): ?array {
192192
if ( ! empty( $args['authentication']['credentials_url'] ) && is_string( $args['authentication']['credentials_url'] ) ) {
193193
$connector['authentication']['credentials_url'] = $args['authentication']['credentials_url'];
194194
}
195-
$connector['authentication']['setting_name'] = 'connectors_ai_' . str_replace( '-', '_', $id ) . '_api_key';
195+
if ( ! empty( $args['authentication']['setting_name'] ) && is_string( $args['authentication']['setting_name'] ) ) {
196+
$connector['authentication']['setting_name'] = $args['authentication']['setting_name'];
197+
} else {
198+
$connector['authentication']['setting_name'] = 'connectors_ai_' . str_replace( '-', '_', $id ) . '_api_key';
199+
}
196200
}
197201

198202
if ( ! empty( $args['plugin'] ) && is_array( $args['plugin'] ) ) {

0 commit comments

Comments
 (0)