This commit is contained in:
Justin Shreve 2019-02-28 16:47:58 -05:00 committed by GitHub
parent fce16ade7a
commit b7d36c90e8
3 changed files with 20 additions and 2 deletions

View File

@ -14,7 +14,7 @@ class WC_Admin_Install {
/**
* Plugin version.
*
* @TODO: get this dynamically?
* @todo get this dynamically?
*/
const VERSION_NUMBER = '0.6.0';

View File

@ -42,7 +42,7 @@ class WC_Admin_Reports_Sync {
const SINGLE_ORDER_ACTION = 'wc-admin_process_order';
/**
* Action hook for processing a batch of orders.
* Action scheduler group.
*/
const QUEUE_GROUP = 'wc-admin-data';
@ -105,6 +105,23 @@ class WC_Admin_Reports_Sync {
self::queue_dependent_action( self::ORDERS_LOOKUP_BATCH_INIT, array(), self::CUSTOMERS_BATCH_ACTION );
}
/**
* Clears all queued actions.
*/
public static function clear_queued_actions() {
$hooks = array(
self::QUEUE_BATCH_ACTION,
self::QUEUE_DEPEDENT_ACTION,
self::CUSTOMERS_BATCH_ACTION,
self::ORDERS_BATCH_ACTION,
self::ORDERS_LOOKUP_BATCH_INIT,
self::SINGLE_ORDER_ACTION,
);
foreach ( $hooks as $hook ) {
self::queue()->cancel_all( $hook, null, self::QUEUE_GROUP );
}
}
/**
* Adds regenerate tool.
*

View File

@ -124,6 +124,7 @@ add_action( 'admin_init', 'possibly_deactivate_wc_admin_plugin' );
*/
function deactivate_wc_admin_plugin() {
wp_clear_scheduled_hook( 'wc_admin_daily' );
WC_Admin_Reports_Sync::clear_queued_actions();
}
register_deactivation_hook( WC_ADMIN_PLUGIN_FILE, 'deactivate_wc_admin_plugin' );