mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-18 00:25:37 +01:00
26f220a947
git-svn-id: http://svn.automattic.com/wordpress/trunk@4378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
require_once('simplepie.php');
|
|
|
|
class WordPress_SimplePie_Cache extends SimplePie_Cache {
|
|
var $name;
|
|
|
|
function WordPress_SimplePie_Cache($location, $filename, $extension) {
|
|
$this->name = rawurlencode($filename);
|
|
}
|
|
|
|
function save($data) {
|
|
$cache_option = "rss_$this->name";
|
|
$cache_timestamp = $cache_option . '_ts';
|
|
if ( false !== get_option($cache_option) ) {
|
|
update_option($cache_option, $data);
|
|
} else {
|
|
add_option($cache_option, $data, '', 'no');
|
|
}
|
|
if ( false !== get_option($cache_timestamp) ) {
|
|
update_option($cache_timestamp, time());
|
|
} else {
|
|
add_option($cache_timestamp, time(), '', 'no');
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function load() {
|
|
return get_option("rss_$this->name");
|
|
}
|
|
|
|
function mtime() {
|
|
return get_option('rss_' . $this->name . '_ts');
|
|
}
|
|
|
|
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');
|
|
}
|
|
}
|
|
|
|
function unlink() {
|
|
delete_option("rss_$this->name");
|
|
delete_option('rss_' . $this->name . '_ts');
|
|
}
|
|
}
|
|
|
|
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;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
?>
|