wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
_wp_connectors_pass_default_keys_to_ai_client is private and should not be used in themes or plugins directly.
_wp_connectors_pass_default_keys_to_ai_client › WordPress Function
Seit7.0.0
Veraltetn/v
› _wp_connectors_pass_default_keys_to_ai_client ( Keine Parameter )
| Zugriff: |
|
| Definiert in: |
|
| Codex: |
Passes stored connector API keys to the WP AI client.
Quellcode
function _wp_connectors_pass_default_keys_to_ai_client(): void {
try {
$ai_registry = AiClient::defaultRegistry();
foreach ( wp_get_connectors() as $connector_id => $connector_data ) {
if ( 'ai_provider' !== $connector_data['type'] ) {
continue;
}
$auth = $connector_data['authentication'];
if ( 'api_key' !== $auth['method'] || empty( $auth['setting_name'] ) ) {
continue;
}
if ( ! $ai_registry->hasProvider( $connector_id ) ) {
continue;
}
// Skip if the key is already provided via env var or constant.
$key_source = _wp_connectors_get_api_key_source( $auth['setting_name'], $auth['env_var_name'] ?? '', $auth['constant_name'] ?? '' );
if ( 'env' === $key_source || 'constant' === $key_source ) {
continue;
}
$api_key = get_option( $auth['setting_name'], '' );
if ( ! is_string( $api_key ) || '' === $api_key ) {
continue;
}
$ai_registry->setProviderRequestAuthentication(
$connector_id,
new ApiKeyRequestAuthentication( $api_key )
);
}
} catch ( Exception $e ) {
wp_trigger_error( __FUNCTION__, $e->getMessage() );
}
}