-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.php
57 lines (50 loc) · 1.57 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
<?php
/**
* Fired when the plugin is uninstalled.
*
* When populating this file, consider the following flow of control:
*
* - This method should be static.
* - Check if the $_REQUEST content actually is the plugin name.
* - Run an admin referrer check to make sure it goes through authentication.
* - Verify the output of $_GET makes sense.
* - Repeat with other user roles. Best directly by using the links/query string parameters.
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
*
* @link https://github.com/sayandey18
* @since 1.0.0
*
* @package Simple_Jwt_Auth
*/
/**
* If the `uninstall.php` is not called by WordPress, die this.
*
* @since 1.0.0
*/
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
die;
}
/**
* Check if the option is set for remove plugin's config data.
*
* @since 1.0.0
*/
$config_status = filter_var(
get_option( 'simplejwt_drop_configs' ),
FILTER_VALIDATE_BOOLEAN
);
/**
* Drop a custom database table for JWT configs and option data.
*
* @since 1.0.0
*/
global $wpdb;
// Set the table name for configs data.
$table_name = $wpdb->prefix . 'simplejwt_config';
// If the option is true, remove the table and the option.
if ( $config_status ) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
$wpdb->query( "DROP TABLE IF EXISTS {$table_name}" );
// Delete the previously defined option.
delete_option( 'simplejwt_drop_configs' );
}