forked from uhm-coe/authorizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
47 lines (43 loc) · 1.25 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
<?php
/**
* Remove traces of plugin when uninstalling it.
*
* @package authorizer
*/
/**
* Exit if uninstall not called from WordPress.
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit();
}
/**
* Delete options in database.
*/
delete_option( 'auth_settings' );
delete_option( 'auth_settings_recently_sent_emails' );
delete_option( 'auth_settings_advanced_admin_notice' );
delete_option( 'auth_settings_advanced_login_error' );
delete_option( 'auth_settings_advanced_lockouts_time_last_failed' );
delete_option( 'auth_settings_advanced_lockouts_failed_attempts' );
/**
* Delete multisite options.
*/
if ( is_multisite() ) {
delete_blog_option( BLOG_ID_CURRENT_SITE, 'auth_multisite_settings' );
}
/**
* For security, delete blocked users (since we can't enforce their blocked
* status without this plugin enabled, which means they would be able to reset
* their passwords and log in). If they have any content, reassign it to the
* current user (the user uninstalling the plugin).
*/
if ( ! is_multisite() ) {
$current_user = wp_get_current_user();
$blocked_users = get_users( array(
'meta_key' => 'auth_blocked',
'meta_value' => 'yes',
));
foreach ( $blocked_users as $blocked_user ) {
wp_delete_user( $blocked_user->ID, $current_user->ID );
}
}