PluginProbe
Simple Analytics / 1.112
Simple Analytics v1.112
1.113 1.112 1.111 1.110 1.109 1.108 1.107 1.106 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 All 102 releases
← All changes | uninstall.php +25 -13 1.8 → 1.112 View file →
@@ -1,17 +1,29 @@
1 1 <?php
2 2
3 -/**
4 - *
5 - * This file runs when the plugin in uninstalled (deleted).
6 - * This will not run when the plugin is deactivated.
7 - * Ideally you will add all your clean-up scripts here
8 - * that will clean-up unused meta, options, etc. in the database.
9 - *
10 - */
3 +defined('WP_UNINSTALL_PLUGIN') || exit;
11 4
12 -// If plugin is not being uninstalled, exit (do nothing)
13 -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
14 - exit;
5 +require_once __DIR__ . '/src/SettingName.php';
6 +
7 +$deleteOptions = static function (): void {
8 + foreach (SimpleAnalytics\SettingName::cases() as $key) {
9 + delete_option($key);
10 + }
11 +};
12 +
13 +if (is_multisite()) {
14 + $offset = 0;
15 + do {
16 + $siteIds = get_sites(['fields' => 'ids', 'number' => 100, 'offset' => $offset, 'orderby' => 'id', 'order' => 'ASC']);
17 + foreach ($siteIds as $siteId) {
18 + switch_to_blog($siteId);
19 + try {
20 + $deleteOptions();
21 + } finally {
22 + restore_current_blog();
23 + }
24 + }
25 + $offset += count($siteIds);
26 + } while (count($siteIds) === 100);
27 +} else {
28 + $deleteOptions();
15 29 }
16 -
17 -// Do something here if plugin is being uninstalled.