Repository navigation
Conversation
Introduces has_ai_credentials() to check if AI credentials have been configured across registered AI provider connectors via database options, environment variables, or PHP constants. Also introduces the wp_has_ai_credentials filter and legacy wpai_has_ai_credentials filter for third-party extensions and backward compatibility. Props therssoftware. Fixes #64924.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Description
Trac Ticket: https://core.trac.wordpress.org/ticket/64924
This PR introduces the
has_ai_credentials(): boolhelper function to WordPress core.Plugins and core AI experiments frequently need to check whether a site has any AI credentials configured before enabling AI features or rendering settings that require an active AI provider.
Changes
has_ai_credentials(): booltowp-includes/connectors.php.ai_providerand inspects their configured authentication settings using_wp_connectors_get_api_key_source()across database options, constants, and environment variables.wp_supports_ai().wp_has_ai_credentialsfilter and backward-compatiblewpai_has_ai_credentialsfilter.tests/phpunit/tests/connectors/hasAiCredentials.php.Props @therssoftware