Skip to content

Administration: Always display the On This Day dashboard widget - #12575

Open
i-am-chitti wants to merge 4 commits into
WordPress:trunkfrom
i-am-chitti:trac-65647
Open

Administration: Always display the On This Day dashboard widget#12575
i-am-chitti wants to merge 4 commits into
WordPress:trunkfrom
i-am-chitti:trac-65647

Conversation

@i-am-chitti

Copy link
Copy Markdown

Trac ticket

https://core.trac.wordpress.org/ticket/65647

Problem

The On This Day dashboard widget is hidden with the core hidden class when there are no posts to show for the current calendar day. This creates inconsistent, confusing behavior:

  • The widget is not visible on the dashboard, but its Screen Options checkbox is still checked — so the reported state disagrees with what's actually shown.
  • Unchecking and re-checking the option reveals the widget, because postbox.js calls jQuery's .show(), which injects an inline display: block that overrides the .hidden class.

The root cause is two independent hide mechanisms competing: a server-side hidden class vs. the persisted per-user Screen Options preference.

Fix

Take the "always show" approach (option 1 from the ticket):

  • Remove the postbox_classes_dashboard_wp_dashboard_on_this_day filter and the wp_dashboard_on_this_day_postbox_classes() function that added the hidden class.
  • The widget is now always registered and always visible. When there are no matching posts, the existing placeholder — "No posts were published on this day in previous years." — is shown.
  • Hiding is deferred entirely to Screen Options, which persists correctly and keeps the checkbox state consistent with on-screen visibility.

This is consistent with other always-registered dashboard widgets (e.g. Activity, At a Glance) and avoids !important CSS hacks.

Testing instructions

  1. Ensure there are no published posts dated on today's month/day in a previous year (a recent install satisfies this by default).
  2. Visit the Dashboard.
  3. Before this change: the widget is not visible, yet "On This Day" is checked in Screen Options; unchecking and re-checking reveals it.
  4. After this change: the widget is always visible and shows the placeholder message; the Screen Options checkbox state matches its visibility. Unchecking hides it and the preference persists across reloads.

Screenshots

Before

image

After

image

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: update unit tests

@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 iamchitti, wildworks, joedolson, mukesh27, annezazu.

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.

@mukeshpanchal27 mukeshpanchal27 left a comment

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.

Thanks @i-am-chitti for the PR!

Overall look solid to me.

# Conflicts:
#	tests/phpunit/tests/admin/wpDashboardOnThisDay.php
Copilot AI review requested due to automatic review settings July 29, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the “On This Day” Dashboard widget behavior so it is always displayed (and therefore consistently represented in Screen Options), showing an existing placeholder message when there are no matching posts for the current calendar day.

Changes:

  • Removes the postbox-class filter mechanism that previously added the core hidden class when there were no matching posts.
  • Updates the widget setup/rendering documentation and inline comments to reflect the “always visible; placeholder when empty” behavior.
  • Updates PHPUnit tests by removing coverage that asserted the old “hide when empty” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/phpunit/tests/admin/wpDashboardOnThisDay.php Updates tests to stop asserting the removed postbox-class filter behavior.
src/wp-admin/includes/dashboard-on-this-day.php Removes the hidden-class filter and updates documentation/comments to match always-visible behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/phpunit/tests/admin/wpDashboardOnThisDay.php Outdated
The setup function only wrapped a single wp_add_dashboard_widget() call,
which added an indirection every other core dashboard widget does without.
Registering the widget directly in wp_dashboard_setup() keeps the On This
Day widget consistent with At a Glance, Activity, and Quick Draft.

The file guard now checks for wp_dashboard_on_this_day(), the render
callback that remains in dashboard-on-this-day.php.

The two unit tests for the removed function only asserted that
wp_add_dashboard_widget() had been called, which no other core widget is
tested for, so they are dropped along with their now unused helpers.
Query and rendering behavior stays covered by the remaining tests.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 29, 2026 01:34
@t-hamano

Copy link
Copy Markdown
Contributor

I have made two changes to this PR. It is ready for re-review.

  • dc0aea5: Resolve conflicts.
  • d218c56: Remove the wp_dashboard_on_this_day_setup function. This is because it is now merely a wrapper for wp_add_dashboard_widget and is deemed to have no further purpose.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

tests/phpunit/tests/admin/wpDashboardOnThisDay.php:103

  • The PR changes how the widget is registered (now directly in wp_dashboard_setup()) and removes the postbox class filter, but there is no test exercising the updated registration path. Adding a small integration-style test that calls wp_dashboard_setup() would cover the regression reported in #65647 (widget always registered/visible via Screen Options, and no hidden postbox filter).

	/**
	 * @ticket 65116
	 *
	 * @covers ::_wp_dashboard_on_this_day_date_query_clause
	 */
	public function test_get_date_query_clause_includes_february_29_on_february_28_in_non_leap_year() {

src/wp-admin/includes/dashboard-on-this-day.php:17

  • Removing wp_dashboard_on_this_day_setup() entirely is a backward-compatibility break for any code that might have called it since it was introduced in 7.1.0. Consider keeping it as a thin wrapper that only registers the widget (without adding any hidden class behavior), so existing callers don’t fatally error while still achieving the “always show” behavior.
/**
 * Renders the On This Day dashboard widget.
 *
 * Outputs the matching posts grouped by publication year, newest year first.
 *
 * @since 7.1.0
 */
function wp_dashboard_on_this_day() {

@joedolson
joedolson self-requested a review July 29, 2026 01:53
@t-hamano

Copy link
Copy Markdown
Contributor

I've been thinking about this, and I'm leaning towards supporting this PR that always displays the On This Day widget.

@m suggested hiding the On This Day widget entirely when there's no content to display. However, implementing this presents some tricky challenges. A significant issue is that the widget might be visually absent, yet its checkbox in the Screen Options would still appear.

image

While we can hide the "On This Day" checkbox within Screen Options, it requires a somewhat convoluted approach.

Furthermore, the current behavior might be perceived as a bug. Please refer to this livestream by Ryan. https://www.twitch.tv/videos/2821389287?t=42m35s

@annezazu @joedolson, I plan to move forward with this PR, what are your thoughts?

@annezazu

Copy link
Copy Markdown

Thanks for surfacing this. I agree in having it always on, both to avoid technical concerns and to prevent confusion around the checkbox problem. I can see how that would be confusing. Since this means the empty state will be more readily visible, perhaps we can spruce it up from this:

Screenshot 2026-07-30 at 1 55 16 PM

For example, here's what site health shows:

Screenshot 2026-07-30 at 1 55 22 PM

Maybe something like this, where we link to "Add post"?

Screenshot 2026-07-30 at 1 57 11 PM

@WordPress/gutenberg-design for any empty state thoughts here :)

@joedolson

Copy link
Copy Markdown
Contributor

I agree with this. Ultimately, hiding it creates a lot of technical problems that are largely unnecessary, and creates a user experience that's potentially confusing.

I feel like the text should be more invitational; something like "You haven't published a post on this day before. Write one now, and be reminded about it next year!"

But I think getting some copy work on this would be good; and we need to nail that down by RC, for translators sakes.

Copilot AI review requested due to automatic review settings July 30, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@joedolson joedolson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Barring polish on the text, I think that this is ready to go. I think it would be fine to commit with the text suggested by @annezazu, and continue to discuss; but if anybody has suggestions on the text that we can land on before RC 1, that would be great.

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.

6 participants