From 498b2d7e33a4eea460126b42a93786a965cc7b48 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 24 Sep 2015 22:00:28 +0000 Subject: [PATCH] Comments: In `comment_form()`, move the comment textarea to the top for logged-out users when replying, improves keyboard/focus navigation. Rehabilitate errant tabbing and extra unnecessary `` toggling. Props afercia, adamsilverstein. Fixes #29974. Built from https://develop.svn.wordpress.org/trunk@34525 git-svn-id: http://core.svn.wordpress.org/trunk@34489 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 332 +++++++++++++++---------------- wp-includes/version.php | 2 +- 2 files changed, 166 insertions(+), 168 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 11968803f7..d8c16a93da 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1974,7 +1974,7 @@ function comment_form( $args = array(), $post_id = null ) { /** This filter is documented in wp-includes/link-template.php */ 'must_log_in' => '

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

', /** This filter is documented in wp-includes/link-template.php */ - 'logged_in_as' => '

' . sprintf( __( 'Logged in as %2$s. Log out?' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

', + 'logged_in_as' => '

' . sprintf( __( 'Logged in as %2$s. Log out?' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

', 'comment_notes_before' => '

' . __( 'Your email address will not be published.' ) . ''. ( $req ? $required_text : '' ) . '

', 'comment_notes_after' => '', 'id_form' => 'commentform', @@ -2008,183 +2008,181 @@ function comment_form( $args = array(), $post_id = null ) { // Ensure that the filtered args contain all required default values. $args = array_merge( $defaults, $args ); - if ( comments_open( $post_id ) ) : ?> + if ( comments_open( $post_id ) ) : ?> + +
-
- + echo $args['title_reply_after']; - - + if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : + echo $args['must_log_in']; + /** + * Fires after the HTML-formatted 'must log in after' message in the comment form. + * + * @since 3.0.0 + */ + do_action( 'comment_form_must_log_in_after' ); + else : ?> +
> $field ) { + /** + * Filter a comment form field for display. + * + * The dynamic portion of the filter hook, `$name`, refers to the name + * of the comment form field. Such as 'author', 'email', or 'url'. + * + * @since 3.0.0 + * + * @param string $field The HTML-formatted output of the comment form field. + */ + echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; + } + /** + * Fires after the comment fields in the comment form. + * + * @since 3.0.0 + */ + do_action( 'comment_form_after_fields' ); + + endif; + + $submit_button = sprintf( + $args['submit_button'], + esc_attr( $args['name_submit'] ), + esc_attr( $args['id_submit'] ), + esc_attr( $args['class_submit'] ), + esc_attr( $args['label_submit'] ) + ); + + /** + * Filter the submit button for the comment form to display. + * + * @since 4.2.0 + * + * @param string $submit_button HTML markup for the submit button. + * @param array $args Arguments passed to `comment_form()`. + */ + $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args ); + + $submit_field = sprintf( + $args['submit_field'], + $submit_button, + get_comment_id_fields( $post_id ) + ); + + /** + * Filter the submit field for the comment form to display. + * + * The submit field includes the submit button, hidden fields for the + * comment form, and any wrapper markup. + * + * @since 4.2.0 + * + * @param string $submit_field HTML markup for the submit field. + * @param array $args Arguments passed to comment_form(). + */ + echo apply_filters( 'comment_form_submit_field', $submit_field, $args ); + + /** + * Fires at the bottom of the comment form, inside the closing
tag. + * + * @since 1.5.0 + * + * @param int $post_id The post ID. + */ + do_action( 'comment_form', $post_id ); ?> - -
> - - - - - - - $field ) { - /** - * Filter a comment form field for display. - * - * The dynamic portion of the filter hook, `$name`, refers to the name - * of the comment form field. Such as 'author', 'email', or 'url'. - * - * @since 3.0.0 - * - * @param string $field The HTML-formatted output of the comment form field. - */ - echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; - } - /** - * Fires after the comment fields in the comment form. - * - * @since 3.0.0 - */ - do_action( 'comment_form_after_fields' ); - ?> - - - - - tag. - * - * @since 1.5.0 - * - * @param int $post_id The post ID. - */ - do_action( 'comment_form', $post_id ); - ?> -
- -
- + +
+