Looks like the menu item setup does run the same function…. wp_setup_nav_menu_item()
that the plugin filters…. However with no possibility of adding a block UI, I wouldn’t think there’s a way to set the properties that I am looking for ( $menu_item->display_mode
and $menu_item->roles
) that I am looking for later when deciding if the item can show or not.
It may be possible to manually code this on a site-by-site basis, but it’s hardly ideal. I tried to start with the following, but for some reason, it’s like it doesn’t run in the FSE and I’m not sure yet why.
/**
* Hard-code settings on the $item object for Nav Menu Roles to interact with.
*/
function kia_wp_setup_nav_menu_item( $menu_item ) {
if ( is_object( $menu_item ) && isset( $menu_item->ID ) ) {
if ( $menu_item->ID === 99 ) {
$menu_item->display_mode = 'show';
$menu_item->roles = array( 'administrator' );
}
}
return $menu_item;
}
add_filter( 'wp_setup_nav_menu_item', 'kia_wp_setup_nav_menu_item', 20 );