2004-12-19 03:30:40 +01:00
|
|
|
<?php
|
|
|
|
|
2006-10-13 12:20:18 +02:00
|
|
|
require_once('class-simplepie.php');
|
2004-12-19 03:30:40 +01:00
|
|
|
|
2006-10-12 01:03:17 +02:00
|
|
|
class WordPress_SimplePie_Cache extends SimplePie_Cache {
|
|
|
|
var $name;
|
|
|
|
|
|
|
|
function WordPress_SimplePie_Cache($location, $filename, $extension) {
|
|
|
|
$this->name = rawurlencode($filename);
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
|
|
|
|
function save($data) {
|
|
|
|
$cache_option = "rss_$this->name";
|
|
|
|
$cache_timestamp = $cache_option . '_ts';
|
|
|
|
if ( false !== get_option($cache_option) ) {
|
|
|
|
update_option($cache_option, $data);
|
2005-11-13 03:54:49 +01:00
|
|
|
} else {
|
2006-10-12 01:03:17 +02:00
|
|
|
add_option($cache_option, $data, '', 'no');
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
if ( false !== get_option($cache_timestamp) ) {
|
|
|
|
update_option($cache_timestamp, time());
|
|
|
|
} else {
|
|
|
|
add_option($cache_timestamp, time(), '', 'no');
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
return true;
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
|
|
|
|
function load() {
|
|
|
|
return get_option("rss_$this->name");
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
|
|
|
|
function mtime() {
|
|
|
|
return get_option('rss_' . $this->name . '_ts');
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
|
|
|
|
function touch() {
|
|
|
|
$cache_timestamp = 'rss_' . $this->name . '_ts';
|
|
|
|
if ( false !== get_option($cache_timestamp) ) {
|
|
|
|
update_option($cache_timestamp, time());
|
|
|
|
} else {
|
|
|
|
add_option($cache_timestamp, time(), '', 'no');
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
|
|
|
|
function unlink() {
|
|
|
|
delete_option("rss_$this->name");
|
|
|
|
delete_option('rss_' . $this->name . '_ts');
|
2004-12-19 03:30:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-12 01:03:17 +02:00
|
|
|
function fetch_simplepie ($url) {
|
|
|
|
$feed = new SimplePie;
|
|
|
|
$feed->feed_url($url);
|
|
|
|
$feed->set_cache_class('WordPress_SimplePie_Cache');
|
|
|
|
$feed->strip_htmltags(false);
|
|
|
|
$feed->strip_attributes(false);
|
|
|
|
$feed->output_encoding(get_option('blog_charset'));
|
|
|
|
$feed->cache_max_minutes(720);
|
|
|
|
$feed->set_useragent('WordPress/' . $wp_version);
|
|
|
|
if ($feed->init()) {
|
|
|
|
return $feed;
|
2004-12-19 03:30:40 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 01:03:17 +02:00
|
|
|
|
2004-12-19 03:30:40 +01:00
|
|
|
?>
|