config = new Config(); $this->database = new DatabaseManager(); } /** * Initialize the plugin * * @return void */ public function init() { // Initialize components $this->init_components(); // Register hooks $this->register_hooks(); // Register cleanup hook add_action('aicog_cleanup', [$this, 'cleanup_old_logs']); } /** * Initialize plugin components * * @return void */ private function init_components() { // Initialize admin area if in admin if (is_admin()) { $this->admin = new AdminManager($this->config, $this->database); $this->admin->init(); } // Initialize comment processor $this->comment_processor = new CommentProcessor($this->config, $this->database); $this->comment_processor->init(); } /** * Register plugin hooks * * @return void */ private function register_hooks() { // Activation/deactivation hooks are now registered in main plugin file // Uninstall is handled by uninstall.php } /** * Plugin activation * * @return void */ public function activate() { // Create database tables $this->database->create_tables(); // Set default options $this->config->set_defaults(); // Clear configuration cache to ensure fresh start $this->config->clear_cache(); // Clear database cache $this->database->clear_log_cache(); // Clear any scheduled hooks wp_clear_scheduled_hook('aicog_cleanup'); // Schedule cleanup wp_schedule_event(time(), 'daily', 'aicog_cleanup'); // Flush rewrite rules flush_rewrite_rules(); } /** * Plugin deactivation * * @return void */ public function deactivate() { // Clear scheduled hooks wp_clear_scheduled_hook('aicog_cleanup'); // Clear caches $this->config->clear_cache(); $this->database->clear_log_cache(); // Flush rewrite rules flush_rewrite_rules(); } /** * Cleanup old logs based on retention policy * * @return void */ public function cleanup_old_logs() { // Delete logs older than retention period $this->database->clean_old_logs(); } }