Initial commit: Hermes AI Bridge WordPress plugin for cPanel agent runtime

This commit is contained in:
2026-07-03 08:49:52 +02:00
commit 17d218c3b6
9 changed files with 981 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace HermesAiBridge;
defined('ABSPATH') or die();
class Installer {
public static function activate() {
self::create_tables();
self::set_default_options();
self::schedule_cron_events();
flush_rewrite_rules();
}
public static function deactivate() {
self::clear_cron_events();
flush_rewrite_rules();
}
private static function create_tables() {
global $wpdb;
$charset = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}hermes_log (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
level VARCHAR(20) NOT NULL DEFAULT 'info',
message TEXT NOT NULL,
context LONGTEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
INDEX idx_level (level),
INDEX idx_created (created_at)
) $charset;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
}
private static function set_default_options() {
if (!get_option('hermes_api_key')) {
update_option('hermes_api_key', wp_hash(wp_generate_password(64, true, true)));
}
add_option('hermes_ai_provider', 'openai');
add_option('hermes_ai_model', 'gpt-4');
add_option('hermes_ai_max_tokens', 2048);
add_option('hermes_cron_interval', 'hourly');
}
private static function schedule_cron_events() {
if (!wp_next_scheduled('hermes_hourly_tick')) {
wp_schedule_event(time(), 'hourly', 'hermes_hourly_tick');
}
if (!wp_next_scheduled('hermes_daily_tick')) {
wp_schedule_event(time(), 'daily', 'hermes_daily_tick');
}
}
private static function clear_cron_events() {
wp_clear_scheduled_hook('hermes_hourly_tick');
wp_clear_scheduled_hook('hermes_daily_tick');
}
}