Cancel all wc-admin actions on deactivate

This commit is contained in:
Joshua Flowers 2019-06-12 14:02:12 +08:00 committed by Jeff Stieler
parent 4f44f97a67
commit e518f13444
2 changed files with 13 additions and 3 deletions

View File

@ -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' );

View File

@ -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.
*