comment_class

Filters the returned CSS classes for the current comment.

Description

apply_filters( 'comment_class', (array) $classes, (string) $class, (int) $comment_comment_id, (WP_Comment) $comment, (int|WP_Post) $post_id ); 

Parameters (5)

0. $classes (array)
An array of comment classes.
1. $class (string)
A comma-separated list of additional classes added to the list.
2. $comment_comment_id (int)
The comment comment id.
3. $comment (WP_Comment)
The comment object.
4. $post_id (int|WP_Post)
The post ID or WP_Post object.

Usage

To run the hook, copy the example below.
  1. $classes = apply_filters( 'comment_class', $classes, $class, $comment_comment_id, $comment, $post_id ); 
  2.  
  3. if ( !empty( $classes ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the comment_class callback 
  2. function filter_comment_class( $classes, $class, $comment_comment_id, $comment, $post_id ) { 
  3. // make filter magic happen here... 
  4. return $classes
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'comment_class', 'filter_comment_class', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'comment_class', 'filter_comment_class', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/comment-template.php  
  1. return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id );