| @@ -1,54 +1,34 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Remove traces of plugin when uninstalling it. | |
| 4 | - * | |
| 5 | - * @package authorizer | |
| 6 | - */ | |
| 7 | 2 | |
| 8 | -/** | |
| 9 | - * Exit if uninstall not called from WordPress. | |
| 10 | - */ | |
| 11 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { | |
| 3 | +// Exit if uninstall not called from WordPress. | |
| 4 | +if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { | |
| 12 | 5 | exit(); |
| 13 | 6 | } |
| 14 | 7 | |
| 15 | -/** | |
| 16 | - * Delete options in database. | |
| 17 | - */ | |
| 8 | +// Delete options in database. | |
| 18 | 9 | delete_option( 'auth_settings' ); |
| 19 | 10 | delete_option( 'auth_settings_recently_sent_emails' ); |
| 11 | +delete_option( 'auth_settings_advanced_admin_notice' ); | |
| 20 | 12 | delete_option( 'auth_settings_advanced_login_error' ); |
| 21 | 13 | delete_option( 'auth_settings_advanced_lockouts_time_last_failed' ); |
| 22 | 14 | delete_option( 'auth_settings_advanced_lockouts_failed_attempts' ); |
| 23 | -delete_option( 'auth_settings_access_users_approved' ); | |
| 24 | -delete_option( 'auth_settings_access_users_blocked' ); | |
| 25 | -delete_option( 'auth_settings_access_users_pending' ); | |
| 26 | -delete_option( 'auth_settings_advanced_public_notice' ); | |
| 27 | -delete_option( 'auth_settings_advanced_admin_notice' ); | |
| 28 | -delete_option( 'auth_version' ); | |
| 29 | 15 | |
| 30 | -/** | |
| 31 | - * Delete multisite options. | |
| 32 | - */ | |
| 16 | +// Delete multisite options | |
| 33 | 17 | if ( is_multisite() ) { |
| 34 | - delete_blog_option( get_main_site_id( get_main_network_id() ), 'auth_multisite_settings' ); | |
| 35 | - delete_blog_option( get_main_site_id( get_main_network_id() ), 'auth_multisite_settings_access_users_approved' ); | |
| 36 | - delete_blog_option( get_main_site_id( get_main_network_id() ), 'auth_version' ); | |
| 18 | + delete_blog_option( BLOG_ID_CURRENT_SITE, 'auth_multisite_settings' ); | |
| 37 | 19 | } |
| 38 | 20 | |
| 39 | -/** | |
| 40 | - * For security, delete blocked users (since we can't enforce their blocked | |
| 41 | - * status without this plugin enabled, which means they would be able to reset | |
| 42 | - * their passwords and log in). If they have any content, reassign it to the | |
| 43 | - * current user (the user uninstalling the plugin). | |
| 44 | - */ | |
| 21 | +// For security, delete blocked users (since we can't enforce their blocked | |
| 22 | +// status without this plugin enabled, which means they would be able to reset | |
| 23 | +// their passwords and log in). If they have any content, reassign it to the | |
| 24 | +// current user (the user uninstalling the plugin). | |
| 45 | 25 | if ( ! is_multisite() ) { |
| 46 | - $authorizer_reassign_user = wp_get_current_user(); | |
| 47 | - $authorizer_blocked_users = get_users( array( | |
| 48 | - 'meta_key' => 'auth_blocked', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key | |
| 49 | - 'meta_value' => 'yes', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value | |
| 50 | - ) ); | |
| 51 | - foreach ( $authorizer_blocked_users as $authorizer_blocked_user ) { | |
| 52 | - wp_delete_user( $authorizer_blocked_user->ID, $authorizer_reassign_user->ID ); | |
| 26 | + $blocked_users = get_users( array( | |
| 27 | + 'meta_key' => 'auth_blocked', | |
| 28 | + 'meta_value' => 'yes', | |
| 29 | + )); | |
| 30 | + $current_user = wp_get_current_user(); | |
| 31 | + foreach ( $blocked_users as $blocked_user ) { | |
| 32 | + wp_delete_user( $blocked_user->ID, $current_user->ID ); | |
| 53 | 33 | } |
| 54 | 34 | } |