Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54267 closed enhancement (fixed)

Allow for custom REST API namespace while register taxonomies

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 5.9 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:


Follow up from #53656

When registering a custom taxonomy, allow developers to define a custom namespace for the REST API, similar to the way they are current register a custom rest_base.

Change History (6)

This ticket was mentioned in PR #1770 on WordPress/wordpress-develop by spacedmonkey.

3 years ago

  • Keywords has-patch added; needs-patch removed

#2 @spacedmonkey
3 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.

3 years ago

#4 @spacedmonkey
3 years ago

  • Owner set to spacedmonkey
  • Status changed from new to assigned

#5 @TimothyBlynJacobs
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 51964:

REST API: Support custom namespaces for taxonomies.

While a taxonomy can define a custom route by using the rest_base argument, a namespace of wp/v2 was assumed. This commit introduces support for a rest_namespace argument.

A new rest_get_route_for_taxonomy_items function has been introduced and the rest_get_route_for_term function updated to facilitate getting the correct route for taxonomies.

For maximum compatibility sticking with the default wp/v2 namespace is recommended until the API functions see wider use.

Props spacedmonkey.
Fixes #54267.
See [51962].

Note: See TracTickets for help on using tickets.