comment_class

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

WordPress Version: 6.2

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|string[] $css_class Optional. One or more classes to add to the class list.
 *                                   Default empty.
 * @param int|WP_Comment  $comment   Optional. Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post     $post      Optional. Post ID or WP_Post object. Default current post.
 * @param bool            $display   Optional. Whether to print or return the output.
 *                                   Default true.
 * @return void|string Void if `$display` argument is true, comment classes if `$display` is false.
 */
function comment_class($css_class = '', $comment = null, $post = null, $display = true)
{
    // Separates classes with a single space, collates classes for comment DIV.
    $css_class = 'class="' . implode(' ', get_comment_class($css_class, $comment, $post)) . '"';
    if ($display) {
        echo $css_class;
    } else {
        return $css_class;
    }
}

WordPress Version: 6.1

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|string[] $css_class Optional. One or more classes to add to the class list.
 *                                   Default empty.
 * @param int|WP_Comment  $comment   Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post     $post      Post ID or WP_Post object. Default current post.
 * @param bool            $display   Optional. Whether to print or return the output.
 *                                   Default true.
 * @return void|string Void if `$display` argument is true, comment classes if `$display` is false.
 */
function comment_class($css_class = '', $comment = null, $post = null, $display = true)
{
    // Separates classes with a single space, collates classes for comment DIV.
    $css_class = 'class="' . implode(' ', get_comment_class($css_class, $comment, $post)) . '"';
    if ($display) {
        echo $css_class;
    } else {
        return $css_class;
    }
}

WordPress Version: 5.7

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|string[] $class    Optional. One or more classes to add to the class list.
 *                                  Default empty.
 * @param int|WP_Comment  $comment  Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post     $post_id  Post ID or WP_Post object. Default current post.
 * @param bool            $echo     Optional. Whether to echo or return the output.
 *                                  Default true.
 * @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false.
 */
function comment_class($class = '', $comment = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV.
    $class = 'class="' . implode(' ', get_comment_class($class, $comment, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 5.6

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|array   $class    Optional. One or more classes to add to the class list.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post    $post_id  Post ID or WP_Post object. Default current post.
 * @param bool           $echo     Optional. Whether to echo or return the output.
 *                                 Default true.
 * @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false.
 */
function comment_class($class = '', $comment = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV.
    $class = 'class="' . implode(' ', get_comment_class($class, $comment, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 5.4

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|array   $class    Optional. One or more classes to add to the class list.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post    $post_id  Post ID or WP_Post object. Default current post.
 * @param bool           $echo     Optional. Whether to echo or return the output.
 *                                 Default true.
 * @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false.
 */
function comment_class($class = '', $comment = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV.
    $class = 'class="' . join(' ', get_comment_class($class, $comment, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 5.3

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|array   $class    Optional. One or more classes to add to the class list.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post    $post_id  Post ID or WP_Post object. Default current post.
 * @param bool           $echo     Optional. Whether to echo or return the output.
 *                                 Default true.
 * @return string If `$echo` is false, the class will be returned. Void otherwise.
 */
function comment_class($class = '', $comment = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV
    $class = 'class="' . join(' ', get_comment_class($class, $comment, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 4.4

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
 *
 * @param string|array   $class    Optional. One or more classes to add to the class list.
 *                                 Default empty.
 * @param int|WP_Comment $comment  Comment ID or WP_Comment object. Default current comment.
 * @param int|WP_Post    $post_id  Post ID or WP_Post object. Default current post.
 * @param bool           $echo     Optional. Whether to cho or return the output.
 *                                 Default true.
 * @return string If `$echo` is false, the class will be returned. Void otherwise.
 */
function comment_class($class = '', $comment = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV
    $class = 'class="' . join(' ', get_comment_class($class, $comment, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 4.3

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 *
 * @param string|array $class      Optional. One or more classes to add to the class list.
 *                                 Default empty.
 * @param int          $comment_id Comment ID. Default current comment.
 * @param int|WP_Post  $post_id    Post ID or WP_Post object. Default current post.
 * @param bool         $echo       Optional. Whether to cho or return the output.
 *                                 Default true.
 * @return string|void
 */
function comment_class($class = '', $comment_id = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV
    $class = 'class="' . join(' ', get_comment_class($class, $comment_id, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 3.9

/**
 * Generates semantic classes for each comment element.
 *
 * @since 2.7.0
 *
 * @param string|array $class      Optional. One or more classes to add to the class list.
 *                                 Default empty.
 * @param int          $comment_id Comment ID. Default current comment.
 * @param int|WP_Post  $post_id    Post ID or WP_Post object. Default current post.
 * @param bool         $echo       Optional. Whether to cho or return the output.
 *                                 Default true.
 */
function comment_class($class = '', $comment_id = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV
    $class = 'class="' . join(' ', get_comment_class($class, $comment_id, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}

WordPress Version: 3.7

/**
 * Generates semantic classes for each comment element
 *
 * @since 2.7.0
 *
 * @param string|array $class      Optional. One or more classes to add to the class list. Default empty.
 * @param int          $comment_id Optional. Comment ID. Default current comment.
 * @param int|WP_Post  $post_id    Optional. Post ID or WP_Post object. Default current post.
 * @param bool         $echo       Optional. Whether comment_class should echo or return. Default true.
 */
function comment_class($class = '', $comment_id = null, $post_id = null, $echo = true)
{
    // Separates classes with a single space, collates classes for comment DIV
    $class = 'class="' . join(' ', get_comment_class($class, $comment_id, $post_id)) . '"';
    if ($echo) {
        echo $class;
    } else {
        return $class;
    }
}