/** * Show the user-requested page */ public function route() { $action = "index"; if (!empty($_REQUEST["action"])) { $action = stripslashes($_REQUEST["action"]); } switch ($action) { case "create": $this->add(); break; case "edit": $id = intval($_REQUEST["id"]); $this->edit($id); break; case "delete": $id = intval($_REQUEST["id"]); // make sure request is real check_admin_referer("bbpp_thankmelater_delete_message_" . $id); // delete the message $message = new Bbpp_ThankMeLater_Message($id); $message->delete(); // go back to list of messages $_REQUEST["action"] = "index"; $this->index(array($id)); break; case "bbpp_thankmelater_message_preview": $data = stripslashes_deep($_POST); $from_name = $data["from_name"]; $from_email = $data["from_email"]; $subject = $data["subject"]; $message = $data["message"]; $this->preview($from_name, $from_email, $subject, $message); break; case "bbpp_thankmelater_message_targeting": $data = stripslashes_deep($_POST); $target_tags = isset($data["target_tags"]) ? $data["target_tags"] : array(); $target_categories = isset($data["target_categories"]) ? $data["target_categories"] : array(); $target_posts = isset($data["target_posts"]) ? $data["target_posts"] : array(); $this->targeting($target_tags, $target_categories, $target_posts); break; case "targets": $id = intval($_REQUEST["id"]); $this->targets($id); break; case "index": default: $this->index(); break; } }
/** * */ public function process_bulk_action() { // TODO: Do we need to check the nonce here. I've assumed it's done automatically for me!? Have a look... if ($this->current_action() === "index-delete") { foreach ($_REQUEST["id"] as $id) { $id = intval($id); // delete the message $message = new Bbpp_ThankMeLater_Message($id); $message->delete(); } } }