Changeset 10687 for trunk/wp-includes/class-feed.php
- Timestamp:
- 03/03/2009 05:41:01 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-feed.php
r10666 r10687 3 3 require_once (ABSPATH . WPINC . '/simplepie.inc'); 4 4 5 class WP_Feed_Cache extends SimplePie_Cache 6 { 5 class WP_Feed_Cache extends SimplePie_Cache { 7 6 /** 8 7 * Don't call the constructor. Please. … … 10 9 * @access private 11 10 */ 12 function WP_Feed_Cache() 13 { 11 function WP_Feed_Cache() { 14 12 trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR); 15 13 } … … 21 19 * @access public 22 20 */ 23 function create($location, $filename, $extension) 24 { 21 function create($location, $filename, $extension) { 25 22 return new WP_Feed_Cache_Transient($location, $filename, $extension); 26 23 } 27 24 } 28 25 29 class WP_Feed_Cache_Transient 30 { 26 class WP_Feed_Cache_Transient { 31 27 var $location; 32 28 var $filename; … … 34 30 var $name; 35 31 36 function WP_Feed_Cache_Transient($location, $filename, $extension) 37 { 32 function WP_Feed_Cache_Transient($location, $filename, $extension) { 38 33 //$this->location = $location; 39 34 //$this->filename = rawurlencode($filename); … … 44 39 } 45 40 46 function save($data) 47 { 48 if (is_a($data, 'SimplePie')) 49 { 41 function save($data) { 42 if ( is_a($data, 'SimplePie') ) 50 43 $data = $data->data; 51 }52 44 53 45 set_transient($this->name, $data, 43200); … … 56 48 } 57 49 58 function load() 59 { 50 function load() { 60 51 return get_transient($this->name); 61 52 } 62 53 63 function mtime() 64 { 54 function mtime() { 65 55 return get_transient($this->mod_name); 66 56 } 67 57 68 function touch() 69 { 58 function touch() { 70 59 return set_transient($this->mod_name, time(), 43200); 71 60 } 72 61 73 function unlink() 74 { 62 function unlink() { 75 63 delete_transient($this->name); 76 64 delete_transient($this->mod_name); … … 78 66 } 79 67 } 68 69 class WP_SimplePie_File extends SimplePie_File { 70 71 function WP_SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { 72 $this->url = $url; 73 $this->timeout = $timeout; 74 $this->redirects = $redirects; 75 $this->headers = $headers; 76 $this->useragent = $useragent; 77 78 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE; 79 80 if ( preg_match('/^http(s)?:\/\//i', $url) ) { 81 $args = array( 'timeout' => $this->timeout, 'redirection' => $this->redirects); 82 83 if ( !empty($this->headers) ) 84 $args['headers'] = $this->headers; 85 86 if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified 87 $args['user-agent'] = $this->useragent; 88 89 $res = wp_remote_request($url, $args); 90 91 if ( is_wp_error($res) ) { 92 $this->error = 'WP HTTP Error: ' . $res->get_error_message(); 93 $this->success = false; 94 } else { 95 $this->headers = $res['headers']; 96 $this->body = $res['body']; 97 $this->status_code = $res['response']['code']; 98 } 99 } else { 100 if ( ! $this->body = file_get_contents($url) ) { 101 $this->error = 'file_get_contents could not read the file'; 102 $this->success = false; 103 } 104 } 105 } 106 }
Note: See TracChangeset
for help on using the changeset viewer.