Make WordPress Core


Ignore:
Timestamp:
09/18/2008 10:31:25 PM (16 years ago)
Author:
ryan
Message:

Column hiding for categories. see #7725

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r8930 r8932  
    104104    $category->count = number_format_i18n( $category->count );
    105105    $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
    106     $output = "<tr id='cat-$category->term_id'$class>
    107                <th scope='row' class='check-column'>";
    108     if ( $default_cat_id != $category->term_id ) {
    109         $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
    110     } else {
    111         $output .= "&nbsp;";
    112     }
    113     $output .= "</th>
    114                 <td>$edit</td>
    115                 <td>$category->description</td>
    116                 <td class='num'>$posts_count</td>\n\t</tr>\n";
     106    $output = "<tr id='cat-$category->term_id'$class>";
     107
     108    $columns = get_column_headers('category');
     109    $hidden = (array) get_user_option( 'manage-category-columns-hidden' );
     110    foreach ( $columns as $column_name => $column_display_name ) {
     111        $class = "class=\"$column_name column-$column_name\"";
     112
     113        $style = '';
     114        if ( in_array($column_name, $hidden) )
     115            $style = ' style="display:none;"';
     116
     117        $attributes = "$class$style";
     118
     119        switch ($column_name) {
     120            case 'cb':
     121                $output .= "<th scope='row' class='check-column'>";
     122                if ( $default_cat_id != $category->term_id ) {
     123                    $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
     124                } else {
     125                    $output .= "&nbsp;";
     126                }
     127                $output .= '</th>';
     128                break;
     129            case 'name':
     130                $output .= "<td $attributes>$edit</td>";
     131                break;
     132            case 'description':
     133                $output .= "<td $attributes>$category->description</td>";
     134                break;
     135            case 'posts':
     136                $attributes = 'class="posts column-posts num"' . $style;
     137                $output .= "<td $attributes>$posts_count</td>\n";
     138        }
     139    }
     140    $output .= '</tr>';
    117141
    118142    return apply_filters('cat_row', $output);
Note: See TracChangeset for help on using the changeset viewer.