钩子文档

comment_row_actions

💡 云策文档标注

概述

comment_row_actions 是一个 WordPress 过滤器,用于修改评论列表表格中每个评论显示的操作链接。它允许开发者自定义或移除默认操作,如“批准”、“编辑”或“垃圾”。

关键要点

  • 过滤器名称:comment_row_actions
  • 参数:$actions(操作链接数组)和 $comment(评论对象)
  • 默认操作包括:Approve、Unapprove、Edit、Reply、Spam、Delete、Trash
  • 应用场景:在 WP_Comments_List_Table 和 _wp_dashboard_recent_comments_row 中使用
  • 引入版本:WordPress 2.6.0

代码示例

/**
 * Get rid of a link
 */
function modify_comments_list_row_actions( $actions, $comment ) {
	unset($actions['reply']);
	return $actions;
}
add_filter( 'comment_row_actions', 'modify_comments_list_row_actions', 100, 2 );

📄 原文内容

Filters the action links displayed for each comment in the Comments list table.

Parameters

$actionsstring[]
An array of comment actions. Default actions include: 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam', 'Delete', and 'Trash'.
$commentWP_Comment
The comment object.

Source

$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );

Changelog

Version Description
2.6.0 Introduced.

User Contributed Notes