Ticket #15080: 15080.args.2.diff
File 15080.args.2.diff, 4.1 KB (added by , 12 years ago) |
---|
-
wp-includes/comment-template.php
1493 1493 } 1494 1494 1495 1495 /** 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 */ 1503 function 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 /** 1496 1516 * Outputs a complete commenting form for use within a template. 1497 1517 * Most strings and form fields may be controlled through the $args array passed 1498 1518 * into the function, while you may also choose to use the comment_form_default_fields … … (this hunk was shorter than expected) 1520 1540 1521 1541 $req = get_option( 'require_name_email' ); 1522 1542 $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 1523 1578 $fields = array( 1524 1579 '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>', 1526 1581 '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>', 1528 1583 '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>', 1530 1585 ); 1531 1586 1532 1587 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); … … 1556 1612 <?php echo $args['must_log_in']; ?> 1557 1613 <?php do_action( 'comment_form_must_log_in_after' ); ?> 1558 1614 <?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' : ''; ?> > 1560 1616 <?php do_action( 'comment_form_top' ); ?> 1561 1617 <?php if ( is_user_logged_in() ) : ?> 1562 1618 <?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>