当前位置: 首页>>代码示例>>PHP>>正文


PHP SimplePie::set_file_class方法代码示例

本文整理汇总了PHP中SimplePie::set_file_class方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::set_file_class方法的具体用法?PHP SimplePie::set_file_class怎么用?PHP SimplePie::set_file_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimplePie的用法示例。


在下文中一共展示了SimplePie::set_file_class方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tweetimport_import_twitter_feed

function tweetimport_import_twitter_feed($twitter_account)
{
  require_once (ABSPATH . WPINC . '/class-feed.php');

  $feed = new SimplePie();

  $account_parts = explode ('/', $twitter_account['twitter_name'], 2);



  if ($twitter_account['account_type'] == 1): //Account is Favorites
    $feed->set_feed_url(str_replace('#=#USER#=#', $account_parts[0], TWEETIMPORT_API_FAVORITES_URL));
  elseif ($twitter_account['account_type'] == 0 && count($account_parts) == 1): //User timeline
      $feed->set_feed_url(str_replace('#=#USER#=#', $account_parts[0], TWEETIMPORT_API_USER_TIMELINE_URL));
  elseif ($twitter_account['account_type'] == 2 && count($account_parts) == 2): //Account is list
      $feed_url = str_replace('#=#USER#=#', $account_parts[0], TWEETIMPORT_API_LIST_URL);
      $feed_url = str_replace('#=#LIST#=#', $account_parts[1], $feed_url);
      $feed->set_feed_url($feed_url);
  else :
      return '<strong>ERROR: Account information not correct. Account type wrong?</strong>';
  endif;

  $feed->set_useragent('Tweet Import http://skinju.com/wordpress/tweetimport');
  $feed->set_cache_class('WP_Feed_Cache');
  $feed->set_file_class('WP_SimplePie_File');
  $feed->enable_cache(true);
  $feed->set_cache_duration (apply_filters('tweetimport_cache_duration', 880));
  $feed->enable_order_by_date(false);
  $feed->init();
  $feed->handle_content_type();

  if ($feed->error()):
   return '<strong>ERROR: Feed Reading Error.</strong>';
  endif;

  $rss_items = $feed->get_items();

  $imported_count = 0;
  foreach ($rss_items as $item)
  {
    $item = apply_filters ('tweetimport_tweet_before_new_post', $item); //return false to stop processing an item.
    if (!$item) continue;

    $processed_description = $item->get_description();

    //Get the twitter author from the beginning of the tweet text
    $twitter_author = trim(preg_replace("~^(\w+):(.*?)$~", "\\1", $processed_description));

    if ($twitter_account['strip_name'] == 1):
      $processed_description = preg_replace("~^(\w+):(.*?)~i", "\\2", $processed_description);
    endif;

    if ($twitter_account['names_clickable'] == 1):
      $processed_description = preg_replace("~@(\w+)~", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $processed_description);
      $processed_description = preg_replace("~^(\w+):~", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>:", $processed_description);
    endif;

    if ($twitter_account['hashtags_clickable'] == 1):
      if ($twitter_account['hashtags_clickable_twitter'] == 1):
          $processed_description = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $processed_description);
      else:
        $processed_description = preg_replace("/#(\w+)/", "<a href=\"" . skinju_get_tag_link("\\1") . "\">#\\1</a>", $processed_description);
      endif;
    endif;

  $processed_description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $processed_description);
  $processed_description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $processed_description);

    $new_post = array('post_title' => trim (substr (preg_replace("~{$account_parts[0]}: ~i", "", $item->get_title()), 0, 25) . '...'),
                      'post_content' => trim ($processed_description),
                      'post_date' => $item->get_date('Y-m-d H:i:s'),
                      'post_author' => $twitter_account['author'],
                      'post_category' => array($twitter_account['category']),
                      'post_status' => 'publish');

    $new_post = apply_filters('tweetimport_new_post_before_create', $new_post); // Offer the chance to manipulate new post data. return false to skip
    if (!$new_post) continue;
    $new_post_id = wp_insert_post($new_post);

    $imported_count++;

    add_post_meta ($new_post_id, 'tweetimport_twitter_author', $twitter_author, true); 
    add_post_meta ($new_post_id, 'tweetimport_date_imported', date ('Y-m-d H:i:s'), true);
    add_post_meta ($new_post_id, 'tweetimport_twitter_id', $item->get_id(), true);
    add_post_meta ($new_post_id, 'tweetimport_twitter_id', $item->get_id(), true);
    add_post_meta ($new_post_id, '_tweetimport_twitter_id_hash', $item->get_id(true), true);
    add_post_meta ($new_post_id, 'tweetimport_twitter_post_uri', $item->get_link(0));
    add_post_meta ($new_post_id, 'tweetimport_author_avatar', $item->get_link(0, 'image'));

    preg_match_all ('~#([A-Za-z0-9_]+)(?=\s|\Z)~', $item->get_description(), $out);
    if ($twitter_account['add_tag']) $out[0][] = $twitter_account['add_tag'];
    wp_set_post_tags($new_post_id, implode (',', $out[0]));
  }

  return $imported_count;
}
开发者ID:robotconscience,项目名称:Robotconscience.com,代码行数:96,代码来源:tweet-import.php

