comment_class()

最后更新于:2021-11-25 21:07:07

comment_class( string|string[]$class=”, int|GC_Comment$comment=null, int|GC_Post$post_id=null, bool$echo=true)

Generates semantic classes for each comment element.

参数

$class

(string|string[]) (Optional) One or more classes to add to the class list.

Default value: ”

$comment

(int|GC_Comment) (Optional) Comment ID or GC_Comment object. Default current comment.

Default value: null

$post_id

(int|GC_Post) (Optional) Post ID or GC_Post object. Default current post.

Default value: null

$echo

(bool) (Optional) Whether to echo or return the output.

Default value: true

响应

(void|string) Void if $echo argument is true, comment classes if $echo is false.

源文件

文件: gc-includes/comment-template.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="' . implode( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';

	if ( $echo ) {
		echo $class;
	} else {
		return $class;
	}
}