[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
Sun Dec 28 04:05:25 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 has-patch needs-unit-      |  Resolution:
  tests 2nd-opinion                              |     Focuses:
-------------------------------------------------+-------------------------

Comment (by theMikeD):

 > Also, the `foreach` loop in the patch can be replaced with something
 simpler, like this:
 >
 > `$terms_to_exclude = implode( ', ', array_map( 'absint', array_keys(
 $term_hierarchy ) ) );`

 This seems neither simpler nor clearer to me. Is there a performance issue
 with how it was done in the submitted patch?


 > Finally, I'm not entirely convinced this argument is very useful. It can
 be manually implemented with minimal code:
 >
 > {{{
 > $terms = get_terms( $taxonomy, array(
 >   'exclude' => array_keys( _get_term_hierarchy( $taxonomy ) )
 > ) );
 > }}}

 `_get_term_hierarchy` is marked as a private function. Doesn't that mean
 it shouldn't be used in userland?

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


More information about the wp-trac mailing list