-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuninstall.php
executable file
·39 lines (25 loc) · 954 Bytes
/
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
<?php
// If uninstall not called from WordPress exit
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
global $wpdb;
// Delete post meta
$regions = array_keys( get_option( 'wc_price_based_country_regions', array() ) );
foreach ( $regions as $region_key ) {
foreach ( array( '_price', '_regular_price', '_sale_price', '_price_method' ) as $price_type ) {
foreach ( array('', '_variable') as $variable) {
$meta_key = '_' . $region_key . $variable . $price_type;
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => $meta_key ) );
}
if ( $price_type !== '_price_method') {
foreach ( array('_min', '_max' ) as $min_or_max ) {
$meta_key = '_' . $region_key . $min_or_max . $price_type . '_variation_id';
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => $meta_key ) );
}
}
}
}
// Delete options
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wc\_price\_based_country\_%';");
?>