comment_class

Advertisement

Summery Summery

Generates semantic classes for each comment element.

Syntax Syntax

comment_class( string|array $class = '', int|WP_Comment $comment = null, int|WP_Post $post_id = null, bool $echo = true )

Parameters Parameters

$class

(Optional) One or more classes to add to the class list.

Default value: ''

$comment

(Optional) Comment ID or WP_Comment object. Default current comment.

Default value: null

$post_id

(Optional) Post ID or WP_Post object. Default current post.

Default value: null

$echo

(Optional) Whether to echo or return the output.

Default value: true

Return Return

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

Source Source

File: wp-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="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';

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

Advertisement

Changelog Changelog

Changelog
Version Description
4.4.0 Added the ability for $comment to also accept a WP_Comment object.
2.7.0 Introduced.

Advertisement

Leave a Reply