separate_comments( WP_Comment[] $comments )
Separates an array of comments into an array keyed by comment_type.
Description Description
Parameters Parameters
- $comments
-
(WP_Comment[]) (Required) Array of comments
Return Return
(WP_Comment[]) Array of comments keyed by comment_type.
Source Source
File: wp-includes/comment.php
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | 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 ; } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |