Translation Events: Make event end date optional#683
Conversation
Adds an "Ongoing event (no end date)" checkbox so events with no scheduled end (e.g. WordPress Credits Contributions) can be modeled explicitly instead of using a fake far-future end date. Fixes https://meta.trac.wordpress.org/ticket/8280
|
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. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Translation Events plugin to support open-ended events by making the event end date optional, removing the need for placeholder far-future end dates. It updates the domain model, queries, UI rendering, RSS output, and stats import behavior so events without _event_end are treated as “Ongoing”.
Changes:
- Make
Event::$endnullable and addis_open_ended(), with null-safeis_active(),is_past(), andvalidate_times(). - Update repository queries/meta handling so events missing
_event_endappear in current/upcoming listings and can be saved/edited. - Update UI (form, templates, block, RSS, JS/CSS) to support and display “Ongoing” events and avoid misleading end-date rendering.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/wporg-gp-translation-events.php | Makes WP Admin metabox end date optional and deletes _event_end when empty. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/themes/wporg-translate-events-2024/blocks/event-date/index.php | Renders “Ongoing” in the event-date block when open-ended. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/parts/event-list.php | Displays “Ongoing” in event lists and avoids end-date output for open-ended events. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/parts/event-form.php | Adds an “Ongoing event” checkbox and disables end date input when selected. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event-details.php | Shows “Ongoing event (no end date)” on the details page and uses is_past(). |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/routes/event/rss.php | Omits <ev:enddate> for open-ended events. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event.php | Makes end date nullable and updates time/status helpers accordingly. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-repository.php | Includes open-ended events in current/upcoming queries; deletes _event_end when null. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-repository-cached.php | Updates cached “current events” filtering to accept null end. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-form-handler.php | Parses new open-ended flag and allows null end dates on create/edit. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/event/event-capabilities.php | Makes end-edit capability logic null-safe for past checks. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/attendee/attendee-adder.php | Caps stats lookback window for open-ended events to avoid unbounded scans. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/assets/js/translation-events.js | Adds toggle behavior + validation adjustments for open-ended end date field. |
| wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/assets/css/translation-events.css | Styles the new end-date/ongoing toggle UI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <?php if ( $event->end()->is_in_the_past() ) : ?> | ||
| <span class="event-list-date"><?php $print_time( $event->end() ); ?></span> | ||
| <?php else : ?> | ||
| <span class="event-list-date"><?php $print_time( $event->end() ); ?></time></span> |
| $endInput.prop( 'disabled', false ); | ||
| if ( '' === $endInput.val() ) { | ||
| const startVal = $( '#event-start' ).val(); | ||
| if ( startVal ) { | ||
| const start = new Date( startVal ); | ||
| start.setHours( start.getHours() + 1 ); | ||
| const pad = ( n ) => String( n ).padStart( 2, '0' ); | ||
| $endInput.val( | ||
| start.getFullYear() + '-' + pad( start.getMonth() + 1 ) + '-' + pad( start.getDate() ) | ||
| + 'T' + pad( start.getHours() ) + ':' + pad( start.getMinutes() ) | ||
| ); | ||
| } | ||
| } |
| <input type="datetime-local" id="event_start" name="event_start" value="<?php echo esc_attr( $event->start() ); ?>" required><br> | ||
| <label for="event_end">End Date (UTC): </label> | ||
| <input type="datetime-local" id="event_end" name="event_end" value="<?php echo esc_attr( $event->end() ); ?>" required><br> | ||
| <label for="event_end">End Date (UTC, leave empty for ongoing event): </label> | ||
| <input type="datetime-local" id="event_end" name="event_end" value="<?php echo esc_attr( null === $event->end() ? '' : (string) $event->end() ); ?>"><br> |
| $is_open_ended = $event->is_open_ended(); | ||
| $end_value = $is_open_ended ? '' : $event->end()->format( 'Y-m-d H:i' ); | ||
| $can_edit_end = $is_create_form || current_user_can( 'edit_translation_event_end', $event->id() ); |
Generated with Claude Code, initially reviewed by myself.
Summary
Makes the event end date optional, providing a semantically explicit way to model open-ended events (e.g. WordPress Credits Contributions) instead of relying on a fake far-future date.
This is an alternative to #676, which only hides the misleading "Ends: in 9 years" display when the configured end date is more than one year out — the underlying fake 2036 date persists. With this change, organizers can mark events as Ongoing via a checkbox; the end date meta is removed and the UI shows "Ongoing event" instead.
Fixes https://meta.trac.wordpress.org/ticket/8280
Key changes
Event):$endis now?Event_End_Date;is_active(),is_past(),validate_times()are null-safe; newis_open_ended()helper.meta_query_end_after_or_unbounded()is applied to all current/upcoming queries so open-ended events (no_event_endmeta) appear in current/upcoming lists.update_event_meta()deletes_event_endwhen null.get_event_meta()tolerates missing end.has_edit_fieldonly modifies end when the event is past.Attendee_Adder: stats import clamps lookback tomax(start, now − 1 year)for open-ended events to avoid unbounded SELECTs.event-endtheme block render an "Ongoing" label.<ev:enddate>is omitted for open-ended events.requiredremoved and an empty value deletes the meta so admins can edit ongoing events from the WP Admin too.Backward compatibility
All existing events have
_event_endset, so their behavior is unchanged. No migration required.Test plan
_event_endmeta is absent._event_endmeta is deleted. Toggle back: meta is repopulated.end < nowcontinues to appear under Past (regression check)./events/rss) omits<ev:enddate>for open-ended events and remains well-formed.