Ticket #11575: my#11838.patch
File my#11838.patch, 4.6 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 (!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'; … … 769 771 // Get a page worth of tags 770 772 $start = ($page - 1) * $pagesize; 771 773 772 $args = array(' offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);774 $args = array('hide_empty' => 0); 773 775 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 $_term_s = get_terms( $taxonomy, $args ); 782 if (empty($_term_s)) 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 foreach($_term_s as $_term_) { $_term_->_found = true; $_terms[$_term_->term_id] = $_term_; } 785 unset($_term_s, $_term_); 797 786 798 // filter and send to screen 799 echo $out; 800 return $count; 801 } 787 $terms = array_slice($_terms, $start, $pagesize, true); 802 788 803 function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) { 789 $count = count($terms); 804 790 805 $start = ($page - 1) * $per_page; 806 $end = $start + $per_page; 791 if ( is_taxonomy_hierarchical($taxonomy) ) { 792 $children = _get_term_hierarchy($taxonomy); 793 foreach($terms as $term) 794 { 795 $my_parent = $term->parent; 796 if (!$my_parent) continue; 807 797 808 $output = ''; 809 foreach ( $terms as $key => $term ) { 810 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 $my_parent = (isset($_terms[$my_parent])) ? $_terms[$my_parent] : get_term( $my_parent, $taxonomy ); 800 if (!isset($terms[$my_parent->term_id])) $terms[$my_parent->term_id] = $my_parent; 801 $my_parent = $my_parent->parent; 802 } while ( $my_parent ); 837 803 } 804 } 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 (recursivity 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 ); // 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'