Version 8.9 of the Advanced Sidebar Menu plugin is now available and ready for general use.
Version 8.9 focused on proving a more robust API for working with excluded menu items.
Excluding of Individual Items
From the beginning, it has always been possible to provide a list of excluded ids to the various widgets using filters or settings. This version introduced the ability to target specific ids for exclusion without requiring a list of all excluded.
New Filters
Each widget now has its own filter for excluding an item or cancelling exclusion of an item without filtering the full excluded list.
advanced-sidebar-menu/menus/page/is-excluded
Filter whether an individual page is excluded from the widgets. Used to exclude/include an item outside of the excluded pages settings.
Accepts 5 arguments:
- If the page is excluded.
bool
- Id of the page.
int
- The widget arguments.
array
- The widget values.
array
- The full menu object.
Menu_Abstract
advanced-sidebar-menu/menus/category/is-excluded
Filter whether an individual term is excluded from the widgets. Used to exclude/include an item outside of the excluded category settings.
Accepts 5 arguments:
- If the term is excluded.
bool
- Id of the page.
int
- The widget arguments.
array
- The widget values.
array
- The full menu object.
Menu_Abstract
advanced-sidebar-menu/menus/navigation/is-excluded
Filter whether an individual navigation menu item is excluded from the widgets. Used to exclude/include an item outside of the excluded menu item settings.
Note: A navigation menu item id is not the same as a page or term id.
Accepts 5 arguments:
- If the menu item is excluded.
bool
- Id of the menu item.
int
- The widget arguments.
array
- The widget values.
array
- The full menu object.
Menu_Abstract
New Method
A new Navigation::is_excluded
method has been introduced to allow checking if the navigation item is excluded. When called, the method automatically calculates the type of menu item being checked and honors the corresponding filters and settings.
Navigation Menu Item Improvements
Introduced an Item::get_level
method for retrieving the level of the menu an item resides in. Returns a numeric representation of a level as follows:
- 1: top
- 2: child
- 3: grandchild
- 4: great grandchild
- 5:…. etc.
Added a $levels
parameter to the Item::get_parent
method. Allows retrieval of higher levels of grandparents like so:
- 1: parent
- 2: grandparent
- 3: great-grandparent
- 4: etc….
Introduced an Item::get_parent_id
method. Simple retrieval of the parent menu item’s id.
Miscellaneous
- Made
is_in_current_hierarchy
honor missing parents and menu items. - Tested to WordPress core version 6.0.0.