From 38e52303afa04d7e78877b4bacf3928a1ef4b2a8 Mon Sep 17 00:00:00 2001 From: Kamran Abdul Aziz Date: Wed, 9 Sep 2026 21:56:28 +0530 Subject: [PATCH] Translation Events: Hide the attendees list on past event pages The event details page lists attendees who pledged to help but did not end up contributing. Once an event is over, showing that list quietly calls out the people who did not show up. This hides the list once the event has ended, in both renderers of the page: the current template and the 2024 block theme renderer, which already shows an event ended notice for past events but still rendered the attendee list after it. The dedicated Manage Attendees page still lists everyone, so hosts can review attendees after an event, and the Contributors section stays as it is since those users did contribute and should stay credited. Adds a test rendering the details route for an active and for a past event, asserting the attendees section is present only while the event is active. The test covers the template renderer path; the block theme path is the same one line gate but is not covered by the suite here. This ports the archived standalone repository's pull request 391 to this repository, refitted to the code as it arrived in the migration. --- .../templates/event-details.php | 2 +- .../routes/Event_Details_Attendees_Test.php | 98 +++++++++++++++++++ .../pages/events/event-details/render.php | 18 ++-- 3 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/tests/routes/Event_Details_Attendees_Test.php 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 b7815f3d48..734993ad90 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 @@ -109,7 +109,7 @@ function ( $host ) { - id() ) ) : ?> + is_past() && current_user_can( 'edit_translation_event', $event->id() ) ) : ?>

event_factory = new Event_Factory(); + + wp_set_current_user( $this->factory->user->create() ); + add_filter( 'gp_translation_events_can_crud_event', '__return_true' ); + } + + /** + * Remove the capability filter. + * + * @return void + */ + public function tearDown(): void { + remove_filter( 'gp_translation_events_can_crud_event', '__return_true' ); + parent::tearDown(); + } + + /** + * The attendees section is shown while the event is active. + * + * @return void + */ + public function test_shows_attendees_for_active_event() { + $event_id = $this->event_factory->create_active( $this->now, array( $this->factory->user->create() ) ); + + $this->assertStringContainsString( 'event-attendees', $this->render_event_details( $event_id ) ); + } + + /** + * The attendees section is hidden once the event has ended. + * + * @return void + */ + public function test_hides_attendees_for_past_event() { + $event_id = $this->event_factory->create_inactive_past( $this->now, array( $this->factory->user->create() ) ); + + $this->assertStringNotContainsString( 'event-attendees', $this->render_event_details( $event_id ) ); + } + + /** + * Render the details route for an event and return the generated HTML. + * + * @param int $event_id Event to render. + * @return string + */ + private function render_event_details( int $event_id ): string { + wp_cache_flush(); + + $route = new Details_Route(); + $route->fake_request = true; + + ob_start(); + $route->handle( get_post( $event_id )->post_name ); + return (string) ob_get_clean(); + } +} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/themes/wporg-translate-events-2024/blocks/pages/events/event-details/render.php b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/themes/wporg-translate-events-2024/blocks/pages/events/event-details/render.php index 9dcd41edff..b979317582 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/themes/wporg-translate-events-2024/blocks/pages/events/event-details/render.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/themes/wporg-translate-events-2024/blocks/pages/events/event-details/render.php @@ -52,17 +52,19 @@ +is_past() ) : ?> +