Changeset 12810
- Timestamp:
- 01/23/2010 06:06:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment-template.php
r12789 r12810 834 834 if ( empty($file) ) 835 835 $file = '/comments.php'; 836 836 837 837 $req = get_option('require_name_email'); 838 838 … … 1417 1417 } 1418 1418 1419 /** 1420 * Outputs a complete commenting form for use within a template. 1421 * Most strings and form fields may be controlled through the $args array passed 1422 * into the function, while you may also choose to use the comments_form_default_fields 1423 * filter to modify the array of default fields if you'd just like to add a new 1424 * one or remove a single field. All fields are also individually passed through 1425 * a filter of the form comments_form_field_$name where $name is the key used 1426 * in the array of fields. 1427 * 1428 * @since x.x 1429 * @param array $args Options for strings, fields etc in the form 1430 * @param mixed $post_id Post ID to generate the form for, uses the current post if null 1431 * @return void 1432 */ 1433 function comment_form( $args = array(), $post_id = null ) { 1434 global $user_identity, $id; 1435 1436 if ( null === $post_id ) 1437 $post_id = $id; 1438 else 1439 $id = $post_id; 1440 1441 $commenter = wp_get_current_commenter(); 1442 1443 $req = get_option( 'require_name_email' ); 1444 $aria_req = ( $req ? " aria-required='true'" : '' ); 1445 $req_str = ( $req ? __( ' (required)' ) : '' ); 1446 $defaults = array( 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '<p><input type="text" name="author" id="author" value="' . esc_attr( $commenter['comment_author'] ) . '" size="22" tabindex="1"' . $aria_req . ' /> <label for="author"><small>' . __( 'Name' ) . $req_str . '</small></label></p>', 1447 'email' => '<p><input type="text" name="email" id="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="22" tabindex="2"' . $aria_req . ' /> <label for="email"><small>' . __( 'Mail (will not be published)' ) . $req_str . '</small></label></p>', 1448 'url' => '<p><input type="text" name="url" id="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="22" tabindex="3" /> <label for="url"><small>' . __( 'Website' ) . '</small></label></p>' ) ), 1449 'comment_field' => '<p><textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea></p>', 1450 'must_log_in' => '<p>' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', 1451 'logged_in_as' => '<p>' . sprintf( __( 'Logged in as <a href="%s">%s</a>. <a href="%s" title="Log out of this account">Log out »</a></p>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ), 1452 'id_form' => 'commentform', 1453 'id_submit' => 'submit', 1454 'title_reply' => __( 'Leave a Reply' ), 1455 'title_reply_to' => __( 'Leave a Reply to %s'), 1456 'cancel_reply_link' => '', 1457 'label_submit' => __( 'Submit Comment' ), 1458 ); 1459 $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); 1460 1461 ?> 1462 <?php if ( comments_open() ) : ?> 1463 <?php do_action( 'comment_form_before' ); ?> 1464 <div id="respond"> 1465 <h3><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?></h3> 1466 <div class="cancel-comment-reply"> 1467 <small><?php cancel_comment_reply_link( $args['cancel_comment_reply_link'] ); ?></small> 1468 </div> 1469 <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> 1470 <?php echo $args['must_log_in']; ?> 1471 <?php do_action( 'comment_form_must_log_in_after' ); ?> 1472 <?php else : ?> 1473 <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>"> 1474 <?php do_action( 'comment_form_top' ); ?> 1475 <?php if ( is_user_logged_in() ) : ?> 1476 <?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?> 1477 <?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?> 1478 <?php else : ?> 1479 <?php 1480 do_action( 'comment_form_before_fields' ); 1481 foreach ( (array) $args['fields'] as $name => $field ) { 1482 echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; 1483 } 1484 do_action( 'comment_form_after_fields' ); 1485 ?> 1486 <?php endif; ?> 1487 <?php echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?> 1488 <p> 1489 <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" tabindex="<?php echo ( count( $args['fields'] ) + 2 ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" /> 1490 <?php comment_id_fields(); ?> 1491 </p> 1492 <?php do_action( 'comments_form', $post_id ); ?> 1493 </form> 1494 <?php endif; ?> 1495 </div> 1496 <?php do_action( 'comment_form_after' ); ?> 1497 <?php else : ?> 1498 <?php do_action( 'comment_form_comments_closed' ); ?> 1499 <?php endif; ?> 1500 <?php 1501 } 1502 1419 1503 ?>
Note: See TracChangeset
for help on using the changeset viewer.