v1.1.0
This commit is contained in:
parent
a157afe625
commit
02cd01e862
20 changed files with 1365 additions and 646 deletions
|
|
@ -23,14 +23,18 @@ if ( ! class_exists( 'AI_Translator_Translator' ) ) {
|
|||
class AI_Translator_Translator {
|
||||
|
||||
/**
|
||||
* Indicates whether the WordPress AI client is available.
|
||||
* Indicates whether AI features are enabled for this WordPress installation.
|
||||
*
|
||||
* `wp_ai_client_prompt()` is a native WordPress 7.0 function — the API is always
|
||||
* present. This method checks `wp_supports_ai()`, which returns false only when the
|
||||
* `WP_AI_SUPPORT` constant is set to false or the `wp_supports_ai` filter disables it.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return bool True if the dependency is active.
|
||||
* @return bool True when WordPress AI is enabled for this installation.
|
||||
*/
|
||||
public function is_available() {
|
||||
return function_exists( 'wp_ai_client_prompt' );
|
||||
return wp_supports_ai();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,15 +82,15 @@ if ( ! class_exists( 'AI_Translator_Translator' ) ) {
|
|||
|
||||
if ( ! $this->is_available() ) {
|
||||
return new WP_Error(
|
||||
'ai_translator_unavailable',
|
||||
__( 'The WordPress AI client is not available. Install and activate the WordPress AI plugin.', 'robotstxt-ai-translator' )
|
||||
'ai_translator_disabled',
|
||||
__( 'AI features are disabled for this WordPress installation.', 'robotstxt-ai-translator' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $this->is_supported() ) {
|
||||
return new WP_Error(
|
||||
'ai_translator_unsupported',
|
||||
__( 'The configured AI providers cannot serve text generation requests. Open the WordPress AI settings to configure a provider.', 'robotstxt-ai-translator' )
|
||||
__( 'No AI provider is configured for text generation. Open Settings → AI to set one up.', 'robotstxt-ai-translator' )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue