MenuItemMarks final class
Minn\Runtime\MenuItemMarks · public/minn/src/Minn/Runtime/MenuItemMarks.php · 203 lines
The classes and current flags the reference gives a menu's items for the page in view (_wp_menu_item_classes_by_context, probe plugin-queue4), in two passes over the items.
First, each item: its own classes, then menu-item and its type and object; menu-item-home and menu-item-privacy-policy for those pages. On a single post of a flat type, the items of the post's terms in hierarchical taxonomies become its menu parents. Otherwise the current item (the post or term in view, the posts page on the blog, the post type archive in view, or a custom address equal to the request's) is marked, with the page compat tokens; its menu ancestors, its menu parent and its object's parent are noted. A custom item pointing home is the home item on every view. The posts page reads as a parent on any view but a page.
Then each item again: an item for a post or term above the one in view is its ancestor (current-{type}-ancestor), the noted items take current-menu-ancestor and current-menu-parent, an item whose object is a noted parent object current-{object}-parent, and a page item the compat tokens of both.
Public
| static | apply(array $items): array# | The items, each given its classes and its current, current_item_parent and current_item_ancestor flags for what the main query has in view.
@return list<object> |
Internals 7
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | own(object $item, array $view, array $noted, array $parents): void# | The first pass for one item.
| |||||||||
| private | related(object $item, array $view, array $noted): void# | The second pass for one item.
| |||||||||
| private | isCurrent(object $item, array $view): bool# |
| |||||||||
| private | view(WP_Query $query): array# | What the main query has in view, as the two passes read it. @return array<string, mixed> | |||||||||
| private | postTerms(WP_Post $post): array# | A post's terms in its hierarchical taxonomies (the items that read as its menu parents) and, per taxonomy, those terms with their ancestors. @return array{list<int>, array<string, list<int>>} | |||||||||
| private | ancestors(int $id, string $type, string $kind): array# | @return list<int> | |||||||||
| private | currentUrl(): string# |
Nothing matches.