-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuninstall.php
55 lines (46 loc) · 1.08 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
<?php
/**
* Uninstalls Simple Sales Tax.
*
* Uninstalling removes all user roles, product data, and options.
*
* @author Simple Sales Tax
* @package SST
* @since 5.0
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Remove data, but only if "Remove Data on Delete" option is enabled
$settings = get_option( 'woocommerce_wootax_settings' );
$remove_data = isset( $settings['remove_all_data'] ) ? 'yes' === $settings['remove_all_data'] : false;
if ( $remove_data ) {
global $wpdb;
// Roles
remove_role( 'exempt-customer' );
// Options
$wpdb->query(
"
DELETE FROM {$wpdb->options}
WHERE option_name LIKE 'woocommerce\_wootax%'
OR option_name LIKE 'wootax\_%'
OR option_name LIKE 'tic\_%';
"
);
// Product settings
$wpdb->query(
"
DELETE FROM {$wpdb->postmeta}
WHERE meta_key LIKE '%wootax%';
"
);
// Category TICs
$wpdb->query(
"
DELETE FROM {$wpdb->termmeta}
WHERE meta_key = 'tic';
"
);
// Database tables
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}sst_tics" );
}