-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuninstall.php
76 lines (58 loc) · 1.56 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
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* WP Multisite WaaS uninstall script.
*
* @package WP_Ultimo
* @since 2.0.0
*/
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
} // end if;
global $wpdb;
$wu_settings_key = 'v2_settings';
/*
* Manually grab the plugin settings. No helpers here =(
*/
$wu_settings = get_network_option(null, "wp-ultimo_{$wu_settings_key}");
/*
* Check if we want to wipe things clean on uninstall...
*/
$wu_settings_uninstall_wipe_tables = isset($wu_settings['uninstall_wipe_tables']) ? $wu_settings['uninstall_wipe_tables'] : false;
/*
* Let's do it.
*/
if ($wu_settings_uninstall_wipe_tables) {
$wu_tables = array(
'customers',
'customermeta',
'discount_codes',
'domain_mappings',
'events',
'forms',
'membershipmeta',
'memberships',
'paymentmeta',
'payments',
'postmeta',
'posts',
'productmeta',
'products',
'webhooks'
);
$wu_prefix_table = "{$wpdb->prefix}wu_";
foreach ($wu_tables as $wu_table) {
$wu_table_name = $wu_prefix_table . $wu_table;
$wu_table_version = "wpdb_wu_{$wu_table}_version";
$wpdb->query("DROP TABLE IF EXISTS $wu_table_name"); // phpcs:ignore
delete_network_option(null, $wu_table_version);
} // end foreach;
/*
* Remove states saved
*/
delete_network_option(null, "wp-ultimo_{$wu_settings_key}");
delete_network_option(null, 'wp-ultimo_debug_faker');
delete_network_option(null, 'wu_setup_finished');
delete_network_option(null, 'wu_default_email_template');
delete_network_option(null, 'wu_default_system_emails_created');
delete_network_option(null, 'wu_default_invoice_template');
} // end if;