Terms
Utility methods to work with terms.
Table of Contents
- $term_cache : array<string|int, mixed>
- Cached terms.
- find_term_by_id() : array<string|int, mixed>|null
- Find a term by id in a taxonomy tree.
- get_color() : string
- Get the color of a term.
- get_grouped_taxonomy_tree() : array<string|int, mixed>
- Split a list of hierachical terms into grouped and ungrouped.
- get_taxonomy_hierarchy() : array<string|int, mixed>
- Retrieve taxonomy tree formatted for the frontend submission field's options property.
- get_term_depths() : array<string|int, mixed>
- Get an array of term information, including depth
- get_term_image() : string
- Get the thumbnail ID attached to a term.
- get_terms() : array<string|int, mixed>
- Get terms across all languages (thanks, WPML)
- has_color() : bool
- Check if term has color.
Properties
$term_cache
Cached terms.
public
static array<string|int, mixed>
$term_cache
Methods
find_term_by_id()
Find a term by id in a taxonomy tree.
public
static find_term_by_id(array<string|int, mixed> $terms, string $target_id) : array<string|int, mixed>|null
Parameters
- $terms : array<string|int, mixed>
- $target_id : string
Return values
array<string|int, mixed>|null —get_color()
Get the color of a term.
public
static get_color(string $term_id) : string
Parameters
- $term_id : string
Return values
string —get_grouped_taxonomy_tree()
Split a list of hierachical terms into grouped and ungrouped.
public
static get_grouped_taxonomy_tree(array<string|int, mixed> $terms) : array<string|int, mixed>
Grouped: are terms that have child terms. Ungrouped: are terms that do not have child terms.
This is needed for hierarchy to work for inputs on the frontend.
Parameters
- $terms : array<string|int, mixed>
Return values
array<string|int, mixed> —get_taxonomy_hierarchy()
Retrieve taxonomy tree formatted for the frontend submission field's options property.
public
static get_taxonomy_hierarchy(string $taxonomy, int $parent[, array<string|int, mixed> $include = [] ]) : array<string|int, mixed>
Parameters
- $taxonomy : string
-
the taxonomy to analyze.
- $parent : int
-
the id of the parent term to analyze.
- $include : array<string|int, mixed> = []
-
the term ids to specifically analyze.
Return values
array<string|int, mixed> —get_term_depths()
Get an array of term information, including depth
public
static get_term_depths(string $taxonomy) : array<string|int, mixed>
Parameters
- $taxonomy : string
Return values
array<string|int, mixed> —get_term_image()
Get the thumbnail ID attached to a term.
public
static get_term_image(string $term_id) : string
Parameters
- $term_id : string
Return values
string —get_terms()
Get terms across all languages (thanks, WPML)
public
static get_terms(string $taxonomy) : array<string|int, mixed>
Parameters
- $taxonomy : string
Return values
array<string|int, mixed> —has_color()
Check if term has color.
public
static has_color(string $term_id) : bool
Parameters
- $term_id : string