示例2: import

 public function import($forceResync)
 {
     if (get_option('goodreads_user_id')) {
         if (!class_exists('SimplePie')) {
             require_once ABSPATH . WPINC . '/class-feed.php';
         }
         $rss_source = sprintf(self::$apiurl, get_option('goodreads_user_id'));
         /* Create the SimplePie object */
         $feed = new SimplePie();
         /* Set the URL of the feed you're retrieving */
         $feed->set_feed_url($rss_source);
         /* Tell SimplePie to cache the feed using WordPress' cache class */
         $feed->set_cache_class('WP_Feed_Cache');
         /* Tell SimplePie to use the WordPress class for retrieving feed files */
         $feed->set_file_class('WP_SimplePie_File');
         /* Tell SimplePie how long to cache the feed data in the WordPress database */
         $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', get_option('reclaim_update_interval'), $rss_source));
         /* Run any other functions or filters that WordPress normally runs on feeds */
         do_action_ref_array('wp_feed_options', array(&$feed, $rss_source));
         /* Initiate the SimplePie instance */
         $feed->init();
         /* Tell SimplePie to send the feed MIME headers */
         $feed->handle_content_type();
         if ($feed->error()) {
             parent::log(sprintf(__('no %s data', 'reclaim'), $this->shortname));
             parent::log($feed->error());
         } else {
             $data = self::map_data($feed);
             parent::insert_posts($data);
             update_option('reclaim_' . $this->shortname . '_last_update', current_time('timestamp'));
         }
     } else {
         parent::log(sprintf(__('%s user data missing. No import was done', 'reclaim'), $this->shortname));
     }
 }
开发者ID:sandeepone,项目名称:reclaim-social-media,代码行数:35,代码来源:goodreads.class.php

示例3: SimplePie

 function fetch_feed2($url)
 {
     require_once ABSPATH . WPINC . '/class-feed.php';
     $feed = new SimplePie();
     $feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
     // We must manually overwrite $feed->sanitize because SimplePie's
     // constructor sets it before we have a chance to set the sanitization class
     $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
     $feed->set_cache_class('WP_Feed_Cache');
     $feed->set_file_class('WP_SimplePie_File');
     $feed->set_feed_url($url);
     $feed->force_feed(true);
     /** This filter is documented in wp-includes/class-feed.php */
     $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url));
     /**
      * Fires just before processing the SimplePie feed object.
      *
      * @since 3.0.0
      *
      * @param object &$feed SimplePie feed object, passed by reference.
      * @param mixed  $url   URL of feed to retrieve. If an array of URLs, the feeds are merged.
      */
     do_action_ref_array('wp_feed_options', array(&$feed, $url));
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return new WP_Error('simplepie-error', $feed->error());
     }
     return $feed;
 }
开发者ID:Telemedellin,项目名称:feriadelasfloresmedellin,代码行数:30,代码来源:getFeed.php

示例4: powerpress_get_news

