TokenTypeRegistry
\Benecaster\Token\TokenTypeRegistry
The list of token types core knows about, and the rules for how each one behaves. Three are built in: subscriber, follower and purchaser. Add-ons can register more, each declaring a label and which of the two base types it behaves as. Only add-ons register types; there is no podcaster setting.
purchaser is a third built-in but not a base. It behaves as subscriber, so it is resolved by tier and gets no exemption from the licence gate: a purchased feed is not part of the free WordPress.org product, so on a lapsed licence a purchaser is refused like any other paid listener. It ranks below subscriber, so an active membership always controls. Its own rules are not inheritable, so a descriptor declaring behaves_as => 'purchaser' is rejected. Only subscriber and follower can be a base.
An add-on that registered the slug purchaser before it became a built-in now has its descriptor replaced by core’s, as with any core type. Core always wins: the built-ins are re-applied after registration, so an add-on can add a type but never remove or redefine one.
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
all(): array |
Public | — | Every known token type, slug to descriptor (label, behaves_as). Rebuilt on every call rather than cached, so a type registered late is never ignored. |
resolve_base( string $slug ): string |
Public | — | The base a type behaves as, subscriber or follower. A type whose add-on has been deactivated resolves to subscriber, so an orphaned listener keeps the treatment of a paying one rather than losing the feed. |
is_registered( string $slug ): bool |
Public | — | Whether the slug is currently registered or built in. |
label_for( string $slug ): string |
Public | — | The display label for a stored type. An orphaned type falls back to its base's label. |
rank( string $slug ): int |
Public | — | Precedence rank, lowest controlling. An orphaned type ranks as its base, so deactivating an add-on cannot change who controls a token. |
controlling( array $slugs ): ?string |
Public | — | Picks the controlling type from those a person qualifies for, or null for an empty list. Ties break on sorted slug, never on registration order, so activating an unrelated plugin cannot change the answer. |
Constants
| Name | Value | Description |
|---|---|---|
BASES |
[ 'subscriber', 'follower' ] |
The only values a descriptor's behaves_as may take. purchaser is deliberately not one of them. |
BUILT_IN_SLUGS |
[ 'subscriber', 'follower', 'purchaser' ] |
The three types core owns. The reserved slugs core will not let an add-on redefine are identical to this list. |
TYPE_PURCHASER |
'purchaser' |
A listener who bought episodes outright and has no active membership. Behaves as subscriber; ranks below it. |
Notes
Counting is not this class's business. A registered type counts toward the plan's paying limit whenever its tier is paid, whatever it behaves like. The exemptions live in TokenRepository::PAYING_EXEMPT_TOKEN_TYPES and CAP_EXEMPT_TOKEN_TYPES, which are core-owned and cannot be changed by an add-on.