-
Notifications
You must be signed in to change notification settings - Fork 2
Add wp ai is-supported #12
Copy link
Copy link
Closed
Labels
command:aiRelated to 'ai' commandRelated to 'ai' commandcommand:ai-statusRelated to 'ai status' commandRelated to 'ai status' commandenhancementNew feature or requestNew feature or requestscope:testingRelated to testingRelated to testing
Description
In WordPress 7.0 there is this new function for hosts and plugins to completely disable any AI features:
/**
* Returns whether AI features are supported in the current environment.
*
* @since 7.0.0
*
* @return bool Whether AI features are supported.
*/
function wp_supports_ai(): bool {
$is_enabled = defined( 'WP_AI_SUPPORT' ) ? WP_AI_SUPPORT : true;
/**
* Filters whether the current request should use AI.
*
* This allows plugins and 3rd-party code to disable AI features on a per-request basis, or to even override explicit
* preferences defined by the site owner.
*
* @since 7.0.0
*
* @param bool $is_enabled Whether the current request should use AI. Default to WP_AI_SUPPORT constant, or true if
* the constant is not defined.
*/
return (bool) apply_filters( 'wp_supports_ai', $is_enabled );
}
Default connectors will only be registered if that function returns true.
It also has an effect on wp ai generate, as the prompt builder will return a WP_Error with code prompt_prevented and message AI features are not supported in this environment..
We should add some coverage for that in the existing tests.
wp ai is-supported is a new command that simply checks this function and returns an error code (0 or 1).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
command:aiRelated to 'ai' commandRelated to 'ai' commandcommand:ai-statusRelated to 'ai status' commandRelated to 'ai status' commandenhancementNew feature or requestNew feature or requestscope:testingRelated to testingRelated to testing