MetaKeys final class
Minn\Runtime\MetaKeys · public/minn/src/Minn/Runtime/MetaKeys.php · 187 lines
The meta keys code registers, kept where the reference keeps them ($wp_meta_keys: object type => subtype => key => arguments), with what a registration wires up (probe meta-api). A key's sanitize and auth callbacks hang on their filters (with _for_{subtype} for a subtype's key); a key with no auth callback gets __return_true, or __return_false when protected. A default is served through filter_default_metadata. A registration is refused (with the reference's notice) for an array shown in REST without its items' schema, revisions where the type or subtype has none, and, once its callbacks are hooked, a default its schema does not accept. The old form (callbacks as plain arguments) hooks them and returns false.
Constants and properties
| private | DEFAULTS = array ( 'object_subtype' => '', 'type' => 'string', 'label' => '', 'description' => '', 'default' => '', 'single' => false, 'sanitize_callback' => NULL, 'auth_callback' => NULL, 'show_in_rest' => false, 'revisions_enabled' => false, ) |
Public
| static | register(string $objectType, string $key, mixed $args, mixed $deprecated): bool# | Registers a key; true when it joins the registry. | |||
| static | unregister(string $objectType, string $key, string $subtype): bool# | Takes a key out of the registry, and its callbacks off their filters. | |||
| static | of(string $objectType, string $subtype = ''): array# | The keys registered for an object type and subtype ('' for every subtype), in registration order. @return array<string, array<string, mixed>> @return array<string, array<string, mixed>> | |||
| static | forObject(string $objectType, string $subtype): array# | The keys that apply to one object: those for every subtype, then its subtype's. @return array<string, array<string, mixed>> @return array<string, array<string, mixed>> | |||
| static | defaultValue(mixed $value, int $objectId, string $key, bool $single, string $objectType): mixed# | The registered default for a key as filter_default_metadata answers: the one for every subtype, else the object's subtype's; the value handed in when neither registered one. | |||
| static | subtype(string $objectType, int $objectId): string# | The object's subtype: a post's type, a term's taxonomy, comment or user while they exist; '' otherwise. | |||
| static | capabilities(string $capability, int $userId, array $args): ?array# | A meta capability (edit, add or delete a post's, comment's, term's or user's meta) as the reference maps it: what editing the object needs, then the capability itself when the key is not allowed (protected, or refused by its auth filter); nothing for an object that does not exist. Null for any other capability.
@return list<string>|null |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | refusal(string $objectType, string $subtype, array $args): ?string# | Why the reference refuses a registration before hooking anything, or null. @param array<string, mixed> $args
| |||
| private | defaultFits(array $args): bool# | Whether a default fits the key's type, and its REST schema when it has one. @param array<string, mixed> $args
|
Nothing matches.