Skip to content

Add a Notes section in the Dashboard Activity widget - #13076

Open
mcrisp1972 wants to merge 21 commits into
WordPress:trunkfrom
mcrisp1972:ticket/65890
Open

Add a Notes section in the Dashboard Activity widget#13076
mcrisp1972 wants to merge 21 commits into
WordPress:trunkfrom
mcrisp1972:ticket/65890

Conversation

@mcrisp1972

@mcrisp1972 mcrisp1972 commented Aug 16, 2026

Copy link
Copy Markdown

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

image

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, in the same date, title, count order the sections above it use.

Activity widget showing the Recent Notes section with five posts

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.

Editor sidebar listing four open note threads and the resolved ones

Eight more states

A post with one open thread uses the singular string.

Recent Notes listing a single post with one open note

Every thread resolved on every post, so the Notes section is not rendered at all and the rest of the widget is unchanged.

Activity widget with no Recent Notes section

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.

Recent Notes ordered by the most recent reply

Dates across the year: today, earlier this year, and last year, which picks up the year.

Recent Notes rows dated today, earlier this year, and last year

Long titles, a post with 24 open notes, and an untitled draft in the same list.

Recent Notes with a wrapping title, a 24 note count, and a no title row

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.

Activity widget for an author, listing only their own post

At 420px wide, the date and the count hold their columns and the title wraps into what is left.

Activity widget at mobile width

The whole dashboard for context.

Full dashboard with the Activity widget

@github-actions

github-actions Bot commented Aug 16, 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 mcrisp1972, ancawonka, aosmichenko, adamsilverstein.

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

@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.

aosmichenko and others added 7 commits August 16, 2026 13:36
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.
Comment thread src/wp-admin/includes/dashboard.php Outdated
@adamsilverstein adamsilverstein changed the title Ticket/65890 Add a Notes section in the Dashboard Activity widget Aug 16, 2026
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().
@adamsilverstein

adamsilverstein commented Aug 16, 2026

Copy link
Copy Markdown
Member

Working on this a few points emerged:

  • Rather than showing recent Notes, we decided to show the Posts with the most recent notes or replies. There is no "Notes" screen to link to, when you have a new note, the main action is to view the note on the edit post screen.
  • Showing the most recent date is tricky, we need only unresolved threads, which is recorded at the top level note - but we still want the date from the most recent reply. This complicated querying for the notes to get what we needed.

Notes are only listed for posts the current user can edit, so a user who
can edit none of them paged through every open note on the site, one
query per page. Stop paging once a hundred notes per row have been
examined, and prime the posts the capability checks load while skipping
the note meta they never read.
The row put the post title in the narrow first column the sibling
sections use for the date, so a title of any length wrapped while the
open note count stretched across the free space. Render the date first,
the title in the column that grows, and the count last, and drop a
duplicated block of rules left over from an earlier iteration.

Skip a row whose post no longer has an edit link along the way, as
esc_url() is passed null for a post deleted since the notes were
queried.
@adamsilverstein

Copy link
Copy Markdown
Member

I had Claude review the branch, and pushed what it turned up:

Two commits, both on top of the existing work here.

d4d4678 bounds the paging loop. Notes are only listed for posts the current user can edit, so a user who can edit none of them - a Subscriber, or an Author on a multi-author site - never satisfied the while condition and paged through every open note on the site, 50 at a time. On a busy site that is a lot of get_comments() calls per dashboard load. Paging now stops after a hundred notes per row have been examined. The same commit adds update_comment_post_cache (the current_user_can( 'edit_post', ... ) check was pulling one get_post() query per note) and turns off update_comment_meta_cache, which was priming meta on every scanned note that nothing ever reads.

c8c9b7f is the row layout. The markup was title, count, date, so the title landed in the narrow clamped column that #published-posts reserves for the date, and the "4 open notes" string stretched across the free space instead. Any title of normal length wrapped in a ~170px column with a wide gap next to it. Rows are now date, title, count, which lines the Notes section up with Recently Published directly above it - see the refreshed screenshots in the description. That commit also drops a duplicated #latest-notes block at the bottom of dashboard.css (every declaration in it was already set earlier in the file), and guards get_edit_post_link(), which returns null for a post deleted between the query and the render and was reaching esc_url() as a PHP 8.1 deprecation.

Tests came along with each: the paging bound, the edit link guard, and the two row helpers that read the date out of the markup. --group notes,dashboard,admin,comment is green at 1657 tests, and PHPCS and PHPStan are clean.

One review note that turned out to be a non-issue, for the record: orderby looked like it needed a comment_ID tiebreaker for stable paging, but WP_Comment_Query already appends one to any orderby - see https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/class-wp-comment-query.php#L672-L703. Nothing to do there.

@mcrisp1972 does the date-first row order look right to you? Happy to put it back if you had a reason for leading with the title.

@mcrisp1972

Copy link
Copy Markdown
Author

I had Claude review the branch, and pushed what it turned up:

