feat: add cross-site events-by-artist LIST ability#409
Merged
Conversation
Register data-machine-events/events-by-artist, a cross-site-callable ability that returns the list of events tagged to an artist term on the events site, split into upcoming/past with all presentational strings (title, permalink, venue name, formatted date/time) pre-resolved in events-blog context. Fixes the broken Shows section on the artist site: switch_to_blog() changes DB context but not loaded PHP, so a consumer on another blog cannot call data_machine_events_query_events() directly. The ability is the bridge — it switches to the events blog internally (restore in try/finally) and returns structured data, not markup. Closes #408
Contributor
Homeboy Results —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Registers a new WordPress Ability
data-machine-events/events-by-artistthat returns the LIST of events tagged to an artist term on the events site, split intoupcoming/past, callable from any site regardless of which plugins are locally active.Closes #408. The companion consumer change (rewiring the artist-platform Shows section to call this ability) lives in extrachill-artist-platform.
The bug it fixes
The artist profile hub (artist.extrachill.com, blog 4) added a "Shows" section that called
data_machine_events_query_events()afterswitch_to_blog(events). That silently renders nothing:switch_to_blog()changes the DB context, not the loaded PHP. On the artist site onlyextrachill-artist-platformis active —data-machine-eventsfunctions don't exist there, so thefunction_exists-guarded section shows nothing.The correct cross-site pattern is an Ability (network-registered, callable anywhere), mirroring extrachill-multisite
TaxonomyCountAbilities— but returning an event LIST, not just counts.Input / output shape
Input:
Output — plain structured data, no markup:
Permalinks, titles, venue names, and formatted date/time strings are pre-resolved while still in events-blog context, because the consumer renders on a different blog and cannot resolve them afterward.
How it works
wp_abilities_api_init(with thedid_actionguard the sibling abilities use), categorydatamachine-events-events.switch_to_blog( events blog )internally, paired withrestore_current_blog()in afinallyblock — context never leaks even on error.ec_get_blog_id('events')when available, behind adata_machine_events_events_blog_idfilter so the generic plugin never hard-codes a site ID (keeps layer purity; supports non-EC installs / tests).artistterm by slug, then reads thedatamachine_event_datestable joined toterm_relationships/term_taxonomydirectly via$wpdb, splitting upcoming (start_datetime >= now, ASC) vs past (< now, DESC),post_status = 'publish',LIMITper scope.time_display.Layer purity & standing rules
function_exists('ec_get_blog_id')graceful-degradation guard retained.Verification
homeboy lint— phpstan level 7 passes; the new fileEventsByArtistAbilities.phpproduces zero phpcs findings. (The repo's overall phpcs step is red on pre-existing debt across ~40 unrelated files, including the siblingUpcomingCountAbilities.php; none of it is from this change.)php -lclean on both changed files.homeboy testcould not run: the host's WP Codebox test runner is currently broken (wp-codebox found, but no candidate passed 'wp-codebox --version') — an environment issue, not a test failure. No local vendor PHPUnit is available in the worktree.Build to PR only — no deploy/release, no CHANGELOG edits, no version bumps.