为每个注释元素生成语义类。
原型
comment_class( string|array $class = '', int|WP_Comment $comment = null, int|WP_Post $post_id = null, bool $echo = true )
参数
$class
(string|array)
(Optional)
要添加到类列表的一个或多个类。
$comment
(int|WP_Comment)
(Optional)
注释ID或WP_Comment对象。默认当前评论。
$post_id
(int|WP_Post)
(Optional)
发布ID或WP_Post对象。默认当前帖子。
$echo
(bool)
(Optional)
是选择还是返回输出。
返回值
(string)
如果
源文件
路径:wp-includes/comment-template.php
<?php
...
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;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/comment_class/