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.
- $classes = apply_filters( 'comment_class', $classes, $class, $comment_comment_id, $comment, $post_id );
- if ( !empty( $classes ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the comment_class callback
- function filter_comment_class( $classes, $class, $comment_comment_id, $comment, $post_id ) {
- // make filter magic happen here...
- return $classes;
- };
- // add the filter
- add_filter( 'comment_class', 'filter_comment_class', 10, 5 );
- To remove a hook callback, use the example below.
- // remove the filter
- 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
- return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id );