API / Minn\Runtime / TermLookup

TermLookup final class

Minn\Runtime\TermLookup · public/minn/src/Minn/Runtime/TermLookup.php · 365 lines

Terms looked up as WordPress's taxonomy functions find them: a list by query arguments, one by a field, whether one exists, a taxonomy's hierarchy, an object's terms, a term's address and one of its fields, its children and ancestors, how many there are, and the caches cleaned after a change; each with the filters plugins hook there.

Public

staticterms(mixed $args = array ( ), mixed $deprecated = ''): mixed#

Terms by query arguments (get_terms), or the old ($taxonomy, $args) shape; an error for an unknown taxonomy; get_terms filters the list unless suppressed (a count never).

staticby(mixed $field, mixed $value, mixed $taxonomy = '', mixed $output = 'OBJECT', mixed $filter = 'raw'): mixed#

A term by slug, name, id or term_taxonomy_id (get_term_by), or false.

staticexists(mixed $term, mixed $taxonomy = '', mixed $parent = NULL): mixed#

Whether a term exists (term_exists): its id (and term_taxonomy_id when a taxonomy is named), or null. Lookup arguments a plugin changes through term_exists_default_query_args are run as a terms query, by slug then by name.

statichierarchy(mixed $taxonomy): array#

A hierarchical taxonomy's parents and their children (_get_term_hierarchy), built from the terms and kept in {taxonomy}_children when not kept yet.

@return array<int, list<int>>
staticdescendants(mixed $termId, mixed $terms, mixed $taxonomy, mixed $ancestors = array ( )): mixed#

Terms below a term among those given (_get_term_children), following only the terms the stored hierarchy says have children; ids for ids.

staticchildren(mixed $termId, mixed $taxonomy): mixed#

Every term below a term (get_term_children), an error for an unknown taxonomy.

staticobjectTerms(mixed $objectIds, mixed $taxonomies, mixed $args = array ( )): mixed#

The terms of objects in taxonomies (wp_get_object_terms), as wp_get_object_terms_args shapes the query and get_object_terms and wp_get_object_terms leave the list.

staticfield(mixed $field, mixed $term, mixed $taxonomy = '', mixed $context = 'display'): mixed#

One of a term's fields in a context (get_term_field): empty when the term has no such field.

staticcount(mixed $args = array ( ), mixed $deprecated = ''): mixed#

How many terms match (wp_count_terms), the old ($taxonomy, $args) shape read too; empty terms counted.

staticlink(mixed $term, mixed $taxonomy = ''): mixed#

A term's address (get_term_link): by its taxonomy's link structure through pre_term_link, a changed one filled with its slug (its ancestors' first when the taxonomy nests), by query without one; then tag_link or category_link, and term_link. An error for no term.

staticancestors(mixed $objectId = 0, mixed $objectType = '', mixed $resourceType = ''): mixed#

An object's ancestors (get_ancestors): a term's parents up the taxonomy, or a post's up its type; as get_ancestors leaves them.

@return array<int, int>
staticpostAncestors(mixed $post): array#

A post's parents up to the top (get_post_ancestors), a loop broken.

@return list<int>
staticcleanCache(mixed $ids, mixed $taxonomy = '', mixed $cleanTaxonomy = true): void#

Terms forgotten after a change (clean_term_cache): each term's cache, its taxonomy's (unless asked not to), then clean_term_cache; with no taxonomy named, each term's own.

staticcleanTaxonomy(mixed $taxonomy): void#

A taxonomy's caches cleaned (clean_taxonomy_cache): its hierarchy rebuilt, the terms' last change moved.

staticqueryLink(Minn\Objects\Term $term): string#

A term's address by query: ?cat= for a category, the taxonomy's query var, else taxonomy and term.

Internals 2

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

privatelookup(string $term, ?string $taxonomy, ?int $parent): ?array#

A term by slug, then by name, under a parent when one is named. @return array<string, mixed>|null

@return array<string, mixed>|null
privatequery(): Minn\Runtime\TermQuery#