function powerpress_get_news($feed_url, $limit = 10)
{
    include_once ABSPATH . WPINC . '/feed.php';
    $rss = fetch_feed($feed_url);
    // If feed doesn't work...
    if (is_wp_error($rss)) {
        require_once ABSPATH . WPINC . '/class-feed.php';
        // Try fetching the feed using CURL directly...
        $content = powerpress_remote_fopen($feed_url, false, array(), 3, false, true);
        if (!$content) {
            return false;
        }
        // Load the content in a fetch_feed object...
        $rss = new SimplePie();
        $rss->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
        // We must manually overwrite $feed->sanitize because SimplePie's
        // constructor sets it before we have a chance to set the sanitization class
        $rss->sanitize = new WP_SimplePie_Sanitize_KSES();
        $rss->set_cache_class('WP_Feed_Cache');
        $rss->set_file_class('WP_SimplePie_File');
        $rss->set_raw_data($content);
        $rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $feed_url));
        do_action_ref_array('wp_feed_options', array(&$rss, $feed_url));
        $rss->init();
        $rss->set_output_encoding(get_option('blog_charset'));
        $rss->handle_content_type();
        if ($rss->error()) {
            return false;
        }
    }
    $rss_items = $rss->get_items(0, $rss->get_item_quantity($limit));
    // If the feed was erroneously
    if (!$rss_items) {
        $md5 = md5($this->feed);
        delete_transient('feed_' . $md5);
        delete_transient('feed_mod_' . $md5);
        $rss->__destruct();
        unset($rss);
        $rss = fetch_feed($this->feed);
        $rss_items = $rss->get_items(0, $rss->get_item_quantity($num));
        $rss->__destruct();
        unset($rss);
    }
    return $rss_items;
}
开发者ID:mattsims,项目名称:powerpress,代码行数:45,代码来源:powerpressadmin-dashboard.php

示例5: SimplePie

 function get_rss_feed($url)
 {
     require_once ABSPATH . WPINC . '/class-feed.php';
     $feed = new SimplePie();
     $feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
     $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
     $feed->set_useragent('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36');
     $feed->set_cache_class('WP_Feed_Cache');
     $feed->set_file_class('WP_SimplePie_File');
     $feed->set_feed_url($url);
     $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url));
     do_action_ref_array('wp_feed_options', array(&$feed, $url));
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return new WP_Error('simplepie-error', $feed->error());
     }
     return $feed;
 }
开发者ID:wilxsv,项目名称:prevensionPublicLibrary,代码行数:19,代码来源:rss-via-shortcode.php

示例6: fetch_feed

/**
 * Build SimplePie object based on RSS or Atom feed from URL.
 *
 * @since 2.8
 *
 * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged
 * using SimplePie's multifeed feature.
 * See also {@link ​http://simplepie.org/wiki/faq/typical_multifeed_gotchas}
 *
 * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success
 */
function fetch_feed($url)
{
    require_once ABSPATH . WPINC . '/class-feed.php';
    $feed = new SimplePie();
    $feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
    // We must manually overwrite $feed->sanitize because SimplePie's
    // constructor sets it before we have a chance to set the sanitization class
    $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
    $feed->set_cache_class('WP_Feed_Cache');
    $feed->set_file_class('WP_SimplePie_File');
    $feed->set_feed_url($url);
    $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url));
    do_action_ref_array('wp_feed_options', array(&$feed, $url));
    $feed->init();
    $feed->handle_content_type();
    if ($feed->error()) {
        return new WP_Error('simplepie-error', $feed->error());
    }
    return $feed;
}
开发者ID:dev-lav,项目名称:htdocs,代码行数:31,代码来源:feed.php

示例7: set_feed_options

 /**
  * This happens immediately before feed initialization.
  * Handles the `wprss_fetch_feed_before` action.
  * 
  * @since 4.7
  * @param SimplePie $feed The instance of the object that represents the feed to be fetched.
  * @param string $url The URL, from which the feed is going to be fetched.
  */
 public function set_feed_options($feed)
 {
     $feed->set_file_class('WPRSS_SimplePie_File');
     WPRSS_SimplePie_File::set_default_certificate_file_path($this->get_certificate_file_path());
 }
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:13,代码来源:feed-access.php

示例8: _displayRSS

 /**
  * _displayRSS
  * 
  * @param string $url
  * @param int $num_items
  */
 protected function _displayRSS($url, $num_items = -1)
 {
     $rss = new SimplePie();
     $rss->strip_htmltags(array_diff($rss->strip_htmltags, array('style')));
     $rss->strip_attributes(array_diff($rss->strip_attributes, array('style', 'class', 'id')));
     $rss->set_feed_url($url);
     $rss->set_cache_class('WP_Feed_Cache');
     $rss->set_file_class('WP_SimplePie_File');
     $rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
     do_action_ref_array('wp_feed_options', array(&$rss, $url));
     $rss->init();
     $rss->handle_content_type();
     if (!$rss->error()) {
         $maxitems = $rss->get_item_quantity(25);
         $rss_items = $rss->get_items(0, $maxitems);
         echo '<ul>';
         if ($num_items !== -1) {
             $rss_items = array_slice($rss_items, 0, $num_items);
         }
         if ($rss_items) {
             foreach ((array) $rss_items as $item) {
                 printf('<li><div class="date">%4$s</div><div class="thethefly-news-item">%2$s</div></li>', esc_url($item->get_permalink()), $item->get_description(), esc_html($item->get_title()), $item->get_date('D, d M Y'));
             }
         } else {
             echo "<li>";
             _e('Unfortunately the news channel is temporarily closed', 'thethe-captcha');
             echo "</li>";
         }
         echo '</ul>';
     } else {
         _e('An error has occurred, which probably means the feed is down. Try again later.', 'thethe-captcha');
     }
 }
开发者ID:jacko5,项目名称:bjj,代码行数:39,代码来源:lib.plugin.php

示例9: fetch

 function fetch($url, $force_feed = true)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     if (version_compare(SIMPLEPIE_VERSION, '1.3-dev', '>')) {
         $feed->set_cache_location('wp-transient');
         $feed->registry->register('Cache', 'WP_Feed_Cache_Transient');
         $feed->registry->register('File', 'FeedWordPress_File');
     } else {
         $feed->set_cache_class('WP_Feed_Cache');
         $feed->set_file_class('FeedWordPress_File');
     }
     $feed->set_content_type_sniffer_class('FeedWordPress_Content_Type_Sniffer');
     $feed->set_file_class('FeedWordPress_File');
     $feed->force_feed($force_feed);
     $feed->set_cache_duration(FeedWordPress::cache_duration());
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         $ret = new WP_Error('simplepie-error', $feed->error());
     } else {
         $ret = $feed;
     }
     return $ret;
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:25,代码来源:feedwordpress.php

示例10: loadTwitterFeed

 function loadTwitterFeed($instance)
 {
     require_once ABSPATH . WPINC . '/class-feed.php';
     $url = 'http://twitter.com/statuses/user_timeline/' . $instance['username'] . '.rss';
     $cache_duration = $instance['refresh'] * 60;
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_cache_class('WP_Feed_Cache');
     $feed->set_file_class('WP_SimplePie_File');
     $feed->set_cache_duration($cache_duration);
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return new WP_Error('simplepie-error', $feed->error());
     }
     return $feed;
 }
开发者ID:uniquegel,项目名称:Feminnova,代码行数:17,代码来源:tweets.php

示例11: feedzy_rss

