Skip to content

Commit

Permalink
Use get_sites()
Browse files Browse the repository at this point in the history
Fixes #104
  • Loading branch information
ajaydsouza committed Nov 2, 2023
1 parent 59c576c commit 7f75006
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ Know of a better profanity filter? Suggest one in the [forums](https://wordpress

== Changelog ==

= 3.3.0 =

* Enhancements:
* Uninstall now uses `get_sites()` behind the scenes to delete options from all sites in a multisite install

= 3.2.2 =

* Enhancements:
Expand Down
16 changes: 8 additions & 8 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

if ( is_multisite() ) {

// Get all blogs in the network and activate plugin on each one.
$blog_ids = $wpdb->get_col( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery
"
SELECT blog_id FROM $wpdb->blogs
WHERE archived = '0' AND spam = '0' AND deleted = '0'
"
$sites = get_sites(
array(
'archived' => 0,
'spam' => 0,
'deleted' => 0,
)
);

foreach ( $blog_ids as $blogid ) {
switch_to_blog( $blogid );
foreach ( $sites as $site ) {
switch_to_blog( (int) $site->blog_id );
bsearch_delete_data();
restore_current_blog();
}
Expand Down

0 comments on commit 7f75006

Please sign in to comment.