public function handle_unexpected_shutdown()
 {
     if ($error = error_get_last()) {
         if ($error['type'] == E_ERROR) {
             if (!empty($this->action_id)) {
                 $this->store->mark_failure($this->action_id);
                 do_action('action_scheduler_unexpected_shutdown', $this->action_id, $error);
             }
         }
         $this->store->release_claim($this->claim);
     }
 }
 public function handle_unexpected_shutdown()
 {
     if ($error = error_get_last()) {
         if (in_array($error['type'], array(E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) {
             if (!empty($this->action_id)) {
                 $this->store->mark_failure($this->action_id);
                 do_action('action_scheduler_unexpected_shutdown', $this->action_id, $error);
             }
         }
         $this->store->release_claim($this->claim);
     }
 }
 public function mark_failures()
 {
     $timeout = apply_filters('action_scheduler_failure_period', $this->five_minutes);
     if ($timeout < 0) {
         return;
     }
     $cutoff = new DateTime($timeout . ' seconds ago');
     $actions_to_reset = $this->store->query_actions(array('status' => ActionScheduler_Store::STATUS_RUNNING, 'modified' => $cutoff, 'modified_compare' => '<=', 'claimed' => TRUE, 'per_page' => apply_filters('action_scheduler_cleanup_batch_size', 20)));
     foreach ($actions_to_reset as $action_id) {
         $this->store->mark_failure($action_id);
         do_action('action_scheduler_failed_action', $action_id);
     }
 }
 protected function schedule_next_instance(ActionScheduler_Action $action)
 {
     $next = $action->get_schedule()->next(new DateTime());
     if ($next) {
         $this->store->save_action($action, $next);
     }
 }
 protected function schedule_next_instance(ActionScheduler_Action $action)
 {
     $next = $action->get_schedule()->next(as_get_datetime_object());
     if ($next) {
         $this->store->save_action($action, $next);
     }
 }
 /**
  * @return ActionScheduler_Store
  */
 public static function instance()
 {
     if (empty(self::$store)) {
         $class = apply_filters('action_scheduler_store_class', 'ActionScheduler_wpPostStore');
         self::$store = new $class();
     }
     return self::$store;
 }
 public static function store()
 {
     return ActionScheduler_Store::instance();
 }
 /**
  * @param ActionScheduler_Action $action
  *
  * @return string The ID of the stored action
  */
 protected function store(ActionScheduler_Action $action)
 {
     $store = ActionScheduler_Store::instance();
     return $store->save_action($action);
 }
    /**
     * Convert an interval of seconds into a two part human friendly string.
     *
     * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
     * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step
     * further to display two degrees of accuracy.
     *
     * Based on Crontrol::interval() funciton by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
     *
     * @param int $interval A interval in seconds.
     * @return string A human friendly string representation of the interval.
     */
    public static function admin_notices()
    {
        if (self::is_admin_page()) {
            if (ActionScheduler_Store::instance()->get_claim_count() >= apply_filters('action_scheduler_queue_runner_concurrent_batches', 5)) {
                ?>
<div id="message" class="updated">
	<p><?php 
                printf(__('Maximum simulatenous batches already in progress (%s queues). No actions will be processed until the current batches are complete.', 'action-scheduler'), ActionScheduler_Store::instance()->get_claim_count());
                ?>
</p>
</div>
			<?php 
            }
            if (isset($_GET['executed']) && isset($_GET['ids'])) {
                $action = ActionScheduler::store()->fetch_action($_GET['ids']);
                $action_hook_html = '<strong>' . $action->get_hook() . '</strong>';
                if (1 == $_GET['executed']) {
                    ?>
<div id="message" class="updated">
	<p><?php 
                    printf(__('Successfully executed the action: %s', 'action-scheduler'), $action_hook_html);
                    ?>
</p>
</div>
			<?php 
                } else {
                    ?>
<div id="message" class="error">
	<p><?php 
                    printf(__('Could not execute the action: %s', 'action-scheduler'), $action_hook_html);
                    ?>
</p>
</div>
			<?php 
                }
            }
        }
    }