-
Notifications
You must be signed in to change notification settings - Fork 38
/
uninstall.php
38 lines (26 loc) · 990 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
37
38
<?php
if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit; // Exit if accessed directly
}
global $wpdb;
if ( is_multisite() ) {
$sql = "DELETE FROM $wpdb->sitemeta WHERE `meta_key` LIKE 'wp_weixin%'";
$blog_ids = array_map( function( $site ) {
return absint( $site->blog_id );
}, get_sites() );
$wpdb->query( $sql ); // @codingStandardsIgnoreLine
} else {
$blog_ids = array( get_current_blog_id() );
}
foreach ( $blog_ids as $blog_id ) {
if ( is_multisite() ) {
switch_to_blog( $blog_id );
}
$sql = "DELETE FROM $wpdb->options WHERE `option_name` LIKE '_transient_wp_weixin_%' OR `option_name` LIKE 'wp_weixin_%'";
$wpdb->query( $wpdb->prepare( $sql ) ); // @codingStandardsIgnoreLine
if ( is_multisite() ) {
restore_current_blog();
}
}
$sql = "DELETE FROM $wpdb->usermeta WHERE `meta_key` LIKE 'wx_openid%' OR `meta_key` IN ( 'wx_unionid', 'wp_weixin_rawdata', 'wx_follower' )";
$wpdb->query( $sql ); // @codingStandardsIgnoreLine