Make WordPress Core

Changeset 62116 for trunk


Ignore:
Timestamp:
03/26/2026 11:43:52 AM (2 weeks ago)
Author:
jorgefilipecosta
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-connector-registry.php

    r62067 r62116  
    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
Note: See TracChangeset for help on using the changeset viewer.