-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuninstall.php
More file actions
executable file
·157 lines (130 loc) · 3.37 KB
/
uninstall.php
File metadata and controls
executable file
·157 lines (130 loc) · 3.37 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/**
* Fired when the plugin is uninstalled.
*
* @package Arlo_For_Wordpress_Admin
* @author Arlo <info@arlo.co>
* @license GPL-2.0+
* @link https://arlo.co
* @copyright 2018 Arlo
*/
// If uninstall not called from WordPress, then exit
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* The uninstall process
* @since: 1.0
* @param:
* @return:
*/
function arlo_uninstall() {
arlo_delete_tables();
arlo_delete_custom_posts();
arlo_delete_options();
arlo_delete_cookies();
// Nuke all settings if "Keep settings..." is unchecked
$settings = get_option('arlo_settings');
if (empty($settings['keep_settings'])) {
arlo_delete_important_options();
}
}
/**
* Drop all tables of plugin
* @since: 1.0
* @param:
* @return:
*/
function arlo_delete_tables() {
//should use the SchemaManager->delete_tables
global $wpdb;
$sql="
DROP TABLE IF EXISTS " .
$wpdb->prefix . "arlo_async_tasks," .
$wpdb->prefix . "arlo_async_task_data," .
$wpdb->prefix . "arlo_categories," .
$wpdb->prefix . "arlo_contentfields, " .
$wpdb->prefix . "arlo_events, " .
$wpdb->prefix . "arlo_events_presenters, " .
$wpdb->prefix . "arlo_eventtemplates," .
$wpdb->prefix . "arlo_eventtemplates_categories," .
$wpdb->prefix . "arlo_eventtemplates_presenters, " .
$wpdb->prefix . "arlo_onlineactivities, " .
$wpdb->prefix . "arlo_onlineactivities_tags, " .
$wpdb->prefix . "arlo_offers, " .
$wpdb->prefix . "arlo_presenters, " .
$wpdb->prefix . "arlo_venues, " .
$wpdb->prefix . "arlo_events_tags, " .
$wpdb->prefix . "arlo_eventtemplates_tags, " .
$wpdb->prefix . "arlo_tags, " .
$wpdb->prefix . "arlo_timezones, " .
$wpdb->prefix . "arlo_messages, " .
$wpdb->prefix . "arlo_log," .
$wpdb->prefix . "arlo_import," .
$wpdb->prefix . "arlo_import_parts," .
$wpdb->prefix . "arlo_import_lock";
$wpdb->query($sql);
}
/**
* Delete Arlo created custom posts
* @since: 1.0
* @param:
* @return:
*/
function arlo_delete_custom_posts() {
global $wpdb;
$sql = "DELETE FROM $wpdb->posts WHERE post_type IN ('arlo_events', 'arlo_presenters', 'arlo_venues', 'arlo_event', 'arlo_presenter', 'arlo_venue')";
$wpdb->query($sql);
}
/**
* Delete Arlo wp-options records but keep important settings
* @since: 1.0
* @param:
* @return:
*/
function arlo_delete_options() {
$options = [
'arlo_import_id',
'arlo_customcss',
'arlo_customcss_timestamp',
'arlo_last_import',
'arlo_new_url_structure',
'arlo_plugin_version',
'arlo_import_disabled',
'arlo_plugin_disabled',
'arlo_updated',
];
foreach ($options as $option) {
delete_option($option);
}
}
/**
* Delete all Arlo wp-options records considered as important settings
* @since: 4.0
* @param:
* @return:
*/
function arlo_delete_important_options() {
$options = [
'arlo_schema_version',
'arlo_settings',
'arlo_regions',
'arlo_theme',
'arlo_themes_settings',
'arlo_filter_settings',
'arlo_page_filter_settings',
'arlo_review_notice_date',
'widget_arlo-for-wordpress-upcoming-widget',
'widget_arlo-for-wordpress-categories-widget',
'widget_arlo-for-wordpress-search-widget',
'widget_arlo-for-wordpress-region-selector',
];
foreach ($options as $option) {
delete_option($option);
}
}
function arlo_delete_cookies() {
setcookie('arlo-vertical-tab', null, -1, '/');
setcookie('arlo-nav-tab', null, -1, '/');
}
arlo_uninstall();