forked from BracketSpace/Notification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
44 lines (29 loc) · 1.13 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
<?php
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
die;
}
global $wpdb;
require_once( 'inc/singleton.php' );
require_once( 'inc/settings/section.php' );
require_once( 'inc/settings/group.php' );
require_once( 'inc/settings/field.php' );
require_once( 'inc/settings/corefields.php' );
require_once( 'inc/settings.php' );
Notification\Settings::get()->register_settings();
$settings = Notification\Settings::get()->get_settings();
file_put_contents( dirname( __FILE__ ) . '/log', print_r( $settings, true ) . "\r\n\r\n", FILE_APPEND );
if ( isset( $settings['general']['uninstallation'] ) ) {
$un = $settings['general']['uninstallation'];
// remove notifications
if ( isset( $un['notifications'] ) && $un['notifications'] == 'true' ) {
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'notification'" );
}
// remove settings
if ( isset( $un['settings'] ) && $un['settings'] == 'true' ) {
$sections = Notification\Settings::get()->get_sections();
foreach ( $sections as $section_slug => $section ) {
delete_option( 'notification_' . $section_slug );
delete_site_option( 'notification_' . $section_slug );
}
}
}