/** * AJAX handler for unarchiving an email */ public static function unarchive_email() { $id = $_POST['id']; $email = new FUE_Email($id); $resp = array('ack' => 'OK'); // activate $email->update_status(FUE_Email::STATUS_ACTIVE); $resp['status_html'] = __('Active', 'follow_up_emails') . '<br/><small><a href="#" class="toggle-activation" data-id="' . $id . '">' . __('Deactivate', 'follow_up_emails') . '</a></small> | <small><a href="#" class="archive-email" data-id="' . $id . '" data-key="' . $email->get_type() . '">' . __('Archive', 'follow_up_emails') . '</a></small>'; die(json_encode($resp)); }
/** * Execute the requested bulk action on the selected emails * @param string $action * @param array $emails */ public static function execute_bulk_action($action, $emails) { if (!is_array($emails) || empty($emails)) { return; } foreach ($emails as $email_id) { $email = new FUE_Email($email_id); switch ($action) { case 'activate': $email->update_status(FUE_Email::STATUS_ACTIVE); break; case 'deactivate': $email->update_status(FUE_Email::STATUS_INACTIVE); break; case 'archive': $email->update_status(FUE_Email::STATUS_ARCHIVED); break; case 'unarchive': $email->update_status(FUE_Email::STATUS_ACTIVE); break; case 'delete': wp_delete_post($email_id, true); break; } } do_action('fue_execute_bulk_action', $action, $emails); }
/** * Archive a Date FUE_Email if there are no more emails of the same * kind that's unsent in the queue. * * The logic behind the archiving being that because it is date-based * and have passed its sending date already, there will be no * more new emails that can be created using this FUE_Email * * @param FUE_Email $email */ public static function maybe_archive_email($email) { if ($email->interval_type != 'date' || $email->type == 'manual') { return; } // if there are no more unsent emails in the queue, archive this email $items = Follow_Up_Emails::instance()->scheduler->get_items(array('email_id' => $email->id, 'is_sent' => 0)); if (count($items) == 0) { $email->update_status(FUE_Email::STATUS_ARCHIVED); } }