wpseek.com
A WordPress-centric search engine for devs and theme authors



comment_class › WordPress Function

Since2.7.0
Deprecatedn/a
comment_class ( $css_class = '', $comment = null, $post = null, $display = true )
Parameters: (4)
  • (string|string[]) $css_class Optional. One or more classes to add to the class list. Default empty.
    Required: No
    Default: (empty)
  • (int|WP_Comment) $comment Optional. Comment ID or WP_Comment object. Default current comment.
    Required: No
    Default: null
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default current post.
    Required: No
    Default: null
  • (bool) $display Optional. Whether to print or return the output. Default true.
    Required: No
    Default: true
Returns:
  • (void|string) Void if `$display` argument is true, comment classes if `$display` is false.
Defined at:
Codex:
Change Log:
  • 4.4.0

Generates semantic classes for each comment element.



Source

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