钩子文档

comment_reply_link_args

💡 云策文档标注

概述

comment_reply_link_args 是一个 WordPress 过滤器,用于修改评论回复链接的参数。它允许开发者自定义回复链接的行为和外观,例如文本、深度和 HTML 结构。

关键要点

  • 过滤器名称:comment_reply_link_args,用于过滤评论回复链接的参数数组。
  • 参数:接受 $args(参数数组)、$comment(WP_Comment 对象)和 $post(WP_Post 对象)作为参数。
  • 用途:覆盖默认参数,如回复文本、深度限制、前后 HTML 等,以定制评论回复功能。

代码示例

$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );

注意事项

  • 参数 $args 包含多个选项,如 add_below、reply_text、max_depth 等,需参考 get_comment_reply_link() 函数文档。
  • 使用时应确保参数值符合 WordPress 核心规范,避免破坏评论功能。

📄 原文内容

Filters the comment reply link arguments.

Parameters

$argsarray
Comment reply link arguments. See get_comment_reply_link() for more information on accepted arguments.

More Arguments from get_comment_reply_link( … $args )

Override default arguments.

  • add_below string
    The first part of the selector used to identify the comment to respond below.
    The resulting value is passed as the first parameter to addComment.moveForm(), concatenated as $add_below-$comment->comment_ID. Default 'comment'.
  • respond_id string
    The selector identifying the responding comment. Passed as the third parameter to addComment.moveForm(), and appended to the link URL as a hash value.
    Default 'respond'.
  • reply_text string
    The visible text of the Reply link. Default 'Reply'.
  • reply_to_text string
    The accessible name of the Reply link, using %s as a placeholder for the comment author’s name. Default ‘Reply to %s’.
    Should start with the visible reply_text value.
  • show_reply_to_text bool
    Whether to use reply_to_text as visible link text. Default false.
  • login_text string
    The text of the link to reply if logged out. Default ‘Log in to Reply’.
  • max_depth int
    The max depth of the comment tree. Default 0.
  • depth int
    The depth of the new comment. Must be greater than 0 and less than the value of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
  • before string
    The text or HTML to add before the reply link.
  • after string
    The text or HTML to add after the reply link.

$commentWP_Comment
The object of the comment being replied to.
$postWP_Post
The WP_Post object.

Source

$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );

Changelog

Version Description
4.1.0 Introduced.