Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending a menu item in the Navigation block #50787

Closed
helgatheviking opened this issue May 19, 2023 · 4 comments
Closed

Extending a menu item in the Navigation block #50787

helgatheviking opened this issue May 19, 2023 · 4 comments
Labels
[Block] Navigation Affects the Navigation Block [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.

Comments

@helgatheviking
Copy link
Contributor

What problem does this address?

I'm the author of Nav Menu Roles which adds allows a site owner to hide/show some menu links depending on the visitor's user role.

In the old nav-menus.php, I do this by adding a user interface into the menu items:
image

But to my knowledge there's currently no way to extend the interface of a menu item in the Navigation block to display/collect additional menu item meta. Meta can already be saved/fetched via API as that was needed to get compatibility with the navigation editor in the Customizer.

What is your proposed solution?

I think some sort of extensibility is needed. How can plugins add their fields here? How can we modify the output, etc?

@mrfoxtalbot
Copy link

Thank you for creating this @helgatheviking.

I suspect this must have come up previously. @getdave, could you confirm if this is already being discussed somewhere else?

@mrfoxtalbot mrfoxtalbot added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience [Block] Navigation Affects the Navigation Block labels May 22, 2023
@mrfoxtalbot
Copy link

If you are not following it already, take a look at this tracking issue #35521 @helgatheviking.

@mrfoxtalbot
Copy link

Also, somehow related to #23745 and #31387.

@ndiego
Copy link
Member

ndiego commented Dec 13, 2023

I was just alerted to this issue. You can add this functionality at the block level using block attributes and a custom UI. Then on the front end, you can use render_block() filter to modify the output of the block. I am doing this with my own Block Visibility plugin, which you could modify to do what you need. All the code is available on GitHub.

Since it is possible to add this functionality, I am going to close this issue, but please let me know if I can answer any additional questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants