-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use wp/v2/types and wp/v2/taxonomies responses to determine post type and taxonomy namespaces #8683
Comments
I'm still not convinced Gutenberg should formally support non- Previously #3462 (comment) |
I can appreciate @greatislander's use-case -- we can currently use filters to arbitrarily modify the data returned by core endpoints, and extending the posts controller into a custom class that you manage through its own namespace I see as a beneficial way to reign that in by declaring that a specific filtered response structure should be unchanged at that namespace version. External applications don't have any way to introspect within WP to understand the shape of the content, so it's safer from an integration standpoint to manage your own versioning. Providing that your post type does not override any of the core posts controller functionality that would be needed for use with gutenberg, none of that stuff about versioning should preclude the use of Gutenberg. I like where #2457 is headed, allowing a custom post type with its own controller to opt back in to Gutenberg through supporting the 'block-editor'. From a strictly code-oriented standpoint, I frown on the hard-coding of What I'd like to see come of this is for #2457 to move forward, and for our logic in |
#8682 is related because it's another implicit expectation of functionality that may or may not be available on non- |
Temporary solution for: WordPress/gutenberg#8683
Temporary solution for: WordPress/gutenberg#8683
Closing this for now as |
Is your feature request related to a problem? Please describe.
Currently, there is no way to load post types or taxonomies in namespaces other than
wp/v2
as all PHP and JS functions and methods for loading and saving data via the REST API assume thewp/v2
namespace. This is related to #3462. It also has implications for future-proofing Gutenberg for core entities. In the event that the WordPress REST API bumps to v3 at some point in the future, dozens of files will have to be updated to reflect the new namespaces for each entity (post type or taxonomy).Describe the solution you'd like
In both PHP and JS functions and methods for loading REST API data, the
wp/v2/types
andwp/v2/taxonomies
endpoints are retrieved. These endpoints contain awp:items
link for each entity in the responses’_links
:As per some discussion in #core-restapi, this data in
_links
is the canonical way of getting the namespace for an entity from the REST API.In both the functions I linked above, the
wp/v2/types
andwp/v2/taxonomies
endpoints could be retrieved and used to determine the namespaces for the entities being fetched via the REST API (in fact, thewp/v2/types
response is already used to determine therest_base
inloadPostTypeEntities()
andloadTaxonomyEntities()
functions, so using it to determine the namespace as well would be a fairly straightforward change).Describe alternatives you've considered
There’s no alternative to loading namespaced post types or taxonomies via the REST API that I’m aware of. If there are no objections, I have a branch in progress which will implement this change and I can open a pull request for review.
The text was updated successfully, but these errors were encountered: