Opened 4 months ago

Last modified 3 months ago

#23378 new enhancement

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

Reported by: danielbachhuber Owned by:
Priority: normal Milestone: Awaiting Review
Component: Taxonomy Version:
Severity: normal Keywords: has-patch
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 4 months ago.
term.php (2.2 KB) - added by joehoyle 3 months ago.
Added unit tests for wp_(update|insert)_term with parent
term.php.diff (2.2 KB) - added by joehoyle 3 months ago.
Added .diff to tests, to try get highlighting

Download all attachments as: .zip

Change History (5)

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

Added .diff to tests, to try get highlighting

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.

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.