forked from code4recovery/12-step-meeting-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
35 lines (28 loc) · 914 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
<?php
//check
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit();
}
//delete settings (removed settings)
//delete taxonomy
global $wpdb;
$wpdb->query('DELETE t.*, tt.*
FROM ' . $wpdb->terms . ' AS t
INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON t.term_id = tt.term_id
WHERE tt.taxonomy = "tsml_region"');
$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => 'tsml_region'), array('%s'));
//remove custom post types
$locations = get_posts('post_type=tsml_location&numberposts=-1');
foreach ($locations as $location) {
wp_delete_post($location->ID, true);
}
$meetings = get_posts('post_type=tsml_meeting&numberposts=-1');
foreach ($meetings as $meeting) {
wp_delete_post($meeting->ID, true);
}
$groups = get_posts('post_type=tsml_group&numberposts=-1');
foreach ($groups as $group) {
wp_delete_post($group->ID, true);
}
//flush rewrite once more for good measure
flush_rewrite_rules();