钩子文档

get_comment_excerpt

💡 云策文档标注

概述

get_comment_excerpt 是一个 WordPress 过滤器钩子,用于修改检索到的评论摘要文本。它允许开发者在获取评论摘要时进行自定义处理。

关键要点

  • 过滤器名称:get_comment_excerpt
  • 参数:$comment_excerpt(评论摘要文本)、$comment_id(评论ID字符串)、$comment(WP_Comment对象)
  • 用途:过滤评论摘要,支持自定义修改或扩展功能
  • 版本历史:从 WordPress 1.5.0 引入,4.1.0 版本添加了 $comment_id 和 $comment 参数

代码示例

return apply_filters( 'get_comment_excerpt', $comment_excerpt, $comment->comment_ID, $comment );

📄 原文内容

Filters the retrieved comment excerpt.

Parameters

$comment_excerptstring
The comment excerpt text.
$comment_idstring
The comment ID as a numeric string.
$commentWP_Comment
The comment object.

Source

return apply_filters( 'get_comment_excerpt', $comment_excerpt, $comment->comment_ID, $comment );

Changelog

Version Description
4.1.0 The $comment_id and $comment parameters were added.
1.5.0 Introduced.