Skip to content

Commit

Permalink
Admin Settings: Delete all settings when the plugin is uninstalled. (
Browse files Browse the repository at this point in the history
…#118)

* `Admin Settings`: Add multisite-safe deletion of all settings.

* Delete all settings when the plugin is uninstalled.
  • Loading branch information
costdev authored Nov 4, 2024
1 parent f9ff7b8 commit 02ec059
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aspire-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ function aspire_update() {
new AspireUpdate\Controller();
}
}

register_activation_hook( __FILE__, 'aspire_update_activation_hook' );
function aspire_update_activation_hook() {
register_uninstall_hook( __FILE__, 'aspire_update_uninstall_hook' );
}

function aspire_update_uninstall_hook() {
$admin_settings = AspireUpdate\Admin_Settings::get_instance();
$admin_settings->delete_all_settings();
}
9 changes: 9 additions & 0 deletions includes/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ public function reset_settings() {
}
}

/**
* Delete all settings.
*
* @return void
*/
public function delete_all_settings() {
delete_site_option( $this->option_name );
}

/**
* The Admin Notice to convey a Reset Operation has happened.
*
Expand Down

0 comments on commit 02ec059

Please sign in to comment.