Make WordPress Core

Ticket #11575: 11575.patch

File 11575.patch, 5.7 KB (added by arena, 13 years ago)
  • wp-admin/categories.php

     
    238238        </tr>
    239239        </tfoot>
    240240
    241         <tbody id="the-list" class="list:cat">
     241        <tbody id="the-list" class="list:cat categories">
    242242<?php
    243 cat_rows(0, 0, 0, $pagenum, $cats_per_page, $taxonomy);
     243cat_rows($pagenum, $cats_per_page);
    244244?>
    245245        </tbody>
    246246</table>
  • wp-admin/css/colors-classic.dev.css

     
    600600        background-color: #fff;
    601601}
    602602
     603.categories .notfound,
     604.categories .notfound th,
     605.categories .notfound td,
    603606.plugins .inactive,
    604607.plugins .inactive th,
    605608.plugins .inactive td,
  • wp-admin/css/colors-fresh.dev.css

     
    595595        background-color: #fff;
    596596}
    597597
     598.categories .notfound,
     599.categories .notfound th,
     600.categories .notfound td,
    598601.plugins .inactive,
    599602.plugins .inactive th,
    600603.plugins .inactive td,
  • wp-admin/includes/template.php

     
    88 * @subpackage Administration
    99 */
    1010
    11 // Ugly recursive category stuff.
     11// Nice recursive category stuff.
    1212/**
    1313 * {@internal Missing Short Description}}
    1414 *
    1515 * @since unknown
    1616 *
    17  * @param unknown_type $parent
    18  * @param unknown_type $level
    19  * @param unknown_type $categories
    20  * @param unknown_type $page
    21  * @param unknown_type $per_page
     17 * @param numeric $page
     18 * @param numeric $per_page
     19 * @return string
    2220 */
    23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20, $taxonomy = 'category' ) {
     21function cat_rows( $page = 1, $per_page = 20, $taxonomy = 'category' ) {
    2422
    25         $count = 0;
     23        $_cats = $cats = $categories = array();
     24        $args = (!empty($_GET['s'])) ? array('search' => $_GET['s'], 'hide_empty' => 0) : array('hide_empty' => 0);
    2625
    27         if ( empty($categories) ) {
     26        $_cats = get_categories( $args );
     27        foreach ($_cats as $_cat) { $_cat->_found = true; $cats[$_cat->term_id] = $_cat;}
     28        unset($_cats, $_cat);
    2829
    29                 $args = array('hide_empty' => 0, 'taxonomy' => $taxonomy);
    30                 if ( !empty($_GET['s']) )
    31                         $args['search'] = $_GET['s'];
     30        $categories     = array_slice($cats, ($page - 1) * $per_page, $per_page, true);
    3231
    33                 $categories = get_categories( $args );
     32        foreach ($categories as $term_id => $category)
     33        {
     34            $my_parent = $category->parent;
    3435
    35                 if ( empty($categories) )
    36                         return false;
     36                if (!$my_parent) continue;
     37
     38                do {
     39                        $my_parent = (isset($cats[$my_parent])) ? $cats[$my_parent] : get_category( $my_parent );
     40                        if (!isset($categories[$my_parent->term_id])) $categories[$my_parent->term_id] = $my_parent;
     41                        $my_parent    = $my_parent->parent;
     42                } while ( $my_parent );
    3743        }
    3844
    3945        $children = _get_term_hierarchy($taxonomy);
    4046
    41         echo _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );
     47        echo _cat_rows( $categories, $children );
    4248
    4349}
    4450
     
    4753 *
    4854 * @since unknown
    4955 *
    50  * @param unknown_type $categories
    51  * @param unknown_type $count
    52  * @param unknown_type $parent
    53  * @param unknown_type $level
    54  * @param unknown_type $page
    55  * @param unknown_type $per_page
    56  * @return string the output of the table.
     56 * @param array $categories
     57 * @param array $children
     58 * @param numeric       $level
     59 * @param numeric       $parent
     60 * @return string
    5761 */
    58 function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) {
     62function _cat_rows( &$categories, &$children, $level = 0, $parent = 0 ) {
    5963
    60         $start = ($page - 1) * $per_page;
    61         $end = $start + $per_page;
    62 
    6364        $output = '';
    64         foreach ( $categories as $key => $category ) {
    65                 if ( $count >= $end )
    66                         break;
    67 
    68                 if ( $category->parent != $parent && empty($_GET['s']) )
    69                         continue;
    70 
    71                 // If the page starts in a subtree, print the parents.
    72                 if ( $count == $start && $category->parent > 0 ) {
    73 
    74                         $my_parents = array();
    75                         $p = $category->parent;
    76                         while ( $p ) {
    77                                 $my_parent = get_category( $p );
    78                                 $my_parents[] = $my_parent;
    79                                 if ( $my_parent->parent == 0 )
    80                                         break;
    81                                 $p = $my_parent->parent;
    82                         }
    83 
    84                         $num_parents = count($my_parents);
    85                         while( $my_parent = array_pop($my_parents) ) {
    86                                 $output =  "\t" . _cat_row( $my_parent, $level - $num_parents );
    87                                 $num_parents--;
    88                         }
    89                 }
    90 
    91                 if ( $count >= $start )
    92                         $output .= "\t" . _cat_row( $category, $level );
    93 
    94                 unset( $categories[ $key ] );
    95 
    96                 $count++;
    97 
    98                 if ( isset($children[$category->term_id]) )
    99                         $output .= _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );
     65        foreach ( $categories as $key => $category )
     66        {
     67                if ( $parent == $category->parent )
     68                {
     69                        $output .= _cat_row( $category, $level );
     70                        unset( $categories[ $key ] );
     71                        if ( isset($children[$category->term_id]) )
     72                        $output .= _cat_rows( $categories, $children, $level + 1, $category->term_id );
     73                }
    10074        }
    10175
    10276        return $output;
     
    142116                $edit = $name;
    143117        }
    144118
    145         $row_class = 'alternate' == $row_class ? '' : 'alternate';
     119        $row_class = (isset($category->_found)) ? 'found' : 'notfound';
    146120        $qe_data = get_category_to_edit($category->term_id);
    147121
    148122        $category->count = number_format_i18n( $category->count );
     
    193167                                $output .= "</td>";
    194168                }
    195169        }
    196         $output .= '</tr>';
     170        $output .= "</tr>\n";
    197171
    198172        return $output;
    199173}