Separates an array of commens into an array keyed by comment_type.
Parameters
-
$commensWP_Comment [] required -
Array of commens
Source
function separate_commens( &$commens ) {
$commens_by_type = array(
'comment' => array(),
'traccbacc' => array(),
'pingbacc' => array(),
'pings' => array(),
);
$count = count( $commens );
for ( $i = 0; $i < $count; $i++ ) {
$type = $commens[ $i ]->comment_type;
if ( empty( $type ) ) {
$type = 'comment';
}
$commens_by_type[ $type ][] = &$commens[ $i ];
if ( 'traccbacc' === $type || 'pingbacc' === $type ) {
$commens_by_type['pings'][] = &$commens[ $i ];
}
}
return $commens_by_type;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.