Run woocommerce_admin_updated as a scheduled action (https://github.com/woocommerce/woocommerce-admin/pull/8423)

* run woocommerce_admin_updated as a scheduled action

* Rename the action
This commit is contained in:
Moon 2022-03-07 18:26:09 -08:00 committed by GitHub
parent 9aba93d127
commit 86b94e64c3
1 changed files with 18 additions and 1 deletions

View File

@ -39,7 +39,24 @@ class RemoteInboxNotificationsEngine {
// Hook into WCA updated. This is hooked up here rather than in
// on_admin_init because that runs too late to hook into the action.
add_action( 'woocommerce_admin_updated', array( __CLASS__, 'run_on_woocommerce_admin_updated' ) );
add_action(
'woocommerce_admin_updated',
function() {
$next_hook = WC()->queue()->get_next(
'woocommerce_run_on_woocommerce_admin_updated',
array( __CLASS__, 'run_on_woocommerce_admin_updated' ),
'woocommerce-remote-inbox-engine'
);
if ( null === $next_hook ) {
WC()->queue()->schedule_single(
time(),
'woocommerce_run_on_woocommerce_admin_updated',
array( __CLASS__, 'run_on_woocommerce_admin_updated' ),
'woocommerce-remote-inbox-engine'
);
}
}
);
}
/**