separate_comments

Definition:
function &separate_comments(&$comments) {}

Separates an array of comments into an array keyed by comment_type.

Parameters

  • array $comments: Array of comments
  • &$comments

Return values

returns:Array of comments keyed by comment_type.

Source code

function &separate_comments(&$comments) {

	$comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());

	$count = count($comments);

	for ( $i = 0; $i < $count; $i++ ) {

		$type = $comments[$i]->comment_type;

		if ( empty($type) )

			$type = 'comment';

		$comments_by_type[$type][] = &$comments[$i];

		if ( 'trackback' == $type || 'pingback' == $type )

			$comments_by_type['pings'][] = &$comments[$i];

	}



	return $comments_by_type;

}

2831

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: