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 #123 from WordPress/enhance/self-deactivating
Browse files Browse the repository at this point in the history
Self-deactivate the plugin after the functionality has been merged to core
  • Loading branch information
audrasjb authored May 13, 2020
2 parents 044c092 + e2ebccd commit 44ed4a2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions wp-autoupdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@
* Text Domain: wp-autoupdates
*/


if ( ! defined( 'ABSPATH' ) ) {
die( 'Invalid request.' );
}


define( 'WP_AUTO_UPDATES_VERSION', '0.7.0' );


/**
* Load only when needed.
*/
if ( ! function_exists( 'wp_is_plugins_auto_update_enabled' ) ) {
include_once plugin_dir_path( __FILE__ ) . 'functions.php';
// Needs to run after the admin APIs have been loaded from wp-admin/includes/.
function wp_autoupdates_self_deactivate() {
if (
function_exists( 'wp_get_auto_update_message' ) ||
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() );
}
}
add_action( 'admin_init', 'wp_autoupdates_self_deactivate', 1 );

include_once plugin_dir_path( __FILE__ ) . 'functions.php';


/**
Expand All @@ -46,3 +50,4 @@ function wp_auto_update_uninstall() {
delete_site_option( 'wp_auto_update_plugins' );
delete_site_option( 'wp_auto_update_themes' );
}

0 comments on commit 44ed4a2

Please sign in to comment.