wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
_wp_connectors_is_ai_api_key_valid is private and should not be used in themes or plugins directly.
_wp_connectors_is_ai_api_key_valid › WordPress Function
Seit7.0.0
Veraltetn/v
› _wp_connectors_is_ai_api_key_valid ( $key, $provider_id )
| Zugriff: |
|
| Parameter: (2) |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Checks whether an API key is valid for a given provider.
Quellcode
function _wp_connectors_is_ai_api_key_valid( string $key, string $provider_id ): ?bool {
try {
$registry = AiClient::defaultRegistry();
if ( ! $registry->hasProvider( $provider_id ) ) {
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: %s: AI provider ID. */
__( 'The provider "%s" is not registered in the AI client registry.' ),
$provider_id
),
'7.0.0'
);
return null;
}
$registry->setProviderRequestAuthentication(
$provider_id,
new ApiKeyRequestAuthentication( $key )
);
return $registry->isProviderConfigured( $provider_id );
} catch ( Exception $e ) {
wp_trigger_error( __FUNCTION__, $e->getMessage() );
return null;
}
}