-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.php
61 lines (49 loc) · 1.4 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
<?php
/**
* Fired when Artemis Backend Theme plugin is uninstalled when it works as is.
*
* @category PHP
* @package ArtemisBackendTheme
* @author Achraf Chouk <[email protected]>
* @since 0.0.1
*/
if (!defined('WP_UNINSTALL_PLUGIN')) {
die('You are not authorized to directly access to this page');
}
global $wpdb;
// Prepare custom Artemis options
$options = [
'ol_artemis_login_theme',
'ol_artemis_login_header_title',
'ol_artemis_login_header_url',
'ol_artemis_login_shake'
];
// Multisite case
if (is_multisite()) {
// Get all sites
$blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A);
// Iterate if found
if ($blogs) {
foreach ($blogs as $blog) {
// Switch to select blog
switch_to_blog($blog['blog_id']);
// Remove all blog options
foreach ($options as $opt) {
delete_option($opt);
}
// Optimize table
$wpdb->query("OPTIMIZE TABLE `".$wpdb->prefix."options`");
// Switch back to current blog
restore_current_blog();
}
}
} else {
// Remove all options
foreach ($options as $opt) {
delete_option($opt);
}
// Optimize table
$wpdb->query("OPTIMIZE TABLE `".$wpdb->prefix."options`");
}
// Remove Artemis themes cache file
unlink(CACHEPATH.'artemisbackendtheme-themes.php');