<?php
/**
 * Security Pack Uninstaller.
 *
 * @package Security_Pack
 */

// If uninstall not called from WordPress, exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}

// Load the database class.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpsp-db.php';

// Run uninstall.
WPSP_DB::uninstall();

// Clear any remaining transients.
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Cleanup during uninstall, caching not applicable.
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_wpsp_%'" );
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Cleanup during uninstall, caching not applicable.
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_wpsp_%'" );

// Clear scheduled events.
wp_clear_scheduled_hook( 'wpsp_daily_cleanup' );
wp_clear_scheduled_hook( 'wpsp_daily_file_scan' );
wp_clear_scheduled_hook( 'wpsp_weekly_malware_scan' );

// Delete user meta for 2FA.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Cleanup during uninstall, caching not applicable.
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '_wpsp_%'" );
