Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #32 from bookdude13/iss29_delete_preference
Browse files Browse the repository at this point in the history
Remove setting from site option when deleting plugin
  • Loading branch information
audrasjb authored Mar 5, 2020
2 parents 4d89b5b + ef837b0 commit a83efc3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions wp-autoupdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,25 @@ function wp_autoupdates_plugins_bulk_actions_handle( $redirect_to, $doaction, $i
add_action( 'handle_bulk_actions-plugins', 'wp_autoupdates_plugins_bulk_actions_handle', 10, 3 );


/**
* Handle cleanup when plugin deleted
*/
function wp_autoupdates_plugin_deleted( $plugin_file, $deleted ) {
// Do nothing if the plugin wasn't deleted
if ( ! $deleted ) {
return;
}

// Remove settings
$wp_auto_update_plugins = get_site_option( 'wp_auto_update_plugins', array() );
if ( in_array( $plugin_file, $wp_auto_update_plugins, true ) ) {
$wp_auto_update_plugins = array_diff( $wp_auto_update_plugins, array( $plugin_file ) );
update_site_option( 'wp_auto_update_plugins', $wp_auto_update_plugins );
}
}
add_action( 'deleted_plugin', 'wp_autoupdates_plugin_deleted', 10, 2 );


/**
* Auto-update notices
*/
Expand Down

0 comments on commit a83efc3

Please sign in to comment.