PluginProbe ʕ •ᴥ•ʔ
WP-Sweep / 2.0.1
WP-Sweep v2.0.1
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 5 days ago js 5 days ago LICENSE 2 weeks ago index.php 2 weeks ago readme.txt 5 days ago uninstall.php 5 days ago wp-sweep.php 5 days ago
uninstall.php
58 lines
1 <?php
2 /**
3 * Removes everything WP-Sweep ever stored.
4 *
5 * The plugin stores nothing: no settings row, no version row, no database
6 * tables, no capabilities and no scheduled events. Two rows are deleted anyway,
7 * because 2.0.0 beta builds wrote them before it settled on storing nothing --
8 * `wp_sweep_options` held settings and `wp_sweep_version` held the two markers
9 * -- and a site that ran one of those builds is the only place either will ever
10 * be found.
11 *
12 * 1.2.0 stored nothing either, so uninstalling one of those installs finds
13 * nothing to remove -- and this file still looped over every site on a network
14 * to call an empty function, a loop that carried three bugs at once, none of
15 * which mattered, because there was nothing to delete.
16 *
17 * The loop is the correct one now: get_sites() with
18 * 'fields' => 'ids' so full WP_Site objects are not hydrated to read one
19 * column, 'number' => 0 so it does not silently stop at the default of 100
20 * sites, and restore_current_blog() inside the loop body so the switch stack
21 * does not end up unwound by exactly one.
22 *
23 * @package WP-Sweep
24 */
25
26 // Exit if WordPress did not initiate this uninstall.
27 defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
28
29 /**
30 * Delete the plugin's option rows on the current site.
31 *
32 * The names are written out literally: uninstall.php runs without the plugin
33 * loaded, and there is no options class to read them from in any case.
34 *
35 * @return void
36 */
37 function wp_sweep_uninstall_site() {
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_uninstall_site();
53 restore_current_blog();
54 }
55 } else {
56 wp_sweep_uninstall_site();
57 }
58