API / Minn\Runtime / Registry

Registry final class

Minn\Runtime\Registry · public/minn/src/Minn/Runtime/Registry.php · 513 lines

Post types, taxonomies, and statuses as plugin code registers and reads them. The built-in set is data/registry.json, captured from the reference; registrations derive their defaults the way the content probe observed (contracts/fixtures/api/content.json).

Constants and properties

privatearray $postTypes
privatearray $taxonomies
privatearray $statuses
propreadonly array $queryVars
propreadonly array $publicQueryVars
privatearray $features
privatearray $postTypeObjects
privatearray $taxonomyObjects
privatereadonly string $engineDir

Promoted from the constructor.

Public

new__construct(string $engineDir)#
methodpostTypes(): array#

Every post type.

@return array<string, array<string, mixed>>
methodpostType(string $name): ?array#

One post type, or null.

methodtaxonomies(): array#

Every taxonomy.

@return array<string, array<string, mixed>>
methodtaxonomy(string $name): ?array#

One taxonomy, or null.

methodshareObjects(): void#

Makes the one object for each registered type and taxonomy and binds $wp_post_types and $wp_taxonomies to them, as the reference shares them: a plugin changing one (relabelling Posts) is heard by every reader (probe type-object-sharing). Called once the facade classes exist; later registrations make their own.

methodpostTypeObject(string $name): ?WP_Post_Type#

The one object for a registered post type, or null.

methodpostTypeObjects(): array#

The objects of every registered post type, in registration order.

@return array<string, \WP_Post_Type>
methodtaxonomyObject(string $name): ?WP_Taxonomy#

The one object for a registered taxonomy, or null.

methodtaxonomyObjects(): array#

The objects of every registered taxonomy, in registration order.

@return array<string, \WP_Taxonomy>
methodstatuses(): array#

Every post status.

@return array<string, array<string, mixed>>
methodstatus(string $name): ?array#

One post status, or null.

methodtranslateBuiltIns(): void#

The built-in types', taxonomies' and statuses' labels in the site's language, as the reference registers them again on init: each label asks for its own message (data/registry-labels.json, captured from the reference), and a type's single-item template and a taxonomy's archive template are named after the singular name. Rows and the shared objects both take them; what a plugin set before init gives way, as it does there.

methodadoptPostType(WP_Post_Type $object): array#

Takes a built post type as the registered one: the object register_post_type made is the one every reader shares, and its properties are the type's row. Registering again puts a new object in the old one's place, as on the reference.

@return array<string, mixed>
methodlabels(array $labels, ?string $label, string $base, string $name): array#

A type's labels from its own (probe post-remaining): the labels of its base type (page for a hierarchical type, post for any other) under the type's own. A missing name comes from the type's label, a missing singular name from the name, the menu name from the name, all items from the menu name, archives from all items, and the admin bar name from the singular name or else the type's name; a type with a singular name also names its single-item template.

$labelsarray<string, mixed>
@return array<string, mixed>
methodtaxonomyLabels(array $labels, ?string $label, string $base, string $name): array#

A taxonomy's labels from its own (probe taxonomy-remaining): derived as a type's are, under the category labels for a hierarchical taxonomy or the tag labels for any other; one that names no template takes "%s Archives" with the singular name it ends up with.

$labelsarray<string, mixed>
@return array<string, mixed>
staticcapabilities(array|string $capabilityType, array $overrides, bool $mapMetaCap): array#

A type's capability names (probe post-remaining): the eight primitive ones, the six more a mapped type uses, the type's own names merged over them, and create_posts last, the edit capability unless named.

$overridesarray<string, string>
@return array<string, string>
methodunregisterPostType(string $name): bool#

Forgets a non-builtin post type.

methodaddSupport(string $type, string $feature, array $args): void#

Adds a feature to a type, registered or not: the reference keeps features apart from the type objects, so declaring one does not make the type exist. A feature with arguments keeps all of them.

$argslist<mixed>
methodremoveSupport(string $type, string $feature): void#

Removes a feature from a post type.

methodremoveSupports(string $type): void#

Removes every feature of a post type.

methodsupports(string $type): array#

The features a post type supports.

@return array<string, mixed> feature => true or the arguments given
methoddefaultLabels(string $plain, string $hierarchical): array#

The default labels of a family as label => [the plain one's, the hierarchical one's]: post and page for types, tag and category for taxonomies, from the built-in data (WP_Post_Type::get_default_labels).

@return array<string, array{0: mixed, 1: mixed}>
methodadoptTaxonomy(WP_Taxonomy $object): array#

Takes a built taxonomy as the registered one, the object every reader shares, its properties the taxonomy's row.

@return array<string, mixed>
staticsettlesRewrites(): bool#

Whether a registered rewrite settles into its full form: with pretty permalinks or in the admin; otherwise it stays as given.

methodunregisterTaxonomy(string $name): bool#

Forgets a non-builtin taxonomy.

methodaddObjectType(string $taxonomy, string $type): bool#

Attaches a taxonomy to a post type.

methodremoveObjectType(string $taxonomy, string $type): bool#

Detaches a taxonomy from a post type.

methodregisterStatus(string $name, array $args): array#

Registers a post status.

$argsarray<string, mixed>

Internals 3

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

privaterowOf(object $object, array $without): array#

An object's properties as a row, its labels and capabilities as arrays.

$withoutlist<string>
@return array<string, mixed>
privateobjectFrom(string $class, array $row): object#

An object of the class holding a row as registration left it, without building it again (no filters, no defaults): the built-in types and taxonomies. A built-in type's supports were taken in, so its object has none of its own.

$classclass-string<T>
$rowarray<string, mixed>
privatederivedLabels(array $labels, ?string $label, string $name): array#

The labels a type or taxonomy gets from its own: a missing name from its label, a missing singular name from the name, the menu name from the name, all items from the menu name, archives from all items, and the admin bar name from the singular name or else its own name.

$labelsarray<string, mixed>
@return array<string, mixed>