WordPress.org

Make WordPress Core

Opened 11 months ago

Last modified 8 months ago

#45166 new enhancement

Prevent deleting default term for any kind of taxonomy

Reported by: ediamin Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

Right now wp_delete_term doesn't have any check point to prevent deleting default term for a taxonomy except category. For example, WooCommerce introduced default_product_cat from v3.3.0. Though, it is not possible to delete this default product category from admin panel, but one can delete this term programmatically or with REST API. There is no hook to prevent this. We have to manually check every time before deleting a term.

So, I propose a change in wp_delete_term function to prevent deleting default term for any kind of taxonomy if we have an option default_{$taxonomy} set in options table.

Attachments (1)

45166.diff (768 bytes) - added by ediamin 11 months ago.
Proposed changes in wp_delete_term function

Download all attachments as: .zip

Change History (3)

@ediamin
11 months ago

Proposed changes in wp_delete_term function

#2 @pento
8 months ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.