From 902848854830d43bab5e0a803cdca127a717adcf Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Wed, 12 Jun 2019 13:04:06 +0800 Subject: [PATCH] Remove table data on plugin deactivate --- plugins/woocommerce-admin/woocommerce-admin.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/woocommerce-admin/woocommerce-admin.php b/plugins/woocommerce-admin/woocommerce-admin.php index d04133e86ed..c7c501b3af7 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,16 @@ class WC_Admin_Feature_Plugin { WC_Admin_Install::create_events(); } + /** + * Remove WooCommerce Admin related table data. + * + * @return void + */ + public function on_deactivation() { + require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-install.php'; + WC_Admin_Install::delete_table_data(); + } + /** * Setup plugin once all other plugins are loaded. *