PluginProbe ʕ •ᴥ•ʔ
WP-Sweep / 2.0.0
WP-Sweep v2.0.0
2.0.1 2.0.0 1.2.0 trunk 1.0.10 1.0.11 1.0.12 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9
wp-sweep / uninstall.php
wp-sweep Last commit date
includes 2 weeks ago js 2 weeks ago LICENSE 2 weeks ago index.php 2 weeks ago readme.txt 2 weeks ago uninstall.php 2 weeks ago wp-sweep.php 2 weeks ago
uninstall.php
58 lines
1 <?php
2 /**
3 * Removes everything WP-Sweep stored.
4 *
5 * One option row and nothing else: no settings row, no database tables, no
6 * capabilities and no scheduled events. `wp_sweep_version` holds the two
7 * markers; `wp_sweep_options` is a settings row that only a 2.0.0 beta ever
8 * wrote, deleted here for the same reason the upgrade deletes it.
9 *
10 * Before 2.0.0 the plugin stored nothing at all, so uninstalling a 1.2.0 install
11 * finds nothing to remove -- and this file still looped over every site on a
12 * network to call an empty function, a loop that carried three bugs at once,
13 * none of which mattered, because there was nothing to delete.
14 *
15 * Now that there is, the loop is the correct one: get_sites() with
16 * 'fields' => 'ids' so full WP_Site objects are not hydrated to read one
17 * column, 'number' => 0 so it does not silently stop at the default of 100
18 * sites, and restore_current_blog() inside the loop body so the switch stack
19 * does not end up unwound by exactly one.
20 *
21 * @package WP-Sweep
22 */
23
24 // Exit if WordPress did not initiate this uninstall.
25 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
26 exit;
27 }
28
29 /**
30 * Delete the plugin's option rows on the current site.
31 *
32 * The names are written out rather than read from WP_Sweep_Options, because
33 * uninstall.php runs without the plugin loaded.
34 *
35 * @return void
36 */
37 function wp_sweep_delete_options() {
38 delete_option( 'wp_sweep_options' );
39 delete_option( 'wp_sweep_version' );
40 }
41
42 if ( is_multisite() ) {
43 $wp_sweep_site_ids = get_sites(
44 array(
45 'fields' => 'ids',
46 'number' => 0,
47 )
48 );
49
50 foreach ( $wp_sweep_site_ids as $wp_sweep_site_id ) {
51 switch_to_blog( (int) $wp_sweep_site_id );
52 wp_sweep_delete_options();
53 restore_current_blog();
54 }
55 } else {
56 wp_sweep_delete_options();
57 }
58