| 1 |
<?php |
| 2 |
/** |
| 3 |
* phpinfo() WP — uninstall cleanup. |
| 4 |
* |
| 5 |
* Fires once when the plugin is deleted via the WP admin (not on deactivate). |
| 6 |
* Remove the safemode mu-plugin we may have installed, clear our options and |
| 7 |
* transients, and tidy up legacy cache files. |
| 8 |
*/ |
| 9 |
defined('WP_UNINSTALL_PLUGIN') or die(); |
| 10 |
|
| 11 |
// 1. Remove the troubleshooting-mode mu-plugin if present. |
| 12 |
$mu_dir = defined('WPMU_PLUGIN_DIR') && WPMU_PLUGIN_DIR |
| 13 |
? WPMU_PLUGIN_DIR |
| 14 |
: WP_CONTENT_DIR . '/mu-plugins'; |
| 15 |
$mu_file = $mu_dir . '/phpinfowp-safemode.php'; |
| 16 |
if (file_exists($mu_file)) @unlink($mu_file); |
| 17 |
|
| 18 |
// 2. Drop our options. |
| 19 |
$options = [ |
| 20 |
'phpinfowp_compat_result', |
| 21 |
'phpinfowp_ssl_domains', |
| 22 |
'phpinfowp_last_unhealthy_ts', |
| 23 |
'phpinfowp_opcache_baseline_hit', |
| 24 |
'phpinfowp_install_ts', |
| 25 |
]; |
| 26 |
foreach ($options as $opt) delete_option($opt); |
| 27 |
|
| 28 |
// 3. Drop our transients (peak-memory daily keys, safemode session tokens, |
| 29 |
// SSL cache per host, security-headers cache). |
| 30 |
global $wpdb; |
| 31 |
$wpdb->query( |
| 32 |
"DELETE FROM {$wpdb->options} |
| 33 |
WHERE option_name LIKE '\\_transient\\_phpinfowp\\_%' |
| 34 |
OR option_name LIKE '\\_transient\\_timeout\\_phpinfowp\\_%'" |
| 35 |
); |
| 36 |
|
| 37 |
// 4. Drop snapshots table (Pro feature). |
| 38 |
$table = $wpdb->prefix . 'phpinfowp_snapshots'; |
| 39 |
$wpdb->query("DROP TABLE IF EXISTS {$table}"); |
| 40 |
|
| 41 |
// 5. Legacy cache files from older versions. |
| 42 |
@unlink('../htaccess.txt'); |
| 43 |
@unlink('../htaccess-phpinfo.txt'); |
| 44 |
@unlink('../userini-phpinfo.txt'); |
| 45 |
|
| 46 |
// 6. Clear scheduled events. |
| 47 |
wp_clear_scheduled_hook('phpinfowp_license_ping'); |
| 48 |
wp_clear_scheduled_hook('phpinfowp_weekly_maintenance'); |
| 49 |
|