Add a Notes section in the Dashboard Activity widget - #13076
Conversation
…p into ticket/65890
|
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. |
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. |
WP_Comment exposes its columns as strings, so passing comment_post_ID straight to _draft_or_post_title() and get_edit_post_link() fails static analysis. It also repeated an error pattern the PHPStan baseline records once for the comments widget, pushing that entry out of date.
…p into ticket/65890
Tallying the open notes of the displayed posts loaded every one of those notes just to count rows, an unbounded query on a busy post. Query each post's count instead, which returns a single value and skips priming the comment and meta caches.
Covers the edit link, the post title and its placeholder, escaping, the open note count and its singular and plural forms, and the relative date each row ends with, including its use of the timezone of the site. The dashboard had no test coverage of its own before this.
…old. A note is created on hold and is approved when it is resolved, so the row tests now create their notes the way the editor does. Adds coverage of the listing itself: the open note count, which posts are listed and in what order, and the exclusion of resolved threads, replies and regular comments.
The section queried the notes that start a thread and dated each post by one of those, so a thread opened weeks ago and replied to this morning was dated weeks ago, and sorted below a thread nobody had touched since it was opened. Query replies too, and date each post by the most recent note or reply in a thread that is still open. Resolving a thread approves the note that starts it while its replies stay on hold, so the thread a reply belongs to is checked before the reply counts as activity. The threads are primed in one query per page rather than fetched one at a time. Also pass 'orderby' => 'none' to the open note counts, which do not need the ordering, matching get_comment_count().
|
Working on this a few points emerged:
|
We are adding notes posted to blocks in the editor to the Recent Activity widget in the admin dashboard.
Trac ticket: https://core.trac.wordpress.org/ticket/65890
Testing
Tool to create many notes: https://github.com/t-hamano/notes-data-generator
https://playground.wordpress.net/wordpress.html?pr=13076
Screenshot
More screenshots
Claude seeded a site with notes and captured the widget in each state:
The test site has six posts carrying note threads: several threads have replies, some threads are resolved, one post has every thread resolved, and one post belongs to another author.
The Activity widget with five posts that have open notes. Each row links to the post, counts the open threads on it, and is dated by the newest note or reply on that post.
Where those counts come from. The same post in the editor: four open threads, two of them with replies, and the resolved threads below the divider. The dashboard reads "4 open notes" for it.
Eight more states
A post with one open thread uses the singular string.
Every thread resolved on every post, so the Notes section is not rendered at all and the rest of the widget is unchanged.
A thread replied to minutes ago on a six-day-old note sorts to the top, dated by the reply rather than by the note that opened the thread.
Dates across the year: today, earlier this year, and last year, which picks up the year.
Long titles, a post with 24 open notes, and an untitled draft in the same list.
Signed in as an author who can only edit their own post: the posts they cannot edit drop out of the list, notes and all.
At 420px wide, the three columns tighten and the count wraps rather than overflowing.
The whole dashboard for context.