Skip to content

feat: make Event Details block tense-aware (expose event timing + adapt past-event CTAs)#407

Open
chubes4 wants to merge 1 commit into
mainfrom
tense-aware-timing
Open

feat: make Event Details block tense-aware (expose event timing + adapt past-event CTAs)#407
chubes4 wants to merge 1 commit into
mainfrom
tense-aware-timing

Conversation

@chubes4

@chubes4 chubes4 commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

Closes #406.

The Event Details block (inc/Blocks/EventDetails/render.php) was tense-blind: it knew the start/end datetimes but never derived or exposed whether an event is past / ongoing / upcoming, and its button hooks only passed ($post_id, $ticket_url). Every consumer had to re-query the event-dates table to derive tense itself, and the block rendered a live "Get Tickets" button + a full Add-to-Calendar dropdown even on shows that already happened.

This PR makes the generic layer know and share tense, and makes its own CTAs tense-aware — without introducing any consumer-specific concept.

What changed

Timing states computed

Timing is computed once per render as 'upcoming' | 'ongoing' | 'past', using the canonical public helper — the same source-of-truth logic (start >= now = upcoming, start < now && end >= now = ongoing, else past) already used by the calendar's upcoming/past SQL filters (datamachine_get_event_timing() / UpcomingFilter). No new date-math was invented.

New hook argument (back-compatible)

$timing is now passed as the trailing argument to:

  • data_machine_events_action_buttons(int $post_id, string $ticket_url, string $timing)
  • data_machine_events_after_price_display(int $post_id, string $price, string $timing)

Existing args are preserved. WordPress actions ignore extra args for callbacks registered with a lower accepted-arg count, so every existing 2-arg / 1-arg consumer keeps working unchanged. The bundled Add-to-Calendar callback was bumped from 23 accepted args (with a defaulted $timing = 'upcoming' param) so it can react to tense.

New filters (sensible generic default, overridable)

  • data_machine_events_show_ticket_button (bool $show, int $post_id, string $timing)defaults to false on past, true otherwise. Buying tickets to a finished show is a dead CTA.
  • data_machine_events_show_add_to_calendar (bool $show, int $post_id, string $timing)defaults to false on past, true otherwise.

When a site overrides the ticket button back on for a past event, it renders with an extra ticket-button--past modifier class for de-emphasis styling. The existing data_machine_events_ticket_button_classes filter now also receives $post_id and $timing (additive; 1-arg callbacks unaffected).

Public helper

data_machine_events_get_timing( int $post_id ): string added to inc/public-api.php, delegating to the existing datamachine_get_event_timing(). It matches the rest of the prefixed data_machine_events_* public surface so consumers stop re-querying the dates table to derive tense. Falls back to 'past' if the underlying helper is unavailable.

Back-compat

Fully back-compatible:

  • All existing hook args preserved; new args are trailing-only.
  • Old-arity add_action/add_filter callbacks receive no extra args and keep working.
  • New behavior (hiding CTAs on past) only activates for past timing and is filterable in both directions.

Layer purity

No consumer-specific concepts introduced — grepped the added lines for attendance|concert|my-shows|setlist|import|extrachill and confirmed clean. This layer only knows/shares tense and adapts its own ticket/calendar CTAs; consumer-side composition (attendance-first layouts, etc.) stays in the downstream plugin per the issue.

Verification

  • php -l clean on all three changed PHP files.
  • homeboy lint data-machine-events: phpstan (level 7) passes with 0 findings on the change. The eslint step fails, but it fails identically on clean main and this PR touches zero JS files — pre-existing env/config issue, not introduced here.
  • homeboy test data-machine-events could not run: the runner aborts at "WP Codebox CLI setup" (no candidate passed 'wp-codebox --version') before any test executes — a stale host wrapper, not a code failure. No existing test references the changed hooks, and all changes are additive/back-compatible.

Docs

Updated docs/integration-api.md (new filters, updated action signatures, new helper) and docs/event-details-block.md (new "Tense-Aware Rendering" section).

…t-event CTAs)

The Event Details block was tense-blind: it knew the start/end datetimes but
never derived or exposed whether an event is past/ongoing/upcoming, and its
button hooks forced every consumer to re-query the event-dates table to derive
tense themselves.

- Compute timing once per render via the canonical public helper (same
  source-of-truth logic as the calendar upcoming/past SQL filters).
- Add public helper data_machine_events_get_timing( $post_id ) delegating to
  the existing datamachine_get_event_timing(), matching the prefixed public API.
- Pass $timing as a new trailing arg to data_machine_events_action_buttons and
  data_machine_events_after_price_display (back-compatible; old-arity callbacks
  keep working).
- Suppress the block's own ticket button and Add-to-Calendar dropdown on past
  events by default, via new filterable defaults
  data_machine_events_show_ticket_button / data_machine_events_show_add_to_calendar.
  A past ticket button forced back on gets a ticket-button--past modifier class.

Fully back-compatible and layer-generic (no consumer-specific concepts).

Closes #406
@homeboy-ci

homeboy-ci Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Homeboy Results — data-machine-events

Audit

audit — passed

Deep dive: homeboy audit data-machine-events --changed-since 0da3223

Artifacts and drill-down
  • CI results artifact: homeboy-ci-results-data-machine-events-audit-homeboy-Linux-node24 contains immediate command JSON for this action invocation.
  • Observation artifact: homeboy-observations-data-machine-events-audit-homeboy-Linux-node24 contains exported Homeboy run history for deeper queries.
  • Drill-down: download the observation artifact, then run homeboy runs import <dir>, homeboy runs list, and homeboy runs findings <run-id>.
  • Artifacts are attached to the workflow run: https://github.com/Extra-Chill/data-machine-events/actions/runs/28694829647
Tooling versions
  • Homeboy CLI: homeboy 0.280.13+89fee93c89fb+6f038dd
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 1ae2ab1f
  • Action: Extra-Chill/homeboy-action@v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event Details block is tense-blind: expose event timing + adapt past-event CTA hierarchy

1 participant