comment_class()
comment_class( string|array $class = ”, int|WP_Comment …
comment_class( string|array $class = ”, int|WP_Comment $comment = null, int|WP_Post $post_id = null, bool $echo = true )
为每个注释元素生成语义类。
Generates semantic classes for each comment element.
为每个注释元素生成语义类。
Generates semantic classes for each comment element.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $class | (string | array) | 可选 | 要添加到类列表中的一个或多个类。 |
| $comment | (int | WP_Comment) | 可选 | 注释ID或WP_Comment对象。默认当前注释。 |
| $post_id | (int | WP_Post) | 可选 | Post ID或WP_Post对象。默认当前职位。 |
| $echo | (bool) | 可选 | 是回显还是返回输出。 |
返回(Return)
(void|string)void如果$echo参数为true,注释类如果$echo为false。
源码(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;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 4.4.0 | wp-includes/comment-template.php:432 | 4 | 1 function |
笔记(Notes)
例子
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!