-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-agent.php
More file actions
73 lines (57 loc) · 1.54 KB
/
wp-agent.php
File metadata and controls
73 lines (57 loc) · 1.54 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
<?php
/**
* Plugin Name: WP Agent
* Description: AI-powered chat assistant for WordPress with memory, slash commands, and agent tools.
* Requires at least: 6.9
* Requires PHP: 7.4
* Requires Plugins: infomaniak-ai-toolkit
* Version: 0.0.1
* Author: Custom
* License: GPL-2.0-or-later
* Text Domain: wp-agent
*
* @package WpAgent
*/
declare(strict_types=1);
namespace WpAgent;
use WpAgent\Admin\ChatPage;
use WpAgent\Admin\EditorMetabox;
use WpAgent\Presets\ChatPreset;
if (!defined('ABSPATH')) {
return;
}
define('WP_AGENT_PLUGIN_FILE', __FILE__);
require_once __DIR__ . '/src/autoload.php';
// Load translations.
add_action('init', static function (): void {
static $loading = false;
if ($loading) {
return;
}
$loading = true;
$domain = 'wp-agent';
$locale = determine_locale();
$dir = __DIR__ . '/languages';
$php_file = "$dir/$domain-$locale.l10n.php";
$mo_file = "$dir/$domain-$locale.mo";
if (file_exists($php_file)) {
load_textdomain($domain, $php_file);
} elseif (file_exists($mo_file)) {
load_textdomain($domain, $mo_file);
}
$loading = false;
});
// Register preset as WordPress Ability.
add_action('wp_abilities_api_init', static function (): void {
if (
!function_exists('wp_register_ability')
|| !class_exists(\WordPress\InfomaniakAiToolkit\Presets\BasePreset::class)
) {
return;
}
(new ChatPreset())->registerAsAbility();
});
// Init admin page.
ChatPage::init();
// Init editor metabox.
EditorMetabox::init();