Make WordPress Core

Opened 13 years ago

Closed 11 years ago

#23378 closed enhancement (wontfix)

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

Reported by: danielbachhuber's profile danielbachhuber Owned by:
Milestone: 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 13 years ago.
term.php (2.2 KB) - added by joehoyle 13 years ago.
Added unit tests for wp_(update|insert)_term with parent
term.php.diff (2.2 KB) - added by joehoyle 13 years ago.
Added .diff to tests, to try get highlighting

Download all attachments as: .zip

Change History (6)

@joehoyle
13 years ago

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

@joehoyle
13 years ago

Added .diff to tests, to try get highlighting

#1 @danielbachhuber
13 years 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.

#2 @nacin
13 years 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.

#3 @boonebgorges
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

As of WP 4.1, it's possible for terms in different taxonomies to have the same slug, and it's possible that at some point we'll allow terms in the same taxonomy to share slugs as long as the taxonomy is hierarchical and the terms are not siblings. This introduces the possibility of ambiguity when identifying a parent merely by slug. Forcing the plugin author to fetch the term ID (using get_term_by( 'slug' ) or whatever) and then passing the ID to 'parent' makes it so that WP doesn't have to make educated guesses in ambiguous cases. For this reason, I'm marking wontfix.

Note: See TracTickets for help on using tickets.