Skip to content

Commit

Permalink
Coding Standards: Fix a whitespace at end of line issue in `wp-admin/…
Browse files Browse the repository at this point in the history
…includes/class-wp-comments-list-table.php`.

Includes minor code layout fixes for better readability.

See #52627.

git-svn-id: https://develop.svn.wordpress.org/trunk@50805 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed May 3, 2021
1 parent 1415ac7 commit 65fb405
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/wp-admin/includes/class-wp-comments-list-table.php
Expand Up @@ -95,6 +95,7 @@ public function prepare_items() {
}

$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';

if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) {
$comment_status = 'all';
}
Expand Down Expand Up @@ -162,6 +163,7 @@ public function prepare_items() {
$args = apply_filters( 'comments_list_table_query_args', $args );

$_comments = get_comments( $args );

if ( is_array( $_comments ) ) {
update_comment_cache( $_comments );

Expand Down Expand Up @@ -198,6 +200,7 @@ public function prepare_items() {
*/
public function get_per_page( $comment_status = 'all' ) {
$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );

/**
* Filters the number of comments listed per page in the comments list table.
*
Expand Down Expand Up @@ -284,6 +287,7 @@ protected function get_views() {
}

$link = admin_url( 'edit-comments.php' );

if ( ! empty( $comment_type ) && 'all' !== $comment_type ) {
$link = add_query_arg( 'comment_type', $comment_type, $link );
}
Expand Down Expand Up @@ -312,15 +316,19 @@ protected function get_views() {
if ( ! isset( $num_comments->$status ) ) {
$num_comments->$status = 10;
}

$link = add_query_arg( 'comment_status', $status, $link );

if ( $post_id ) {
$link = add_query_arg( 'p', absint( $post_id ), $link );
}

/*
// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
if ( !empty( $_REQUEST['s'] ) )
$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
*/

$status_links[ $status ] = "<a href='$link'$current_link_attributes>" . sprintf(
translate_nooped_plural( $label, $num_comments->$status ),
sprintf(
Expand Down Expand Up @@ -352,12 +360,15 @@ protected function get_bulk_actions() {
global $comment_status;

$actions = array();

if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) {
$actions['unapprove'] = __( 'Unapprove' );
}

if ( in_array( $comment_status, array( 'all', 'moderated' ), true ) ) {
$actions['approve'] = __( 'Approve' );
}

if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ), true ) ) {
$actions['spam'] = _x( 'Mark as spam', 'comment' );
}
Expand Down Expand Up @@ -414,7 +425,7 @@ protected function extra_tablenav( $which ) {
}

if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && $has_items
&& current_user_can( 'moderate_comments' )
&& current_user_can( 'moderate_comments' )
) {
wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
$title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
Expand Down Expand Up @@ -519,7 +530,8 @@ protected function comment_type_dropdown( $comment_type ) {
);
}
}
echo '</select>';

echo '</select>';
}
}

Expand Down Expand Up @@ -558,6 +570,7 @@ public function display() {

if ( ! isset( $has_items ) ) {
$has_items = $this->has_items();

if ( $has_items ) {
$this->display_tablenav( 'top' );
}
Expand Down Expand Up @@ -614,14 +627,17 @@ public function single_row( $item ) {
$comment = $item;

$the_comment_class = wp_get_comment_status( $comment );

if ( ! $the_comment_class ) {
$the_comment_class = '';
}

$the_comment_class = implode( ' ', get_comment_class( $the_comment_class, $comment, $comment->comment_post_ID ) );

if ( $comment->comment_post_ID > 0 ) {
$post = get_post( $comment->comment_post_ID );
}

$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );

echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
Expand Down Expand Up @@ -873,6 +889,7 @@ public function column_comment( $comment ) {

if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );

if ( $parent ) {
$parent_link = esc_url( get_comment_link( $parent ) );
$name = get_comment_author( $parent );
Expand Down Expand Up @@ -912,13 +929,15 @@ public function column_author( $comment ) {
$author_url = get_comment_author_url( $comment );

$author_url_display = untrailingslashit( preg_replace( '|^http(s)?://(www\.)?|i', '', $author_url ) );

if ( strlen( $author_url_display ) > 50 ) {
$author_url_display = wp_html_excerpt( $author_url_display, 49, '&hellip;' );
}

echo '<strong>';
comment_author( $comment );
echo '</strong><br />';

if ( ! empty( $author_url_display ) ) {
printf( '<a href="%s">%s</a><br />', esc_url( $author_url ), esc_html( $author_url_display ) );
}
Expand All @@ -934,6 +953,7 @@ public function column_author( $comment ) {
}

$author_ip = get_comment_author_IP( $comment );

if ( $author_ip ) {
$author_ip_url = add_query_arg(
array(
Expand All @@ -942,9 +962,11 @@ public function column_author( $comment ) {
),
admin_url( 'edit-comments.php' )
);

if ( 'spam' === $comment_status ) {
$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
}

printf( '<a href="%1$s">%2$s</a>', esc_url( $author_ip_url ), esc_html( $author_ip ) );
}
}
Expand All @@ -964,6 +986,7 @@ public function column_date( $comment ) {
);

echo '<div class="submitted-on">';

if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
printf(
'<a href="%s">%s</a>',
Expand All @@ -973,6 +996,7 @@ public function column_date( $comment ) {
} else {
echo $submitted;
}

echo '</div>';
}

Expand Down Expand Up @@ -1002,18 +1026,23 @@ public function column_response( $comment ) {
}

echo '<div class="response-links">';

if ( 'attachment' === $post->post_type ) {
$thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true );
if ( $thumb ) {
echo $thumb;
}
}

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>';

echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">';
$this->comments_bubble( $post->ID, $pending_comments );
echo '</span> ';

echo '</div>';
}

Expand Down

0 comments on commit 65fb405

Please sign in to comment.