Make WordPress Core

Ticket #16206: 16206.6.patch

File 16206.6.patch, 3.4 KB (added by sabernhardt, 4 years ago)
  • src/wp-includes/comment-template.php

     
    23502350                $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
    23512351        }
    23522352
    2353         $req      = get_option( 'require_name_email' );
    2354         $html_req = ( $req ? " required='required'" : '' );
    2355         $html5    = 'html5' === $args['format'];
     2353        $req   = get_option( 'require_name_email' );
     2354        $html5 = 'html5' === $args['format'];
    23562355
     2356        // Glyph to identify required fields visually.
     2357        $required_glyph = ( $req ? '<span class="required" aria-hidden="true">*</span>' : '' );
     2358
     2359        // HTML required attribute.
     2360        $html_req = '';
     2361        if ( $req && $html5 ) {
     2362                $html_req = ' required';
     2363        } elseif ( $req ) {
     2364                // XHTML syntax
     2365                $html_req = ' required="required"';
     2366        }
     2367
    23572368        $fields = array(
    23582369                'author' => sprintf(
    23592370                        '<p class="comment-form-author">%s %s</p>',
    23602371                        sprintf(
    2361                                 '<label for="author">%s%s</label>',
     2372                                '<label for="author">%s %s</label>',
    23622373                                __( 'Name' ),
    2363                                 ( $req ? ' <span class="required">*</span>' : '' )
     2374                                $required_glyph
    23642375                        ),
    23652376                        sprintf(
    23662377                                '<input id="author" name="author" type="text" value="%s" size="30" maxlength="245"%s />',
     
    23712382                'email'  => sprintf(
    23722383                        '<p class="comment-form-email">%s %s</p>',
    23732384                        sprintf(
    2374                                 '<label for="email">%s%s</label>',
     2385                                '<label for="email">%s %s</label>',
    23752386                                __( 'Email' ),
    2376                                 ( $req ? ' <span class="required">*</span>' : '' )
     2387                                $required_glyph
    23772388                        ),
    23782389                        sprintf(
    23792390                                '<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes"%s />',
     
    24192430
    24202431        $required_text = sprintf(
    24212432                /* translators: %s: Asterisk symbol (*). */
    2422                 ' ' . __( 'Required fields are marked %s' ),
    2423                 '<span class="required">*</span>'
     2433                ' <span class="comment-required-message" aria-hidden="true">' . __( 'Required fields are marked %s' ) . '</span>',
     2434                $required_glyph
    24242435        );
    24252436
    24262437        /**
     
    24372448                'comment_field'        => sprintf(
    24382449                        '<p class="comment-form-comment">%s %s</p>',
    24392450                        sprintf(
    2440                                 '<label for="comment">%s</label>',
    2441                                 _x( 'Comment', 'noun' )
     2451                                '<label for="comment">%s %s</label>',
     2452                                _x( 'Comment', 'noun' ),
     2453                                $required_glyph
    24422454                        ),
    2443                         '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>'
     2455                        '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525"' . $html_req . '></textarea>'
    24442456                ),
    24452457                'must_log_in'          => sprintf(
    24462458                        '<p class="must-log-in">%s</p>',
  • src/wp-includes/comment.php

     
    35293529
    35303530        if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
    35313531                if ( '' == $comment_author_email || '' == $comment_author ) {
    3532                         return new WP_Error( 'require_name_email', __( '<strong>Error</strong>: Please fill the required fields (name, email).' ), 200 );
     3532                        return new WP_Error( 'require_name_email', __( '<strong>Error</strong>: Please fill the required fields.' ), 200 );
    35333533                } elseif ( ! is_email( $comment_author_email ) ) {
    35343534                        return new WP_Error( 'require_valid_email', __( '<strong>Error</strong>: Please enter a valid email address.' ), 200 );
    35353535                }