comment_class
apply_filters( ‘comment_class’, string[] $classes, stri…
apply_filters( ‘comment_class’, string[] $classes, string $class, int $comment_id, WP_Comment $comment, int|WP_Post $post_id )
过滤器::为当前注释过滤返回的CSS类。
Filter Hook: Filters the returned CSS classes for the current comment.
目录锚点:#参数#源码
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $classes | (string[]) | 注释类的数组。 |
| $class | (string) | 添加到列表中的其他类的逗号分隔列表。 |
| $comment_id | (int) | 评论id。 |
| $comment | (WP_Comment) | 注释对象。 |
| $post_id | (int | WP_Post) | post ID或WP_post对象。 |
源码(Source)
/**
* Generates semantic classes for each comment element.
*
* @since 2.7.0
*
* @param string|array $class Optional. One or more classes to add to the class list.
* Default empty.
* @param int $comment_id Comment ID. Default current comment.
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
* @param bool $echo Optional. Whether to cho or return the output.
* Default true.
* @return string|void
*/
function comment_class( $class = '', $comment_id = 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_id, $post_id ) ) . '"';
if ( $echo)
echo $class;
else
return $class;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.7.0 | wp-includes/comment-template.php:537 | 1 | 0 |
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!