WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 7 days ago

Last modified 7 days ago

#48558 closed enhancement (fixed)

Return the taxonomy object in register_taxonomy()

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:
PR Number:

Description

Background:

  • register_post_type() returns the registered post type object on success, a WP_Error object on error.
  • register_taxonomy() returns nothing on success, a WP_Error object on error.

From a consistency point of view, I think it would make sense for register_taxonomy() to return the registered taxonomy object as well.

Some history, for context:

  • [5525] introduced register_taxonomy().
  • [11998] introduced register_post_type().
  • [12597] introduced a return value for register_post_type(), the $args array at the time.
  • [37890] introduced WP_Post_Type object, and changed register_post_type() return value to that.
  • [38747] introduced WP_Taxonomy object, but not as a register_taxonomy() return value, as it never had one.

Attachments (1)

48558.diff (1016 bytes) - added by krynes 3 months ago.

Download all attachments as: .zip

Change History (5)

@krynes
3 months ago

#1 @krynes
3 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @SergeyBiryukov
7 days ago

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

In 47186:

Taxonomy: In register_taxonomy(), return the registered taxonomy object on success, for consistency with register_post_type().

Props krynes, SergeyBiryukov.
Fixes #48558.

#4 @SergeyBiryukov
7 days ago

In 47187:

Docs: Add a @since note for [47186].

See #48558.

Note: See TracTickets for help on using tickets.