[wp-trac] [WordPress Trac] #15475: Proposed new function: wp_unset_object_terms

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 21 16:47:18 UTC 2012


#15475: Proposed new function: wp_unset_object_terms
---------------------------------+-----------------------------
 Reporter:  simonwheatley        |       Owner:
     Type:  enhancement          |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  Taxonomy             |     Version:
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 3.3-early  |
---------------------------------+-----------------------------

Comment (by nacin):

 Since we have wp_set_object_terms(), I would agree the counterpart should
 be wp_unset_object_terms().

 Whitespace issues aside, I'm curious of some structural aspects.

 The filter in wp_set_object_terms() (and
 wp_delete_object_term_relationships()) is called
 delete_term_relationships, not delete_term_relationship.

 The code at large needs to be abstracted and, overall, DRY. You can see at
 how relatively concise wp_delete_object_term_relationships() is -- it uses
 wp_get_object_terms() and then does the simple delete. The patch tries to
 do too much by emulating wp_get_object_terms(), rather than calling it.

 Likewise, I would think that we could probably get away with
 wp_delete_object_term_relationships() becoming a wrapper for
 wp_unset_object_terms(), and wp_set_object_terms() calling
 wp_unset_object_terms() when it is time to delete the terms that need to
 be deleted. Ideally, delete_term_relationships should only fire once,
 anywhere, not in three places. It demonstrates that our API is properly
 structured.

 Since we are passing around term IDs and need TTIDs, then this full level
 of abstraction may not be necessary or efficient. But maybe someone can
 take a crack at it?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15475#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list