钩子文档

comment_form_submit_field

💡 云策文档标注

概述

comment_form_submit_field 是一个 WordPress 过滤器,用于修改评论表单的提交字段 HTML 标记。它允许开发者自定义提交按钮、隐藏字段及其包装标记。

关键要点

  • 过滤器名称:comment_form_submit_field
  • 参数:$submit_field(提交字段的 HTML 标记字符串)和 $args(传递给 comment_form() 的参数数组)
  • 作用:过滤评论表单的提交字段,包括提交按钮、隐藏字段和包装标记
  • 相关函数:comment_form(),用于输出评论表单
  • 引入版本:WordPress 4.2.0

注意事项

  • 使用此过滤器时,需确保返回有效的 HTML 字符串以保持表单功能正常
  • 参数 $args 包含 comment_form() 的所有可配置选项,如字段、类、ID 等,可用于自定义输出

📄 原文内容

Filters the submit field for the comment form to display.

Description

The submit field includes the submit button, hidden fields for the comment form, and any wrapper markup.

Parameters

$submit_fieldstring
HTML markup for the submit field.
$argsarray
Arguments passed to comment_form() .
More Arguments from comment_form( … $args )Default arguments and form fields to override.
  • fields array
    Default comment fields, filterable by default via the ‘comment_form_default_fields’ hook.
    • author string
      Comment author field HTML.
    • email string
      Comment author email field HTML.
    • url string
      Comment author URL field HTML.
    • cookies string
      Comment cookie opt-in field HTML.
  • comment_field string
    The comment textarea field HTML.
  • must_log_in string
    HTML element for a ‘must be logged in to comment’ message.
  • logged_in_as string
    The HTML for the ‘logged in as [user]’ message, the Edit profile link, and the Log out link.
  • comment_notes_before string
    HTML element for a message displayed before the comment fields if the user is not logged in.
    Default ‘Your email address will not be published.’.
  • comment_notes_after string
    HTML element for a message displayed after the textarea field.
  • action string
    The comment form element action attribute. Default '/wp-comments-post.php'.
  • novalidate bool
    Whether the novalidate attribute is added to the comment form. Default false.
  • id_form string
    The comment form element id attribute. Default 'commentform'.
  • id_submit string
    The comment submit element id attribute. Default 'submit'.
  • class_container string
    The comment form container class attribute. Default 'comment-respond'.
  • class_form string
    The comment form element class attribute. Default 'comment-form'.
  • class_submit string
    The comment submit element class attribute. Default 'submit'.
  • name_submit string
    The comment submit element name attribute. Default 'submit'.
  • title_reply string
    The translatable 'reply' button label. Default ‘Leave a Reply’.
  • title_reply_to string
    The translatable 'reply-to' button label. Default ‘Leave a Reply to %s’, where %s is the author of the comment being replied to.
  • title_reply_before string
    HTML displayed before the comment form title.
    Default: <h3 id="reply-title" class="comment-reply-title">.
  • title_reply_after string
    HTML displayed after the comment form title.
    Default: <code></h3>.
  • cancel_reply_before string
    HTML displayed before the cancel reply link.
  • cancel_reply_after string
    HTML displayed after the cancel reply link.
  • cancel_reply_link string
    The translatable ‘cancel reply’ button label. Default ‘Cancel reply’.
  • label_submit string
    The translatable 'submit' button label. Default ‘Post a comment’.
  • submit_button string
    HTML format for the Submit button.
    Default: <input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />.
  • submit_field string
    HTML format for the markup surrounding the Submit button and comment hidden fields. Default: <p class="form-submit">%1$s %2$s</p>, where %1$s is the submit button markup and %2$s is the comment hidden fields.
  • format string
    The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.

Source

echo apply_filters( 'comment_form_submit_field', $submit_field, $args );

Changelog

VersionDescription
4.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.