tasks() as $interval => $job ) { if ( ! wp_next_scheduled( $job['hook'], $job['callback_args'] ) ) { wp_schedule_event( time() + $recurrences[ $interval ]['interval'], $interval, $job['hook'], $job['callback_args'] ); } add_action( $job['hook'], $job['callback'] ); } } /** * Unschedule the job * * @param string $hook Parameter passed from the scheduled event. * * @return void */ public function unschedule( $hook = '' ) { foreach ( $this->tasks() as $interval => $job ) { $timestamp = wp_next_scheduled( $job['hook'], $job['callback_args'] ); if ( false !== $timestamp ) { wp_unschedule_event( $timestamp, $job['hook'], $job['callback_args'] ); } } } /** * Register the tasks * * @return mixed */ abstract public function tasks(); }