API / Minn\Runtime / Abilities

Abilities final class

Minn\Runtime\Abilities · public/minn/src/Minn/Runtime/Abilities.php · 226 lines

The abilities registry behind WP_Abilities_Registry, WP_Ability_Categories_Registry and the wp_*_ability facade, as the reference keeps it (probes abilities-registry, abilities-classes). The categories init and then the abilities init fire once each, lazily, on the first lookup of their kind, each handed its registry. The registries themselves take a registration at any time; only the wp_register_* functions insist on the init action. A registration is checked as the reference checks it (name shape, duplicates, a known category, then the properties the ability and category classes check) and refused with its notice. An ability's meta gains the default annotations, show_in_rest (public's value when unset) and public.

Uses 1

Constants and properties

privateSTATE = 'abilities'
privateCATEGORIES = 'WP_Ability_Categories_Registry'
privateABILITIES = 'WP_Abilities_Registry'
privateNAME = '/^[a-z0-9-]+\\/[a-z0-9-]+$/'
privateSLUG = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/'
privateANNOTATIONS = array ( 'readonly' => NULL, 'destructive' => NULL, 'idempotent' => NULL, )

Public

staticinitializeCategories(): void#

Fires the categories action once.

staticinitialize(): void#

Fires the categories action, then the abilities action, each once.

staticregisterCategory(string $slug, array $args): ?array#

Registers a category; its row, or null with the reference's notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticregister(string $name, array $args): ?array#

Registers an ability; its row, or null with the reference's notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticunregister(string $name): ?array#

Removes an ability; its row, or null with the reference's notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticunregisterCategory(string $slug): ?array#

Removes a category; its row, or null with the reference's notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticfind(string $name): ?array#

One ability, or null with the reference's notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticability(string $name): ?array#

One ability, or null, asked after without a notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticfindCategory(string $slug): ?array#

One category, or null with the reference's notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticcategory(string $slug): ?array#

One category, or null, asked after without a notice. @return array<string, mixed>|null

@return array<string, mixed>|null
staticall(): array#

Every ability, by name. @return array<string, array>

@return array<string, array>
staticallCategories(): array#

Every category, by slug. @return array<string, array>

@return array<string, array>
staticabilityRefusal(array $args): ?string#

Why an ability's properties are refused, as WP_Ability::prepare_properties says it, or null. @param array<string, mixed> $args

$argsarray<string, mixed>
staticcategoryRefusal(array $args): ?string#

Why a category's properties are refused, as WP_Ability_Category::prepare_properties says it, or null. @param array<string, mixed> $args

$argsarray<string, mixed>
staticmeta(array $meta): array#

An ability's meta with the reference's defaults: the three annotations first, show_in_rest (public's value when unset), then public.

@return array<string, mixed>

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatestate(): array#
@return array{categoriesFired: bool, abilitiesFired: bool, categories: array<string, array>, abilities: array<string, array>}
privatesave(array $state): void#
privateforget(string $key, string $name, string $function, string $notice): ?array#
@return array<string, mixed>|null