get_commentdata()
云策文档标注
概述
get_commentdata() 函数用于根据评论 ID 检索评论数据数组,但自 WordPress 2.7.0 起已被弃用,建议改用 get_comment() 函数。
关键要点
- 函数已弃用:自 WordPress 2.7.0 版本起,get_commentdata() 被标记为弃用,推荐使用 get_comment() 替代。
- 参数说明:接受 $comment_id(评论 ID,必需)、$no_cache(是否使用缓存,必需,转换为布尔值)和 $include_unapproved(是否包含未批准评论,可选,默认 false)。
- 返回值:返回评论数据数组。
- 内部实现:函数内部调用 get_comment($comment_id, ARRAY_A) 并触发 _deprecated_function() 警告。
注意事项
- 在开发中应避免使用此函数,转而使用 get_comment() 以确保代码兼容性和最佳实践。
- 函数弃用信息可通过 _deprecated_function() 在 wp-includes/functions.php 中查看。
原文内容
Retrieve an array of comment data about comment $comment_id.
Description
See also
Parameters
$comment_idintrequired-
The ID of the comment
$no_cacheintrequired-
Whether to use the cache (cast to bool)
$include_unapprovedbooloptional-
Whether to include unapproved comments
Default:
false
Source
function get_commentdata( $comment_id, $no_cache = 0, $include_unapproved = false ) {
_deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' );
return get_comment($comment_id, ARRAY_A);
}
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Deprecated. Use get_comment() |
| 0.71 | Introduced. |