load_dependencies(); $this->init_hooks(); } private function load_dependencies() { require_once WISPER_PLUGIN_DIR . 'includes/class-wisper-i18n.php'; require_once WISPER_PLUGIN_DIR . 'includes/class-wisper-antispam.php'; require_once WISPER_PLUGIN_DIR . 'includes/class-wisper-rate-limiter.php'; require_once WISPER_PLUGIN_DIR . 'includes/Telegram/class-wisper-telegram-api.php'; require_once WISPER_PLUGIN_DIR . 'includes/Telegram/class-wisper-webhook.php'; require_once WISPER_PLUGIN_DIR . 'includes/Frontend/class-wisper-widget.php'; require_once WISPER_PLUGIN_DIR . 'includes/Frontend/class-wisper-ajax.php'; require_once WISPER_PLUGIN_DIR . 'includes/Admin/class-wisper-admin.php'; } private function init_hooks() { Wisper_I18n::init(); Wisper_Webhook::init(); Wisper_Ajax::init(); Wisper_Widget::init(); if (is_admin()) { Wisper_Admin::init(); } Wisper_Activator::maybe_upgrade_db(); // Auto-close cron with >= 4 char prefix add_action('wisper_auto_close_cron', ['Wisper_Telegram_API', 'auto_close_stale_sessions']); add_action('alc_auto_close_cron', ['Wisper_Telegram_API', 'auto_close_stale_sessions']); // legacy alias add_action('init', function () { if (!wp_next_scheduled('wisper_auto_close_cron')) { wp_schedule_event(time(), 'hourly', 'wisper_auto_close_cron'); } }); } /** * Unified option getter supporting modern wisper_ and legacy alc_ prefixes */ public static function get_option($key, $default = false) { $wisper_key = strpos($key, 'wisper_') === 0 ? $key : ('wisper_' . preg_replace('/^alc_/', '', $key)); $val = get_option($wisper_key, null); if ($val !== null) { return $val; } $legacy_key = 'alc_' . preg_replace('/^wisper_/', '', $key); return get_option($legacy_key, $default); } /** * Unified option updater always writing under wisper_ prefix */ public static function update_option($key, $value) { $wisper_key = strpos($key, 'wisper_') === 0 ? $key : ('wisper_' . preg_replace('/^alc_/', '', $key)); return update_option($wisper_key, $value); } }