public function get_channel_tags($namespace, $tag)
{
$type = $this->get_type();
if ($type & SIMPLEPIE_TYPE_ATOM_ALL) {
if ($return = $this->get_feed_tags($namespace, $tag)) {
return $return;
}
}
if ($type & SIMPLEPIE_TYPE_RSS_10) {
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) {
if (isset($channel[0]['child'][$namespace][$tag])) {
return $channel[0]['child'][$namespace][$tag];
}
}
}
if ($type & SIMPLEPIE_TYPE_RSS_090) {
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) {
if (isset($channel[0]['child'][$namespace][$tag])) {
return $channel[0]['child'][$namespace][$tag];
}
}
}
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) {
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) {
if (isset($channel[0]['child'][$namespace][$tag])) {
return $channel[0]['child'][$namespace][$tag];
}
}
}
return null;
}
/** * Find the feed's icon * * @param SimplePie $feed SimplePie object to retrieve logo for * @return string URL to feed icon */ protected static function discover_favicon($feed, $id) { if ($return = $feed->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) { $favicon = SimplePie_Misc::absolutize_url($return[0]['data'], $feed->get_base($return[0])); } elseif (($url = $feed->get_link()) !== null && preg_match('/^http(s)?:\\/\\//i', $url)) { $filename = $id . '.ico'; $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url); } else { return false; } $cache = new DataHandler(get_option('cachedir')); $request = new HTTPRequest(); $file = $request->get($favicon, array('X-Forwarded-For' => $_SERVER['REMOTE_ADDR'])); if ($file->success && strlen($file->body) > 0) { $sniffer = new $feed->content_type_sniffer_class($file); if (substr($sniffer->get_type(), 0, 6) === 'image/') { $body = array('type' => $sniffer->get_type(), 'body' => $file->body); return $cache->save($filename, serialize($body)); } else { return false; } } return false; }