WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 39 hours ago

#43517 accepted enhancement

Adding support of default category term for custom taxonomies

Reported by: enrico.sorcinelli Owned by: whyisjake
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.1
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

This patch aims to add the support for default category term in custom taxonomies in the same way that is done for built-in taxonomies.

The new default_term argument is added to register_taxonomy() allowing to define the default term name and optionally slug and description. For example:

register_taxonomy( 'custom-tax', 'my-cpt', array(
   'default_term' => array( 'name' => 'My default category', 'slug' => 'default-category' ),
));

This way, by inserting a new my-cpt object without setting any custom-tax terms, the default term 'My default category' will be used for that taxonomy.

The default_taxonomy_{$axonomy} value is used as option_name in order to save default terms id in wp_options.

PS: Apparently, I haven't found any related ticket other than this old one.

Attachments (3)

43517.patch (6.9 KB) - added by enrico.sorcinelli 2 years ago.
43517.2.diff (7.2 KB) - added by davidbaumwald 9 months ago.
Refreshed patch
43517.2.patch (7.0 KB) - added by enrico.sorcinelli 4 weeks ago.

Download all attachments as: .zip

Change History (23)

#1 @mukesh27
2 years ago

  • Keywords has-patch added

#2 @enrico.sorcinelli
2 years ago

  • Keywords has-unit-tests added

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


2 years ago

#4 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 5.0

#5 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#7 @pento
21 months ago

  • Milestone changed from 5.0 to 5.1

#9 @pento
18 months ago

  • Milestone changed from 5.1 to 5.2

#10 @SergeyBiryukov
16 months ago

  • Milestone changed from 5.2 to 5.3

Missed the 5.2 Beta 1 deadline, moving to 5.3.

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


10 months ago

#12 @desrosj
10 months ago

  • Keywords needs-refresh added

43517.patch needs a refresh against current trunk. @SergeyBiryukov are you still up for reviewing this one?

@davidbaumwald
9 months ago

Refreshed patch

#13 @davidbaumwald
9 months ago

  • Keywords needs-refresh removed

@SergeyBiryukov I refreshed the patch an cleaned up a couple of things. Is this something that can be reviewed in time for 5.3 Beta 1 tomorrow or should this have more time for testing?

#14 @davidbaumwald
9 months ago

  • Milestone changed from 5.3 to Future Release

The deadline for version 5.3 Beta 1 enhancements is now passed, so this is being moved to Future Release.

#15 @enrico.sorcinelli
4 weeks ago

I just refreshed my patch for current trunk.

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


3 weeks ago

#17 @whyisjake
3 weeks ago

  • Milestone changed from Future Release to 5.5

#18 @whyisjake
3 weeks ago

  • Owner changed from SergeyBiryukov to whyisjake
  • Status changed from reviewing to accepted

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


39 hours ago

#20 @davidbaumwald
39 hours ago

@whyisjake Is this still on your list to review prior to Beta 1 for 5.5 due to release next week?

Note: See TracTickets for help on using tickets.