v1.1.0
This commit is contained in:
parent
a157afe625
commit
02cd01e862
20 changed files with 1365 additions and 646 deletions
|
|
@ -3,8 +3,8 @@
|
|||
* Plugin Name: AI Translator (by ROBOTSTXT)
|
||||
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-ai-translator
|
||||
* Gitea Plugin URI: ROBOTSTXT/robotstxt-ai-translator
|
||||
* Description: Translate post titles and content from the editor using the native WordPress AI plugin as backend. Multisite-ready with global or per-site configuration.
|
||||
* Version: 1.0.0
|
||||
* Description: Translate post titles and content from the editor using the native WordPress AI client (available in WP 7.0+). Multisite-ready with global or per-site configuration.
|
||||
* Version: 1.1.0
|
||||
* Author: ROBOTSTXT
|
||||
* Author URI: https://www.robotstxt.es/
|
||||
* License: GPL-3.0-or-later
|
||||
|
|
@ -13,7 +13,6 @@
|
|||
* Domain Path: /languages
|
||||
* Requires at least: 7.0
|
||||
* Requires PHP: 7.4
|
||||
* Requires Plugins: ai
|
||||
* Network: true
|
||||
*
|
||||
* @package ROBOTSTXT\AI_Translator
|
||||
|
|
@ -26,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Plugin version.
|
||||
*/
|
||||
define( 'AI_TRANSLATOR_VERSION', '1.0.0' );
|
||||
define( 'AI_TRANSLATOR_VERSION', '1.1.0' );
|
||||
|
||||
/**
|
||||
* Main plugin file path.
|
||||
|
|
@ -57,7 +56,11 @@ require_once AI_TRANSLATOR_DIR . 'includes/class-ai-translator-settings.php';
|
|||
require_once AI_TRANSLATOR_DIR . 'includes/class-ai-translator-translator.php';
|
||||
require_once AI_TRANSLATOR_DIR . 'includes/class-ai-translator-admin.php';
|
||||
require_once AI_TRANSLATOR_DIR . 'includes/class-ai-translator-editor-ui.php';
|
||||
require_once AI_TRANSLATOR_DIR . 'robotstxt-updater.php';
|
||||
require_once AI_TRANSLATOR_DIR . 'class-robotstxt-updater.php';
|
||||
|
||||
if ( class_exists( '\Inpsyde\MultilingualPress\TranslationUi\Post\MetaboxAction' ) ) {
|
||||
require_once AI_TRANSLATOR_DIR . 'includes/class-ai-translator-mlp-integration.php';
|
||||
}
|
||||
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
require_once AI_TRANSLATOR_DIR . 'includes/class-ai-translator-cli.php';
|
||||
|
|
@ -103,30 +106,43 @@ function ai_translator_bootstrap() {
|
|||
$cli->register();
|
||||
}
|
||||
|
||||
if ( class_exists( 'AI_Translator_MLP_Integration' ) ) {
|
||||
$mlp = new AI_Translator_MLP_Integration( $settings, $translator );
|
||||
$mlp->register();
|
||||
}
|
||||
|
||||
Robotstxt_Updater::init( AI_TRANSLATOR_FILE );
|
||||
}
|
||||
add_action( 'plugins_loaded', 'ai_translator_bootstrap' );
|
||||
|
||||
/**
|
||||
* Renders an admin notice when the WordPress AI plugin is not active.
|
||||
* Renders an admin notice when no AI provider is configured for text generation.
|
||||
*
|
||||
* `wp_ai_client_prompt()` is part of WordPress 7.0 core, so the function always
|
||||
* exists. The meaningful check is whether a provider capable of text generation has
|
||||
* been configured — which is what `AI_Translator_Translator::is_supported()` tests.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function ai_translator_dependency_notice() {
|
||||
if ( function_exists( 'wp_ai_client_prompt' ) ) {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'activate_plugins' ) ) {
|
||||
$translator = new AI_Translator_Translator();
|
||||
|
||||
if ( $translator->is_supported() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings_url = admin_url( 'options-general.php?page=options-connectors-wp-admin' );
|
||||
|
||||
$message = sprintf(
|
||||
/* translators: %s: WordPress AI plugin link. */
|
||||
esc_html__( 'AI Translator (by ROBOTSTXT) requires the %s plugin to be active. Translation features will be disabled until it is installed and configured.', 'robotstxt-ai-translator' ),
|
||||
'<a href="https://wordpress.org/plugins/ai/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'WordPress AI', 'robotstxt-ai-translator' ) . '</a>'
|
||||
/* translators: %s: Link to the WordPress AI settings page. */
|
||||
esc_html__( 'AI Translator (by ROBOTSTXT) requires a configured AI provider for text generation. Open %s to set one up.', 'robotstxt-ai-translator' ),
|
||||
'<a href="' . esc_url( $settings_url ) . '">' . esc_html__( 'Settings → AI', 'robotstxt-ai-translator' ) . '</a>'
|
||||
);
|
||||
|
||||
printf(
|
||||
|
|
@ -135,9 +151,7 @@ function ai_translator_dependency_notice() {
|
|||
$message,
|
||||
array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'target' => array(),
|
||||
'rel' => array(),
|
||||
'href' => array(),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue