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


PHP SimplePie::set_cache_class方法代码示例

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


在下文中一共展示了SimplePie::set_cache_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: 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

示例3: 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

示例4: testDirectOverrideLegacy

 /**
  * @expectedException Exception_Success
  */
 public function testDirectOverrideLegacy()
 {
     $feed = new SimplePie();
     $feed->set_cache_class('Mock_CacheLegacy');
     $feed->get_registry()->register('File', 'MockSimplePie_File');
     $feed->set_feed_url('http://example.com/feed/');
     $feed->init();
 }
开发者ID:sintoris,项目名称:Known,代码行数:11,代码来源:CacheTest.php

示例5: 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

示例6: 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

示例7: 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

示例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: fetch_feed

/**
 * Build SimplePie object based on RSS or Atom feed from URL.
 *
 * @since 2.8
 *
 * @param string $url URL to retrieve feed
 * @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();
    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', 'WP_SimplePie_File');
    } else {
        $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', 43200, $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:ranjithinnergys,项目名称:WordPress,代码行数:30,代码来源:feed.php

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: array

 */
$kb_queries = array(__('How-To Articles', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=how-tos'), __('Usage Articles', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=usage-easy-forms-for-mailchimp'), __('Troubleshooting Articles', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=troubleshooting'), __('Code Snippets', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=snippet-library'), __('Setting Articles', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=settings'), __('Integration Articles', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=integrations'), __('Designer Articles', 'yikes-inc-easy-mailchimp-extender') => esc_url_raw('https://yikesplugins.com/feed/?post_type=kbe_knowledgebase&kbe_taxonomy=easy-forms-for-mailchimp&kbe_taxonomy=designer-documentation'));
/**
 *	Loop over all of our queries set above
 *	@sicne 6.0.3.8
 */
foreach ($kb_queries as $article_title => $rss_feed_url) {
    $page = isset($_GET['page']) ? $_GET['page'] : 'yikes-inc-easy-mailchimp-support';
    /* Create the SimplePie object */
    $article_feed = new SimplePie();
    $article_feed->enable_cache(true);
    // temporary
    /* Set the URL of the feed you're retrieving */
    $article_feed->set_feed_url($rss_feed_url);
    /* Tell SimplePie to cache the feed using WordPress' cache class */
    $article_feed->set_cache_class('WP_Feed_Cache');
    /* Tell SimplePie to use the WordPress class for retrieving feed files */
    $article_feed->set_file_class('WP_SimplePie_File');
    /* Tell SimplePie how long to cache the feed data in the WordPress database - Cached for 8 hours */
    $article_feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 28800, $rss_feed_url));
    /* Run any other functions or filters that WordPress normally runs on feeds */
    do_action_ref_array('wp_feed_options', array($article_feed, $rss_feed_url));
    /* Initiate the SimplePie instance */
    $article_feed->init();
    /* Tell SimplePie to send the feed MIME headers */
    $article_feed->handle_content_type();
    if ($article_feed->error()) {
        return $article_feed = new WP_Error('simplepie-error', $article_feed->error());
    }
    // loop over latest items
    if ($article_feed->get_items()) {
开发者ID:misfist,项目名称:missdrepants-network,代码行数:31,代码来源:knowledge-base-articles-RSS.php


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