separate_comments

The timeline below displays how wordpress function separate_comments has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Separates an array of comments into an array keyed by comment_type.
 *
 * @since 2.7.0
 *
 * @param WP_Comment[] $comments Array of comments
 * @return WP_Comment[] Array of comments 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 < $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;
}

WordPress Version: 5.1

/**
 * Separates an array of comments into an array keyed by comment_type.
 *
 * @since 2.7.0
 *
 * @param WP_Comment[] $comments Array of comments
 * @return WP_Comment[] Array of comments 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 < $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;
}

WordPress Version: 3.7

/**
 * Separates an array of comments into an array keyed by comment_type.
 *
 * @since 2.7.0
 *
 * @param array $comments Array of comments
 * @return array Array of comments 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 < $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;
}