comment_class

函式
comment_class ( $css_class = '', $comment = null, $post = null, $display = true )
引數
  • (string|string[]) $css_class Optional. One or more classes to add to the class list. Default empty.
    Required:
    Default: (empty)
  • (int|WP_Comment) $comment Comment ID or WP_Comment object. Default current comment.
    Required:
    Default: null
  • (int|WP_Post) $post Post ID or WP_Post object. Default current post.
    Required:
    Default: null
  • (bool) $display Optional. Whether to print or return the output. Default true.
    Required:
    Default: true
返回值
  • (void|string) Void if `$display` argument is true, comment classes if `$display` is false.
定義位置
相關方法
get_comment_classcomments_rsscomment_existscomment_linkcomment_date
引入
2.7.0
棄用
-

comment_class: 這個函式生成一串用於顯示評論的HTML元素的類。這些類別是基於評論的狀態(批准、待定、垃圾郵件等)以及評論是否是對另一個評論的回覆。

為每個評論元素生成語義類別。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
}
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; } }
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;
	}
}

常見問題

FAQs
檢視更多 >