Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#38439 closed defect (bug) (wontfix)

Should we commit to `wp/v2/taxonomies/post_tag` or switch to `wp/v2/taxonomies/tag` ?

Reported by: danielbachhuber's profile danielbachhuber Owned by: rachelbaker's profile rachelbaker
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords:
Focuses: Cc:

Description

Given we've intentionally gone with wp/v2/tags, should we transform the post_tag slug to tag in the REST API?

Attachments (1)

38439.1.diff (2.9 KB) - added by rachelbaker 9 years ago.
Accept the rest_base as the item path parameter for Taxonomies and Types controllers

Download all attachments as: .zip

Change History (17)

#1 @kadamwhite
9 years ago

I can see arguments for both cases, but given the pains we've taken to standardize naming within the API already, I feel the most internally-consistent option would be to use "tag".

#2 @Braad
9 years ago

+1 for standardizing on "tag"

#3 @rachelbaker
9 years ago

@rmccue @joehoyle This needs a decision for 4.7.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


9 years ago

#5 @jnylen0
9 years ago

Another option would be to use each taxonomy's rest_base here.

  • post_tagtags
  • categorycategories

This is more consistent with the rest of the API in both removing the post_ prefix and in pluralizing tags and categories in most places where they appear.

#6 @jorbin
9 years ago

I like @jnylen0's idea. Let's do it unless someone has a better argument they want to make.


#7 @danielbachhuber
9 years ago

Meant to comment yesterday but not sure where that went. Historically, rest_base was intended for the base route of resources, and singular slugs for identifiers. Posts are /wp/v2/types/post, not /wp/v2/types/posts.

#8 @jnylen0
9 years ago

If we make a change other than post_tagtag here, we should do the same change for /wp/v2/types also.

I like the consistency of using rest_base everywhere, but I agree it looks a bit strange to have wp/v2/taxonomies/tags.

If we don't switch to rest_base, then we should add rest_base as a response property on both the taxonomy and post type items. Currently there's not a way to programmatically link the taxonomy parameters to the term endpoints or the post type items to the corresponding post endpoints.

#9 @jnylen0
9 years ago

We should add rest_base as a response property

We should probably do this regardless of the decision made here. @youknowriad has a patch up at #38607.

#10 @rachelbaker
9 years ago

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

@rachelbaker
9 years ago

Accept the rest_base as the item path parameter for Taxonomies and Types controllers

#11 @rachelbaker
9 years ago

In 38439.1.diff I have a proof of concept for how we can change the item routes for the taxonomies and types controllers to look-up the resources by the rest_base value. This still needs unit tests and testing.

The attached patch would still allow tags to be accessible from their rest_base taxonomies/tags OR the taxonomy name taxonomies/post_tag. This is the part that I don't like... if we were to do this we likely want to return an error if the taxonomy name is used, but a rest_base is set and does not match.

Thoughts @rmccue @joehoyle @jnylen0 @danielbachhuber ?

Last edited 9 years ago by rachelbaker (previous) (diff)

#12 @rachelbaker
9 years ago

  • Keywords has-patch needs-testing needs-unit-tests added
  • Version set to trunk

#13 follow-up: @danielbachhuber
9 years ago

I'm -1 on using rest_base as the slug for taxonomy or post type entities. The original intent of rest_base was to use it as the 'base' for routes, not as an identifier for the resource.

I'm still +1 on changing post_tag to tag, because I think post_tag is an anachronism we can move beyond.

#14 in reply to: ↑ 13 @rachelbaker
9 years ago

I am -1 on having special case handling for just tag. I agree post_tag is ugly, but I don't want to make a special case for it either.

#15 @joehoyle
9 years ago

I'm also -1 on special casing post_tag, that's the taxonomy name - and I think that's what we should stick with. The decision was taken to name the taxonomy that way, so I think it's simpler and more consistent all around if that's it.

#16 @danielbachhuber
9 years ago

  • Keywords dev-feedback has-patch needs-testing needs-unit-tests removed
  • Milestone 4.7 deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed
  • Version trunk deleted

Long live post_tag, forever throughout the universe.

Note: See TracTickets for help on using tickets.