钩子文档

manage_comments_nav

💡 云策文档标注

概述

manage_comments_nav 是一个 WordPress 动作钩子,在评论类型筛选提交按钮后触发,用于在评论管理页面添加自定义导航元素。

关键要点

  • 触发时机:在评论管理页面的筛选提交按钮后执行,允许开发者插入额外内容。
  • 参数:$comment_status(评论状态,默认 'All')和 $which(位置,'top' 或 'bottom'),用于控制输出位置和状态。
  • 用途:常用于扩展 WP_Comments_List_Table 类的导航功能,例如添加自定义筛选或操作按钮。

代码示例

add_action( 'manage_comments_nav', 'custom_comments_nav', 10, 2 );
function custom_comments_nav( $comment_status, $which ) {
    if ( 'top' === $which ) {
        echo '<div>自定义导航内容</div>';
    }
}

注意事项

  • 参数 $which 从 WordPress 5.6.0 版本开始添加,用于区分顶部或底部导航位置。
  • 此钩子自 WordPress 2.5.0 版本引入,确保兼容性时需检查版本。

📄 原文内容

Fires after the Filter submit button for comment types.

Parameters

$comment_statusstring
The comment status name. Default 'All'.
$whichstring
The location of the extra table nav markup: Either 'top' or 'bottom'.

Source

do_action( 'manage_comments_nav', $comment_status, $which );

Changelog

Version Description
5.6.0 The $which parameter was added.
2.5.0 Introduced.