-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
50 lines (48 loc) · 1.63 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
<?php
if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) {
// Make sure not to call this file directly
exit();
} else {
// Is this WordPressMU or not?
if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
$s2_mu = true;
}
if ( function_exists('is_multisite') && is_multisite() ) {
$s2_mu = true;
}
if ( $s2_mu ) {
global $wpdb;
$blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
foreach ( $blogs as $blog ) {
switch_to_blog($blog);
s2_uninstall();
restore_current_blog();
}
} else {
s2_uninstall();
}
}
function s2_uninstall() {
global $wpdb;
// get name of subscribe2 table
$public = $wpdb->prefix . "subscribe2";
// delete entry from wp_options table
delete_option('subscribe2_options');
// delete legacy entry from wp-options table
delete_option('s2_future_posts');
// remove and scheduled events
wp_clear_scheduled_hook('s2_digest_cron');
// delete usermeta data for registered users
// use LIKE and % wildcard as meta_key names are prepended on WPMU
// and s2_cat is appended with category ID integer
$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_cat%'");
$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_subscribed'");
$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_format'");
$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_autosub'");
// delete any postmeta data that supressed notifications
$wpdb->query("DELETE from $wpdb->postmeta WHERE meta_key = 's2mail'");
// drop the subscribe2 table
$sql = "DROP TABLE IF EXISTS `" . $public . "`";
$wpdb->query($sql);
} // end s2_uninstall()
?>