From 218162803eb98b86368ca663dc6cdf856561aa74 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 20 Feb 2019 23:36:26 +0000 Subject: [PATCH] Accessibility: Comments: Improve links and buttons semantics and interaction. With the exception of the "Edit" link, the "row actions" controls in the Comments table behave differently depending if JavaScript support is on or off. When JavaScript support is off, they behave like links. When JavaScript support is on, they behave like buttons and they need to be buttons or have an ARIA `role="button"` added via JavaScript. Lastly, the buttons in the Reply/Quick Edit form and the "Add Comment" in the edit post page meta box need to be buttons. Fixes #43412. git-svn-id: https://develop.svn.wordpress.org/trunk@44759 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/edit-comments.js | 10 +++------- .../includes/class-wp-comments-list-table.php | 18 +++++++++--------- src/wp-admin/includes/dashboard.php | 12 ++++++------ src/wp-admin/includes/meta-boxes.php | 2 +- src/wp-admin/includes/template.php | 6 +++--- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 626a6b6e35..fff7191a1a 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -288,7 +288,7 @@ window.setCommentsList = function() { a = $('.undo a', '#undo-' + id); a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce); a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1'); - a.attr('class', 'vim-z vim-destructive'); + a.attr('class', 'vim-z vim-destructive aria-button-if-js'); $('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside'); a.click(function( e ){ @@ -582,8 +582,8 @@ window.commentReply = { init : function() { var row = $('#replyrow'); - $('a.cancel', row).click(function() { return commentReply.revert(); }); - $('a.save', row).click(function() { return commentReply.send(); }); + $( '.cancel', row ).click( function() { return commentReply.revert(); } ); + $( '.save', row ).click( function() { return commentReply.send(); } ); $( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) { if ( e.which == 13 ) { commentReply.send(); @@ -631,8 +631,6 @@ window.commentReply = { $('#replyrow').fadeOut('fast', function(){ commentReply.close(); }); - - return false; }, close : function() { @@ -808,8 +806,6 @@ window.commentReply = { success : function(x) { commentReply.show(x); }, error : function(r) { commentReply.error(r); } }); - - return false; }, show : function(xml) { diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 5787a8e91d..1c196fcf87 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -618,29 +618,29 @@ class WP_Comments_List_Table extends WP_List_Table { // Not looking at all comments. if ( $comment_status && 'all' != $comment_status ) { if ( 'approved' === $the_comment_status ) { - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; } elseif ( 'unapproved' === $the_comment_status ) { - $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['approve'] = "" . __( 'Approve' ) . ''; } } else { - $actions['approve'] = "" . __( 'Approve' ) . ''; - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; } if ( 'spam' !== $the_comment_status ) { - $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; } elseif ( 'spam' === $the_comment_status ) { - $actions['unspam'] = "" . _x( 'Not Spam', 'comment' ) . ''; + $actions['unspam'] = "" . _x( 'Not Spam', 'comment' ) . ''; } if ( 'trash' === $the_comment_status ) { - $actions['untrash'] = "" . __( 'Restore' ) . ''; + $actions['untrash'] = "" . __( 'Restore' ) . ''; } if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) { - $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; + $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; } else { - $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; + $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; } if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) { diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 3a2d3a69f8..7bebe3ff20 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -649,16 +649,16 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); - $actions['approve'] = "" . __( 'Approve' ) . ''; - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; $actions['edit'] = "" . __( 'Edit' ) . ''; - $actions['reply'] = '' . __( 'Reply' ) . ''; - $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + $actions['reply'] = ''; + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; if ( ! EMPTY_TRASH_DAYS ) { - $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; + $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; } else { - $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; + $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; } $actions['view'] = '' . __( 'View' ) . ''; diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 508168a5bf..38850e9d59 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -804,7 +804,7 @@ function post_comment_meta_box_thead( $result ) { function post_comment_meta_box( $post ) { wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); ?> -

+

- + +