| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin uninstall handler. |
| 4 |
* |
| 5 |
* Fired by WordPress when the user clicks "Delete" on the Plugins |
| 6 |
* screen and confirms. Our job here is to leave the site in the same |
| 7 |
* state it would be in if the plugin had never been installed: |
| 8 |
* |
| 9 |
* - Delete the unified settings option and the version marker. |
| 10 |
* - Delete the legacy single-key options from pre-3.0 installs. |
| 11 |
* - Delete the review-notice scheduling option and the per-user |
| 12 |
* dismissal meta. |
| 13 |
* |
| 14 |
* We intentionally do NOT touch the `session_tokens` user meta — that |
| 15 |
* is core WordPress data, not ours; nuking it would log every user |
| 16 |
* out unnecessarily. |
| 17 |
* |
| 18 |
* @package FoxeLabs\Loggedin |
| 19 |
*/ |
| 20 |
|
| 21 |
// `WP_UNINSTALL_PLUGIN` is set by core only when this file is invoked |
| 22 |
// through the official uninstall path. Direct browser hits to this |
| 23 |
// file bail here. |
| 24 |
defined( 'WP_UNINSTALL_PLUGIN' ) || exit; |
| 25 |
|
| 26 |
// Current option keys. |
| 27 |
delete_option( 'loggedin_settings' ); |
| 28 |
delete_option( 'loggedin_version' ); |
| 29 |
|
| 30 |
// Legacy single-key options — kept here in addition to the migrator |
| 31 |
// so that a clean uninstall removes them even on sites that never ran |
| 32 |
// a version with the upgrader. |
| 33 |
delete_option( 'loggedin_maximum' ); |
| 34 |
delete_option( 'loggedin_logic' ); |
| 35 |
|
| 36 |
// Review-notice scheduling. |
| 37 |
delete_option( 'loggedin_rating_notice' ); |
| 38 |
|
| 39 |
global $wpdb; |
| 40 |
|
| 41 |
/* |
| 42 |
* Drop the per-user "I dismissed the review notice" meta in a single |
| 43 |
* query. `WP_User_Query` would iterate users one at a time, which |
| 44 |
* scales poorly on large sites; a direct `wpdb->delete` is the |
| 45 |
* pragmatic choice here even though it bypasses any cache layer |
| 46 |
* stacked on top of the usermeta table (the cache is invalidated |
| 47 |
* automatically on the next read). |
| 48 |
*/ |
| 49 |
$wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery |
| 50 |
$wpdb->usermeta, |
| 51 |
array( |
| 52 |
'meta_key' => 'loggedin_rating_notice_dismissed', // phpcs:ignore WordPress.DB.SlowDBQuery |
| 53 |
) |
| 54 |
); |
| 55 |
|