PluginProbe
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… / 2.9.8
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… v2.9.8
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.8, at uninstall.php

157 lines 5.1 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 // Safety copies taken before writing to the site's configuration files.
69 // The wp-config.php one holds the database credentials and the
70 // authentication salts, so leaving it behind would keep them readable in
71 // the options table long after the plugin is gone.
72 'vigilante_htaccess_backup',
73 'vigilante_wpconfig_backup',
74 'vigilante_plugin_status_state',
75 'vigilante_plugin_status_last_check',
76 );
77
78 foreach ( $options_to_delete as $option ) {
79 delete_option( $option );
80 }
81
82 // Per-backup records are named after their timestamp
83 // (vigilante_backup_info_<Y-m-d_H-i-s>), so a fixed list cannot reach them.
84 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
85 $wpdb->query(
86 "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'vigilante_backup_info_%'"
87 );
88
89 // Delete all transients
90 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
91 $wpdb->query(
92 "DELETE FROM {$wpdb->options}
93 WHERE option_name LIKE '_transient_vigilante_%'
94 OR option_name LIKE '_transient_timeout_vigilante_%'"
95 );
96
97 // Remove backup directory
98 $backup_dir = WP_CONTENT_DIR . '/vigilante-backups/';
99 if ( is_dir( $backup_dir ) ) {
100 vigilante_recursive_rmdir( $backup_dir );
101 }
102
103 // Clear scheduled hooks
104 $hooks_to_clear = array(
105 'vigilante_daily_maintenance',
106 'vigilante_hourly_check',
107 'vigilante_hourly_checks',
108 'vigilante_file_integrity_scan',
109 'vigilante_cleanup_logs',
110 'vigilante_password_expiry_reminder',
111 'vigilante_analyzer_weekly_scan',
112 'vigilante_under_attack_post_scan',
113 );
114
115 foreach ( $hooks_to_clear as $hook ) {
116 wp_clear_scheduled_hook( $hook );
117 }
118
119 // Post-update verification events are scheduled with per-update arguments,
120 // so clear every instance regardless of args.
121 wp_unschedule_hook( 'vigilante_fi_postupdate_verify' );
122
123 // Delete all user meta with vigilante_ prefix
124 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
125 $wpdb->query(
126 "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'vigilante\_%'"
127 );
128 }
129
130 /**
131 * Recursively remove directory
132 *
133 * @param string $dir Directory path.
134 * @return bool
135 */
136 function vigilante_recursive_rmdir( $dir ) {
137 if ( ! is_dir( $dir ) ) {
138 return false;
139 }
140
141 // Initialize WP_Filesystem
142 global $wp_filesystem;
143 if ( ! function_exists( 'WP_Filesystem' ) ) {
144 require_once ABSPATH . 'wp-admin/includes/file.php';
145 }
146 WP_Filesystem();
147
148 if ( ! $wp_filesystem ) {
149 return false;
150 }
151
152 // Use WP_Filesystem delete with recursive flag
153 return $wp_filesystem->delete( $dir, true );
154 }
155
156 // Run uninstall
157 vigilante_uninstall();