diff --git a/uninstall.php b/uninstall.php index bb5cb13fdc..89e2fac25f 100644 --- a/uninstall.php +++ b/uninstall.php @@ -11,4 +11,31 @@ exit; } -delete_option( 'perflab_modules_settings' ); +// 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). +if ( is_multisite() ) { + $site_ids = get_sites( + array( + 'fields' => 'ids', + 'number' => 100, + 'update_site_cache' => false, + 'update_site_meta_cache' => false, + ) + ); + + foreach ( $site_ids as $site_id ) { + switch_to_blog( $site_id ); + perflab_delete_plugin_option(); + restore_current_blog(); + } +} + +perflab_delete_plugin_option(); + +/** + * Delete the current site's option. + * + * @since n.e.x.t + */ +function perflab_delete_plugin_option() { + delete_option( 'perflab_modules_settings' ); +}