Two commits, both on top of the existing work here.

d4d4678 bounds the paging loop. Notes are only listed for posts the current user can edit, so a user who can edit none of them - a Subscriber, or an Author on a multi-author site - never satisfied the while condition and paged through every open note on the site, 50 at a time. On a busy site that is a lot of get_comments() calls per dashboard load. Paging now stops after a hundred notes per row have been examined. The same commit adds update_comment_post_cache (the current_user_can( 'edit_post', ... ) check was pulling one get_post() query per note) and turns off update_comment_meta_cache, which was priming meta on every scanned note that nothing ever reads.

c8c9b7f is the row layout. The markup was title, count, date, so the title landed in the narrow clamped column that #published-posts reserves for the date, and the "4 open notes" string stretched across the free space instead. Any title of normal length wrapped in a ~170px column with a wide gap next to it. Rows are now date, title, count, which lines the Notes section up with Recently Published directly above it - see the refreshed screenshots in the description. That commit also drops a duplicated #latest-notes block at the bottom of dashboard.css (every declaration in it was already set earlier in the file), and guards get_edit_post_link(), which returns null for a post deleted between the query and the render and was reaching esc_url() as a PHP 8.1 deprecation.

Tests came along with each: the paging bound, the edit link guard, and the two row helpers that read the date out of the markup. --group notes,dashboard,admin,comment is green at 1657 tests, and PHPCS and PHPStan are clean.

One review note that turned out to be a non-issue, for the record: orderby looked like it needed a comment_ID tiebreaker for stable paging, but WP_Comment_Query already appends one to any orderby - see https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/class-wp-comment-query.php#L672-L703. Nothing to do there.

@mcrisp1972 does the date-first row order look right to you? Happy to put it back if you had a reason for leading with the title.

@adamsilverstein

I had Claude review the branch, and pushed what it turned up:

Two commits, both on top of the existing work here.

d4d4678 bounds the paging loop. Notes are only listed for posts the current user can edit, so a user who can edit none of them - a Subscriber, or an Author on a multi-author site - never satisfied the while condition and paged through every open note on the site, 50 at a time. On a busy site that is a lot of get_comments() calls per dashboard load. Paging now stops after a hundred notes per row have been examined. The same commit adds update_comment_post_cache (the current_user_can( 'edit_post', ... ) check was pulling one get_post() query per note) and turns off update_comment_meta_cache, which was priming meta on every scanned note that nothing ever reads.

c8c9b7f is the row layout. The markup was title, count, date, so the title landed in the narrow clamped column that #published-posts reserves for the date, and the "4 open notes" string stretched across the free space instead. Any title of normal length wrapped in a ~170px column with a wide gap next to it. Rows are now date, title, count, which lines the Notes section up with Recently Published directly above it - see the refreshed screenshots in the description. That commit also drops a duplicated #latest-notes block at the bottom of dashboard.css (every declaration in it was already set earlier in the file), and guards get_edit_post_link(), which returns null for a post deleted between the query and the render and was reaching esc_url() as a PHP 8.1 deprecation.

Tests came along with each: the paging bound, the edit link guard, and the two row helpers that read the date out of the markup. --group notes,dashboard,admin,comment is green at 1657 tests, and PHPCS and PHPStan are clean.

One review note that turned out to be a non-issue, for the record: orderby looked like it needed a comment_ID tiebreaker for stable paging, but WP_Comment_Query already appends one to any orderby - see https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/class-wp-comment-query.php#L672-L703. Nothing to do there.

@mcrisp1972 does the date-first row order look right to you? Happy to put it back if you had a reason for leading with the title.

@adamsilverstein , Jen

Update the layout and view

@adamsilverstein , this is looking good. Regarding the ordering of row date and title, Jen and @aosmichenko built out the rows, so we might want their input on that, but I think the date first makes sense, especially if that is the sorted field.

@aosmichenko

aosmichenko commented Aug 18, 2026

Copy link
Copy Markdown

I was initially thinking of making "time ago" format, so if you would rather do that instead. I have no hard preferences on the format and column order, was trying to find the most useful to read.

@adamsilverstein

Copy link
Copy Markdown
Member

I was initially thinking of making "time ago" format, so if you would rather do that instead. I have no hard preferences on the format and column order, was trying to find the most useful to read.

I like the human readable time ago format, we use that for most user facing dates.

Review on the PR favored the relative "time ago" format over the
Today/Tomorrow/date wording, matching how most user facing dates are
shown elsewhere in the admin, such as the Media list table and the
revisions screen.

Compute the difference from the GMT date of the note so it is correct
in any site timezone, which also removes the dead branch guarding a
non-integer timestamp: get_comment_date( 'U' ) always returned one.
The separate clock time is dropped because the difference already
carries it, taking the '%1$s, %2$s' join and the date format strings
out of the translation catalog. The row markup keeps its shape, so the
column layout and dashboard.css are unchanged.
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.

4 participants