TermLookup final class
Minn\Runtime\TermLookup · public/minn/src/Minn/Runtime/TermLookup.php · 438 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
| static | terms(mixed $args = array ( ), mixed $deprecated = '', ?Closure $answer = NULL): 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). The engine may hand an answer for the query it writes (QueryAnswers). | |||
| static | by(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. As the reference finds one (probe term-lookup): by id through get_term; by the other three through a terms query of one result in no order (the taxonomy left out for a term_taxonomy_id), and the term it finds through get_term again; a slug or name needs a taxonomy that exists and a value. The theme's own term, once its templates are read, and a slug a taxonomy query has just found are answered without the database. | |||
| static | knownByName(string $taxonomy, string $name, ?array $row): void# | A taxonomy's term by name as the engine has read it elsewhere (its row, or none when there is no such term), kept so get_term_by answers its lookup for that name without the database.
| |||
| static | exists(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. | |||
| static | hierarchy(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>> | |||
| static | descendants(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. | |||
| static | children(mixed $termId, mixed $taxonomy): mixed# | Every term below a term (get_term_children), an error for an unknown taxonomy. As the reference walks the stored hierarchy (probe tax-terms): a term's own children, then those of each child that has any, the hierarchy read again for each term walked. | |||
| static | objectTerms(mixed $objectIds, mixed $taxonomies, mixed $args = array ( ), ?Closure $answer = NULL): 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; the engine may hand an answer for its terms query. | |||
| static | field(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. | |||
| static | count(mixed $args = array ( ), mixed $deprecated = ''): mixed# | How many terms match (wp_count_terms), the old ($taxonomy, $args) shape read too; empty terms counted. | |||
| static | link(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. | |||
| static | ancestors(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> | |||
| static | postAncestors(mixed $post): array# | A post's parents up to the top (get_post_ancestors), a loop broken. @return list<int> | |||
| static | cleanCache(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. | |||
| static | cleanTaxonomy(mixed $taxonomy): void# | A taxonomy's caches cleaned (clean_taxonomy_cache): its hierarchy rebuilt, the terms' last change moved. | |||
| static | queryLink(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 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | below(int $termId, string $taxonomy, array $walked): array# | The terms below a term in the stored hierarchy, a term already walked not walked again.
@return list<int> | |||
| private | lookup(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 | |||
| private | query(): Minn\Runtime\TermQuery# |
Nothing matches.