<?php
/**
 * Plugin deactivation: clears all scheduled cron events that Brainwerk Security Suite
 * may have registered (Activator + Pro modules).
 *
 * @package Brainwerk Security Suite
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

class Shieldforge_Deactivator {
    /** All cron hooks the plugin can possibly schedule. */
    const HOOKS = array(
        'shieldforge_daily_digest',
        'shieldforge_cleanup_logs',
        'shieldforge_daily_scan',
        'shieldforge_daily_vulnscan',
        'shieldforge_repo_integrity',
        'shieldforge_license_refresh',
        // Pro-module hooks (cleared even if Pro isn't currently active —
        // they may have been scheduled in an earlier session)
        'shieldforge_pro_threatintel_refresh',
        'shieldforge_pro_multisite_aggregate',
        'shieldforge_pro_geoblock_refresh',
        'shieldforge_pro_notify_digest',
    );

    public static function deactivate() {
        foreach ( self::HOOKS as $hook ) {
            wp_clear_scheduled_hook( $hook );
        }
        // Auch Transients aufräumen — vermeidet stale bruteforce-/lockout-Daten
        // wenn das Plugin später re-aktiviert wird.
        global $wpdb;
        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- deactivation cleanup; one-off LIKE-based purge with no core API equivalent, fixed literal pattern (no user input).
        $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_shieldforge_%' OR option_name LIKE '_transient_timeout_shieldforge_%'" );
    }
}
