Only check for unsnooze note scheduled action in admin_init

This commit is contained in:
Ron Rennick 2019-04-01 11:31:28 -03:00
parent 17141cd4d8
commit f730a8ec5d
1 changed files with 14 additions and 8 deletions

View File

@ -18,16 +18,10 @@ class WC_Admin_Notes {
const UNSNOOZE_HOOK = 'wc_admin_unsnooze_admin_notes';
/**
* Schedule events and hook appropriate actions.
* Hook appropriate actions.
*/
public static function init() {
$queue = WC()->queue();
$next = $queue->get_next( self::UNSNOOZE_HOOK );
if ( ! $next ) {
$queue->schedule_recurring( time(), HOUR_IN_SECONDS, self::UNSNOOZE_HOOK );
}
add_action( 'admin_init', array( __CLASS__, 'schedule_unsnooze_notes' ) );
add_action( self::UNSNOOZE_HOOK, array( __CLASS__, 'unsnooze_notes' ) );
}
@ -128,6 +122,18 @@ class WC_Admin_Notes {
}
}
}
/**
* Schedule unsnooze notes event.
*/
public static function schedule_unsnooze_notes() {
$queue = WC()->queue();
$next = $queue->get_next( self::UNSNOOZE_HOOK );
if ( ! $next ) {
$queue->schedule_recurring( time(), HOUR_IN_SECONDS, self::UNSNOOZE_HOOK );
}
}
}
WC_Admin_Notes::init();