-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathuninstall.php
More file actions
57 lines (53 loc) · 1.73 KB
/
Copy pathuninstall.php
File metadata and controls
57 lines (53 loc) · 1.73 KB
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
51
52
53
54
55
56
57
<?php
/**
* Removes everything WP-Sweep stored.
*
* One option row and nothing else: no settings row, no database tables, no
* capabilities and no scheduled events. `wp_sweep_version` holds the two
* markers; `wp_sweep_options` is a settings row that only a 2.0.0 beta ever
* wrote, deleted here for the same reason the upgrade deletes it.
*
* Before 2.0.0 the plugin stored nothing at all, so uninstalling a 1.2.0 install
* finds nothing to remove -- and this file still looped over every site on a
* network to call an empty function, a loop that carried three bugs at once,
* none of which mattered, because there was nothing to delete.
*
* Now that there is, the loop is the correct one: get_sites() with
* 'fields' => 'ids' so full WP_Site objects are not hydrated to read one
* column, 'number' => 0 so it does not silently stop at the default of 100
* sites, and restore_current_blog() inside the loop body so the switch stack
* does not end up unwound by exactly one.
*
* @package WP-Sweep
*/
// Exit if WordPress did not initiate this uninstall.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* Delete the plugin's option rows on the current site.
*
* The names are written out rather than read from WP_Sweep_Options, because
* uninstall.php runs without the plugin loaded.
*
* @return void
*/
function wp_sweep_delete_options() {
delete_option( 'wp_sweep_options' );
delete_option( 'wp_sweep_version' );
}
if ( is_multisite() ) {
$wp_sweep_site_ids = get_sites(
array(
'fields' => 'ids',
'number' => 0,
)
);
foreach ( $wp_sweep_site_ids as $wp_sweep_site_id ) {
switch_to_blog( (int) $wp_sweep_site_id );
wp_sweep_delete_options();
restore_current_blog();
}
} else {
wp_sweep_delete_options();
}