wp-includes/comment-template.php:2494$args array passed into the function, while you may also choose to use the 'comment_form_default_fields' filter to modify the array of default fields if you'd just like to add a new one or remove a single field. All fields are also individually passed through a filter of the 'comment_form<em>field</em>$name' where $name is the key used in the array of fields.$argsarrayoptionalarray()$fieldsarray
$authorstring
$emailstring
$urlstring
$cookiesstring
$must_log_instring
$logged_in_asstring
$comment_notes_beforestringdefault: 'Your email address will not be published.'
$comment_notes_afterstring
$actionstringdefault: '/wp-comments-post.php'
$novalidatebooldefault: false
$id_formstringdefault: 'commentform'
$id_submitstringdefault: 'submit'
$class_containerstringdefault: 'comment-respond'
$class_formstringdefault: 'comment-form'
$class_submitstringdefault: 'submit'
$name_submitstringdefault: 'submit'
$title_replystringdefault: 'Leave a Reply'
$title_reply_tostringdefault: 'Leave a Reply to %s', where %s is the author of the comment being replied to
$title_reply_beforestringdefault: ''
$title_reply_afterstringdefault: ''
$cancel_reply_beforestring
$cancel_reply_afterstring
$cancel_reply_linkstringdefault: 'Cancel reply'
$label_submitstringdefault: 'Post a comment'
$submit_buttonstringdefault: ''
$submit_fieldstring
$formatstringdefault: 'xhtml'. Accepts 'xhtml', 'html5'
$postint|WP_Postoptionalnull19 hooks fire while comment_form() runs, in this order:
Fires after the comment form if comments are closed.
Filters the default comment form fields.
Filters the display of the permalink for the current post.
Filters the display of the permalink for the current post.
Filters the comment form default arguments.
Fires after the HTML-formatted 'must log in after' message in the comment form.
Fires at the top of the comment form, inside the form tag.
Filters the 'logged in' message for the comment form for display.
Fires after the is_user_logged_in() check in the comment form.
Filters the comment form fields, including the textarea.
Filters the content of the comment textarea field for display.
Fires before the comment fields in the comment form, excluding the textarea.
Filters a comment form field for display.
Fires after the comment fields in the comment form, excluding the textarea.
Filters the submit button for the comment form to display.
Filters the submit field for the comment form to display.
Fires at the bottom of the comment form, inside the closing form tag.
function comment_form( $args = array(), $post = null ) { $post = get_post( $post ); // Exit the function if the post is invalid or comments are closed. if ( ! $post || ! comments_open( $post ) ) { /** * Fires after the comment form if comments are closed. * * For backward compatibility, this action also fires if comment_form() * is called with an invalid post object or ID. * * @since 3.0.0 */ do_action( 'comment_form_comments_closed' ); return; } $post_id = $post->ID; $commenter = wp_get_current_commenter(); $user = wp_get_current_user(); $user_identity = $user->exists() ? $user->display_name : ''; $args = wp_parse_args( $args ); if ( ! isset( $args['format'] ) ) { $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; } $req = get_option( 'require_name_email' ); $html5 = 'html5' === $args['format']; // Define attributes in HTML5 or XHTML syntax. $required_attribute = ( $html5 ? ' required' : ' required="required"' ); $checked_attribute = ( $html5 ? ' checked' : ' checked="checked"' ); // Identify required fields visually and create a message about the indicator. $required_indicator = ' ' . wp_required_field_indicator(); $required_text = ' ' . wp_required_field_message(); $fields = array( 'author' => sprintf( '<p class="comment-form-author">%s %s</p>', sprintf( '<label for="author">%s%s</label>', __( 'Name' ), ( $req ? $required_indicator : '' ) ), sprintf( '<input id="author" name="author" type="text" value="%s" size="30" maxlength="245" autocomplete="name"%s />', esc_attr( $commenter['comment_author'] ), ( $req ? $required_attribute : '' ) ) ), 'email' => sprintf( '<p class="comment-form-email">%s %s</p>', sprintf( '<label for="email">%s%s</label>', __( 'Email' ), ( $req ? $required_indicator : '' ) ), sprintf( '<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes" autocomplete="email"%s />', ( $html5 ? 'type="email"' : 'type="text"' ), esc_attr( $commenter['comment_author_email'] ), ( $req ? $required_attribute : '' ) ) ), 'url' => sprintf( '<p class="comment-form-url">%s %s</p>', sprintf( '<label for="url">%s</label>', __( 'Website' ) ), sprintf( '<input id="url" name="url" %s value="%s" size="30" maxlength="200" autocomplete="url" />', ( $html5 ? 'type="url"' : 'type="text"' ), esc_attr( $commenter['comment_author_url'] ) ) ), );Introduced in 6.8.2. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/comment-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.