Taxonomy
Overview
The Taxonomy module handles taxonomy registration, labels, capabilities, admin menu placement, custom taxonomy meta boxes, term query helpers, and object wrapping for individual terms. Legacy store_user_terms_in_meta behavior has been removed in v6.0 beta.
Types in this module
Lipe\Lib\Taxonomy\CapabilitiesLipe\Lib\Taxonomy\Get_TermsLipe\Lib\Taxonomy\LabelsLipe\Lib\Taxonomy\Meta_BoxLipe\Lib\Taxonomy\TaxonomyLipe\Lib\Taxonomy\Taxonomy_Trait(trait)Lipe\Lib\Taxonomy\Wp_Dropdown_CategoriesLipe\Lib\Taxonomy\Wp_List_CategoriesLipe\Lib\Taxonomy\Wp_Terms_ChecklistLipe\Lib\Taxonomy\Taxonomy\MenuLipe\Lib\Taxonomy\Taxonomy\Register_TaxonomyLipe\Lib\Taxonomy\Meta_Box\Gutenberg_BoxLipe\Lib\Taxonomy\Meta_Box\Radio_Walker
Taxonomy
Primary fluent wrapper for registering a taxonomy and its admin/rest behavior.
Key public methods
public function __construct(string $taxonomy, array $post_types)public function capabilities(): Capabilitiespublic function meta_box(string $type, bool $checked_ontop = false): voidpublic function custom_meta_box(callable|false $callback, callable $sanitize): voidpublic function add_initial_terms(array $terms = []): voidpublic function remove_column(string $column): voidpublic function show_admin_column(string $label = ''): voidpublic function post_list_filter(bool $enabled = true): voidpublic function default_term(string $slug, string $name, string $description = ''): voidpublic function show_in_menu(): Menupublic function show_in_rest(bool $show = true, ?string $base = null, string $space = 'wp/v2', string $controller = \WP_REST_Terms_Controller::class): voidpublic function args(Get_Terms $query_args): voidpublic function description(string $description): voidpublic function hierarchical(bool $is_hierarchical): voidpublic function public(bool $is_public): voidpublic function publicly_queryable(bool $is_queryable): voidpublic function query_var(bool|string $query_var): voidpublic function rewrite(bool|array $rewrite): voidpublic function show_in_nav_menus(bool $show): voidpublic function show_in_quick_edit(bool $show): voidpublic function show_tagcloud(bool $show): voidpublic function show_ui(bool $show): voidpublic function sort(bool $should_short): voidpublic function update_count_callback(callable $update_cb): voidpublic function labels(string $singular = '', string $plural = ''): Labelspublic function show_in_admin_bar(): voidpublic static function get_taxonomy(string $taxonomy): ?static
Example
<?php
use Lipe\Lib\Taxonomy\Taxonomy;
$genre = new Taxonomy('genre', ['book']);
$genre->labels('Genre', 'Genres');
$genre->show_in_rest();
$genre->show_admin_column();
Labels
Fluent builder for taxonomy labels, obtained via Taxonomy::labels().
Key public methods
public function name(string $value): staticpublic function singular_name(string $value): staticpublic function search_items(string $value): staticpublic function popular_items(string $value): staticpublic function all_items(string $value): staticpublic function parent_item(string $value): staticpublic function parent_item_colon(string $value): staticpublic function edit_item(string $value): staticpublic function view_item(string $value): staticpublic function update_item(string $value): staticpublic function add_new_item(string $value): staticpublic function new_item_name(string $value): staticpublic function separate_items_with_commas(string $value): staticpublic function add_or_remove_items(string $value): staticpublic function choose_from_most_used(string $value): staticpublic function not_found(string $value): staticpublic function no_terms(string $value): staticpublic function no_item(string $value): staticpublic function items_list_navigation(string $value): staticpublic function items_list(string $value): staticpublic function most_used(string $value): staticpublic function back_to_items(string $value): staticpublic function menu_name(string $value): staticpublic function desc_field_description(string $value): staticpublic function name_admin_bar(string $value): staticpublic function name_field_description(string $value): staticpublic function parent_field_description(string $value): staticpublic function single_field_description(string $value): staticpublic function filter_by_item(string $value): staticpublic function item_link(string $value): staticpublic function item_link_description(string $value): staticpublic function get_label(string $key): ?stringpublic function get_labels(): array
Capabilities
Fluent builder for taxonomy capabilities, obtained via Taxonomy::capabilities().
Key public methods
public function manage_terms(string $capability = 'manage_categories'): staticpublic function edit_terms(string $capability = 'manage_categories'): staticpublic function delete_terms(string $capability = 'manage_categories'): staticpublic function assign_terms(string $capability = 'edit_posts'): staticpublic function get_cap(string $capability): ?stringpublic function get_capabilities(): array
Get_Terms
Fluent wrapper for the get_terms() argument array, also used as the query type for Taxonomy::args().
Key public methods
public function get_light_args(): arraypublic function __construct(array $existing)public function merge(ArgsRules $overrides): voidpublic function get_args(): array
Get_Terms also implements Query\Clause\Meta_Query_Interface, adding the meta_query() factory documented in the Query module.
Example
<?php
use Lipe\Lib\Taxonomy\Get_Terms;
$terms = new Get_Terms([]);
$terms->taxonomy = 'genre';
$terms->hide_empty = true;
$terms->orderby = Get_Terms::ORDERBY_NAME;
$results = get_terms($terms->get_args());
Meta_Box
Renders a custom taxonomy meta box (radio, dropdown, or simple checklist) on the post editing screen, replacing the WordPress default UI.
Key public methods
public function __construct(string $taxonomy, string $type, bool $checked_ontop)public function replace_default_meta_box(string $post_type, $post): voidpublic function translate_string_term_ids_to_int(string $taxonomy, array|string $terms): arraypublic function do_meta_box(\WP_Post $post): void
Example
<?php
use Lipe\Lib\Taxonomy\Taxonomy;
$genre = new Taxonomy('genre', ['book']);
$genre->meta_box('radio', true);
Taxonomy_Trait trait
Wraps a single WP_Term (by ID or object) so it can be read and lazily hydrated.
Key public methods
public function __construct($term)public function get_object(): ?\WP_Termpublic function get_id(): intpublic function get_meta_type(): MetaTypepublic function exists(): boolpublic static function factory(int|\WP_Term $term): static
Taxonomy_Trait also composes Container\Factory and Meta\Mutator_Trait, which add meta-access helpers such as get_meta(), update_meta(), and delete_meta() — see the Meta module.
Wp_Dropdown_Categories
Fluent argument object for wp_dropdown_categories(). Extends Get_Terms and adds properties such as $show_option_all, $show_option_none, $option_none_value, $show_count, $echo, $depth, $id, $class, $selected, $value_field, $hide_if_empty, $required, and $walker.
Wp_List_Categories
Fluent argument object for wp_list_categories(). Extends Get_Terms and adds properties such as $current_category, $depth, $echo, $feed, $feed_image, $feed_type, $hide_title_if_empty, $separator, $show_count, $show_option_all, $show_option_none, $style, $title_li, $use_desc_for_title, and $walker.
Wp_Terms_Checklist
Fluent argument object for wp_terms_checklist().
Key public methods
public function __construct(array $existing)public function merge(ArgsRules $overrides): voidpublic function get_args(): array
Example
<?php
use Lipe\Lib\Taxonomy\Wp_Terms_Checklist;
$args = new Wp_Terms_Checklist([]);
$args->taxonomy = 'genre';
$args->checked_ontop = true;
wp_terms_checklist($post_id, $args->get_args());
Taxonomy\Menu
Custom admin menu placement for a taxonomy (WordPress does not natively support this). Obtained via Taxonomy::show_in_menu().
Key public methods
public function __construct(Taxonomy $taxonomy)public function sub_menu(string $parent_menu, int $position = 100): voidpublic function parent_menu(string|Dashicons $icon = 'dashicons-category', ?int $position = null): void
Example
<?php
use Lipe\Lib\Taxonomy\Taxonomy;
$genre = new Taxonomy('genre', ['book']);
$genre->show_in_menu()->parent_menu();
Taxonomy\Register_Taxonomy
Fluent argument object for register_taxonomy(), built internally by Taxonomy.
Key public methods
public function args(): Get_Termspublic function __construct(array $existing)public function merge(ArgsRules $overrides): voidpublic function get_args(): array
Meta_Box\Gutenberg_Box
Serializes a taxonomy meta box configuration to JSON so the block editor can render it.
Key public methods
public function load_script(): voidpublic function jsonSerialize(): arraypublic static function get_boxes(): arraypublic static function factory(Meta_Box $box): static
Meta_Box\Radio_Walker
Extends \Walker_Category_Checklist to render taxonomy terms as radio inputs instead of checkboxes.
Key public methods
public function start_el(&$output, $data_object, $depth = 0, $args = [], $current_object_id = 0): voidpublic function end_el(&$output, $data_object, $depth = 0, $args = []): void