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

Remove setting from site option when deleting plugin #32

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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