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

Copy the plugin's site options to core's site options on self-deactivation #133

Merged
merged 2 commits into from
May 17, 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
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