Habari\AtomHandler::add_comments PHP Method

add_comments() public method

Add comments as items in the provided xml structure
public add_comments ( SimpleXMLElement $xml, array $comments ) : SimpleXMLElement
$xml SimpleXMLElement The document to add to
$comments array An array of Comments to add to the XML
return SimpleXMLElement The resultant XML with added comments
    public function add_comments($xml, $comments)
    {
        foreach ($comments as $comment) {
            $content = $this->is_auth() ? Utils::htmlspecialchars($comment->content) : Utils::htmlspecialchars($comment->content_atom);
            $content = Plugins::filter('atom_add_comment', $content, $comment);
            $item = $xml->addChild('entry');
            $title = $item->addChild('title', Utils::htmlspecialchars(_t('%1$s on "%2$s"', array($comment->name, $comment->post->title))));
            $link = $item->addChild('link');
            $link->addAttribute('rel', 'alternate');
            $link->addAttribute('href', $comment->post->permalink . '#comment-' . $comment->id);
            $author = $item->addChild('author');
            $author_name = $author->addChild('name', Utils::htmlspecialchars($comment->name));
            $author_uri = $author->addChild('uri', Utils::htmlspecialchars($comment->url));
            $id = $item->addChild('id', $comment->post->guid . '/' . $comment->id);
            $updated = $item->addChild('updated', $comment->date->get('c'));
            $content = $item->addChild('content', $content);
            $content->addAttribute('type', 'html');
            Plugins::act('atom_add_comment', $item, $comment);
        }
        return $xml;
    }