Ticket #15080: 15080.3.diff
File 15080.3.diff, 3.5 KB (added by , 12 years ago) |
---|
-
wp-includes/comment-template.php
1491 1491 1492 1492 $in_comment_loop = false; 1493 1493 } 1494 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 to omit 1500 * an optional value as per HTML5 syntax 1501 * 1502 * @param array $args attributes and the values they should have 1503 */ 1504 function input_builder( $args ) { 1505 $defaults = array( 1506 'type' => 'text', 1507 ); 1508 $args = wp_parse_args( $args, $defaults ); 1509 $input_string = '<input '; 1494 1510 1511 foreach( $args as $attr => $val ) { 1512 if ( is_null( $val ) ) 1513 $input_string .= esc_attr( $attr ) . ' '; 1514 else 1515 $input_string .= esc_attr( $attr ) . '="'. esc_attr( $val ) . '" '; 1516 } 1517 1518 $input_string .= '/>'; 1519 return $input_string; 1520 } 1521 1522 1495 1523 /** 1496 1524 * Outputs a complete commenting form for use within a template. 1497 1525 * Most strings and form fields may be controlled through the $args array passed … … 1520 1548 1521 1549 $req = get_option( 'require_name_email' ); 1522 1550 $aria_req = ( $req ? " aria-required='true'" : '' ); 1551 1552 $html5 = isset( $args['html5'] ) && $args['html5']; 1553 1554 $author_input_attr = array( 1555 'id' => 'author', 1556 'name' => 'author', 1557 'type' => 'text', 1558 'value' => esc_attr( $commenter['comment_author'] ), 1559 'size' => '30', 1560 'aria-required' => ( $req ) ? 'true' : 'false', 1561 ); 1562 if ( $html5 ) { 1563 $author_input_attr['placeholder'] = __( 'Your Name' ); 1564 if( $req ) 1565 $author_input_attr['required'] = null; 1566 } 1567 1568 $email_input_attr = array( 1569 'id' => 'email', 1570 'name' => 'email', 1571 'type' => $html5 ? 'email' : 'text', 1572 'value' => esc_attr( $commenter['comment_author_email'] ), 1573 'size' => '30', 1574 'aria-required' => ( $req ) ? 'true' : 'false', 1575 ); 1576 if ( $html5 ) { 1577 $email_input_attr['pattern'] = ''; 1578 $email_input_attr['placeholder'] = __( 'Your@Email.com' ); 1579 if( $req ) 1580 $email_input_attr['required'] = null; 1581 } 1582 1583 $url_input_attr = array( 1584 'id' => 'url', 1585 'name' => 'url', 1586 'type' => $html5 ? 'url' : 'text', 1587 'value' => esc_attr( $commenter['comment_author_url'] ), 1588 'size' => '30' 1589 ); 1590 if ( $html5 ) { 1591 $url_input_attr['pattern'] = ''; 1592 $url_input_attr['placeholder'] = __( 'http://YourWebsite.com' ); 1593 } 1594 1523 1595 $fields = array( 1524 1596 '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>',1597 input_builder( $author_input_attr ) . '</p>', 1526 1598 '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>',1599 input_builder( $email_input_attr ) . '</p>', 1528 1600 '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>',1601 input_builder( $url_input_attr ) . '</p>', 1530 1602 ); 1531 1603 1532 1604 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );