Ticket #11838: my#11838.3.patch
File my#11838.3.patch, 4.3 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/template.php
671 671 * @return unknown 672 672 */ 673 673 function _tag_row( $tag, $level, $class = '', $taxonomy = 'post_tag' ) { 674 675 if ( is_taxonomy_hierarchical($taxonomy) && !isset($tag->_found)) $class .= " style='background-color:#EBEEEF;' "; 674 676 $count = number_format_i18n( $tag->count ); 675 677 if ( 'post_tag' == $taxonomy ) 676 678 $tagsel = 'tag'; … … 774 776 if ( !empty( $searchterms ) ) 775 777 $args['search'] = $searchterms; 776 778 777 // convert it to table rows 778 $out = ''; 779 $count = 0; 780 if ( is_taxonomy_hierarchical($taxonomy) ) { 781 // We'll need the full set of terms then. 782 $args['number'] = $args['offset'] = 0; 779 $children = array(); 783 780 784 $terms = get_terms( $taxonomy, $args ); 785 if ( !empty( $searchterms ) ) // Ignore children on searches. 786 $children = array(); 787 else 788 $children = _get_term_hierarchy($taxonomy); 781 $_terms = get_terms( $taxonomy, $args ); 782 if (empty($_terms)) return false; 789 783 790 // Some funky recursion to get the job done is contained within, Skip it for non-hierarchical taxonomies for performance sake 791 $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count); 792 } else { 793 $terms = get_terms( $taxonomy, $args ); 794 foreach( $terms as $term ) 795 $out .= _tag_row( $term, 0, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 796 } 784 $count = count($_terms); 797 785 798 // filter and send to screen 799 echo $out; 800 return $count; 801 } 786 if ( is_taxonomy_hierarchical($taxonomy) ) { 802 787 803 function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) { 788 $children = _get_term_hierarchy($taxonomy); 804 789 805 $start = ($page - 1) * $per_page;806 $end = $start + $per_page;790 foreach($_terms as $_term) { $_term->_found = true; $terms[$_term->term_id] = $_term; } 791 unset($_terms, $_term); 807 792 808 $output = ''; 809 foreach ( $terms as $key => $term ) { 793 foreach($terms as $term) 794 { 795 $my_parent = $term->parent; 796 if (!$my_parent) continue; 810 797 811 if ( $count >= $end ) 812 break; 813 814 if ( $term->parent != $parent && empty($_GET['s']) ) 815 continue; 816 817 // If the page starts in a subtree, print the parents. 818 if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) { 819 $my_parents = $parent_ids = array(); 820 $p = $term->parent; 821 while ( $p ) { 822 $my_parent = get_term( $p, $taxonomy ); 823 $my_parents[] = $my_parent; 824 $p = $my_parent->parent; 825 if ( in_array($p, $parent_ids) ) // Prevent parent loops. 826 break; 827 $parent_ids[] = $p; 828 } 829 unset($parent_ids); 830 831 $num_parents = count($my_parents); 832 $count -= $num_parents; // Do not include parents in the per-page count, This is due to paging issues with unknown numbers of rows. 833 while ( $my_parent = array_pop($my_parents) ) { 834 $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 835 $num_parents--; 836 } 798 do { 799 if (!isset($terms[$my_parent])) $terms[$my_parent] = get_term( $my_parent, $taxonomy ); 800 $my_parent = $terms[$my_parent]->parent; 801 } while ( $my_parent ); 837 802 } 803 } 804 else $terms = $_terms; 838 805 839 if ( $count >= $start ) 840 $output .= "\t" . _tag_row( $term, $level, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 841 else 842 ++$count; 806 // convert it to table rows (recursion only applies to hierarchies so no performance issue) 807 echo _term_rows($taxonomy, $terms, $children); 843 808 844 unset($terms[$key]); 809 return $count; 810 } 845 811 846 if ( isset($children[$term->term_id]) ) 847 $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 ); 848 } 812 function _term_rows( $taxonomy, &$terms, &$children, $level = 0, $parent = 0 ) { 849 813 850 return $output; 814 $output = ''; 815 foreach ( $terms as $key => $term ) 816 { 817 if ( $parent == $term->parent ) 818 { 819 $output .= _tag_row( $term, $level, '', $taxonomy); // class alternate stuff not supported in crazyhorse ... 820 unset( $terms[ $key ] ); 821 if ( isset($children[$term->term_id]) ) 822 $output .= _term_rows( $taxonomy, $terms, $children, $level + 1, $term->term_id ); 823 } 824 } 825 return $output; 851 826 } 852 827 853 828 // define the columns to display, the syntax is 'internal name' => 'display name'