[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 18:47:08 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:  Awaiting Review
Component:  Taxonomy                  |     Version:  4.0
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:
--------------------------------------+------------------------------

Comment (by boonebgorges):

 Thanks for the additional patches, theMikeD.

 I'd like for the unit tests to be a bit more specific. You're testing
 `count()` values, but it's far more accurate (ie less likely to result in
 false positives) if you assemble an array and use `assertEqualSets()`.
 Something like:

 {{{
 $terms = get_terms( $tax, array( 'children_only' => true, 'hide_empty' =>
 false, 'child_of' => $quebec );
 $this->assertEqualSets( array( $montreal ), wp_list_pluck( $terms,
 'term_id' ) );
 }}}

 I also wanted to ask about the parameter name 'children_only'. To me, this
 is a bit misleading: 'children_only' suggests to me that it'll return any
 item that has a 'parent', but what you're *really* querying is items that
 have no children. Something like 'childless' or 'leaf' or 'terminal' seems
 more precise. See
 https://en.wikipedia.org/wiki/Tree_%28data_structure%29#Terminology.

 For documentation - what I mean is the function docblock, though an update
 to the codex will be most welcome as well :)

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


More information about the wp-trac mailing list