List tables: Better accessibility and design for the comments bubble.
It is now plain text in the comments list table's "In Response To" column, where it was visually a bit confusing to have the bubble. For other list tables, it now shows a little notification bubble with the number of pending comments. The bubble and notification become plain text in the responsive list table view. It also shows no bubble when there are no comments at all, reducing some of the visual noise. props picard102, afercia, karinchristen. fixes #32152. Built from https://develop.svn.wordpress.org/trunk@33155 git-svn-id: http://core.svn.wordpress.org/trunk@33127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -678,21 +678,23 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
|
||||
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
|
||||
$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
|
||||
} else {
|
||||
$post_link = esc_html( get_the_title( $post->ID ) );
|
||||
}
|
||||
|
||||
echo '<div class="response-links"><span class="post-com-count-wrapper">';
|
||||
echo $post_link . '<br />';
|
||||
echo '<div class="response-links">';
|
||||
echo $post_link;
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>';
|
||||
if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) ) {
|
||||
echo $thumb;
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<span class="post-com-count-wrapper">';
|
||||
$this->comments_bubble( $post->ID, $pending_comments );
|
||||
echo '</span> ';
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
echo "<a href='" . get_permalink( $post->ID ) . "'>" . $post_type_object->labels->view_item . '</a>';
|
||||
echo '</div>';
|
||||
if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
|
||||
echo $thumb;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -614,15 +614,41 @@ class WP_List_Table {
|
||||
* @param int $pending_comments Number of pending comments.
|
||||
*/
|
||||
protected function comments_bubble( $post_id, $pending_comments ) {
|
||||
$pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
|
||||
$approved_comments = get_comments_number();
|
||||
|
||||
if ( $pending_comments )
|
||||
echo '<strong>';
|
||||
$approved_comments_number = number_format_i18n( $approved_comments );
|
||||
$pending_comments_number = number_format_i18n( $pending_comments );
|
||||
|
||||
echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";
|
||||
$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
|
||||
$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
|
||||
$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
|
||||
|
||||
if ( $pending_comments )
|
||||
echo '</strong>';
|
||||
// No comments at all.
|
||||
if ( ! $approved_comments && ! $pending_comments ) {
|
||||
printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
||||
__( 'No comments' )
|
||||
);
|
||||
// Approved comments have different display depending on some conditions.
|
||||
} elseif ( $approved_comments ) {
|
||||
printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
|
||||
esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ),
|
||||
$approved_comments_number,
|
||||
$pending_comments ? $approved_phrase : $approved_only_phrase
|
||||
);
|
||||
} else {
|
||||
printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
|
||||
$approved_comments_number,
|
||||
$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $pending_comments ) {
|
||||
printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
|
||||
esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ),
|
||||
$pending_comments_number,
|
||||
$pending_phrase
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user