Ticket #15080: 15080.args.2.diff

File 15080.args.2.diff, 4.1 KB (added by jorbin, 3 months ago)
  • wp-includes/comment-template.php

     
    14931493} 
    14941494 
    14951495/** 
     1496 * Builds an input field bassed on arguments of your choosing 
     1497 * 
     1498 * Pass in an array of attributes that the input field should have. 
     1499 * Properties can be passed as well with the value of null 
     1500 * 
     1501 * @param array $args attributes and the values they should have 
     1502 */ 
     1503function input_builder($args) { 
     1504    $input_string = '<input '; 
     1505    foreach( $args as $attr => $val ) { 
     1506        if (NULL === $val ) 
     1507            $input_string .= $attr . " "; 
     1508        else 
     1509            $input_string .= $attr . '="'. $val . '" ';  
     1510    } 
     1511    $input_string .= ' />'; 
     1512    return $input_string; 
     1513} 
     1514 
     1515/** 
    14961516 * Outputs a complete commenting form for use within a template. 
    14971517 * Most strings and form fields may be controlled through the $args array passed 
    14981518 * into the function, while you may also choose to use the comment_form_default_fields 
    (this hunk was shorter than expected) 
    15201540 
    15211541        $req = get_option( 'require_name_email' ); 
    15221542        $aria_req = ( $req ? " aria-required='true'" : '' ); 
     1543    $author_input_attr = array( 
     1544        'id' => 'author', 
     1545        'name' => 'author', 
     1546        'type' => 'text', 
     1547        'value' =>  esc_attr( $commenter['comment_author'] ), 
     1548        'size' => '30', 
     1549        'aria-required' => ( $req) ? 'true' : 'false', 
     1550    ); 
     1551    $email_input_attr = array( 
     1552        'id' => 'email', 
     1553        'name' => 'eamil', 
     1554        'type' => 'text', 
     1555        'value' =>  esc_attr( $commenter['comment_author_email'] ), 
     1556        'size' => '30', 
     1557        'aria-required' => ( $req) ? 'true' : 'false', 
     1558    ); 
     1559    $url_input_attr = array( 
     1560        'id' => 'url', 
     1561        'name' => 'url', 
     1562        'type' => 'text', 
     1563        'value' => esc_attr( $commenter['comment_author_url'] ), 
     1564        'size' => '30' 
     1565    ); 
     1566    if (isset($args['html5']) && $args['html5'] == true){ 
     1567        $email_input_attr['type'] = 'email'; 
     1568        $email_input_attr['pattern'] = ''; 
     1569        $url_input_attr['type'] = 'url'; 
     1570        $url_input_attr['pattern'] = ''; 
     1571        if ($req){ 
     1572            $author_input_attr['required'] = null; 
     1573            $email_input_attr['required'] = null; 
     1574        } 
     1575 
     1576    } 
     1577 
    15231578        $fields =  array( 
    15241579                'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . 
    1525                             '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', 
     1580                                        input_builder($author_input_attr) . '</p>', 
    15261581                'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . 
    1527                             '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', 
     1582                                        input_builder($email_input_attr) . '</p>', 
    15281583                'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' . 
    1529                             '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', 
     1584                                        input_builder($url_input_attr) . '</p>', 
    15301585        ); 
    15311586 
    15321587        $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); 
     
    15561612                                        <?php echo $args['must_log_in']; ?> 
    15571613                                        <?php do_action( 'comment_form_must_log_in_after' ); ?> 
    15581614                                <?php else : ?> 
    1559                                         <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>"> 
     1615                                        <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" <?php echo (isset($args['html5']) && $args['html5'] == true) ? 'novalidate' : ''; ?>  > 
    15601616                                                <?php do_action( 'comment_form_top' ); ?> 
    15611617                                                <?php if ( is_user_logged_in() ) : ?> 
    15621618                                                        <?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>