BridgeManager
\Benecaster\Bridge\BridgeManager
Responsible for bridge detection, activation, and lookup. Benecaster and add-ons never instantiate bridges directly — they ask BridgeManager for the bridge configured for a given show. When no bridge is configured or the stored slug is unrecognised, get_active_bridge() returns an inert no-op bridge so callers never need to guard against null. Registered as a singleton in the container; access via benecaster_boot.
Bridges are not limited to the built-in set. A third party registers one through the benecaster_bridges filter, and a registered slug behaves exactly like a built-in one.
For reading or setting a show’s bridge, use the functions rather than this class. benecaster_get_active_bridge_slug() and benecaster_set_active_bridge() are the supported route: they work before the container has booted, and branching on which bridge is in use should not require knowing BridgeInterface’s shape. BridgeManager is how Benecaster resolves a bridge; the functions are how you ask which one it is.
BridgeInterface remains the contract you implement — see Integrate a Custom Membership Plugin.
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
get_available_bridges(): array |
Public | — | Returns the bridges that can answer right now. Returns array. For a picker, use get_offered_bridges() instead. Availability comes from the optional available callable on each entry in the benecaster_bridges filter, not from a fixed check. Benecaster's own five defaults happen to use class_exists() / defined() in theirs — that is their implementation, not the rule. An entry with no available callable is always offered, which is the deliberate contract for third-party bridges, since they have no equivalent of Benecaster's per-plugin detection and would otherwise be permanently hidden. This gates the PICKER only. benecaster_set_active_bridge() accepts any registered slug whether or not available returns true. |
get_offered_bridges(): array |
Public | — | Returns the bridges a podcaster can pick: everything get_available_bridges() returns, plus Built-in membership, always first. Returns array. Built-in membership is listed here even before its Stripe keys and first tier exist, so a new site can choose it and finish setting it up afterwards. get_available_bridges() lists it only once both are in place. Use get_offered_bridges() for pickers, and get_available_bridges() for "can this bridge answer right now?". |
get_active_bridge( int $show_id ): BridgeInterface |
Public | — | Returns the configured bridge for a show by reading _benecaster_show_active_bridge post meta. Returns an inert no-op bridge when no bridge is configured or the stored slug is unrecognised. |
set_active_bridge( int $show_id, string $slug ): bool |
Public | — | Persists the active bridge slug for a show in _benecaster_show_active_bridge post meta. Pass an empty string to clear. Returns false for unrecognised slugs. |
get_bridge_by_slug( string $slug ): BridgeInterface |
Public | — | Returns a bridge instance by slug regardless of show context. Used internally by SubscriptionListener to register callbacks on all active bridges at boot. Returns an inert no-op bridge for unknown slugs. |