Commit 7b3e71d862 for wordpress.org
commit 7b3e71d862f565d3371d697ee0306c57fef5e8cd
Author: Weston Ruter <weston@xwp.co>
Date: Sat Jan 17 06:39:34 2026 +0000
Administration: Avoid PHP type error with `gmdate()` in `wp_dashboard_recent_posts()`.
This fixes an issue when a non-integer is returned by `get_the_time( 'U' )` which can occur when a plugin filters `get_the_time`. In this case, the non-relative date is displayed in the Activity dashboard widget.
Developed in https://github.com/WordPress/wordpress-develop/pull/10729
Follow-up to [26690], [26242].
Props sabernhardt, vanhoucke, westonruter.
Fixes #64496.
Built from https://develop.svn.wordpress.org/trunk@61495
git-svn-id: http://core.svn.wordpress.org/trunk@60806 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index cac03b1fe3..6cb0c881f9 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -1014,16 +1014,19 @@ function wp_dashboard_recent_posts( $args ) {
$time = get_the_time( 'U' );
- if ( gmdate( 'Y-m-d', $time ) === $today ) {
- $relative = __( 'Today' );
+ if ( ! is_int( $time ) ) {
+ /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
+ $date = get_the_date( __( 'M jS Y' ) );
+ } elseif ( gmdate( 'Y-m-d', $time ) === $today ) {
+ $date = __( 'Today' );
} elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) {
- $relative = __( 'Tomorrow' );
+ $date = __( 'Tomorrow' );
} elseif ( gmdate( 'Y', $time ) !== $year ) {
/* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
- $relative = date_i18n( __( 'M jS Y' ), $time );
+ $date = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */
- $relative = date_i18n( __( 'M jS' ), $time );
+ $date = date_i18n( __( 'M jS' ), $time );
}
// Use the post edit link for those who can edit, the permalink otherwise.
@@ -1033,7 +1036,7 @@ function wp_dashboard_recent_posts( $args ) {
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' ), $relative, get_the_time() ),
+ sprintf( _x( '%1$s, %2$s', 'dashboard' ), $date, get_the_time() ),
$recent_post_link,
/* translators: %s: Post title. */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
diff --git a/wp-includes/version.php b/wp-includes/version.php
index f4878b94a9..15cff46e40 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61494';
+$wp_version = '7.0-alpha-61495';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.