/** * Create taxonomy terms from entry * * @param integer $postId * @param EntryInterface $entry * * @return array of term ids */ protected function createTermsFromEntry($postId, EntryInterface $entry) { $ids = []; foreach ($entry->getCategories() as $category) { $term = term_exists($category['term'], $this->entryParams['taxonomy']); if ($term === 0 || $term === null) { $term = wp_insert_term($category['term'], $this->entryParams['taxonomy']); if (is_array($term)) { if (is_callable($this->entryParams['afterInsertTerm'])) { call_user_func($this->entryParams['afterInsertTerm'], $term['term_id']); } } } $ids[] = (int) $term['term_id']; } if (!empty($ids)) { wp_set_post_terms($postId, $ids, $this->entryParams['taxonomy']); } }
/** * Implements FormatterInterface->format(). * * @param \Zend\Feed\Reader\Entry\EntryInterface $item * @return string */ public function format(EntryInterface $item) { $created = $item->getDateCreated(); if ($created instanceof \DateTime) { $created = $created->format($this->datePattern); } $modified = $item->getDateModified(); if ($modified instanceof \DateTime) { $modified = $modified->format($this->datePattern); } $author = $item->getAuthor(); if (is_array($author)) { $authorname = $author['name']; $authoremail = isset($author['email']) ? $author['email'] : null; $authoruri = isset($author['uri']) ? $author['uri'] : null; } else { $authorname = ''; $authoremail = ''; $authoruri = ''; } $replacements = array('%authorname%' => $authorname, '%authoremail%' => $authoremail, '%authoruri%' => $authoruri, '%content%' => $item->getContent(), '%datecreated%' => $created, '%datemodified%' => $modified, '%description%' => $item->getDescription(), '%id%' => $item->getId(), '%link%' => $item->getLink(), '%links%' => implode(' ', $item->getLinks()), '%permalink%' => $item->getPermalink(), '%title%' => $item->getTitle(), '%commentcount%' => $item->getCommentCount(), '%commentlink%' => $item->getCommentLink(), '%commentfeedlink%' => $item->getCommentFeedLink()); $formatted = str_replace(array_keys($replacements), array_values($replacements), $this->pattern); return $formatted; }
/** * @param EntryInterface $entry * * @return bool */ protected function currentEntryIgnored(EntryInterface $entry) { $outletUrl = $this->getOutlet()->getUrl(); if (substr($outletUrl, 0, -1) !== '/') { $outletUrl .= '/'; } return strpos($entry->getLink(), $outletUrl . 'gallery/') !== false; }
/** * @inheritDoc */ protected function entryIsNew(EntryInterface $entry) { $query = new WP_Query(['post_type' => $this->postType, 'post_status' => 'any', 'lang' => $this->language, 'meta_query' => [['key' => 'feed_importer_feed_entry_id', 'value' => $entry->getId()]]]); return $query->post_count == 0; }
public function format(EntryInterface $item) { return $item->getTitle(); }