WordPress.org

Make WordPress Core

Ticket #47595: 47595-novalidate_form-argument.0.diff

File 47595-novalidate_form-argument.0.diff, 2.7 KB (added by westonruter, 19 months ago)

Option 1: Add a novalidate_form argument to allow the novalidate attribute to be omitted

  • src/wp-includes/comment-template.php

    diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php
    index ca0a8de714..d95c21bf4d 100644
    a b function wp_list_comments( $args = array(), $comments = null ) { 
    21942194 *              and 200 characters, respectively.
    21952195 * @since 4.6.0 Introduced the 'action' argument.
    21962196 * @since 4.9.6 Introduced the 'cookies' default comment field.
     2197 * @since 5.3.0 Introduced the 'novalidate_form' argument.
    21972198 *
    21982199 * @param array       $args {
    21992200 *     Optional. Default arguments and form fields to override.
    function wp_list_comments( $args = array(), $comments = null ) { 
    22142215 *                                        Default 'Your email address will not be published.'.
    22152216 *     @type string $comment_notes_after  HTML element for a message displayed after the textarea field.
    22162217 *     @type string $action               The comment form element action attribute. Default '/wp-comments-post.php'.
     2218 *     @type bool   $novalidate_form      Whether the novalidate attribute is added to the comment from when the format is html5. Default true.
    22172219 *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
    22182220 *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
    22192221 *     @type string $class_form           The comment form element class attribute. Default 'comment-form'.
    function comment_form( $args = array(), $post_id = null ) { 
    23202322                'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>' . ( $req ? $required_text : '' ) . '</p>',
    23212323                'comment_notes_after'  => '',
    23222324                'action'               => site_url( '/wp-comments-post.php' ),
     2325                'novalidate_form'      => 'html5' === $args['format'],
    23232326                'id_form'              => 'commentform',
    23242327                'id_submit'            => 'submit',
    23252328                'class_form'           => 'comment-form',
    function comment_form( $args = array(), $post_id = null ) { 
    23832386                        do_action( 'comment_form_must_log_in_after' );
    23842387                else :
    23852388                        ?>
    2386                         <form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>>
     2389                        <form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 && ! empty( $args['novalidate_form'] ) ? ' novalidate' : ''; ?>>
    23872390                                <?php
    23882391                                /**
    23892392                                 * Fires at the top of the comment form, inside the form tag.