-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranslatepress-llm-engines.php
More file actions
94 lines (86 loc) · 3.11 KB
/
translatepress-llm-engines.php
File metadata and controls
94 lines (86 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Plugin Name: TranslatePress - LLM Translation Engines
* Plugin URI: https://github.com/Livvux/translatepress-llm-engines
* Description: Adds OpenAI, Anthropic (Claude), OpenRouter, and DeepSeek as automatic translation engines for TranslatePress. Use your own API keys for AI-powered translations.
* Version: 1.1.0
* Author: Livvux
* Author URI: https://livvux.com/
* License: GPL2
* Text Domain: translatepress-llm-engines
* Domain Path: /languages
* Requires at least: 5.0
* Requires PHP: 7.4
*
* == Copyright ==
* Copyright 2024-2026 Livvux
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Initialize the LLM Translation Engines addon
*/
function trp_llm_engines_init() {
// Define plugin constants
define( 'TRP_LLM_ENGINES_VERSION', '1.1.0' );
define( 'TRP_LLM_ENGINES_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'TRP_LLM_ENGINES_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Check if TranslatePress is active
if ( ! class_exists( 'TRP_Translate_Press' ) ) {
add_action( 'admin_notices', 'trp_llm_engines_missing_translatepress_notice' );
return;
}
// Load the main class
require_once TRP_LLM_ENGINES_PLUGIN_DIR . 'includes/class-llm-translate.php';
// Initialize the addon
new TRP_LLM_Translate();
}
add_action( 'plugins_loaded', 'trp_llm_engines_init', 0 );
/**
* Admin notice when TranslatePress is not active
*/
function trp_llm_engines_missing_translatepress_notice() {
?>
<div class="notice notice-error">
<p>
<?php
echo wp_kses(
sprintf(
__( '<strong>TranslatePress - LLM Translation Engines</strong> requires <a href="%s" target="_blank">TranslatePress</a> to be installed and activated.', 'translatepress-llm-engines' ),
'https://wordpress.org/plugins/translatepress-multilingual/'
),
array( 'strong' => array(), 'a' => array( 'href' => array(), 'target' => array() ) )
);
?>
</p>
</div>
<?php
}
/**
* Plugin activation hook
*/
function trp_llm_engines_activate() {
// Activation tasks if needed
}
register_activation_hook( __FILE__, 'trp_llm_engines_activate' );
/**
* Plugin deactivation hook
*/
function trp_llm_engines_deactivate() {
// Deactivation tasks if needed
}
register_deactivation_hook( __FILE__, 'trp_llm_engines_deactivate' );