sg-security
Last commit date
assets
1 year ago
core
1 year ago
templates
1 year ago
vendor
1 year ago
react-strings.php
1 year ago
readme.txt
1 year ago
sg-security.php
1 year ago
uninstall.php
1 year ago
uninstall.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly. |
| 5 | } |
| 6 | |
| 7 | global $wpdb; |
| 8 | |
| 9 | // The plugin tables. |
| 10 | $tables = array( |
| 11 | 'sgs_log_visitors', |
| 12 | 'sgs_log_events', |
| 13 | ); |
| 14 | |
| 15 | $user_2fa_meta = array( |
| 16 | 'configured', |
| 17 | 'secret', |
| 18 | 'qr', |
| 19 | 'backup_codes', |
| 20 | ); |
| 21 | |
| 22 | // Loop through all tables and delete them. |
| 23 | foreach ( $tables as $table ) { |
| 24 | $wpdb->query( // phpcs:ignore |
| 25 | 'DROP TABLE IF EXISTS ' . $wpdb->dbname . '.' . $wpdb->prefix . $table // phpcs:ignore |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | // Reset all users 2FA. |
| 30 | foreach ( $user_2fa_meta as $meta ) { |
| 31 | delete_metadata( 'user', 0, 'sg_security_2fa_' . $meta, '', true ); |
| 32 | } |
| 33 | |
| 34 | // Delete encryption file. |
| 35 | wp_delete_file( defined( 'SGS_ENCRYPTION_KEY_FILE_PATH' ) ? SGS_ENCRYPTION_KEY_FILE_PATH : WP_CONTENT_DIR . '/sgs_encrypt_key.php' ); |
| 36 | |
| 37 | // Stop uninstall service if SG Optimizer plugin exists. |
| 38 | if ( file_exists( WP_PLUGIN_DIR . '/sg-cachepress/sg-cachepress.php' ) ) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | // Stop collecting data. |
| 43 | require_once dirname( __FILE__ ) . '/vendor/siteground/siteground-data/src/Settings.php'; |
| 44 | |
| 45 | use SiteGround_Data\Settings; |
| 46 | |
| 47 | $settings = new Settings(); |
| 48 | |
| 49 | $settings->stop_collecting_data(); |