-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Posts list: show part of excerpt in Compact view if post has no title #11553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 ) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The checkbox label should include the same text as the link (with 'Select'). The locked icon text might not require the same, but I updated that anyway. |
||
| 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, ' …' ) ); | ||
| } | ||
| } | ||
| ?> | ||
| <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 ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this might make it more confusing for users with screen readers or not. Visual users have the luxury of styling to differentiate "(no title)" (bold) from the trimmed excerpt (regular weight). Should we rearrange the output for screen readers? Otherwise it'll look like this: <span class="screen-reader-text">Select (no title) Lorem ipsum dolor sit amet</span> |
||
| ?> | ||
| </span> | ||
| </label> | ||
|
|
@@ -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 | ||
| ); | ||
| ?> | ||
| </span> | ||
|
|
@@ -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, ' …' ) ) . '</span>'; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Escapes the output even though
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About the
… whereas I expected something like: // translators: If your locale needs a different [bla bla…]
$more = _x( '…', 'ellipsis or equivalent typographic marker of a trimmed excerpt' );
// ...
wp_trim_words( $excerpt, 15, $more ) ) |
||
| } | ||
| } | ||
|
|
||
| if ( $can_edit_post && 'trash' !== $post->post_status ) { | ||
| printf( | ||
| '<a class="row-title" href="%s">%s%s</a>', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I want the lighter
font-weightwhen it is still part of the link, but I like having a small amount of padding to offset the excerpt.And the title is not linked in Trash: