mirror of
https://github.com/WordPress/WordPress.git
synced 2026-06-19 07:37:07 +00:00
Connectors: Gate default setting auto-registration on is_active.
Update `_wp_register_default_connector_settings()` to register a connector's default API key setting only when the connector's `plugin.is_active` callback returns `true`. Add tests covering the gate's branches: setting skipped when `is_active` returns `false`, setting registered when it returns `true`. Props jorgefilipecosta, gziolo, peterwilsoncc. Fixes #65099. Built from https://develop.svn.wordpress.org/trunk@62289 git-svn-id: http://core.svn.wordpress.org/trunk@61569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -549,10 +549,9 @@ add_filter( 'rest_post_dispatch', '_wp_connectors_rest_settings_dispatch', 10, 3
|
||||
* @access private
|
||||
*/
|
||||
function _wp_register_default_connector_settings(): void {
|
||||
$ai_registry = AiClient::defaultRegistry();
|
||||
$registered_settings = get_registered_settings();
|
||||
|
||||
foreach ( wp_get_connectors() as $connector_id => $connector_data ) {
|
||||
foreach ( wp_get_connectors() as $connector_data ) {
|
||||
$auth = $connector_data['authentication'];
|
||||
if ( 'api_key' !== $auth['method'] || empty( $auth['setting_name'] ) ) {
|
||||
continue;
|
||||
@@ -563,8 +562,11 @@ function _wp_register_default_connector_settings(): void {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For AI providers, skip if the provider is not in the AI Client registry.
|
||||
if ( 'ai_provider' === $connector_data['type'] && ! $ai_registry->hasProvider( $connector_id ) ) {
|
||||
if ( ! isset( $connector_data['plugin']['is_active'] ) || ! is_callable( $connector_data['plugin']['is_active'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! call_user_func( $connector_data['plugin']['is_active'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '7.1-alpha-62288';
|
||||
$wp_version = '7.1-alpha-62289';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user