本文整理汇总了PHP中SimplePie::set_timeout方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::set_timeout方法的具体用法?PHP SimplePie::set_timeout怎么用?PHP SimplePie::set_timeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimplePie
的用法示例。
在下文中一共展示了SimplePie::set_timeout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFromWebService
private function loadFromWebService()
{
$feed = new \SimplePie();
$feed->set_feed_url($this->endPoint);
$feed->set_cache_location(THELIA_ROOT . 'cache/feeds');
$feed->init();
$feed->handle_content_type();
$feed->set_timeout(10);
$this->data = $feed->get_items();
}
示例2: buildArray
public function buildArray()
{
$cachedir = THELIA_ROOT . 'cache/feeds';
if (!is_dir($cachedir)) {
if (!mkdir($cachedir)) {
throw new \Exception(sprintf("Failed to create cache directory '%s'", $cachedir));
}
}
$feed = new \SimplePie($this->getUrl(), THELIA_ROOT . 'cache/feeds');
$feed->init();
$feed->handle_content_type();
$feed->set_timeout($this->getTimeout());
$items = $feed->get_items();
return $items;
}
示例3: parseFeed
/**
* Opens an RSS feed, parses and loads the contents.
*
* @param string $url The URL of the RSS feed
* @param bool $nativeOrder If true, disable order by date to preserve native ordering
* @param bool $force Force SimplePie to parse the feed despite errors
*
* @return object An object that encapsulates the feed contents and operations on those contents.
* @throws FeedParserException If opening or parsing feed fails
**/
public function parseFeed($url, $nativeOrder = false, $force = false)
{
require_once PATH_SYSTEM . '/vendors/SimplePie.php';
$feed = new SimplePie();
$feed->set_timeout($this->timeout);
$feed->set_feed_url($url);
$feed->enable_order_by_date(!$nativeOrder);
$feed->force_feed($force);
if ($this->cacheDuration != null) {
$feed->set_cache_duration(intval($this->cacheDuration));
}
if ($this->cacheDirectory != null) {
$feed->set_cache_location($this->cacheDirectory);
}
if ($this->stripHtmlTags != null) {
$feed->strip_htmltags($this->stripHtmlTags);
}
@$feed->init();
if ($err = $feed->error()) {
throw new FeedParserException($err);
}
return $feed;
}
示例4: fetchPosts
public function fetchPosts()
{
global $_wp_additional_image_sizes;
global $wpdb;
$lastRefreshTime = (int) get_option('wpab_last_refresh_time', 0);
$fetchPeriod = (int) get_option('wpab_fetch_feed_period', 30) * MINUTE_IN_SECONDS;
if (time() - $lastRefreshTime < $fetchPeriod) {
return;
}
WPAutoblog_Log::log(null, 'Started updating feeds');
set_time_limit($fetchPeriod);
update_option('wpab_last_refresh_time', time());
$body = null;
$blogs = get_posts(array('post_type' => self::postName(), 'posts_per_page' => -1));
$cache_ids = array();
foreach ($blogs as $k => $blog) {
$url = get_post_meta($blog->ID, WPAB_ID . '-feed', true) ?: get_post_meta($blog->ID, WPAB_ID . '-url', true);
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->set_cache_location('../cache/');
$feed->set_cache_duration($fetchPeriod);
$feed->set_timeout(15);
$result = $feed->init();
$feed->handle_content_type();
if (!$result) {
WPAutoblog_Log::log($feed->error(), 'An error occured while fetching the feed: <i>' . $blog->post_title . '</i>');
continue;
}
$items = $feed->get_items();
foreach ($items as $item) {
if (!in_array($item->get_id(), $cache_ids)) {
$posts = get_posts(array('hierarchical' => false, 'meta_key' => WPAB_ID . '-uuid', 'meta_value' => $item->get_id(), 'post_type' => WPAutoblog_BlogFeedPost::postName()));
if (count($posts) === 0) {
$images = $this->extractImages($item->get_content());
$attachments = array();
$isFeaturedImageFeatured = get_field('featured_image_featured', $blog->ID);
$isFirstImageFeatured = get_field('first_image_featured', $blog->ID);
$featuredImageFetched = false;
if ($isFeaturedImageFeatured) {
$enclosure = $item->get_enclosure();
$featuredImageUrl = $enclosure->get_link();
if ($featuredImageUrl) {
$attachments[] = WPAutoblog_BlogFeedPost::prepareAttachment($featuredImageUrl);
$featuredImageFetched = true;
}
}
if ($isFirstImageFeatured && count($images) && !$featuredImageFetched) {
$attachments[] = WPAutoblog_BlogFeedPost::prepareAttachment($images[0]);
}
if ($this->readability->isAvailable()) {
$body = $this->readability->parse($item->get_permalink());
}
$cache_ids[] = $item->get_id();
$post_id = $this->createBlogPost($blog, $item, $body, $attachments);
$this->assignCategories($post_id, $blog->ID);
do_action(WPAB_ID . '_blog_post_created_from_feed', $post_id, $item, $attachments);
WPAutoblog_Stat::incrementPostsCount($item->get_date('Y/m/d'));
}
}
}
}
$postsToSweep = $wpdb->get_results('SELECT post_id FROM `wp_postmeta`
WHERE meta_key = "' . WPAB_ID . '-uuid"
GROUP BY meta_value
HAVING COUNT(*) > 1
LIMIT 0, 100', ARRAY_A);
$postsToSweepIds = array_map(function ($item) {
return $item['post_id'];
}, $postsToSweep);
WPAutoblog_Sweeper::remove($postsToSweepIds);
WPAutoblog_Log::log($feed, 'Finished updating feeds');
}
示例5: ikit_social_remote_fetch_flickr_images_rss
/**
* Refresh the flickr images cache
*/
function ikit_social_remote_fetch_flickr_images_rss()
{
global $g_options;
$flickr_user_id = null;
if (isset($g_options[IKIT_PLUGIN_OPTION_FLICKR_USER_ID])) {
$flickr_user_id = $g_options[IKIT_PLUGIN_OPTION_FLICKR_USER_ID];
}
if ($flickr_user_id != null) {
$feed = new SimplePie();
$feed->set_cache_duration(0);
$feed->set_timeout(5);
$feed->set_feed_url(sprintf(IKIT_SOCIAL_FLICKR_IMAGES_RSS_URL, $flickr_user_id));
$feed->set_cache_location(IKIT_DIR_CACHE);
$feed->init();
}
}
示例6: wprss_fetch_feed
/**
* A clone of the function 'fetch_feed' in wp-includes/feed.php [line #529]
*
* Called from 'wprss_get_feed_items'
*
* @since 3.5
*/
function wprss_fetch_feed($url, $source = NULL)
{
// Import SimplePie
require_once ABSPATH . WPINC . '/class-feed.php';
// Trim the URL
$url = trim($url);
// Initialize the Feed
$feed = new SimplePie();
// Obselete method calls ?
//$feed->set_cache_class( 'WP_Feed_Cache' );
//$feed->set_file_class( 'WP_SimplePie_File' );
$feed->set_feed_url($url);
$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL);
// If a feed source was passed
if ($source !== NULL) {
// Get the force feed option for the feed source
$force_feed = get_post_meta($source, 'wprss_force_feed', TRUE);
// If turned on, force the feed
if ($force_feed == 'true') {
$feed->force_feed(TRUE);
}
}
// Set timeout to 30s. Default: 15s
$feed->set_timeout(30);
//$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
$feed->enable_cache(FALSE);
// Reference array action hook, for the feed object and the URL
do_action_ref_array('wp_feed_options', array(&$feed, $url));
// Prepare the tags to strip from the feed
$tags_to_strip = apply_filters('wprss_feed_tags_to_strip', $feed->strip_htmltags, $source);
// Strip them
$feed->strip_htmltags($tags_to_strip);
// Fetch the feed
$feed->init();
$feed->handle_content_type();
// Convert the feed error into a WP_Error, if applicable
if ($feed->error()) {
return new WP_Error('simplepie-error', $feed->error());
}
// If no error, return the feed
return $feed;
}
示例7: SimplePie
/* Set the maximum number of items here */
$rss_url = 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml';
/* Enter the URL of your RSS feed here */
$show_errors = 'no';
?>
<div id="block_rss" class="block">
<div class="block_header">
<h4><a href="http://news.bbc.co.uk/">BBC News</a></h4>
</div>
<div class="block_body">
<ul>
<?php
echo "\n";
$feed = new SimplePie();
$feed->set_timeout(30);
$feed->set_feed_url($rss_url);
$feed->enable_cache(TRUE);
$feed->set_cache_location('files/cache');
$feed->set_item_limit($number_of_items);
$feed->set_cache_duration(900);
$feed->init();
$feed->handle_content_type();
$feed_items = $feed->get_items(0, $number_of_items);
if ($show_errors == 'yes' && $feed->error()) {
echo $feed->error();
}
foreach ($feed_items as $item) {
$item_link = $item->get_permalink();
$item_title = $item->get_title();
echo "\t\t\t\t\t\t\t<li><a href=\"{$item_link}\">{$item_title}</a></li>\n";
示例8: updateRSS
function updateRSS()
{
$db = DBCxn::get();
$selectRSS = $db->query("SELECT id, rssLink, updateMd5 FROM rss");
$selectRSS->setFetchMode(PDO::FETCH_ASSOC);
$selectRSS = $selectRSS->fetchAll();
//构建分析
$feed = new SimplePie();
$feed->enable_order_by_date(false);
$feed->enable_cache(true);
$feed->set_useragent('Mozilla/4.0 ' . SIMPLEPIE_USERAGENT);
$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
//拿出每个RSS调用分析函数
foreach ($selectRSS as $rows) {
$rssId = $rows['id'];
//博客ID
$updateMd5 = $rows['updateMd5'];
//最后更新记录的md5值
$feed->set_feed_url($rows['rssLink']);
//feed地址做参数进行解析操作
$feed->set_timeout(30);
$feed->init();
//如果feed出错,执行下一个
if ($feed->error()) {
continue;
}
readRSS($rssId, $updateMd5, $feed);
}
return true;
}
示例9: trim
foreach($feeds_array as $feed_item) {
if (trim($feed_item['feeds']) != '') {
$feed_urls[] = trim($feed_item['feeds']);
}
// limit to 10 URLs in OPML
if (count($feed_urls) >= 10) break;
}
// setup SimplePie again
if ($order == 'asc') {
$feed = new SimplePie_Chronological();
} else {
$feed = new SimplePie();
}
$feed->set_feed_url($feed_urls);
//$feed->force_feed(true);
$feed->set_timeout(120);
$feed->enable_cache(false);
$feed->set_stupidly_fast(true);
$feed->enable_order_by_date(true);
$feed->set_url_replacements(array());
$result = $feed->init();
//$feed->handle_content_type();
//if ($feed->error()) echo $feed->error();exit;
if (!$result) {
die('Sorry, no feed items found');
}
}
/////////////////////////////////////////////////
// Create new PDF document (LETTER/A4)
/////////////////////////////////////////////////
示例10: SimplePieWP
/**
* The actual function that can be called on webpages.
*/
function SimplePieWP($feed_url, $options = null)
{
// Quit if the SimplePie class isn't loaded.
if (!class_exists('SimplePie')) {
die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> There is a problem with the SimplePie Plugin for WordPress. Check your <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">Installation Status</a> for more information.</p>');
}
if (isset($locale) && !empty($locale) && $locale != 'auto') {
setlocale(LC_TIME, $locale);
}
// Default general settings
$template = get_option('simplepie_template');
$items = get_option('simplepie_items');
$items_per_feed = get_option('simplepie_items_per_feed');
$date_format = get_option('simplepie_date_format');
$enable_cache = get_option('simplepie_enable_cache');
$set_cache_location = get_option('simplepie_set_cache_location');
$set_cache_duration = get_option('simplepie_set_cache_duration');
$enable_order_by_date = get_option('simplepie_enable_order_by_date');
$set_timeout = get_option('simplepie_set_timeout');
// Default text-shortening settings
$truncate_feed_title = get_option('simplepie_truncate_feed_title');
$truncate_feed_description = get_option('simplepie_truncate_feed_description');
$truncate_item_title = get_option('simplepie_truncate_item_title');
$truncate_item_description = get_option('simplepie_truncate_item_description');
// Default advanced settings
$processing = get_option('simplepie_processing');
$locale = get_option('simplepie_locale');
$local_date_format = get_option('simplepie_local_date_format');
$strip_htmltags = get_option('simplepie_strip_htmltags');
$strip_attributes = get_option('simplepie_strip_attributes');
$set_max_checked_feeds = get_option('simplepie_set_max_checked_feeds');
// Overridden settings
if ($options) {
// Fix the template location if one was passed in.
if (isset($options['template']) && !empty($options['template'])) {
$options['template'] = SIMPLEPIE_PLUGINDIR . '/templates/' . strtolower(str_replace(' ', '_', $options['template'])) . '.tmpl';
}
// Fix the processing location if one was passed in.
if (isset($options['processing']) && !empty($options['processing'])) {
$options['processing'] = SIMPLEPIE_PLUGINDIR . '/processing/' . strtolower(str_replace(' ', '_', $options['processing'])) . '.php';
}
extract($options);
}
// Load post-processing file.
if ($processing && $processing != '') {
include_once $processing;
}
// If template doesn't exist, die.
if (!file_exists($template) || !is_readable($template)) {
die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> The SimplePie template file is not readable by WordPress. Check the <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">WordPress Control Panel</a> for more information.</p>');
}
// Initialize SimplePie
$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->enable_cache($enable_cache);
$feed->set_item_limit($items_per_feed);
$feed->set_cache_location($set_cache_location);
$feed->set_cache_duration($set_cache_duration);
$feed->enable_order_by_date($enable_order_by_date);
$feed->set_timeout($set_timeout);
$feed->strip_htmltags(explode(' ', $strip_htmltags));
$feed->strip_attributes(explode(' ', $strip_attributes));
$feed->set_max_checked_feeds($set_max_checked_feeds);
$feed->init();
// Load up the selected template file
$handle = fopen($template, 'r');
$tmpl = fread($handle, filesize($template));
fclose($handle);
/**************************************************************************************************************/
// ERRORS
// I'm absolutely sure that there is a better way to do this.
// Define what we're looking for
$error_start_tag = '{IF_ERROR_BEGIN}';
$error_end_tag = '{IF_ERROR_END}';
$error_start_length = strlen($error_start_tag);
$error_end_length = strlen($error_end_tag);
// Find what we're looking for
$error_start_pos = strpos($tmpl, $error_start_tag);
$error_end_pos = strpos($tmpl, $error_end_tag);
$error_length_pos = $error_end_pos - $error_start_pos;
// Grab what we're looking for
$error_string = substr($tmpl, $error_start_pos + $error_start_length, $error_length_pos - $error_start_length);
$replacable_string = $error_start_tag . $error_string . $error_end_tag;
if ($error_message = $feed->error()) {
$tmpl = str_replace($replacable_string, $error_string, $tmpl);
$tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', $error_message), $tmpl);
} elseif ($feed->get_item_quantity() == 0) {
$tmpl = str_replace($replacable_string, $error_string, $tmpl);
$tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', 'There are no items in this feed.'), $tmpl);
} else {
$tmpl = str_replace($replacable_string, '', $tmpl);
}
/**************************************************************************************************************/
// FEED
// FEED_AUTHOR_EMAIL
/* if ($author = $feed->get_author())
{
//.........这里部分代码省略.........
示例11: repress_blog
function repress_blog($feed_url)
{
$output = array();
$output[snippet] = '';
$output[title] = '';
$output[link] = '';
if (filter_var($feed_url, FILTER_VALIDATE_URL)) {
/* Check in cache if we've collected the latest post from this blog within past 24 hours */
$cache_file = repressed_cache_dirname() . '/' . repressed_cache_filename($feed_url);
/* Cache the whole RSS to a file if the file isn't there, or if it's older than 24 hours */
$expire_seconds = 86400;
$expire_date = time() + $expire_seconds;
$max = 3;
/* Number of posts to collect from each feed */
$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->set_cache_name_function('repressed_cache_filename');
$feed->enable_order_by_date(true);
$feed->set_cache_duration($expire_seconds);
$feed->set_cache_location(repressed_cache_dirname());
$feed->enable_cache(true);
$feed->set_timeout(3);
$feed->set_item_limit($max);
$feed->init();
$post_title = array();
$post_link = array();
$post_snip = array();
$post_date = array();
$snip_words = 15;
/* Length of snippet in words */
foreach ($feed->get_items() as $item) {
array_push($post_title, $item->get_title());
array_push($post_link, $item->get_link());
$snip = substr(strip_tags($item->get_content()), 0, 500);
$snip = implode(" ", array_slice(explode(" ", $snip), 0, $snip_words));
$snip = preg_replace('/\\s*$/', '...', $snip);
array_push($post_snip, $snip);
}
$output[title] = $post_title[0];
$output[link] = $post_link[0];
$output[snippet] = $post_snip[0];
return $output;
} else {
return FALSE;
}
}
示例12: get_items_feed
public static function get_items_feed($url, $params = null)
{
$feed = new SimplePie();
$mode = isset($params->mode) ? $params->mode : 0;
if ($mode == 0) {
$feed->set_feed_url($url);
} else {
$html = ogbFile::get_curl($url);
$feed->set_raw_data($html);
}
$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
$feed->set_timeout(20);
$feed->enable_cache(false);
$feed->set_stupidly_fast(true);
$feed->enable_order_by_date(false);
// we don't want to do anything to the feed
$feed->set_url_replacements(array());
$feed->force_feed(true);
$result = $feed->init();
if (isset($_GET['x'])) {
echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n";
echo "<p>URL: [{$url}]</p>";
echo "<p>Error: [{$feed->error}]</p>";
}
$items = $feed->get_items();
$c_items = count($items);
if ($c_items == 0) {
echo "<p>Error: [{$feed->error}]</p>";
return array();
}
for ($i = 0; $i < count($items); $i++) {
$row = new stdclass();
$row->title = $items[$i]->get_title();
# the title for the post
$row->link = $items[$i]->get_link();
# a single link for the post
$row->description = $items[$i]->get_description();
# the content of the post (prefers summaries)
$row->author = $items[$i]->get_author();
# a single author for the post
$row->date = $items[$i]->get_date('Y-m-d H:i:s');
$row->enclosures = $items[$i]->get_enclosures();
$rows[] = $row;
}
return $rows;
}
示例13: initRss
function initRss($rssLink, $user)
{
$db = DBCxn::get();
//构建对象
$feed = new SimplePie();
$feed->set_feed_url($rssLink);
//feed地址做参数进行解析操作
$feed->set_timeout(30);
$feed->enable_cache(false);
$feed->init();
if ($feed->error()) {
//feed地址错误
//echo $feed->error();
return "error";
}
$blogName = $feed->get_title();
$blogLink = $feed->get_link();
$selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
$selectOneRSS->execute(array($blogLink));
$blogLinkId = $selectOneRSS->fetchColumn();
//此RSS在数据库表中id
//检查是否存在,如果不存在添加此feed
if ($blogLinkId > 0) {
//echo "此订阅源已经存在!";
//检查用户是否已经订阅
$checkSub = $db->prepare("SELECT count(*) FROM readinfo WHERE userName = ? AND rssId = ?");
$checkSub->execute(array($user, $blogLinkId));
$boolCheckSub = $checkSub->fetchColumn();
if ($boolCheckSub != 1) {
//用户没有订阅
$insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
$insertReadInfo->bindParam(':user', $user);
$insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
$insertReadInfo->execute();
//"此源已经存在,你之前尚未订阅,现在已经订阅";
//return "succeed1";
return "rss-" . $blogLinkId;
} else {
//"此源已经存在,你之前已经订阅";
return "succeed2";
}
} else {
$sql = "INSERT INTO rss(blogName,blogLink,rssLink,updateMd5) VALUES(:blogName,:blogLink,:rssLink,:updateMd5)";
$insertRSS = $db->prepare($sql);
$insertRSS->bindParam(':blogName', $blogName);
$insertRSS->bindParam(':blogLink', $blogLink);
$insertRSS->bindParam(':rssLink', $rssLink);
$insertRSS->bindParam(':updateMd5', $updateMd5);
$updateMd5 = md5("123456");
$insertRSS->execute();
//查询该源的ID
$selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
$selectOneRSS->execute(array($blogLink));
$blogLinkId = $selectOneRSS->fetchColumn();
//订阅此源
//$db->exec("INSERT INTO readinfo(userName,rssId) VALUES ($user, $blogLinkId)");
$insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
$insertReadInfo->bindParam(':user', $user);
$insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
$insertReadInfo->execute();
//"此源不存在,现在已经订阅";
return "rss-" . $blogLinkId;
}
}
示例14: WPZOOM_Dashboard
function WPZOOM_Dashboard()
{
?>
<div class="table table_news">
<p class="sub">From our Blog</p>
<div class="rss-widget">
<?php
/**
* Get RSS Feed(s)
*/
$items = get_transient('wpzoom_dashboard_widget_news');
if (!(is_array($items) && count($items))) {
include_once ABSPATH . WPINC . '/class-simplepie.php';
$rss = new SimplePie();
$rss->set_timeout(5);
$rss->set_feed_url('http://www.wpzoom.com/feed/');
$rss->strip_htmltags(array_merge($rss->strip_htmltags, array('h1', 'a', 'img')));
$rss->enable_cache(false);
$rss->init();
$items = $rss->get_items(0, 3);
$cached = array();
foreach ($items as $item) {
$cached[] = array('url' => $item->get_permalink(), 'title' => $item->get_title(), 'date' => $item->get_date("d M Y"), 'content' => substr(strip_tags($item->get_content()), 0, 128) . "...");
}
$items = $cached;
set_transient('wpzoom_dashboard_widget_news', $cached, 60 * 60 * 24);
}
?>
<ul class="news">
<?php
if (empty($items)) {
echo '<li>No items</li>';
} else {
foreach ($items as $item) {
?>
<li class="post">
<a href="<?php
echo $item['url'];
?>
" class="rsswidget"><?php
echo $item['title'];
?>
</a>
<span class="rss-date"><?php
echo $item['date'];
?>
</span>
<div class="rssSummary"><?php
echo $item['content'];
?>
</div>
</li>
<?php
}
}
?>
</ul><!-- end of .news -->
</div>
</div>
<div class="table table_theme">
<p class="sub">Latest Theme</p>
<div class="theme_thumb">
<?php
$current = get_transient('wpzoom_dashboard_widget_theme');
if (!is_object($current) || !isset($current->data)) {
$current = new stdClass();
$current->lastChecked = 0;
}
$time_changed = 24 * HOUR_IN_SECONDS < time() - $current->lastChecked;
if ($time_changed) {
$response = wp_remote_get('http://www.wpzoom.com/frame/latest_theme.html');
if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
$current->data = wp_remote_retrieve_body($response);
}
$current->lastChecked = time();
set_transient('wpzoom_dashboard_widget_theme', $current);
}
?>
<?php
if ($current) {
echo $current->data;
}
?>
</div>
<a href="http://wpzoom.com/themes/" target="_blank" alt="Browse our wide selection of WordPress themes to find the right one for you" class="button">Browse more →</a>
</div>
<div class="clear"> </div>
<?php
}
示例15: execute
public function execute()
{
parent::execute();
if ($this->action == 'NewsreaderCache') {
$urls = preg_split('/\\r?\\n/', SPNRBOX_FEEDS);
$cache_location = WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/cache';
// CHARSET
if (!defined('CHARSET')) {
define('CHARSET', 'UTF-8');
}
if (!defined('SPNRBOX_CHARSET')) {
define('SPNRBOX_CHARSET', 'UTF-8');
}
if (SPNRBOX_CHARSET == 'default') {
$charset = CHARSET;
} else {
$charset = SPNRBOX_CHARSET;
}
// FILTER?
if (SPNRBOX_FILTER && strlen(SPNRBOX_FILTERWORDS) >= 3) {
require_once WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/simplepie_filter.php';
$feed = new SimplePie_Filter();
if (!defined('SPNRBOX_FILTERCLASS')) {
define('SPNRBOX_FILTERCLASS', 'hightlight');
}
define('SPNRBOX_FILTERON', 1);
} else {
$feed = new SimplePie();
define('SPNRBOX_FILTERON', 0);
}
$feed->set_feed_url($urls);
$feed->set_cache_location($cache_location);
$feed->set_autodiscovery_cache_duration(0);
$feed->set_cache_duration(0);
$feed->set_favicon_handler(RELATIVE_WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/handler_image.php');
$feed->set_image_handler(RELATIVE_WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/handler_image.php');
$feed->set_output_encoding($charset);
$feed->set_timeout(10);
$feed->init();
$feed->handle_content_type();
if (SPNRBOX_FILTERON) {
$feed->set_filter(SPNRBOX_FILTERWORDS, SPNRBOX_FILTERMODE);
}
header("Content-type: text/plain; charset=UTF-8");
foreach ($urls as $feeds) {
$feeds = trim($feeds);
if (empty($feeds)) {
continue;
}
$feed->set_feed_url($feeds);
$feed->init();
$items = $feed->get_items();
if (SPNRBOX_FILTERON) {
$items = $feed->filter($items);
}
echo $feed->get_title() . "\n";
if (!count($items)) {
echo "\tKeine Feeds gefunden.\n";
} else {
$i = 0;
foreach ($items as $item) {
if ($i >= SPNRBOX_NUMOFFEEDS) {
break;
}
SPNRBOX_FILTERON ? $this->highlight(SPNRBOX_FILTERWORDS, $item->get_content(), SPNRBOX_FILTERCLASS) : $item->get_content();
echo "\t\"" . $item->get_title() . "\" -> wurde geladen.\n";
$i++;
}
}
}
}
}