Add On This Day section to Activity widget#66
Conversation
|
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. |
| * in the recently published list is within the past year (minus 1 day). | ||
| */ | ||
| if ( 'published-posts' === $args['id'] && is_int( $time ) | ||
| && $time > ( current_time( 'U' ) - YEAR_IN_SECONDS + ( 1 * DAY_IN_SECONDS ) ) ) { |
There was a problem hiding this comment.
The time condition avoids running the On This Day query if the Recent posts list might already include a post from the same day in a previous year. If the query uses a date range, the number of days in seconds would increase.
| if ( 'published-posts' === $args['id'] && is_int( $time ) | ||
| && $time > ( current_time( 'U' ) - YEAR_IN_SECONDS + ( 1 * DAY_IN_SECONDS ) ) ) { | ||
|
|
||
| $wp_otd_date = current_datetime(); |
There was a problem hiding this comment.
These variable names with otd would need editing, but I was more concerned with making them unique for now.
| ); | ||
|
|
||
| $wp_otd_args = array( | ||
| 'author' => (int) $user_id, |
There was a problem hiding this comment.
Like PR 11630, this limits the posts to any created by (or assigned to) the current user instead of all posts on the site. The argument could be removed, either for the default query or for individual sites with the wp_dashboard_on_this_day_query_args filter.
| /* translators: %s: Post title. */ | ||
| esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), | ||
| $draft_or_post_title | ||
| ); |
There was a problem hiding this comment.
I copied this from lines 1040 to 1052, and changed the date and time to only the date.
As a result, the link is for editing the post if the user has edit access. If the link is for viewing regardless of access, it would have no need for the ARIA label.
| ); | |
| $draft_or_post_title = _draft_or_post_title(); | |
| printf( | |
| '<li><span>%1$s</span> <a href="%2$s">%3$s</a></li>', | |
| $date, | |
| get_permalink(), | |
| $draft_or_post_title | |
| ); |
But then the Recent posts could indicate visually that links in the recent and future lists are for editing, to make the difference clearer.
$draft_or_post_title = _draft_or_post_title();
if ( current_user_can( 'edit_post', get_the_ID() ) ) {
printf(
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
/* translators: 1: Relative date, 2: Time. */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $date, get_the_time() ),
get_edit_post_link(),
/* translators: %s: Post title. */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
'<span class="dashicons dashicons-edit" aria-hidden="true"></span>' . $draft_or_post_title
);
} else {
printf(
'<li><span>%1$s</span> <a href="%2$s">%3$s</a></li>',
/* translators: 1: Relative date, 2: Time. */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $date, get_the_time() ),
get_permalink(),
$draft_or_post_title
);
}
Lists posts published on the same day (or within date range) in previous years, within the Activity widget.
Based on WordPress#11630 by @alshakero
Trac 65116
Use of AI Tools
nothing in addition to the tool used in PR 11630
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.