Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?

The problem is that do_shortcode() expects a string in it’s first parameters while wp_nav_menu_objects get’s passed an array of menu objects.

Sou you’d have to write your own wrapper function to do_shortcode, something like this…

function my_nav_menu_objects_shortcode_mangler($items) {
    foreach ($items as $item) {
        $item->classes = explode(' ', do_shortcode(implode(' ', (array)$item->classes)));
    }
    return $items;
}

may work. You’d have to find out about the structure of the nav menu objects ($item) by looking at the source in wp-includes/nav-menu-template.php and then derive which properties best to modify and how (which format they have, how to convert that to a string so you can run a shortcode over it, etc.).

It would appear to me, though, that other means of implementing such logic might be better than hacking shortcode functionality into it.

Also note that using that model you cannot have a shortcode in one property of your menu item and expect it to modify the output of another…like you can’t have a shortcode in your menu item label and hope it adds or removes css classes. Just doesn’t work that way.