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

Closed
getdave opened this issue Nov 7, 2019 · 9 comments
Closed

REST API endpoint for Menu Post Types #18373

getdave opened this issue Nov 7, 2019 · 9 comments
Assignees
Labels
[Block] Navigation Affects the Navigation Block Core REST API Task Task for Core REST API efforts REST API Interaction Related to REST API

Comments

@getdave
Copy link
Contributor

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.

@getdave getdave added the [Block] Navigation Affects the Navigation Block label Nov 7, 2019
@getdave getdave self-assigned this Nov 7, 2019
@TimothyBJacobs TimothyBJacobs added REST API Interaction Related to REST API Core REST API Task Task for Core REST API efforts labels Nov 7, 2019
@TimothyBJacobs
Copy link
Member

@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
Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Member

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

Let me know if you need anymore support.

@draganescu
Copy link
Contributor

Hey everyone!

Now that the master branch of the WP-API/menus-endpoints feature plugin contains what is needed for the navigation block to be developed further, I believe that all the problems, issues and suggestions should be tracked in the WP-API/menus-endpoints repository, until core has them integrated, and Trac afterwards.

In light of the above I will close this issue in order to avoid duplicate issues in different repositories.

Thank you 🌮

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 Core REST API Task Task for Core REST API efforts REST API Interaction Related to REST API
Projects
None yet
Development

No branches or pull requests

4 participants