wppaste
WordPress

separate_comments( WP_Comment[] $comments ): array<string,

Since
2.7.0
Source
wp-includes/comment.php:999
Separates an array of comments into an array keyed by comment_type.

Parameters

$commentsWP_Comment[]
Array of comments.

Return

array<string,
WP_Comment[]&gt; Array of comments keyed by comment type.

Used by · 2

Source

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;}

History

Introduced in 2.7.0. One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.9.7
Return type changed from WP_Comment[] to array<string,.verified against source
2.7.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/comment.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.