Skip to content

Commit a79feb4

Browse files
committed
Render date pill only on the header of the postbox (not the title)
1 parent a32a13f commit a79feb4

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

src/wp-admin/css/on-this-day.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Organised as:
55
1. Design tokens (custom properties on the widget root)
66
2. Postbox chrome (#dashboard_on_this_day)
7-
3. Widget title accents (calendar icon + date pill in `.hndle`)
7+
3. Widget title date pill (`.hndle::after`)
88
4. Timeline (year headers, vertical line, post rows)
99
5. Post row (icon circle, title, excerpt, meta row)
1010
6. Empty state
@@ -69,15 +69,16 @@
6969
}
7070

7171
/* -----------------------------------------------------------------------------
72-
3. Widget title (in .hndle)
73-
----------------------------------------------------------------------------- */
74-
.on-this-day-title-main {
75-
display: inline-flex;
76-
align-items: center;
77-
gap: 6px;
78-
}
72+
3. Widget title date pill
7973
80-
.on-this-day-title-date {
74+
The widget is registered with a plain-text title ("On This Day") so that
75+
Screen Options and box-order preferences stay clean. The current date
76+
("F j") is injected into `--otd-today` as a quoted CSS string by PHP and
77+
rendered here as a pseudo-element pill. The `none` fallback keeps the
78+
pseudo-element hidden in contexts where the variable isn't set.
79+
----------------------------------------------------------------------------- */
80+
#dashboard_on_this_day .hndle::after {
81+
content: var(--otd-today, none);
8182
display: inline-block;
8283
margin-left: 10px;
8384
padding: 2px 9px;

src/wp-admin/includes/dashboard.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ function wp_dashboard_setup() {
9696

9797
wp_enqueue_style( 'on-this-day' );
9898

99-
$on_this_day_title = sprintf(
100-
'<span class="on-this-day-title-main dashicons-before dashicons-calendar-alt">%1$s</span><span class="on-this-day-title-date">%2$s</span>',
101-
__( 'On This Day' ),
102-
esc_html( date_i18n( 'F j' ) )
99+
wp_add_inline_style(
100+
'on-this-day',
101+
sprintf(
102+
'#dashboard_on_this_day{--otd-today:%s;}',
103+
wp_json_encode( date_i18n( 'F j' ) )
104+
)
103105
);
104106

105-
wp_add_dashboard_widget( 'dashboard_on_this_day', $on_this_day_title, array( 'WP_On_This_Day', 'render_dashboard_widget' ) );
107+
wp_add_dashboard_widget( 'dashboard_on_this_day', __( 'On This Day' ), array( 'WP_On_This_Day', 'render_dashboard_widget' ) );
106108
}
107109

108110
// WordPress Events and News.

0 commit comments

Comments
 (0)