-
Notifications
You must be signed in to change notification settings - Fork 11
/
uninstall.php
65 lines (53 loc) · 1.41 KB
/
uninstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @package WP Google Authenticator/Uninstall
* @author Julien Liabeuf <[email protected]>
* @license GPL-2.0+
* @link https://julienliabeuf.com
* @copyright 2016 Julien Liabeuf
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
wpga_uninstallPlugin();
/**
* Remove plugin data from database
*/
function wpga_uninstallPlugin() {
/* Plugin main options */
delete_option( WPGA_PREFIX . '_options' );
delete_option( WPGA_PREFIX . '_used_totp' );
$args = array( 'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'wpga_attempts',
'value' => '',
'compare' => '!='
),
array(
'key' => 'wpga_secret',
'value' => '',
'compare' => '!='
)
)
);
$users = new WP_User_Query( $args );
/* Delete all user metas */
if ( ! empty( $users->results ) ) {
foreach( $users->results as $key => $user ) {
delete_user_meta( $user->ID, 'wpga_active' );
delete_user_meta( $user->ID, 'wpga_attempts' );
delete_user_meta( $user->ID, 'wpga_secret' );
delete_user_meta( $user->ID, 'wpga_backup_key' );
delete_user_meta( $user->ID, 'wpga_backup_key_time' );
delete_user_meta( $user->ID, 'wpga_apps_passwords' );
delete_user_meta( $user->ID, 'wpga_apps_passwords_log' );
}
}
/**
* Remove cron task
*/
$timestamp = wp_next_scheduled( 'wpas_clean_totps' );
wp_unschedule_event( $timestamp, 'wpas_clean_totps' );
}