Administration: Show excerpts for untitled On This Day posts#12581
Administration: Show excerpts for untitled On This Day posts#12581alshakero wants to merge 2 commits into
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
7ce530a to
29a796a
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thank you @alshakero for jumping right on it! |
| * @param WP_Post $post The current WP_Post object. | ||
| * @return string The trimmed excerpt, or an empty string. | ||
| */ | ||
| function _wp_dashboard_on_this_day_get_no_title_excerpt( $post ) { |
There was a problem hiding this comment.
Core introduced get_no_title_excerpt() for the upcoming WordPress 7.1 release. See:
It looks like this duplicates the functionality we're adding here.
There was a problem hiding this comment.
Yes I actually copied that, but it's protected inside a class. Do you think we should make a util and use it in both places?
There was a problem hiding this comment.
So I checked once more and I think these two functions are only slightly similar to each other.
WP_Posts_List_Table::get_no_title_excerpt()is list-table-specific, it checks compact mode,current_user_can, and returns already-escaped text.- The On This Day widget does not need compact mode nor the
current_user_cancheck and it escapes at render time.
Summary
Trac: https://core.trac.wordpress.org/ticket/65658
See: https://wordpress.org/support/topic/on-this-day-widget/
This adds the same untitled-post fallback used in the posts list table to the On This Day dashboard widget. When a matching post has no title, the widget now appends a trimmed excerpt after
(no title)when the current user can read the post and the post is not password protected.The change keeps protected post excerpts hidden and adds PHPUnit coverage for the trimmed excerpt and password-protected cases.
Testing
(no title) 15 word excerpt.Screenshots
Before
After