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;
}
}