Log1x / navi

A developer-friendly alternative to the WordPress NavWalker.
https://github.com/Log1x/navi
MIT License
315 stars 30 forks source link

Add type and object properties to menu item stdClass #69

Closed slobich closed 7 months ago

slobich commented 8 months ago

Hey. Great library.

Any chance of adding type and object properties to the list of attributes so they get passed down from the original menu WP_Post object?

I'm working on a project where I need to change the the URL and appearance of links based on their target. I can do most of it by checking the classes property but some of the classes are being removed here so it doesn't cover all of the scenarios. For example if the target is a page the classes property is empty since they get removed since those classes are in the $disallowedClasses property.

I can do a PR but I just wanted to check if this request makes sense to you.

Thnx.

Log1x commented 8 months ago

I don't recall what those properties look like but that should be fine. Feel free to open a PR.

slobich commented 8 months ago

They get added with wp_setup_nav_menu_item() function. They both have info about the actual item the menu item is linking to. For example if the link is for a page the type property will be post_type and the object property will be page.

I'll go ahead with creating a PR and get back to you then.

Thank you.