separate_comments

函数


separate_comments ( $comments )
参数
  • (WP_Comment[])
    $comments
    Array of comments
    Required:
返回值
  • (WP_Comment[]) Array of comments keyed by comment_type.
定义位置
  • wp-includes/comment.php
    , line 951
引入
2.7.0
弃用

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

function separate_comments( &$comments ) {
	$comments_by_type = array(
		'comment'   => array(),
		'trackback' => array(),
		'pingback'  => array(),
		'pings'     => array(),
	);

	$count = count( $comments );

	for ( $i = 0; $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;
}