8 * Create a new SimplePie_Cache object |
8 * Create a new SimplePie_Cache object |
9 * |
9 * |
10 * @static |
10 * @static |
11 * @access public |
11 * @access public |
12 */ |
12 */ |
13 function create($location, $filename, $extension) { |
13 public function create($location, $filename, $extension) { |
14 return new WP_Feed_Cache_Transient($location, $filename, $extension); |
14 return new WP_Feed_Cache_Transient($location, $filename, $extension); |
15 } |
15 } |
16 } |
16 } |
17 |
17 |
18 class WP_Feed_Cache_Transient { |
18 class WP_Feed_Cache_Transient { |
19 var $name; |
19 public $name; |
20 var $mod_name; |
20 public $mod_name; |
21 var $lifetime = 43200; //Default lifetime in cache of 12 hours |
21 public $lifetime = 43200; //Default lifetime in cache of 12 hours |
22 |
22 |
23 function __construct($location, $filename, $extension) { |
23 public function __construct($location, $filename, $extension) { |
24 $this->name = 'feed_' . $filename; |
24 $this->name = 'feed_' . $filename; |
25 $this->mod_name = 'feed_mod_' . $filename; |
25 $this->mod_name = 'feed_mod_' . $filename; |
26 |
26 |
27 $lifetime = $this->lifetime; |
27 $lifetime = $this->lifetime; |
28 /** |
28 /** |
34 * @param string $filename Unique identifier for the cache object. |
34 * @param string $filename Unique identifier for the cache object. |
35 */ |
35 */ |
36 $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename); |
36 $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename); |
37 } |
37 } |
38 |
38 |
39 function save($data) { |
39 public function save($data) { |
40 if ( is_a($data, 'SimplePie') ) |
40 if ( $data instanceof SimplePie ) { |
41 $data = $data->data; |
41 $data = $data->data; |
|
42 } |
42 |
43 |
43 set_transient($this->name, $data, $this->lifetime); |
44 set_transient($this->name, $data, $this->lifetime); |
44 set_transient($this->mod_name, time(), $this->lifetime); |
45 set_transient($this->mod_name, time(), $this->lifetime); |
45 return true; |
46 return true; |
46 } |
47 } |
47 |
48 |
48 function load() { |
49 public function load() { |
49 return get_transient($this->name); |
50 return get_transient($this->name); |
50 } |
51 } |
51 |
52 |
52 function mtime() { |
53 public function mtime() { |
53 return get_transient($this->mod_name); |
54 return get_transient($this->mod_name); |
54 } |
55 } |
55 |
56 |
56 function touch() { |
57 public function touch() { |
57 return set_transient($this->mod_name, time(), $this->lifetime); |
58 return set_transient($this->mod_name, time(), $this->lifetime); |
58 } |
59 } |
59 |
60 |
60 function unlink() { |
61 public function unlink() { |
61 delete_transient($this->name); |
62 delete_transient($this->name); |
62 delete_transient($this->mod_name); |
63 delete_transient($this->mod_name); |
63 return true; |
64 return true; |
64 } |
65 } |
65 } |
66 } |
66 |
67 |
67 class WP_SimplePie_File extends SimplePie_File { |
68 class WP_SimplePie_File extends SimplePie_File { |
68 |
69 |
69 function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { |
70 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { |
70 $this->url = $url; |
71 $this->url = $url; |
71 $this->timeout = $timeout; |
72 $this->timeout = $timeout; |
72 $this->redirects = $redirects; |
73 $this->redirects = $redirects; |
73 $this->headers = $headers; |
74 $this->headers = $headers; |
74 $this->useragent = $useragent; |
75 $this->useragent = $useragent; |