Only check for unsnooze note scheduled action in admin_init
This commit is contained in:
parent
17141cd4d8
commit
f730a8ec5d
|
@ -18,16 +18,10 @@ class WC_Admin_Notes {
|
||||||
const UNSNOOZE_HOOK = 'wc_admin_unsnooze_admin_notes';
|
const UNSNOOZE_HOOK = 'wc_admin_unsnooze_admin_notes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule events and hook appropriate actions.
|
* Hook appropriate actions.
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
public static function init() {
|
||||||
$queue = WC()->queue();
|
add_action( 'admin_init', array( __CLASS__, 'schedule_unsnooze_notes' ) );
|
||||||
$next = $queue->get_next( self::UNSNOOZE_HOOK );
|
|
||||||
|
|
||||||
if ( ! $next ) {
|
|
||||||
$queue->schedule_recurring( time(), HOUR_IN_SECONDS, self::UNSNOOZE_HOOK );
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( self::UNSNOOZE_HOOK, array( __CLASS__, '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();
|
WC_Admin_Notes::init();
|
||||||
|
|
Loading…
Reference in New Issue