Add @menu, @hasmenu and @endhasmenu #147
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I love using your directives in blade files, but this one was missing for a while and I was initially debating about its utility, but I find myself not using Navi on smaller projects but hate using @php or passing ['echo' => false] in the arguments just to have those ugly exclamation brackets to echo it {!! !!}.
Conversations could be had about having @menu be smarter and do the "has_nav_menu" automatically which is the "normally expected behavior" (the nav location you call doesn't have anything = don't show anything), but in reality WordPress acquainted people could be thrown off by this since wp_nav_menu does some internal checks to always have something output in the navigation when the location has nothing in it like displaying the website's pages when no menu location has been set, thus allowing people to preview themes more easily. And so, I ended up deciding against it to keep this simple, but you be the final judge!
Tested locally on a real project, PHP 8.2, WordPress 6.5.
Thanks for looking at this.