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.
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_TraitLipe\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 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 labels(string $singular = '', string $plural = ''): Labelspublic static function get_taxonomy(string $taxonomy): ?Taxonomy
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.
Key public methods
public function name(string $value): Labelspublic function singular_name(string $value): Labelspublic function search_items(string $value): Labelspublic function menu_name(string $value): Labelspublic function get_label(string $key): ?stringpublic function get_labels(): array
Capabilities
Fluent builder for taxonomy capabilities.
Key public methods
public function manage_terms(string $capability = 'manage_categories'): Capabilitiespublic function edit_terms(string $capability = 'manage_categories'): Capabilitiespublic function delete_terms(string $capability = 'manage_categories'): Capabilitiespublic function assign_terms(string $capability = 'edit_posts'): Capabilitiespublic function get_cap(string $capability): ?stringpublic function get_capabilities(): array
Query and object helpers
Get_Termsis the fluentget_terms()builder and exposespublic function get_light_args(): arrayplus sharedArgsbehavior.Taxonomy_Traitwraps a singleWP_Termand exposes__construct($term),get_object(),get_id(),get_meta_type(),exists(), andfactory().Wp_Dropdown_Categories,Wp_List_Categories, andWp_Terms_Checklistare fluent arg objects for the corresponding WordPress template functions.
Admin menu and meta-box helpers
Taxonomy\Menumanages custom admin menu placement throughpublic function sub_menu(string $parent_menu, int $position = 100): voidandpublic function parent_menu(string|Dashicons $icon = 'dashicons-category', ?int $position = null): void.Taxonomy\Register_Taxonomyis the fluent argument object forregister_taxonomy()and exposespublic function args(): Get_Terms.Meta_Boxswaps the default taxonomy meta box and exposesreplace_default_meta_box(),translate_string_term_ids_to_int(), anddo_meta_box().Meta_Box\Gutenberg_Boxserializes taxonomy meta-box configuration for the block editor.Meta_Box\Radio_Walkercustomizes term output with radio-button markup.