function feedzy_rss($atts, $content = '')
{
    global $feedzyStyle;
    $feedzyStyle = true;
    $count = 0;
    //Load SimplePie if not already
    if (!class_exists('SimplePie')) {
        require_once ABSPATH . WPINC . '/class-feed.php';
    }
    //Retrieve & extract shorcode parameters
    extract(shortcode_atts(array("feeds" => '', "max" => '5', "feed_title" => 'yes', "target" => '_blank', "title" => '', "meta" => 'yes', "summary" => 'yes', "summarylength" => '', "thumb" => 'yes', "default" => '', "size" => '', "keywords_title" => ''), $atts, 'feedzy_default'));
    //Use "shortcode_atts_feedzy_default" filter to edit shortcode parameters default values or add your owns.
    if (!empty($feeds)) {
        $feeds = rtrim($feeds, ',');
        $feeds = explode(',', $feeds);
        //Remove SSL from HTTP request to prevent fetching errors
        foreach ($feeds as $feed) {
            $feedURL[] = preg_replace("/^https:/i", "http:", $feed);
        }
        if (count($feedURL) === 1) {
            $feedURL = $feedURL[0];
        }
    }
    if ($max == '0') {
        $max = '999';
    } else {
        if (empty($max) || !ctype_digit($max)) {
            $max = '5';
        }
    }
    if (empty($size) || !ctype_digit($size)) {
        $size = '150';
    }
    $sizes = array('width' => $size, 'height' => $size);
    $sizes = apply_filters('feedzy_thumb_sizes', $sizes, $feedURL);
    if (!empty($title) && !ctype_digit($title)) {
        $title = '';
    }
    if (!empty($keywords_title)) {
        $keywords_title = rtrim($keywords_title, ',');
        $keywords_title = array_map('trim', explode(',', $keywords_title));
    }
    if (!empty($summarylength) && !ctype_digit($summarylength)) {
        $summarylength = '';
    }
    if (!empty($default)) {
        $default = $default;
    } else {
        $default = apply_filters('feedzy_default_image', $default, $feedURL);
    }
    //Load SimplePie Instance
    $feed = new SimplePie();
    $feed->set_feed_url($feedURL);
    $feed->enable_cache(true);
    $feed->enable_order_by_date(true);
    $feed->set_cache_class('WP_Feed_Cache');
    $feed->set_file_class('WP_SimplePie_File');
    $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 7200, $feedURL));
    do_action_ref_array('wp_feed_options', array($feed, $feedURL));
    $feed->strip_comments(true);
    $feed->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'));
    $feed->init();
    $feed->handle_content_type();
    // Display the error message
    if ($feed->error()) {
        $content .= apply_filters('feedzy_default_error', $feed->error(), $feedURL);
    }
    $content .= '<div class="feedzy-rss">';
    if ($feed_title == 'yes') {
        $content .= '<div class="rss_header">';
        $content .= '<h2><a href="' . $feed->get_permalink() . '" class="rss_title">' . html_entity_decode($feed->get_title()) . '</a> <span class="rss_description"> ' . $feed->get_description() . '</span></h2>';
        $content .= '</div>';
    }
    $content .= '<ul>';
    //Loop through RSS feed
    $items = apply_filters('feedzy_feed_items', $feed->get_items(), $feedURL);
    foreach ((array) $items as $item) {
        $continue = apply_filters('feedzy_item_keyword', true, $keywords_title, $item, $feedURL);
        if ($continue == true) {
            //Count items
            if ($count >= $max) {
                break;
            }
            $count++;
            //Fetch image thumbnail
            if ($thumb == 'yes' || $thumb == 'auto') {
                $thethumbnail = feedzy_retrieve_image($item);
            }
            $itemAttr = apply_filters('feedzy_item_attributes', $itemAttr = '', $sizes, $item, $feedURL);
            //Build element DOM
            $content .= '<li ' . $itemAttr . '>';
            if ($thumb == 'yes' || $thumb == 'auto') {
                $contentThumb = '';
                if (!empty($thethumbnail) && $thumb == 'auto' || $thumb == 'yes') {
                    $contentThumb .= '<div class="rss_image" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px;">';
                    $contentThumb .= '<a href="' . $item->get_permalink() . '" target="' . $target . '" title="' . $item->get_title() . '" >';
                    if (!empty($thethumbnail)) {
                        $thethumbnail = feedzy_image_encode($thethumbnail);
                        $contentThumb .= '<span class="default" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image:  url(' . $default . ');" alt="' . $item->get_title() . '"></span>';
                        $contentThumb .= '<span class="fetched" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image:  url(' . $thethumbnail . ');" alt="' . $item->get_title() . '"></span>';
//.........这里部分代码省略.........
开发者ID:fritzdenim,项目名称:pangMoves,代码行数:101,代码来源:feedzy-rss-feeds-shortcode.php

示例12: SimplePie

 function piratenkleider_fetch_feed($url, $lifetime = 0)
 {
     global $defaultoptions;
     global $options;
     if ($lifetime == 0) {
         $lifetime = $options['feed_cache_lifetime'];
     }
     if ($lifetime < 600) {
         $lifetime = 1800;
     }
     // Das holen von feeds sollte auf keinen Fall haeufiger als alle 10 Minuten erfolgen
     require_once ABSPATH . WPINC . '/class-feed.php';
     $feed = new SimplePie();
     if ($defaultoptions['use_wp_feed_defaults']) {
         $feed->set_cache_class('WP_Feed_Cache');
         $feed->set_file_class('WP_SimplePie_File');
     } else {
         if (isset($defaultoptions['dir_feed_cache']) && !empty($defaultoptions['dir_feed_cache'])) {
             if (is_dir($defaultoptions['dir_feed_cache'])) {
                 $feed->set_cache_location($defaultoptions['dir_feed_cache']);
             } else {
                 mkdir($defaultoptions['dir_feed_cache']);
                 if (!is_dir($defaultoptions['dir_feed_cache'])) {
                     echo "Wasnt able to create Feed-Cache directory";
                 } else {
                     $feed->set_cache_location($defaultoptions['dir_feed_cache']);
                 }
             }
         }
     }
     $feed->set_feed_url($url);
     $feed->set_cache_duration($lifetime);
     do_action_ref_array('wp_feed_options', array($feed, $url));
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return new WP_Error('simplepie-error', $feed->error());
     }
     return $feed;
 }
开发者ID:tierce,项目名称:Piratenkleider,代码行数:40,代码来源:functions.php

示例13: array

<?php

/** @version $Id: inc.sidebar.themes.php 972 2011-08-25 18:31:32Z lexx-ua $ */
/** Require RSS lib */
require_once ABSPATH . WPINC . '/class-simplepie.php';
require_once ABSPATH . WPINC . '/class-feed.php';
require_once ABSPATH . WPINC . '/feed.php';
$_theme_rss_url = 'http://thethefly.com/index-themes-rss.php';
$_theme_rss_data = array();
$_theme_rss = new SimplePie();
$_theme_rss->set_feed_url($_theme_rss_url);
$_theme_rss->set_cache_class('WP_Feed_Cache');
$_theme_rss->set_file_class('WP_SimplePie_File');
$_theme_rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $_theme_rss_url));
do_action_ref_array('wp_feed_options', array(&$_theme_rss, $_theme_rss_url));
$_theme_rss->init();
$_theme_rss->handle_content_type();
if (!$_theme_rss->error()) {
    $maxitems = $_theme_rss->get_item_quantity(50);
    $rss_items = $_theme_rss->get_items(0, $maxitems);
    if ($rss_items) {
        $_theme_rss_data = (array) $rss_items;
    }
}
if (is_array($_theme_rss_data)) {
    ?>
<div class="thethe-themes postbox">
  <div class="handlediv" title="<?php 
    _e('Click to toggle');
    ?>
"><br />
开发者ID:fwelections,项目名称:fwelections,代码行数:31,代码来源:inc.sidebar.themes.php

示例14: fetch_feed

/**
 * Build SimplePie object based on RSS or Atom feed from URL.
 *
 * @since 2.8
 *
 * @param string $url URL to retrieve feed
 * @return nxt_Error|SimplePie nxt_Error object on failure or SimplePie object on success
 */
function fetch_feed($url)
{
    require_once ABSPATH . nxtINC . '/class-feed.php';
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->set_cache_class('nxt_Feed_Cache');
    $feed->set_file_class('nxt_SimplePie_File');
    $feed->set_cache_duration(apply_filters('nxt_feed_cache_transient_lifetime', 43200, $url));
    do_action_ref_array('nxt_feed_options', array(&$feed, $url));
    $feed->init();
    $feed->handle_content_type();
    if ($feed->error()) {
        return new nxt_Error('simplepie-error', $feed->error());
    }
    return $feed;
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:24,代码来源:feed.php

示例15: bebop_rss_import

function bebop_rss_import($extension, $user_metas = null)
{
    global $wpdb, $bp;
    $itemCounter = 0;
    if (empty($extension)) {
        bebop_tables::log_general('Importer', 'The $extension parameter is empty.');
        return false;
    } else {
        $this_extension = bebop_extensions::bebop_get_extension_config_by_name($extension);
    }
    require_once ABSPATH . WPINC . '/class-feed.php';
    //if user_metas is not defined, get some user meta.
    if (!isset($user_metas)) {
        $user_metas = bebop_tables::get_user_ids_from_meta_type($this_extension['name']);
    } else {
        $secondary_importers = true;
    }
    if (isset($user_metas)) {
        foreach ($user_metas as $user_meta) {
            //Ensure the user is wanting to import items.
            if (bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_active_for_user')) {
                if (isset($secondary_importers) && $secondary_importers === true) {
                    $feeds = bebop_tables::get_initial_import_feeds($user_meta->user_id, $this_extension['name']);
                    $user_feeds = bebop_tables::get_user_feeds_from_array($user_meta->user_id, $this_extension['name'], $feeds);
                } else {
                    $user_feeds = bebop_tables::get_user_feeds($user_meta->user_id, $this_extension['name']);
                }
                foreach ($user_feeds as $user_feed) {
                    $errors = null;
                    $items = null;
                    $feed_name = $user_feed->meta_name;
                    $feed_url = $user_feed->meta_value;
                    $import_username = stripslashes($feed_name);
                    //Check the user has not gone past their import limit for the day.
                    if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $import_username)) {
                        if (bebop_tables::check_for_first_import($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_' . $import_username . '_do_initial_import')) {
                            bebop_tables::delete_from_first_importers($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_' . $import_username . '_do_initial_import');
                        }
                        /* 
                         * ******************************************************************************************************************
                         * Depending on the data source, you will need to switch how the data is retrieved. If the feed is RSS, use the 	*
                         * SimplePie method, as shown in the youtube extension. If the feed is oAuth API based, use the oAuth implementation*
                         * as shown in the twitter extension. If the feed is an API without oAuth authentication, use SlideShare			*
                         * ******************************************************************************************************************
                         */
                        //import the url
                        //Configure the feed
                        $feed = new SimplePie();
                        $feed->set_feed_url($feed_url);
                        $feed->set_cache_class('WP_Feed_Cache');
                        $feed->set_file_class('WP_SimplePie_File');
                        $feed->enable_cache(false);
                        $feed->set_cache_duration(0);
                        do_action_ref_array('wp_feed_options', array($feed, $feed_url));
                        $feed->init();
                        $feed->handle_content_type();
                        /* 
                         * ******************************************************************************************************************
                         * We can get as far as loading the items, but you will need to adjust the values of the variables below to match 	*
                         * the values from the extension's feed.																			*
                         * This is because each feed return data under different parameter names, and the simplest way to get around this is*
                         * to quickly match the values. To find out what values you should be using, consult the provider's documentation.	*
                         * You can also contact us if you get stuck - details are in the 'support' section of the admin homepage.			*
                         * ******************************************************************************************************************
                         * 
                         * Values you will need to check and update are:
                         * 		$errors 				- Must point to the error boolean value (true/false)
                         * 		$id						- Must be the ID of the item returned through the data feed.
                         * 		$description			- The actual content of the imported item.
                         * 		$item_published			- The time the item was published.
                         * 		$action_link			- This is where the link will point to - i.e. where the user can click to get more info.
                         */
                        //Edit the following variables to point to where the relevant content is being stored in the feed:
                        $errors = $feed->error;
                        if (!$errors) {
                            //Edit the following variable to point to where the relevant content is being stored in the feed:
                            $items = $feed->get_items();
                            if ($items) {
                                foreach ($items as $item) {
                                    if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $import_username)) {
                                        //Edit the following variables to point to where the relevant content is being stored:
                                        //$description	= $item->get_content();
                                        $item_published = date('Y-m-d H:i:s', strtotime($item->get_date()));
                                        $title = $item->get_title();
                                        $action_link = $item->get_permalink();
                                        $id_array = array_reverse(explode('/', $action_link));
                                        $id = $id_array[1];
                                        //Stop editing - you should be all done.
                                        //generate an $item_id
                                        $item_id = bebop_generate_secondary_id($user_meta->user_id, $id, $item_published);
                                        //if the id is not found, import the content.
                                        if (!bebop_tables::check_existing_content_id($user_meta->user_id, $this_extension['name'], $item_id)) {
                                            $item_content = $title . '
											' . $action_link;
                                            if (bebop_create_buffer_item(array('user_id' => $user_meta->user_id, 'extension' => $this_extension['name'], 'type' => $this_extension['content_type'], 'username' => $import_username, 'content' => $item_content, 'content_oembed' => $this_extension['content_oembed'], 'item_id' => $item_id, 'raw_date' => $item_published, 'actionlink' => $action_link))) {
                                                $itemCounter++;
                                            }
                                        }
                                        //End if ( ! empty( $secondary->secondary_item_id ) ) {
                                    }
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:import.php


注:本文中的SimplePie::set_file_class方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。