From d3c032bc35c44aeec884811b2f4bb8c0242596c6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 29 Jan 2020 02:19:08 +0000 Subject: [PATCH] Dashboard: Improve the appearance of "WordPress Events and News" dashboard widget for multi-day events. If an upcoming event spans over several days, this information is now properly reflected in the widget. Props imath, casiepa, iandunn, hareesh-pillai, melchoyce, mapk, desrosj, audrasjb, SergeyBiryukov. Fixes #47798. Built from https://develop.svn.wordpress.org/trunk@47124 git-svn-id: http://core.svn.wordpress.org/trunk@46924 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-community-events.php | 43 ++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-community-events.php b/wp-admin/includes/class-wp-community-events.php index 8b7acc04ab..1d76b8e30d 100644 --- a/wp-admin/includes/class-wp-community-events.php +++ b/wp-admin/includes/class-wp-community-events.php @@ -376,8 +376,47 @@ class WP_Community_Events { * are available, without having to open the link. */ /* translators: Date format for upcoming events on the dashboard. Include the day of the week. See https://www.php.net/date */ - $response_body['events'][ $key ]['formatted_date'] = date_i18n( __( 'l, M j, Y' ), $timestamp ); - $response_body['events'][ $key ]['formatted_time'] = date_i18n( get_option( 'time_format' ), $timestamp ); + $formatted_date = date_i18n( __( 'l, M j, Y' ), $timestamp ); + $formatted_time = date_i18n( get_option( 'time_format' ), $timestamp ); + + if ( isset( $event['end_date'] ) ) { + $end_timestamp = strtotime( $event['end_date'] ); + $formatted_end_date = date_i18n( __( 'l, M j, Y' ), $end_timestamp ); + + if ( 'meetup' !== $event['type'] && $formatted_end_date !== $formatted_date ) { + /* translators: Upcoming events month format. See https://www.php.net/date */ + $start_month = date_i18n( _x( 'F', 'upcoming events month format' ), $timestamp ); + $end_month = date_i18n( _x( 'F', 'upcoming events month format' ), $end_timestamp ); + + if ( $start_month === $end_month ) { + $formatted_date = sprintf( + /* translators: Date string for upcoming events. 1: Month, 2: Starting day, 3: Ending day, 4: Year. */ + __( '%1$s %2$dā€“%3$d, %4$d' ), + $start_month, + /* translators: Upcoming events day format. See https://www.php.net/date */ + date_i18n( _x( 'j', 'upcoming events day format' ), $timestamp ), + date_i18n( _x( 'j', 'upcoming events day format' ), $end_timestamp ), + /* translators: Upcoming events year format. See https://www.php.net/date */ + date_i18n( _x( 'Y', 'upcoming events year format' ), $timestamp ) + ); + } else { + $formatted_date = sprintf( + /* translators: Date string for upcoming events. 1: Starting month, 2: Starting day, 3: Ending month, 4: Ending day, 5: Year. */ + __( '%1$s %2$d ā€“ %3$s %4$d, %5$d' ), + $start_month, + date_i18n( _x( 'j', 'upcoming events day format' ), $timestamp ), + $end_month, + date_i18n( _x( 'j', 'upcoming events day format' ), $end_timestamp ), + date_i18n( _x( 'Y', 'upcoming events year format' ), $timestamp ) + ); + } + + $formatted_date = wp_maybe_decline_date( $formatted_date, 'F j, Y' ); + } + } + + $response_body['events'][ $key ]['formatted_date'] = $formatted_date; + $response_body['events'][ $key ]['formatted_time'] = $formatted_time; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index ff5a123587..9bd5ad5eb3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-alpha-47123'; +$wp_version = '5.4-alpha-47124'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.