Opened 13 years ago
Closed 13 years ago
#25082 closed defect (bug) (wontfix)
register_taxonomy_for_object_type cannot be used with non-post types
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.0 |
| Component: | Taxonomy | Keywords: | has-patch |
| Focuses: | Cc: |
Description
register_taxonomy_for_object_type checks that the object type is a post_type object, and will not let you register the taxonomy for the object type if it is not:
http://core.trac.wordpress.org/browser/trunk/src/wp-includes/taxonomy.php#L475
During discussion with nacin on IRC relating to #11058 he suggesting removing the get_post_type_object check from the new unregister_taxonomy_from_object_type function since it didn't seem to be sensible.
This ticket is open to investigate the restriction in register_taxonomy_for_object_type and see if it can also be removed.
Patch attached in case the collective wisdom decides that it is unnecessary.
Attachments (1)
Change History (4)
#1
@
13 years ago
- Version changed from 3.6 to 3.0
Introduced in [12597] along with the function itself.
#2
@
13 years ago
Which object types do we have in mind? Seems we'd have to make sure that the taxonomy isn't registered for multiple object types that aren't all of the same class ( post | user | whatever ).
#3
@
13 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
On further thought, this function should be limited to post types. I was wrong earlier.
Registering a taxonomy for an object type that isn't a post type is a fairly dangerous affair. If a single taxonomy handles both a post type and a non-post type, you end up with ID conflicts. I'm not sure I can think of a situation where it should be allowed. Removing this check therefore probably isn't prudent — actual assignment of a non-post object type should occur only on registration of the taxonomy.
Wontfix.
Proposed patch