diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index f48dc91fb..fcf37e722 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -833,7 +833,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false if ( empty($file) ) $file = '/comments.php'; - + $req = get_option('require_name_email'); /** @@ -1416,4 +1416,88 @@ function wp_list_comments($args = array(), $comments = null ) { $in_comment_loop = false; } +/** + * Outputs a complete commenting form for use within a template. + * Most strings and form fields may be controlled through the $args array passed + * into the function, while you may also choose to use the comments_form_default_fields + * filter to modify the array of default fields if you'd just like to add a new + * one or remove a single field. All fields are also individually passed through + * a filter of the form comments_form_field_$name where $name is the key used + * in the array of fields. + * + * @since x.x + * @param array $args Options for strings, fields etc in the form + * @param mixed $post_id Post ID to generate the form for, uses the current post if null + * @return void + */ +function comment_form( $args = array(), $post_id = null ) { + global $user_identity, $id; + + if ( null === $post_id ) + $post_id = $id; + else + $id = $post_id; + + $commenter = wp_get_current_commenter(); + + $req = get_option( 'require_name_email' ); + $aria_req = ( $req ? " aria-required='true'" : '' ); + $req_str = ( $req ? __( ' (required)' ) : '' ); + $defaults = array( 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '

', + 'email' => '

', + 'url' => '

' ) ), + 'comment_field' => '

', + 'must_log_in' => '

' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

', + 'logged_in_as' => '

' . sprintf( __( 'Logged in as %s. Log out »

' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ), + 'id_form' => 'commentform', + 'id_submit' => 'submit', + 'title_reply' => __( 'Leave a Reply' ), + 'title_reply_to' => __( 'Leave a Reply to %s'), + 'cancel_reply_link' => '', + 'label_submit' => __( 'Submit Comment' ), + ); + $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); + + ?> + + +
+

+
+ +
+ + + + +
+ + + + + + $field ) { + echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; + } + do_action( 'comment_form_after_fields' ); + ?> + + +

+ + +

+ +
+ +
+ + + + +