wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



comment_class › WordPress Function

Od2.7.0
Przestarzałyn/a
comment_class ( $css_class = '', $comment = null, $post = null, $display = true )
Parametry: (4)
  • (string|string[]) $css_class Optional. One or more classes to add to the class list. Default empty.
    Wymagane: Nie
    Domyślny: (puste)
  • (int|WP_Comment) $comment Optional. Comment ID or WP_Comment object. Default current comment.
    Wymagane: Nie
    Domyślny: null
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default current post.
    Wymagane: Nie
    Domyślny: null
  • (bool) $display Optional. Whether to print or return the output. Default true.
    Wymagane: Nie
    Domyślny: true
Powrót:
  • (void|string) Void if `$display` argument is true, comment classes if `$display` is false.
Zdefiniowane na:
Codex:
Dziennik zmian:
  • 4.4.0

Generates semantic classes for each comment element.



Źródło

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