/** * Check if there is another element in the media library * * @return boolean $hasNext * * @throws \Comodojo\Exception\WPException */ public function hasNext() { if (!$this->has_next) { $image = new WPMedia($this->getBlog()); $image->setPostID($this->post); $this->object = $image->loadFromLibrary($this->current, $this->mime); if (!is_null($this->object)) { $this->has_next = true; } } return $this->has_next; }
/** * Load data for a post * * @param array $data Post data * * @return WPPostLoader $this */ public function loadData($data) { $this->resetData(); if (!isset($data['post_id'])) { return null; } $this->setID($data['post_id']); $this->setTitle($data['post_title']); $this->setCreationDate(is_numeric($data['post_date']) ? $data['post_date'] : strtotime($data['post_date'])); $this->setLastModifiedDate(is_numeric($data['post_modified']) ? $data['post_modified'] : strtotime($data['post_modified'])); $this->setStatus($data['post_status']); $this->setType($data['post_type']); $this->setFormat($data['post_format']); $this->setName($data['post_name']); $this->setAuthor(new WPUser($this->getBlog(), $data['post_author'])); $this->setPassword($data['post_password']); $this->setExcerpt($data['post_excerpt']); $this->setContent($data['post_content']); $this->setParent($data['post_parent']); $this->setMimeType($data['post_mime_type']); $this->setLink($data['link']); $this->setGUID($data['guid']); $this->setMenuOrder(intval($data['menu_order'])); $this->setCommentStatus($data['comment_status']); $this->setPingStatus($data['ping_status']); $this->setSticky(filter_var($data['sticky'], FILTER_VALIDATE_BOOLEAN)); if (isset($data['custom_fields'])) { foreach ($data['custom_fields'] as $value) { $this->setCustomField($value['key'], $value['value']); } } if (isset($data['enclosure'])) { $this->setEnclosureURL($data['enclosure']['url']); $this->setEnclosureLength($data['enclosure']['length']); $this->setEnclosureType($data['enclosure']['type']); } if (isset($data['post_thumbnail']['attachment_id'])) { $thumbnail = new WPMedia($this->getBlog()); $thumbnail->loadData($data['post_thumbnail']); $this->setThumbnail($thumbnail); } foreach ($data['terms'] as $term) { $taxonomy = $this->getBlog()->getTaxonomy($term['taxonomy']); $termObj = new WPTerm($taxonomy); $termObj->loadData($term); $this->addTerm($termObj); } return $this; }