public function getChildrens() { $comments = get_comments(array('parent' => $this->properties['id'])); $len = count($comments); if ($len != 0) { for ($i = 0; $i < $len; $i++) { $this->properties['childrens'][$i] = CommentDataHelper::createCommentObject($comments[$i]); $this->properties['childrens'][$i]->getChildrens(); } } return $this->properties['childrens']; }
public function getRecentComments($number = 10, $args = array()) { $args['number'] = $number; $args['status'] = 'approve'; $comments = get_comments($args); if (is_array($comments)) { $result = array(); foreach ($comments as $comment) { $result[] = CommentDataHelper::createCommentObject($comment); } return $result; } else { return null; } }
public static function getComments($postId, $args = array()) { $args['post_id'] = $postId; $comments = get_comments($args); if (is_array($comments)) { $result = array(); foreach ($comments as $comment) { $params = array('comment_content' => get_comment_text($comment), 'comment_author' => get_comment_author($comment), 'avatar' => self::getAvatar($comment), 'authorLink' => get_comment_author_link($comment)); $comment_object_var = get_object_vars($comment); $comment_params = $params + $comment_object_var; $result[] = new Comment($comment_params); } return CommentDataHelper::buildCommentTree($result); } else { return null; } }