diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css index c659079bea2e9..69838c026f57b 100644 --- a/src/wp-admin/css/list-tables.css +++ b/src/wp-admin/css/list-tables.css @@ -363,6 +363,11 @@ td.plugin-title p { margin: 6px 0; } +.trimmed-post-excerpt { + font-weight: 400; + padding-left: 4px; +} + /* Media file column */ table.media .column-title .media-icon { float: left; diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index c7d10fca217ef..8c6f019130701 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -1018,9 +1018,13 @@ private function _page_rows( &$children_pages, &$count, $parent_page, $level, $p * @since 4.3.0 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. * + * @global string $mode List table view mode. + * * @param WP_Post $item The current WP_Post object. */ public function column_cb( $item ) { + global $mode; + // Restores the more descriptive, specific name for use within this method. $post = $item; @@ -1037,13 +1041,23 @@ public function column_cb( $item ) { * @param WP_Post $post The current WP_Post object. */ if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) : + + $post_title = _draft_or_post_title(); + + // If the post has no title, try adding part of the excerpt. + if ( 'excerpt' !== $mode && '' === get_the_title( $post ) && ! post_password_required( $post ) ) { + $excerpt = get_the_excerpt( $post ); + if ( '' !== $excerpt && is_string( $excerpt ) ) { + $post_title .= ' ' . esc_html( wp_trim_words( $excerpt, 15, ' …' ) ); + } + } ?> @@ -1054,7 +1068,7 @@ public function column_cb( $item ) { printf( /* translators: Hidden accessibility text. %s: Post title. */ __( '“%s” is locked' ), - _draft_or_post_title() + $post_title ); ?> @@ -1142,6 +1156,14 @@ public function column_title( $post ) { $title = _draft_or_post_title(); + // If the post has no title, try adding part of the excerpt. + if ( 'excerpt' !== $mode && '' === get_the_title( $post ) && ! post_password_required( $post ) ) { + $excerpt = get_the_excerpt( $post ); + if ( '' !== $excerpt && is_string( $excerpt ) ) { + $title .= ' ' . esc_html( wp_trim_words( $excerpt, 15, ' …' ) ) . ''; + } + } + if ( $can_edit_post && 'trash' !== $post->post_status ) { printf( '%s%s',