From e518f13444098153f4aa1369691206da4f7f0d45 Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Wed, 12 Jun 2019 14:02:12 +0800 Subject: [PATCH] Cancel all wc-admin actions on deactivate --- plugins/woocommerce-admin/uninstall.php | 3 --- plugins/woocommerce-admin/woocommerce-admin.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce-admin/uninstall.php b/plugins/woocommerce-admin/uninstall.php index 4dca624bc44..cce9bc68cc7 100644 --- a/plugins/woocommerce-admin/uninstall.php +++ b/plugins/woocommerce-admin/uninstall.php @@ -10,7 +10,4 @@ defined( 'WP_UNINSTALL_PLUGIN' ) || exit; require_once dirname( __FILE__ ) . '/woocommerce-admin.php'; WC_Admin_Feature_Plugin::instance()->includes(); -WC_Admin_Reports_Sync::clear_queued_actions(); -WC_Admin_Notes::clear_queued_actions(); WC_Admin_Install::delete_table_data(); -wp_clear_scheduled_hook( 'wc_admin_daily' ); diff --git a/plugins/woocommerce-admin/woocommerce-admin.php b/plugins/woocommerce-admin/woocommerce-admin.php index d04133e86ed..28c64136973 100755 --- a/plugins/woocommerce-admin/woocommerce-admin.php +++ b/plugins/woocommerce-admin/woocommerce-admin.php @@ -56,6 +56,7 @@ class WC_Admin_Feature_Plugin { public function init() { $this->define_constants(); register_activation_hook( WC_ADMIN_PLUGIN_FILE, array( $this, 'on_activation' ) ); + register_deactivation_hook( WC_ADMIN_PLUGIN_FILE, array( $this, 'on_deactivation' ) ); add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) ); add_filter( 'action_scheduler_store_class', array( $this, 'replace_actionscheduler_store_class' ) ); } @@ -71,6 +72,18 @@ class WC_Admin_Feature_Plugin { WC_Admin_Install::create_events(); } + /** + * Remove WooCommerce Admin scheduled actions on deactivate. + * + * @return void + */ + public function on_deactivation() { + $this->includes(); + WC_Admin_Reports_Sync::clear_queued_actions(); + WC_Admin_Notes::clear_queued_actions(); + wp_clear_scheduled_hook( 'wc_admin_daily' ); + } + /** * Setup plugin once all other plugins are loaded. *