/** * @return Entry|null the parent entry of null if none */ public function getParent() { if ($this->parent == null && $this->parent_id) { $this->parent = Entry::find_one($this->parent_id); } return $this->parent; }
/** * override this to setup anything that needs to be done before * @param $action null|string the action the is attempting if any */ public function processRequest($action = null) { if (!isset($_GET["id"]) || $_GET["id"] == "") { wp_redirect("admin.php?page=collapsing_content&task=view"); } $this->entry = Entry::find_one($_GET["id"]); if ($action) { $this->handlePost(); } }
/** * override this to setup anything that needs to be done before * @param $action string the action the user is trying to complete */ public function processRequest($action = null) { $id = isset($_GET["id"]) ? $_GET["id"] : false; if (!$id) { header("Location: admin.php?page=collapsing_content&task=view_entries"); } $entry = Entry::find_one($id); $entry->delete(); if ($entry->getParent()) { header("Location: admin.php?page=collapsing_content&task=edit_entry&id=" . $entry->getParent()->id); } else { header("Location: admin.php?page=collapsing_content&task=view_entries"); } }
/** * @param $atts array inputs * @return string shortcode content */ public function handleShortcode($atts) { if (!isset($atts["id"])) { $entries = Entry::fetchAll(); } else { $entries = [Entry::find_one($atts["id"])]; } $collections = $this->buildCollections($entries); $exportedHTML = ''; foreach ($collections as $collection) { $exportedHTML .= $collection->export(); } return $exportedHTML; }