| @@ -54,11 +54,11 @@ | ||
| 54 | 54 | // Verify feeds and resolve relative URIs |
| 55 | 55 | foreach ($href as $u) { |
| 56 | 56 | $the_uri = Relative_URI::resolve($u, $this->uri); |
| 57 | 57 | if ($this->verify) { |
| 58 | - $feed =& new FeedFinder($the_uri); | |
| 58 | + $feed = new FeedFinder($the_uri); | |
| 59 | 59 | if ($feed->is_feed()) $ret[] = $the_uri; |
| 60 | - $feed = NULL; | |
| 60 | + unset($feed); | |
| 61 | 61 | } else { |
| 62 | 62 | $ret[] = $the_uri; |
| 63 | 63 | } |
| 64 | 64 | } /* foreach */ |
| @@ -74,10 +74,10 @@ | ||
| 74 | 74 | |
| 75 | 75 | function status ($uri = NULL) { |
| 76 | 76 | $this->_get($uri); |
| 77 | 77 | |
| 78 | - if (isset($this->_response->status)) : | |
| 79 | - $ret = $this->_response->status; | |
| 78 | + if (!is_wp_error($this->_response) and isset($this->_response['response']['code'])) : | |
| 79 | + $ret = $this->_response['response']['code']; | |
| 80 | 80 | else : |
| 81 | 81 | $ret = NULL; |
| 82 | 82 | endif; |
| 83 | 83 | return $ret; |
| @@ -82,10 +82,18 @@ | ||
| 82 | 82 | endif; |
| 83 | 83 | return $ret; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - function error () { | |
| 87 | - return $this->_error; | |
| 86 | + function error ($index = NULL) { | |
| 87 | + $message = NULL; | |
| 88 | + if (count($this->_error) > 0) : | |
| 89 | + if (is_scalar($index) and !is_null($index)) : | |
| 90 | + $message = $this->_error[$index]; | |
| 91 | + else : | |
| 92 | + $message = implode(" / ", $this->_error)."\n"; | |
| 93 | + endif; | |
| 94 | + endif; | |
| 95 | + return $message; | |
| 88 | 96 | } |
| 89 | 97 | |
| 90 | 98 | function is_feed ($uri = NULL) { |
| 91 | 99 | $data = $this->data($uri); |
| @@ -110,17 +118,22 @@ | ||
| 110 | 118 | $headers['Connection'] = 'close'; |
| 111 | 119 | $headers['Accept'] = 'application/atom+xml application/rdf+xml application/rss+xml application/xml text/html */*'; |
| 112 | 120 | $headers['User-Agent'] = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress'; |
| 113 | 121 | |
| 114 | - // Use function provided by MagpieRSS package | |
| 115 | - $client = _fetch_remote_file($this->uri, $headers); | |
| 116 | - if (isset($client->error)) : | |
| 117 | - $this->_error = $client->error; | |
| 122 | + // Use WordPress API function | |
| 123 | + $client = wp_remote_request($this->uri, array( | |
| 124 | + 'headers' => $headers, | |
| 125 | + 'timeout' => FEEDWORDPRESS_FETCH_TIME_OUT, | |
| 126 | + )); | |
| 127 | + | |
| 128 | + $this->_response = $client; | |
| 129 | + if (is_wp_error($client)) : | |
| 130 | + $this->_data = NULL; | |
| 131 | + $this->_error = $client->get_error_messages(); | |
| 118 | 132 | else : |
| 133 | + $this->_data = $client['body']; | |
| 119 | 134 | $this->_error = NULL; |
| 120 | 135 | endif; |
| 121 | - $this->_response = $client; | |
| 122 | - $this->_data = $client->results; | |
| 123 | 136 | |
| 124 | 137 | // Kilroy was here |
| 125 | 138 | $this->_cache_uri = $this->uri; |
| 126 | 139 | endif; |