WordPress.org

Make WordPress Core

Ticket #47595: 47595-use-html5-exclusively-and-remove-novalidate.0.diff

File 47595-use-html5-exclusively-and-remove-novalidate.0.diff, 5.0 KB (added by westonruter, 19 months ago)

Option 3: Eliminate format argument entirely in favor of using HTML5 only, while also removing novalidate form attribute since browsers should be consistent

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

    diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php
    index ca0a8de714..cc1584623e 100644
    a b function comment_form_title( $noreplytext = false, $replytext = false, $linktopa 
    19771977 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
    19781978 *     @type bool   $reverse_top_level Ordering of the listed comments. If true, will display newest comments first.
    19791979 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
    1980  *     @type string $format            How to format the comments list.
    1981  *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
    19821980 *     @type bool   $short_ping        Whether to output short pings. Default false.
    19831981 *     @type bool   $echo              Whether to echo the output or return it. Default true.
    19841982 * }
    function wp_list_comments( $args = array(), $comments = null ) { 
    20042002                'avatar_size'       => 32,
    20052003                'reverse_top_level' => null,
    20062004                'reverse_children'  => '',
    2007                 'format'            => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
    20082005                'short_ping'        => false,
    20092006                'echo'              => true,
    20102007        );
    function wp_list_comments( $args = array(), $comments = null ) { 
    21942191 *              and 200 characters, respectively.
    21952192 * @since 4.6.0 Introduced the 'action' argument.
    21962193 * @since 4.9.6 Introduced the 'cookies' default comment field.
     2194 * @since 5.3.0 Removed the 'format' argument as HTML5 is now standard. Also removed novalidate form attribute since
     2195 *              browsers are now consistent in how they validate.
    21972196 *
    21982197 * @param array       $args {
    21992198 *     Optional. Default arguments and form fields to override.
    function wp_list_comments( $args = array(), $comments = null ) { 
    22352234 *     @type string $submit_field         HTML format for the markup surrounding the Submit button and comment hidden
    22362235 *                                        fields. Default: '<p class="form-submit">%1$s %2$s</p>', where %1$s is the
    22372236 *                                        submit button markup and %2$s is the comment hidden fields.
    2238  *     @type string $format               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
    22392237 * }
    22402238 * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
    22412239 */
    function comment_form( $args = array(), $post_id = null ) { 
    22612259        $user_identity = $user->exists() ? $user->display_name : '';
    22622260
    22632261        $args = wp_parse_args( $args );
    2264         if ( ! isset( $args['format'] ) ) {
    2265                 $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
    2266         }
    22672262
    22682263        $req      = get_option( 'require_name_email' );
    22692264        $html_req = ( $req ? " required='required'" : '' );
    2270         $html5    = 'html5' === $args['format'];
    22712265        $fields   = array(
    22722266                'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
    22732267                                         '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>',
    22742268                'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
    2275                                          '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>',
     2269                                         '<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>',
    22762270                'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
    2277                                          '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
     2271                                         '<input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
    22782272        );
    22792273
    22802274        if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) {
    function comment_form( $args = array(), $post_id = null ) { 
    23832377                        do_action( 'comment_form_must_log_in_after' );
    23842378                else :
    23852379                        ?>
    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' : ''; ?>>
     2380                        <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'] ); ?>">
    23872381                                <?php
    23882382                                /**
    23892383                                 * Fires at the top of the comment form, inside the form tag.