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

REST API endpoint for Menu Post Types #18373

Open
getdave opened this issue Nov 7, 2019 · 8 comments

Comments

@getdave
Copy link
Contributor

@getdave getdave commented Nov 7, 2019

Currently there is no way to access Menu Post data via the REST API.

This will be required for the enhanced version of the Block placeholder for new Nav Menu Block where you need the option to select from an existing WP Menu. See here for more context.

Describe the solution you'd like
A custom API endpoint in Gutenberg which provides access to data about Menu Post Types.

Describe alternatives you've considered
Asking WP Core to add an endpoint seems unlikely.

@TimothyBJacobs

This comment has been minimized.

Copy link
Member

@TimothyBJacobs TimothyBJacobs commented Nov 7, 2019

@getdave The REST API team has been working on menu endpoints in WP-API/menus-endpoints. Read endpoints are pretty solid. Writes are more a work in progress.

cc @spacedmonkey.

@getdave

This comment has been minimized.

Copy link
Contributor Author

@getdave getdave commented Nov 18, 2019

Thanks @TimothyBJacobs!

@kadamwhite @TimothyBJacobs! Would it be possible for you to raise this in the next REST API chat in Slack?

I'd be interested to learn:

  • How likely it is this will be added to Core REST API?
  • What indicative timelines are available (if any).
  • Whether we've considered adding the endpoint to Gutenberg first as a testing ground?

If possible it would be great if you could update this Issue with the status? I would do this myself but I can't easily attend the 18:00 UTC meeting time.

Very much appreciated.

@spacedmonkey

This comment has been minimized.

Copy link
Contributor

@spacedmonkey spacedmonkey commented Nov 18, 2019

Hi @getdave

I am also work on the REST API team and I worked on the feature plugin WP-API/menus-endpoints. We have working on / discussing this plugin over 6 months in the REST API core chats in slack. This api was written as a plugin, so that other could test it and once ready, it could become a core patch and end up in WP core.

What would really help is if you can install the plugin and play around with it. We need to answer these questions.

Is the data in a workable format for requirements?
Are all required fields in the API?
Do you just need to get data out of the menus or to also create menus ( the plugin does both )?

Once have confirmed this and a need for this API in core, we can start adding polish and unit tests and get it merged in :D

@draganescu

This comment has been minimized.

Copy link
Contributor

@draganescu draganescu commented Nov 20, 2019

@spacedmonkey first, great work! 👍

Second, what is the exact status of the plugin in terms of available data? Are all the endpoints in the plugin's readme file available or is it work in progress?

Third, about the need in core:

a) the navigation block needs to be able to copy existing site menus and transform them into navigation blocks. For that alone we only need reading the available menus and the data of each available menu, by Id.

b) since the block menus are stored like any other block in the post_content, I do not think we need create/update functionality. At least not at this point.

For the last point there is an interesting talk to have about the future of the current WordPress menus as a whole: are they still needed when full site editing arrives? If yes, what for? But We should do that in a separate issue that I am still writing on, slowly ... :P

@getdave

This comment has been minimized.

Copy link
Contributor Author

@getdave getdave commented Nov 20, 2019

I'm intending on installing the Plugin and developing the necessary Gutenberg functionality to create Nav Blocks from existing Menus using the new endpoints it provides. Should be a good test.

@spacedmonkey

This comment has been minimized.

Copy link
Contributor

@spacedmonkey spacedmonkey commented Nov 20, 2019

Is there any chance you could test on this branch. I just remember there a couple of notice error on the current master branch. I will work to get this merged ASAP.

As for the state of the API, we have full CRUD for menus, menu items and menu locations.
There are 2 PRs outstanding from me
Add menu location assignment ( used by themes but not useful for this use case).
Validation - Which fixes a number of known issues and make sure types are correct.

Once these are merged and we have feedback from the community / gutenberg team, we can lock down the format of the API. From there, it is a matter of final tweaks, comments and unit tests added. Then we can port the plugin to a core patch.

Your feedback and input is massively valuable here. If you have issue, do feel free to create issues on the repo.

@getdave

This comment has been minimized.

Copy link
Contributor Author

@getdave getdave commented Dec 3, 2019

I've started testing against this yesterday with a PR to allow Nav Block item creation from existing Menus.

Initially, I found it odd that the /menus endpoint did provide info about the Menu items.

Overall however, it worked 🎉

Will continue iterating on my PR to further stress test.

@spacedmonkey

This comment has been minimized.

Copy link
Contributor

@spacedmonkey spacedmonkey commented Dec 4, 2019

@getdave Now that Validation is merged, can you use master on WP-API/menus-endpoints.

Let me know if you need anymore support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Navigation block
  
🗂 To do
4 participants
You can’t perform that action at this time.