function comment_link()
{
$url = null;
// RSS 2.0 has a standard <comments> element:
// "<comments> is an optional sub-element of <item>. If present,
// it is the url of the comments page for the item."
// <http://cyber.law.harvard.edu/rss/rss.html#ltcommentsgtSubelementOfLtitemgt>
if (isset($this->item['comments'])) {
$url = $this->item['comments'];
}
// The convention in Atom feeds is to use a standard <link>
// element with @rel="replies" and @type="text/html".
// Unfortunately, SimplePie_Item::get_links() allows us to filter
// by the value of @rel, but not by the value of @type. *sigh*
// Try Atom 1.0 first
$linkElements = $this->entry->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link');
// Fall back and try Atom 0.3
if (is_null($linkElements)) {
$linkElements = $this->entry->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link');
}
// Now loop through the elements, screening by @rel and @type
if (is_array($linkElements)) {
foreach ($linkElements as $link) {
$rel = isset($link['attribs']['']['rel']) ? $link['attribs']['']['rel'] : 'alternate';
$type = isset($link['attribs']['']['type']) ? $link['attribs']['']['type'] : NULL;
$href = isset($link['attribs']['']['href']) ? $link['attribs']['']['href'] : NULL;
if (strtolower($rel) == 'replies' and $type == 'text/html' and !is_null($href)) {
$url = $href;
}
}
}
return $url;
}