forked from sovware/directorist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
82 lines (78 loc) · 3.72 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
77
78
79
80
81
82
<?php
/**
* @package Directorist
*/
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
// Access the database via SQL
global $wpdb;
include_once("directorist-base.php");
$enable_uninstall = get_directorist_option('enable_uninstall',0);
// Clear schedules
wp_clear_scheduled_hook('directorist_hourly_scheduled_events');
if(!empty($enable_uninstall)) {
// Delete selected pages.
wp_delete_post(get_directorist_option('add_listing_page'), true);
wp_delete_post(get_directorist_option('all_listing_page'), true);
wp_delete_post(get_directorist_option('user_dashboard'), true);
wp_delete_post(get_directorist_option('author_profile_page'), true);
wp_delete_post(get_directorist_option('all_categories_page'), true);
wp_delete_post(get_directorist_option('single_category_page'), true);
wp_delete_post(get_directorist_option('all_locations_page'), true);
wp_delete_post(get_directorist_option('single_location_page'), true);
wp_delete_post(get_directorist_option('single_tag_page'), true);
wp_delete_post(get_directorist_option('custom_registration'), true);
wp_delete_post(get_directorist_option('user_login'), true);
wp_delete_post(get_directorist_option('search_listing'), true);
wp_delete_post(get_directorist_option('search_result_page'), true);
wp_delete_post(get_directorist_option('checkout_page'), true);
wp_delete_post(get_directorist_option('payment_receipt_page'), true);
wp_delete_post(get_directorist_option('transaction_failure_page'), true);
wp_delete_post(get_directorist_option('privacy_policy'), true);
wp_delete_post(get_directorist_option('terms_conditions'), true);
// Delete posts + data.
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'at_biz_dir', 'atbdp_fields', 'atbdp_orders', 'atbdp_listing_review' );" );
//Delete all metabox
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id Not IN (SELECT id FROM {$wpdb->posts})");
//Delete term relationships
$wpdb->query("DELETE FROM {$wpdb->term_relationships} WHERE object_id Not IN (SELECT id FROM {$wpdb->posts})");
//Delete all taxonomy
$wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-location'");
$wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-category'");
$wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-tags'");
//Delete all term meta
$wpdb->query("DELETE FROM {$wpdb->termmeta} WHERE term_id Not IN (SELECT term_id FROM {$wpdb->term_taxonomy})");
$wpdb->query("DELETE FROM {$wpdb->terms} WHERE term_id Not IN (SELECT term_id FROM {$wpdb->term_taxonomy})");
//Delete raview database
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}atbdp_review");
//Delete usermeta.
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '%atbdp%';");
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'pro_pic';");
// Delete all the Plugin Options
$atbdp_settings = array(
"{$wpdb->prefix}atbdp_review_db_version",
'atbdp_option',
'widget_bdpl_widget',
'widget_bdvd_widget',
'widget_bdco_widget',
'widget_bdsb_widget',
'widget_bdlf_widget',
'widget_bdcw_widget',
'widget_bdlw_widget',
'widget_bdtw_widget',
'widget_bdsw_widget',
'widget_bdmw_widget',
'widget_bdamw_widget',
'widget_bdsl_widget',
'widget_bdsi_widget',
'widget_bdfl_widget',
'atbdp_meta_version',
'atbdp_pages_version',
'atbdp_roles_mapped',
'atbdp_roles_version',
'at_biz_dir-location_children',
'at_biz_dir-category_children',
);
foreach ($atbdp_settings as $settings) {
delete_option($settings);
}
}