Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



comment_class ›

Seit2.7.0
Veraltetn/v
comment_class ( $class = '', $comment = null, $post_id = null, $echo = true )
Parameter: (4)
  • (string|array) $class Optional. One or more classes to add to the class list. Default empty.
    Erforderlich: Nein
    Standard: (leer)
  • (int|WP_Comment) $comment Comment ID or WP_Comment object. Default current comment.
    Erforderlich: Nein
    Standard: null
  • (int|WP_Post) $post_id Post ID or WP_Post object. Default current post.
    Erforderlich: Nein
    Standard: null
  • (bool) $echo Optional. Whether to cho or return the output. Default true.
    Erforderlich: Nein
    Standard: true
Gibt zurück:
  • (string) If `$echo` is false, the class will be returned. Void otherwise.
Definiert in:
Codex:
Changelog:
  • 4.4.0

Generates semantic classes for each comment element.



Quellcode

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