Skip to content

Commit e0ad3d8

Browse files
committed
Remove plugin option for Multisite during uninstall
1 parent ab08abd commit e0ad3d8

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

uninstall.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,34 @@
1111
exit;
1212
}
1313

14-
delete_option( 'perflab_modules_settings' );
14+
if ( is_multisite() ) {
15+
delete_data_multisite();
16+
} else {
17+
delete_data();
18+
}
19+
20+
/**
21+
* Delete data for the current blog.
22+
*/
23+
function delete_data() {
24+
25+
delete_option( 'perflab_modules_settings' );
26+
}
27+
28+
/**
29+
* Delete data for multisite blogs.
30+
*/
31+
function delete_data_multisite() {
32+
global $wpdb;
33+
34+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
35+
$original_blog_id = get_current_blog_id();
36+
37+
foreach ( $blog_ids as $current_blog_id ) {
38+
switch_to_blog( $current_blog_id );
39+
40+
delete_data();
41+
}
42+
43+
switch_to_blog( $original_blog_id );
44+
}

0 commit comments

Comments
 (0)