WordPress.org

Make WordPress Core

Opened 15 months ago

Last modified 15 months ago

#23378 new enhancement

wp_(insert|update)_term() should accept term slug as 'parent' argument

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

Description

For those programmatically using wp_insert_term() and wp_update_term(), it would be great if the 'parent' argument could be a term_id or term slug.

Attachments (3)

23378.diff (1.1 KB) - added by danielbachhuber 15 months ago.
term.php (2.2 KB) - added by joehoyle 15 months ago.
Added unit tests for wp_(update|insert)_term with parent
term.php.diff (2.2 KB) - added by joehoyle 15 months ago.
Added .diff to tests, to try get highlighting

Download all attachments as: .zip

Change History (5)

danielbachhuber15 months ago

joehoyle15 months ago

Added unit tests for wp_(update|insert)_term with parent

joehoyle15 months ago

Added .diff to tests, to try get highlighting

comment:1 danielbachhuber15 months ago

We discussed this at dinner the other night and realized where it would break is when the term name (and slug) is an ID.

If this enhancement was of general interest, it would probably be better to go with a new parent_slug argument or similar.

comment:2 nacin15 months ago

In general: we treat an integer as an ID, and a numeric string as a slug. While that could work here, adding this behavior to a function after the fact can result in compatibility issues.

Note: See TracTickets for help on using tickets.