v0.3.0
This commit is contained in:
parent
f936aeb807
commit
968211baad
1 changed files with 15548 additions and 14530 deletions
|
|
@ -1,32 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Uninstall cleanup for the 2FA (by ROBOTSTXT) plugin.
|
||||
*
|
||||
* @package Robotstxt_2FA
|
||||
*/
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
delete_option( 'robotstxt_2fa_settings' );
|
||||
delete_site_option( 'robotstxt_2fa_settings' );
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$meta_keys = array(
|
||||
'robotstxt_2fa_user_settings',
|
||||
'robotstxt_2fa_email_challenge',
|
||||
'robotstxt_2fa_last_verifications',
|
||||
'robotstxt_2fa_recovery_codes',
|
||||
'robotstxt_2fa_otp_secret',
|
||||
);
|
||||
|
||||
foreach ( $meta_keys as $meta_key ) {
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s",
|
||||
$meta_key
|
||||
)
|
||||
);
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Uninstall cleanup for the 2FA (by ROBOTSTXT) plugin.
|
||||
*
|
||||
* Data is only deleted when the administrator has explicitly enabled the
|
||||
* "Delete data on uninstall" option. The default is to preserve all data so
|
||||
* it survives a reinstall.
|
||||
*
|
||||
* @package Robotstxt_2FA
|
||||
*/
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the delete-on-uninstall option is enabled.
|
||||
*
|
||||
* On multisite the network option takes precedence; falls back to the
|
||||
* per-site option on the main site.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function robotstxt_2fa_should_delete_data(): bool {
|
||||
$option_name = 'robotstxt_2fa_settings';
|
||||
|
||||
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||
$network = get_site_option( $option_name, array() );
|
||||
|
||||
if ( is_array( $network ) && ! empty( $network ) ) {
|
||||
return ! empty( $network['delete_on_uninstall'] );
|
||||
}
|
||||
}
|
||||
|
||||
$settings = get_option( $option_name, array() );
|
||||
|
||||
return is_array( $settings ) && ! empty( $settings['delete_on_uninstall'] );
|
||||
}
|
||||
|
||||
if ( ! robotstxt_2fa_should_delete_data() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove plugin-level options.
|
||||
delete_option( 'robotstxt_2fa_settings' );
|
||||
delete_site_option( 'robotstxt_2fa_settings' );
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$robotstxt_2fa_meta_keys = array(
|
||||
'robotstxt_2fa_user_settings',
|
||||
'robotstxt_2fa_email_challenge',
|
||||
'robotstxt_2fa_last_verifications',
|
||||
'robotstxt_2fa_recovery_codes',
|
||||
'robotstxt_2fa_otp_secret',
|
||||
);
|
||||
|
||||
foreach ( $robotstxt_2fa_meta_keys as $robotstxt_2fa_meta_key ) {
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s",
|
||||
$robotstxt_2fa_meta_key
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue