diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/class-wp-comments-list-table.php --- a/wp/wp-admin/includes/class-wp-comments-list-table.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/class-wp-comments-list-table.php Fri Sep 05 18:40:08 2025 +0200 @@ -11,7 +11,6 @@ * Core class used to implement displaying comments in a list table. * * @since 3.1.0 - * @access private * * @see WP_List_Table */ @@ -141,16 +140,17 @@ ); $args = array( - 'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status, - 'search' => $search, - 'user_id' => $user_id, - 'offset' => $start, - 'number' => $number, - 'post_id' => $post_id, - 'type' => $comment_type, - 'orderby' => $orderby, - 'order' => $order, - 'post_type' => $post_type, + 'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status, + 'search' => $search, + 'user_id' => $user_id, + 'offset' => $start, + 'number' => $number, + 'post_id' => $post_id, + 'type' => $comment_type, + 'orderby' => $orderby, + 'order' => $order, + 'post_type' => $post_type, + 'update_comment_post_cache' => true, ); /** @@ -165,8 +165,6 @@ $_comments = get_comments( $args ); if ( is_array( $_comments ) ) { - update_comment_cache( $_comments ); - $this->items = array_slice( $_comments, 0, $comments_per_page ); $this->extra_items = array_slice( $_comments, $comments_per_page ); @@ -179,9 +177,10 @@ array_merge( $args, array( - 'count' => true, - 'offset' => 0, - 'number' => 0, + 'count' => true, + 'offset' => 0, + 'number' => 0, + 'orderby' => 'none', ) ) ); @@ -238,7 +237,7 @@ $status_links = array(); $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); - $stati = array( + $statuses = array( /* translators: %s: Number of comments. */ 'all' => _nx_noop( 'All (%s)', @@ -283,7 +282,7 @@ ); if ( ! EMPTY_TRASH_DAYS ) { - unset( $stati['trash'] ); + unset( $statuses['trash'] ); } $link = admin_url( 'edit-comments.php' ); @@ -292,13 +291,7 @@ $link = add_query_arg( 'comment_type', $comment_type, $link ); } - foreach ( $stati as $status => $label ) { - $current_link_attributes = ''; - - if ( $status === $comment_status ) { - $current_link_attributes = ' class="current" aria-current="page"'; - } - + foreach ( $statuses as $status => $label ) { if ( 'mine' === $status ) { $current_user_id = get_current_user_id(); $num_comments->mine = get_comments( @@ -306,6 +299,7 @@ 'post_id' => $post_id ? $post_id : 0, 'user_id' => $current_user_id, 'count' => true, + 'orderby' => 'none', ) ); $link = add_query_arg( 'user_id', $current_user_id, $link ); @@ -329,14 +323,18 @@ $link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link ); */ - $status_links[ $status ] = "" . sprintf( - translate_nooped_plural( $label, $num_comments->$status ), - sprintf( - '%s', - ( 'moderated' === $status ) ? 'pending' : $status, - number_format_i18n( $num_comments->$status ) - ) - ) . ''; + $status_links[ $status ] = array( + 'url' => esc_url( $link ), + 'label' => sprintf( + translate_nooped_plural( $label, $num_comments->$status ), + sprintf( + '%s', + ( 'moderated' === $status ) ? 'pending' : $status, + number_format_i18n( $num_comments->$status ) + ) + ), + 'current' => $status === $comment_status, + ); } /** @@ -348,7 +346,7 @@ * @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine', * 'Pending', 'Approved', 'Spam', and 'Trash'. */ - return apply_filters( 'comment_status_links', $status_links ); + return apply_filters( 'comment_status_links', $this->get_views_links( $status_links ) ); } /** @@ -439,7 +437,7 @@ * @since 5.6.0 The `$which` parameter was added. * * @param string $comment_status The comment status name. Default 'All'. - * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. + * @param string $which The location of the extra table nav markup: Either 'top' or 'bottom'. */ do_action( 'manage_comments_nav', $comment_status, $which ); @@ -460,7 +458,7 @@ /** * @global int $post_id * - * @return array + * @return string[] Array of column titles keyed by their column name. */ public function get_columns() { global $post_id; @@ -509,7 +507,11 @@ ); if ( $comment_types && is_array( $comment_types ) ) { - printf( '', __( 'Filter by comment type' ) ); + printf( + '', + /* translators: Hidden accessibility text. */ + __( 'Filter by comment type' ) + ); echo ' + @@ -1066,6 +1102,9 @@ * @param string $column_name The custom column's name. */ public function column_default( $item, $column_name ) { + // Restores the more descriptive, specific name for use within this method. + $comment = $item; + /** * Fires when the default column output is displayed for a single row. * @@ -1074,6 +1113,6 @@ * @param string $column_name The custom column's name. * @param string $comment_id The comment ID as a numeric string. */ - do_action( 'manage_comments_custom_column', $column_name, $item->comment_ID ); + do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); } }