From a635c159d465f3b1248c468baf0e5e3335cd335f Mon Sep 17 00:00:00 2001
From: Khokan Sardar
Date: Fri, 5 Jun 2026 09:18:09 +0530
Subject: [PATCH 1/2] Translation Events: Hide end date when more than 1 year
in the future
On the event details page, stop displaying the end date and its relative
time (e.g. "Ends: in 9 years") when the end date is more than one year
away. Past end dates and near-future ones are unaffected.
Fixes https://meta.trac.wordpress.org/ticket/8280
---
.../wporg-gp-translation-events/includes/event/event-date.php | 4 ++++
.../wporg-gp-translation-events/templates/event-details.php | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php
index f5d2055032..587f8bfc77 100644
--- a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php
+++ b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php
@@ -62,6 +62,10 @@ public function is_in_the_past() {
return $this->utc() < Translation_Events::now();
}
+ public function is_more_than_one_year_in_the_future(): bool {
+ return $this->utc() > Translation_Events::now()->modify( '+1 year' );
+ }
+
public function print_relative_time_html() {
echo wp_kses(
'
From e8dcbd4944c77673579eab8dcab54d3a33a8a658 Mon Sep 17 00:00:00 2001
From: Khokan Sardar
Date: Fri, 5 Jun 2026 09:50:03 +0530
Subject: [PATCH 2/2] Translation Events: Address code review feedback
- Extract Translation_Events::now() to a variable before calling modify()
to make the immutability explicit and avoid any side-effect ambiguity.
- Store $event->end() in a local $end variable in the event details
template to avoid repeated method calls within the conditional block.
---
.../includes/event/event-date.php | 3 ++-
.../templates/event-details.php | 9 +++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php
index 587f8bfc77..1c70f303cc 100644
--- a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php
+++ b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-date.php
@@ -63,7 +63,8 @@ public function is_in_the_past() {
}
public function is_more_than_one_year_in_the_future(): bool {
- return $this->utc() > Translation_Events::now()->modify( '+1 year' );
+ $now = Translation_Events::now();
+ return $this->utc() > $now->modify( '+1 year' );
}
public function print_relative_time_html() {
diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-details.php b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-details.php
index fcf77f2921..11494ac1dc 100644
--- a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-details.php
+++ b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-details.php
@@ -266,12 +266,13 @@ function ( $contributor ) {
start()->print_relative_time_html(); ?>
start()->print_time_html(); ?>
- end()->is_in_the_past() || ! $event->end()->is_more_than_one_year_in_the_future() ) : ?>
+ end(); ?>
+ is_in_the_past() || ! $end->is_more_than_one_year_in_the_future() ) : ?>
- end()->is_in_the_past() ? __( 'Ended', 'gp-translation-events' ) : __( 'Ends', 'gp-translation-events' ) ); ?>:
- end()->print_relative_time_html(); ?>
+ is_in_the_past() ? __( 'Ended', 'gp-translation-events' ) : __( 'Ends', 'gp-translation-events' ) ); ?>:
+ print_relative_time_html(); ?>
- end()->print_time_html(); ?>
+ print_time_html(); ?>