Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/wp-admin/css/list-tables.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 24 additions & 2 deletions src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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, ' …' ) );
}
}
?>
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<label for="cb-select-<?php the_ID(); ?>">
<span class="screen-reader-text">
<?php
/* translators: %s: Post title. */
printf( __( 'Select %s' ), _draft_or_post_title() );
printf( __( 'Select %s' ), $post_title );
?>
</span>
</label>
Expand All @@ -1054,7 +1068,7 @@ public function column_cb( $item ) {
printf(
/* translators: Hidden accessibility text. %s: Post title. */
__( '&#8220;%s&#8221; is locked' ),
_draft_or_post_title()
$post_title
);
?>
</span>
Expand Down Expand Up @@ -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 .= ' <span class="trimmed-post-excerpt">' . esc_html( wp_trim_words( $excerpt, 15, ' &hellip;' ) ) . '</span>';
}
}

if ( $can_edit_post && 'trash' !== $post->post_status ) {
printf(
'<a class="row-title" href="%s">%s%s</a>',
Expand Down
Loading