PluginProbe
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… / 2.9.5
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… v2.9.5
3.0.0 2.11.12 2.11.11 2.11.10 2.11.9 2.11.7 2.11.8 2.11.6 2.11.5 2.11.4 2.11.3 2.11.1 2.11.2 2.11.0 2.10.5 2.10.4 2.10.3 2.10.2 2.10.1 2.10.0 2.9.9 2.9.8 2.9.6 2.9.7 2.9.5 All 88 releases
vigilante / uninstall.php

uninstall.php in Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… 2.9.5, at uninstall.php

142 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall Vigilante AyudaWP
4 *
5 * This file runs when the plugin is deleted via WordPress admin.
6 * It removes all plugin data including database tables and options.
7 *
8 * @package Vigilante
9 */
10
11 // Exit if not called by WordPress
12 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13 exit;
14 }
15
16 // Load required files
17 require_once plugin_dir_path( __FILE__ ) . 'includes/class-settings.php';
18 require_once plugin_dir_path( __FILE__ ) . 'includes/class-database.php';
19 require_once plugin_dir_path( __FILE__ ) . 'includes/class-backup-manager.php';
20 require_once plugin_dir_path( __FILE__ ) . 'includes/class-deactivator.php';
21
22 // Define constants if not already defined
23 if ( ! defined( 'VIGILANTE_BACKUP_DIR' ) ) {
24 define( 'VIGILANTE_BACKUP_DIR', WP_CONTENT_DIR . '/vigilante-backups/' );
25 }
26
27 /**
28 * Uninstall function
29 */
30 function vigilante_uninstall() {
31 global $wpdb;
32
33 // Drop custom tables
34 $tables = array(
35 $wpdb->prefix . 'vigilante_activity_log',
36 $wpdb->prefix . 'vigilante_login_attempts',
37 $wpdb->prefix . 'vigilante_file_integrity',
38 $wpdb->prefix . 'vigilante_2fa_codes',
39 $wpdb->prefix . 'vigilante_2fa_trusted_devices',
40 $wpdb->prefix . 'vigilante_2fa_notifications',
41 $wpdb->prefix . 'vigilante_2fa_totp',
42 );
43
44 foreach ( $tables as $table ) {
45 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
46 $wpdb->query( "DROP TABLE IF EXISTS {$table}" );
47 }
48
49 // Delete options
50 $options_to_delete = array(
51 'vigilante_options',
52 'vigilante_db_version',
53 'vigilante_backup_timestamp',
54 'vigilante_last_integrity_scan',
55 'vigilante_last_integrity_results',
56 'vigilante_ignored_files',
57 'vigilante_dismissed_notices',
58 'vigilante_under_attack_mode',
59 'vigilante_active_preset',
60 'vigilante_firewall_blocks',
61 'vigilante_critical_files_baseline',
62 'vigilante_activated_time',
63 'vigilante_analyzer_last_scan',
64 'vigilante_analyzer_history',
65 'vigilante_legacy_backups_cleaned',
66 'vigilante_css_exclusion_migrated',
67 'vigilante_checksum_cache_flushed_290',
68 );
69
70 foreach ( $options_to_delete as $option ) {
71 delete_option( $option );
72 }
73
74 // Delete all transients
75 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
76 $wpdb->query(
77 "DELETE FROM {$wpdb->options}
78 WHERE option_name LIKE '_transient_vigilante_%'
79 OR option_name LIKE '_transient_timeout_vigilante_%'"
80 );
81
82 // Remove backup directory
83 $backup_dir = WP_CONTENT_DIR . '/vigilante-backups/';
84 if ( is_dir( $backup_dir ) ) {
85 vigilante_recursive_rmdir( $backup_dir );
86 }
87
88 // Clear scheduled hooks
89 $hooks_to_clear = array(
90 'vigilante_daily_maintenance',
91 'vigilante_hourly_check',
92 'vigilante_hourly_checks',
93 'vigilante_file_integrity_scan',
94 'vigilante_cleanup_logs',
95 'vigilante_password_expiry_reminder',
96 'vigilante_analyzer_weekly_scan',
97 'vigilante_under_attack_post_scan',
98 );
99
100 foreach ( $hooks_to_clear as $hook ) {
101 wp_clear_scheduled_hook( $hook );
102 }
103
104 // Post-update verification events are scheduled with per-update arguments,
105 // so clear every instance regardless of args.
106 wp_unschedule_hook( 'vigilante_fi_postupdate_verify' );
107
108 // Delete all user meta with vigilante_ prefix
109 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
110 $wpdb->query(
111 "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'vigilante\_%'"
112 );
113 }
114
115 /**
116 * Recursively remove directory
117 *
118 * @param string $dir Directory path.
119 * @return bool
120 */
121 function vigilante_recursive_rmdir( $dir ) {
122 if ( ! is_dir( $dir ) ) {
123 return false;
124 }
125
126 // Initialize WP_Filesystem
127 global $wp_filesystem;
128 if ( ! function_exists( 'WP_Filesystem' ) ) {
129 require_once ABSPATH . 'wp-admin/includes/file.php';
130 }
131 WP_Filesystem();
132
133 if ( ! $wp_filesystem ) {
134 return false;
135 }
136
137 // Use WP_Filesystem delete with recursive flag
138 return $wp_filesystem->delete( $dir, true );
139 }
140
141 // Run uninstall
142 vigilante_uninstall();