Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #133 from WordPress/enhance/copy-site-options-on-s…
Browse files Browse the repository at this point in the history
…elf-deactivation

Copy the plugin's site options to core's site options on self-deactivation
  • Loading branch information
pbiron authored May 17, 2020
2 parents 7fd47c2 + a766457 commit 9f51e85
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions wp-autoupdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ function_exists( 'wp_is_auto_update_enabled_for_type' )
) {
// Deactivate the plugin. This functionality has already been merged to core.
deactivate_plugins( plugin_basename( __FILE__ ), false, is_network_admin() );

// The names of the site options changed in the core merge,
// so copy the plugin's site options to core's.
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
if ( ! empty( $auto_updates ) ) {
$auto_updates = array_merge( $auto_updates, (array) get_site_option( 'wp_auto_update_plugins', array() ) );

update_site_option( 'auto_update_plugins', $auto_updates );
}

$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
if ( ! empty( $auto_updates ) ) {
$auto_updates = array_merge( $auto_updates, (array) get_site_option( 'wp_auto_update_themes', array() ) );

update_site_option( 'auto_update_themes', $auto_updates );
}
}
}
add_action( 'admin_init', 'wp_autoupdates_self_deactivate', 1 );
Expand Down

0 comments on commit 9f51e85

Please sign in to comment.