Clear scheduled actions on plugin deactivate (https://github.com/woocommerce/woocommerce-admin/pull/1715)
This commit is contained in:
parent
fce16ade7a
commit
b7d36c90e8
|
@ -14,7 +14,7 @@ class WC_Admin_Install {
|
|||
/**
|
||||
* Plugin version.
|
||||
*
|
||||
* @TODO: get this dynamically?
|
||||
* @todo get this dynamically?
|
||||
*/
|
||||
const VERSION_NUMBER = '0.6.0';
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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' );
|
||||
|
||||
|
|
Loading…
Reference in New Issue