private function map_data($feed, $type = "posts") { $data = array(); $count = self::$count; foreach ($feed->get_items(0, $count) as $item) { $id = $item->get_permalink(); // check if item already exists. if so, // no need to run through scraping et all if (!parent::post_exists($id)) { $title = str_replace("on Yelp", "", $item->get_title()); $link = $item->get_permalink(); $image_url = ''; $published = $item->get_date(); // http://www.yelp.com/biz/salon-graf-frisiersalon-berlin#hrid:C2JflaCF8jja2a5PHr7iHQ // lets get the yelp id from the url (hrid) //preg_match_all('/#hrid:(\w+)/', $link, $match); preg_match_all('/#hrid:(.*)/', $link, $match); $hrid = $match[1][0]; // scrape the full description, not only the shortened RSS version // $description = self::process_content($item); $long_description = self::get_yelp_description($link, $hrid); $description = '<p class="anonce-yelp"><a rel="syndication" href="' . $link . '">' . __('I wrote a review on Yelp', 'reclaim') . '</a>:</p>'; $description .= $long_description != '' ? $long_description : self::process_content($item); $description .= '<p class="viewpost-yelp">(<a rel="syndication" href="' . $link . '">' . __('View on Yelp', 'reclaim') . '</a>)</p>'; /* * set post meta galore start */ $post_meta["_" . $this->shortname . "_link_id"] = $id; $post_meta["_post_generator"] = $this->shortname; // in case someone uses WordPress Post Formats Admin UI // http://alexking.org/blog/2011/10/25/wordpress-post-formats-admin-ui $post_meta["_format_link_url"] = $link; $post_meta["_reclaim_post_type"] = $type; $post_meta["geo_latitude"] = $item->get_latitude(); $post_meta["geo_longitude"] = $item->get_longitude(); /* * set post meta galore end */ $data[] = array('post_author' => get_option(self::shortName() . '_author'), 'post_category' => array(get_option(self::shortName() . '_category')), 'post_format' => self::$post_format, 'post_date' => get_date_from_gmt(date('Y-m-d H:i:s', strtotime($published))), 'post_content' => $description, 'post_title' => $title, 'post_type' => 'post', 'post_status' => 'publish', 'ext_permalink' => $link, 'ext_image' => $image_url, 'tags_input' => $tags, 'ext_guid' => $id, 'post_meta' => $post_meta); } } return $data; }