comment_class
Filter HookDescription
Filters the returned CSS classes for the current comment.Hook Information
File Location |
wp-includes/comment-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 599 |
Hook Parameters
Type | Name | Description |
---|---|---|
string[]
|
$classes
|
An array of comment classes. |
string[]
|
$css_class
|
An array of additional classes added to the list. |
string
|
$comment_id
|
The comment ID as a numeric string. |
WP_Comment
|
$comment
|
The comment object. |
int|WP_Post
|
$post
|
The post ID or WP_Post object. |
Usage Examples
Basic Usage
<?php
// Hook into comment_class
add_filter('comment_class', 'my_custom_filter', 10, 5);
function my_custom_filter($classes, $css_class, $comment_id, $comment, $post) {
// Your custom filtering logic here
return $classes;
}
Source Code Context
wp-includes/comment-template.php:599
- How this hook is used in WordPress core
<?php
594 * @param string[] $css_class An array of additional classes added to the list.
595 * @param string $comment_id The comment ID as a numeric string.
596 * @param WP_Comment $comment The comment object.
597 * @param int|WP_Post $post The post ID or WP_Post object.
598 */
599 return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post );
600 }
601
602 /**
603 * Retrieves the comment date of the current comment.
604 *
PHP Documentation
<?php
/**
* Filters the returned CSS classes for the current comment.
*
* @since 2.7.0
*
* @param string[] $classes An array of comment classes.
* @param string[] $css_class An array of additional classes added to the list.
* @param string $comment_id The comment ID as a numeric string.
* @param WP_Comment $comment The comment object.
* @param int|WP_Post $post The post ID or WP_Post object.
*/
Quick Info
- Hook Type: Filter
- Parameters: 5
- File: wp-includes/comment-template.php
Related Hooks
Related hooks will be displayed here in future updates.