示例#1
0
 private function fetch(Feed $feed)
 {
     $num = 5;
     $cache_time = 30 * MINUTE_IN_SECONDS;
     // Include SimplePie RSS parsing engine
     include_once ABSPATH . WPINC . '/feed.php';
     // Set the cache time for SimplePie
     add_filter('wp_feed_cache_transient_lifetime', create_function('$a', "return {$cache_time};"));
     // Build the SimplePie object
     $rss = fetch_feed($feed->get_rss_url());
     // Check for errors in the RSS XML
     if (!is_wp_error($rss)) {
         // Set a limit for the number of items to parse
         $maxitems = $rss->get_item_quantity($num);
         $rss_items = $rss->get_items(0, $maxitems);
         /* @var $feedItems FeedItem[] */
         $feedItems = array();
         foreach ($rss_items as $item) {
             $feedItems[] = new FeedItem(array('title' => $item->get_title(), 'link' => $item->get_permalink(), 'desc' => $item->get_description(), 'date_posted' => $item->get_date()));
         }
         return $feedItems;
     } else {
         return false;
     }
     return false;
 }
示例#2
0
 protected function installDatabaseTables()
 {
     Feed::installDatabaseTables();
     Feed::installFixtures();
 }