API / Minn\Runtime / NavMenuItems

NavMenuItems final class

Minn\Runtime\NavMenuItems · public/minn/src/Minn/Runtime/NavMenuItems.php · 154 lines

Classic menu items as the reference serves them to walkers and plugins (probe nav-menu-items). wp_setup_nav_menu_item dresses a nav_menu_item post with the fields walkers read: its _menu_item_* meta (ids as strings), kept when already set; then by its kind the label, address and title of what it points at (a post's title through the_title, every time, the item's own title winning when it has one; a post or term gone, or a post trashed, marks it _invalid; a post not published is labelled by its status); its title attribute and description through their filters. A post or term of another kind is dressed as a would-be item, as the admin's boxes use it: id 0, its own title, address and parent. wp_get_nav_menu_items reads a menu's items through get_posts, sets each up, drops the invalid ones outside the admin, and for ARRAY_A output sorts them by the output key and numbers that key from 1, all before its filter.

Public

staticsetUp(mixed $item): mixed#

wp_setup_nav_menu_item: the item dressed, whatever it was, then the filter.

staticforMenu(WP_Term $menu, array $args): array#

wp_get_nav_menu_items for a menu found.

$argsarray<string, mixed>
@return array<int, object>

Internals 7

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

privatemenuItem(object $item): void#

A nav_menu_item post: its meta, what it points at, its attribute and description.

privatepointsAtPost(object $item): void#

An item for a post: the post type's name (its status's for a post not published), the post's address and filtered title.

privatepointsAtTerm(object $item): void#

An item for a term: the taxonomy's name, the term's address and name.

privatepointsAtArchive(object $item): void#

An item for a post type's archive: the archives label, the archive's address.

privatecustom(object $item, string $url): void#

A custom link: its own title and stored address.

privatepost(object $item): void#

A post of another kind, as a would-be item for it.

privateterm(object $item): void#

A term, as a would-be item for it.