[wp-trac] [WordPress Trac] #29839: Enhance get_terms to return only bottom child terms (terms without children) when taxonomy is heirarchical

WordPress Trac noreply at wordpress.org
Sat Nov 15 20:31:07 UTC 2014


#29839: Enhance get_terms to return only bottom child terms (terms without
children) when taxonomy is heirarchical
------------------------------------------------+--------------------------
 Reporter:  theMikeD                            |       Owner:
     Type:  enhancement                         |      Status:  new
 Priority:  normal                              |   Milestone:  Future
Component:  Taxonomy                            |  Release
 Severity:  normal                              |     Version:  4.0
 Keywords:  4.2-early good-first-bug has-patch  |  Resolution:
                                                |     Focuses:
------------------------------------------------+--------------------------

Comment (by boonebgorges):

 Cool, thanks, theMikeD. I think this is pretty close, though I'm going to
 nitpick a little more since 4.1 is in beta so we'll have to wait for 4.2,
 meaning there's no rush.

 * I think the '_terms' part of 'childless_terms' is redundant. (We don't
 say 'parent_term' or 'term_is_child_of', etc.)
 * You got the right place for the docblock :) I don't think it's correct
 to say that 'childless' is the opposite of 'parent', because 'parent'
 takes a term ID and returns only children of the parent, while 'childless'
 doesn't care what part of the taxonomy tree you're in and takes a boolean
 argument.
 * You bail out of the function with an empty array if the taxonomy
 hierarchy is empty. Why? (This is kind of a trick question: a couple other
 parameters do this, and it's not totally obvious why they do it either.)
 If it's intended to save database queries, or prevent false positives, or
 whatever, it would be nice to see a unit test that demonstrates it.
 Alternatively, if that block doesn't affect anything, we should tear it
 out.
 * When you are building the `$exclusions` string, make sure you run each
 item through `intval()` - better safe than sorry when building SQL
 queries.
 * It's spelled "hierarchical" and "hierarchy" :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29839#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list