[wp-trac] Re: [WordPress Trac] #2623: Need hook for admin category list

WordPress Trac wp-trac at lists.automattic.com
Thu Nov 29 17:46:42 GMT 2007


#2623: Need hook for admin category list
----------------------------+-----------------------------------------------
 Reporter:  coppit          |        Owner:  davidhouse
     Type:  defect          |       Status:  reopened  
 Priority:  normal          |    Milestone:  2.3       
Component:  Administration  |      Version:  2.1       
 Severity:  normal          |   Resolution:            
 Keywords:  has-patch       |  
----------------------------+-----------------------------------------------
Changes (by BenDeRydt):

  * status:  closed => reopened
  * type:  enhancement => defect
  * resolution:  fixed =>

Comment:

 Replying to [comment:10 rob1n]:
 > (In [5379]) Apply get_nested_cats filter. Props davidhouse and Nazgul.
 fixes #2623

 This hook is unusable with nested categories. get_nested_categories() is a
 recursive function that traverses the category tree depth-first. The hook
 will be called multiple times, first with the grandchildren, than the
 children and finally the parents.

 '''Testcase:'''
 Create a nested category tree. Add a hook to 'get_nested_categories':
 {{{
 function test_hook_get_nested_category($results) {
      print_r($results);
      return $results;
 }
 }}}
 and look at the output: it will contain lot's of empty arrays, then the
 grandchildren, then the children and finally the whole nested category
 tree.

 '''Solution:'''
 Drop
 {{{
         $result = apply_filters('get_nested_categories', $result);
 }}}
 from the function get_nested_categories()

 and change the function dropdown_categories() to:

 {{{
 function dropdown_categories( $default = 0 ) {
         $result = get_nested_categories( $default );
         $result = apply_filters('get_nested_categories', $result);
         write_nested_categories( $result );
 }
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2623#comment:11>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list