-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.php
64 lines (61 loc) · 1.78 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
<?php
/**
* Fired when the plugin is uninstalled.
*
* We are not using an uninstall hook because WordPress performs bad when using it.
* Even if below issue is "fixed", it did not resolve the performance issue.
*
* @see https://core.trac.wordpress.org/ticket/31792
*
*
* When populating this file, consider the following flow
* of control:
*
* - Check if the $_REQUEST['plugin'] content actually is coupon/coupon.php
* - Check if the $_REQUEST['action'] content actually is delete-plugin
* - Run a check_ajax_referer check to make sure it goes through authentication
* - Run a current_user_can check to make sure current user can delete a plugin
*
* @todo Consider multisite. Once for a single site in the network, once sitewide.
*
* @link https://github.com/lelinhtinh
* @since 1.0.0
* @package Coupon
*/
/**
* Perform Uninstall Actions.
*
* If uninstall not called from WordPress,
* If no uninstall action,
* If not this plugin,
* If no caps,
* then exit.
*
* @since 1.0.0
*/
function oms_uninstall()
{
if (
!defined('WP_UNINSTALL_PLUGIN')
|| empty($_REQUEST)
|| !isset($_REQUEST['plugin'])
|| !isset($_REQUEST['action'])
|| dirname(plugin_basename(__FILE__)) . '/coupon.php' !== $_REQUEST['plugin']
|| 'delete-plugin' !== $_REQUEST['action']
|| !check_ajax_referer('updates', '_ajax_nonce')
|| !current_user_can('activate_plugins')
) {
exit;
}
/**
* It is now safe to perform your uninstall actions here.
*
* @see https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/#method-2-uninstall-php
*/
global $wpdb;
$plugin_name = 'oms_coupons';
$table_name = $wpdb->prefix . $plugin_name;
$wpdb->query("DROP TABLE IF EXISTS {$table_name},{$table_name}_user;");
delete_option($plugin_name . '_version');
}
oms_uninstall();