-
Notifications
You must be signed in to change notification settings - Fork 30
/
uninstall.php
70 lines (53 loc) · 2.02 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
<?php
/**
* Uninstall plugin file
*
* @package notification
*/
declare(strict_types=1);
/**
* Load the vendor autoload.
*/
require_once __DIR__ . '/vendor/autoload.php';
global $wpdb;
$generalSettings = get_option('notification_general');
$un = $generalSettings['uninstallation'];
// Remove notifications.
if (isset($un['notifications']) && $un['notifications'] === 'true') {
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'notification'" ); // phpcs:ignore
}
// Remove settings.
if (isset($un['settings']) && $un['settings'] === 'true') {
$settingsConfig = get_option('_transient_notification_settings_config');
foreach ($settingsConfig as $sectionSlug => $section) {
delete_option('notification_' . $sectionSlug);
delete_site_option('notification_' . $sectionSlug);
}
delete_option('_notification_settings_config');
delete_option('_notification_settings_hash');
}
// Remove licenses.
if (isset($un['licenses']) && $un['licenses'] === 'true') {
$extensionsClass = new BracketSpace\Notification\Admin\Extensions();
$extensionsClass->loadExtensions();
$premiumExtensions = $extensionsClass->premiumExtensions;
foreach ($premiumExtensions as $extension) {
$license = $extension['license'];
if (!$license->isValid()) {
continue;
}
$license->deactivate();
}
delete_option('notification_licenses');
}
// Remove tables.
$wpdb->query($wpdb->prepare('DROP TABLE IF EXISTS %i', $wpdb->prefix . 'notification_logs')); // phpcs:ignore
$wpdb->query($wpdb->prepare('DROP TABLE IF EXISTS %i', $wpdb->prefix . 'notifications')); // phpcs:ignore
$wpdb->query($wpdb->prepare('DROP TABLE IF EXISTS %i', $wpdb->prefix . 'notification_carriers')); // phpcs:ignore
$wpdb->query($wpdb->prepare('DROP TABLE IF EXISTS %i', $wpdb->prefix . 'notification_extras')); // phpcs:ignore
// Remove other things.
delete_option('notification_story_dismissed');
delete_option('notification_wizard_dismissed');
delete_option('notification_debug_log');
delete_option('notification_data_version');
delete_option('notification_db_version');