| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin uninstaller logic. |
| 4 |
* |
| 5 |
* @package speculation-rules |
| 6 |
* @since 1.2.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
// If uninstall.php is not called by WordPress, bail. |
| 10 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
// For a multisite, delete the option for all sites (however limited to 100 sites to avoid memory limit or timeout problems in large scale networks). |
| 15 |
if ( is_multisite() ) { |
| 16 |
$site_ids = get_sites( |
| 17 |
array( |
| 18 |
'fields' => 'ids', |
| 19 |
'number' => 100, |
| 20 |
'update_site_cache' => false, |
| 21 |
'update_site_meta_cache' => false, |
| 22 |
) |
| 23 |
); |
| 24 |
|
| 25 |
foreach ( $site_ids as $site_id ) { |
| 26 |
switch_to_blog( $site_id ); |
| 27 |
plsr_delete_plugin_option(); |
| 28 |
restore_current_blog(); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
plsr_delete_plugin_option(); |
| 33 |
|
| 34 |
/** |
| 35 |
* Delete the current site's option. |
| 36 |
* |
| 37 |
* @since 1.2.0 |
| 38 |
*/ |
| 39 |
function plsr_delete_plugin_option(): void { |
| 40 |
delete_option( 'plsr_speculation_rules' ); |
| 41 |
} |
| 42 |
|