forked from samperrow/pre-party-browser-hints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
36 lines (28 loc) · 994 Bytes
/
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
<?php
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
die();
}
function gktpp_uninstall_plugin() {
global $wpdb;
delete_option( 'gktpp_preconnect_status' );
delete_option( 'gktpp_reset_preconnect' );
delete_option( 'gktpp_send_in_header' );
delete_user_meta( get_current_user_id(), 'gktpp_screen_options' );
$table = $wpdb->prefix . 'gktpp_table';
$sites = [ $table ];
if ( is_multisite() ) {
$blogTable = $wpdb->base_prefix . 'blogs';
$data = $wpdb->get_results("SELECT blog_id FROM $blogTable WHERE blog_id != 1;");
if ($data) {
foreach ($data as $object) {
$sitePpTable = $wpdb->base_prefix . $object->blog_id . '_gktpp_table';
array_push( $sites, $sitePpTable );
}
}
}
foreach ( $sites as $site ) {
$sql = "DROP TABLE IF EXISTS $site";
$wpdb->query( $sql, null );
}
}
gktpp_uninstall_plugin();