Пример #1
0
 public function parse_crons()
 {
     foreach (_get_cron_array() as $timestamp => $crons) {
         foreach ($crons as $cron_name => $cron_args) {
             foreach ($cron_args as $cron) {
                 $this->crons[$timestamp + $this->time_offset][] = array('hook' => $cron_name, 'cron' => $cron, 'hash' => acm_get_cron_hash($cron_name, $timestamp, $cron['args'], !isset($cron['interval']) ? 0 : $cron['interval']));
             }
         }
     }
     ksort($this->crons);
 }
Пример #2
0
 public function remove_task()
 {
     $params = $_REQUEST;
     // Return error when noonce doesn't match
     if (!wp_verify_nonce($params['noonce'], 'remove_task_' . $params['task'])) {
         die(json_encode(array('status' => 'error', 'details' => __('Sorry, wrong noonce.', 'acm'))));
     }
     $args = empty($params['args']) ? array() : explode(',', $params['args']);
     $timestamp = wp_next_scheduled($params['task'], $args);
     $hash = acm_get_cron_hash($params['task'], $timestamp, $args, !isset($params['interval']) ? 0 : $params['interval']);
     if (empty($timestamp)) {
         die(json_encode(array('status' => 'error', 'details' => __('Sorry, it\'s wrong data to remove', 'acm'))));
     }
     wp_unschedule_event($timestamp, $params['task'], $args);
     die(json_encode(array('status' => 'success', 'task' => $params['task'], 'info' => '<td colspan="4">' . __('Removed.', 'acm') . '</td>', 'hash' => $hash)));
 }