Skip to main content

SupporterWallController

\Benecaster\REST\SupporterWallController

Class Free

REST controller for the public Supporter Wall endpoint. Exposes GET /shows/{id}/supporter-wall — no authentication required (__return_true). Mirrors the [benecaster_supporter_wall] shortcode’s own query; limit / tier / order query params share the same names and semantics. 404s when the show’s wall is disabled, which callers must treat as distinct from a 200 with an empty items array (wall enabled, nobody has opted in yet). limit defaults to 100 and is always capped at SupporterWallQuery::MAX_LIMIT, regardless of what the caller requests. The message field is always present in the item shape for schema stability, but is returned as '' — even when a stored message exists — whenever the show’s _benecaster_show_supporter_wall_show_why_field toggle is off. token_type is normalised to subscriber or follower via TokenTypeRegistry::resolve_base(); followers are listed alongside paying subscribers and carry a “Follower” badge (source: follower_auto) so a client can present them distinctly.

Constructor Dependencies

Type Description
\Benecaster\SupporterWall\SupporterWallQuery Fetches the roster rows for the show, applying limit/tier/order.
\Benecaster\Avatar\AvatarManager Resolves each listed subscriber's avatar URL.
\Benecaster\Membership\BadgeChipRenderer Serializes each subscriber's badges (tier badges, the Follower chip) to the REST shape.

Methods

Method Visibility Since Description
register_routes(): void Public — Registers GET /shows/{id}/supporter-wall with permission_callback '__return_true' (public) and per-arg validate/sanitize callbacks for id (numeric), limit (absint), tier (sanitize_text_field), and order (sanitize_key).
get_supporter_wall( WP_REST_Request $request ): WP_REST_Response|WP_Error Public — 404 for a missing/zero show id, or when ShowMeta::is_supporter_wall_enabled() is false for the show. Resolves limit (default 100, capped at SupporterWallQuery::MAX_LIMIT), tier (null when empty — no filter), and order (falls back to the show's configured get_supporter_wall_sort_order() unless the request supplies one of ShowMeta::SUPPORTER_WALL_SORT_ORDERS). Fetches rows via SupporterWallQuery::find(), and for each: resolves display name via benecaster_resolve_wall_display_name(), avatar URL, badges (benecaster_get_user_badges() when that function exists, else []), the show-why-gated message, and the normalised token_type. Rows with no resolvable user_id are skipped.

Notes

Extends the plugin's internal RestController base — not part of the public API; its own docblock tells add-on developers not to extend it, and to register independent routes on rest_api_init with the public benecaster_rest_permission_admin() function instead. Inherits register() (hooks register_routes() onto rest_api_init), the permission_callback_admin / permission_callback_editor / permission_callback_subscriber callbacks, rest_error(), and not_found(). This controller does not use permission_callback_* itself — the route is deliberately public.