Skip to content

Administration: Show excerpts for untitled On This Day posts#12581

Open
alshakero wants to merge 2 commits into
WordPress:trunkfrom
alshakero:alshakero/on-this-day-untitled-excerpt
Open

Administration: Show excerpts for untitled On This Day posts#12581
alshakero wants to merge 2 commits into
WordPress:trunkfrom
alshakero:alshakero/on-this-day-untitled-excerpt

Conversation

@alshakero

@alshakero alshakero commented Jul 17, 2026

Copy link
Copy Markdown

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

  • Checkout this PR locally and run npm run env:start, then npm run env:install.
  • Go to Dashboard (admin:password), you should see the widget.
  • Insepect its empty state.
  • Import this file to create backdated posts: filexml
  • Use the widget.
  • Update the post to get rid of the title.
  • It should render (no title) 15 word excerpt.

Screenshots

Before

image

After

image

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@alshakero
alshakero force-pushed the alshakero/on-this-day-untitled-excerpt branch from 7ce530a to 29a796a Compare July 17, 2026 14:51
@alshakero
alshakero marked this pull request as ready for review July 17, 2026 14:59
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props alshakero, mukesh27, bph.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@bph

bph commented Jul 17, 2026

Copy link
Copy Markdown

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 ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core introduced get_no_title_excerpt() for the upcoming WordPress 7.1 release. See:

protected function get_no_title_excerpt( $post ) {

It looks like this duplicates the functionality we're adding here.

@alshakero alshakero Jul 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@alshakero alshakero Jul 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_can check and it escapes at render time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants