Skip to content

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

Open
i-am-chitti wants to merge 1 commit 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 1 commit 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

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.

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.

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.

2 participants