26 public static function init()
28 static $instance = null;
29 if ( is_null( $instance ) ) {
45 add_filter(
'cron_schedules', array( $this,
'cron_schedules' ) );
59 $new_schedules = array(
60 self::HALF_HOUR => array(
61 'interval' => HOUR_IN_SECONDS / 2,
62 'display' => __(
'Half hour', WPDK_TEXTDOMAIN )
64 self::TWO_MINUTES => array(
65 'interval' => MINUTE_IN_SECONDS * 2,
66 'display' => __(
'Two minutes', WPDK_TEXTDOMAIN )
70 return array_merge( $schedules, $new_schedules );
106 $this->cron = _get_cron_array();
116 public static function remove( $name )
118 $name = sanitize_title( $name );
121 $timestamp = wp_next_scheduled( $name );
124 wp_unschedule_event( $timestamp, $name );
136 $name = sanitize_title( $name );
137 wp_clear_scheduled_hook( $name );
173 $this->name = sanitize_title(
$name );
174 $this->timestamp = empty( $timestap ) ? time() : $timestap;
178 add_action( $this->name, array( $this,
'cron' ) );
181 if ( !wp_next_scheduled( $this->name ) ) {
184 if ( empty( $timestap ) && !empty(
$recurrence ) ) {
185 wp_schedule_event( time(),
$recurrence, $this->name );
188 elseif ( !empty( $timestap ) ) {
189 wp_schedule_single_event( $timestap, $this->name );
212 public function remove()
274 parent::__construct(
$name, $timestap );