Make WordPress Core


Ignore:
Timestamp:
09/15/2008 05:53:30 PM (17 years ago)
Author:
ryan
Message:

Column hiding for media library. see #7725

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-attachment-rows.php

    r8682 r8894  
    1313    <tr>
    1414
    15 <?php $posts_columns = wp_manage_media_columns(); ?>
    16 <?php foreach($posts_columns as $post_column_key => $column_display_name) {
     15<?php
     16$posts_columns = wp_manage_media_columns();
     17$hidden = (array) get_user_option( 'manage-media-columns-hidden' );
     18?>
     19<?php foreach ($posts_columns as $post_column_key => $column_display_name ) {
    1720    if ( 'cb' === $post_column_key )
    1821        $class = ' class="check-column"';
    1922    elseif ( 'comments' === $post_column_key )
    20         $class = ' class="num"';
     23        $class = ' class="manage-column column-comments num"';
     24    elseif ( 'modified' === $post_column_key )
     25        $class = ' class="manage-column column-date"';
    2126    else
    22         $class = '';
    23 ?>
    24     <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
     27        $class = " class=\"manage-column column-$post_column_key\"";
     28
     29    $style = '';
     30    if ( in_array($post_column_key, $hidden) )
     31        $style = ' style="display:none;"';
     32?>
     33    <th scope="col"<?php echo "id=\"$post_column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
    2534<?php } ?>
    2635
     
    4554<?php
    4655
    47 foreach($posts_columns as $column_name=>$column_display_name) {
     56foreach ($posts_columns as $column_name => $column_display_name ) {
     57    $class = "class=\"$column_name column-$column_name\"";
     58
     59    $style = '';
     60    if ( in_array($column_name, $hidden) )
     61        $style = ' style="display:none;"';
     62
     63    $attributes = "$class$style";
    4864
    4965    switch($column_name) {
     
    5167    case 'cb':
    5268        ?>
    53         <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
     69        <th scope="row" <?php echo $attributes ?>><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
    5470        <?php
    5571        break;
    5672
    5773    case 'icon':
     74        $attributes = 'class="post-title column-title"' . $style;
    5875        ?>
    5976        <td class="media-icon"><?php
     
    7390    case 'media':
    7491        ?>
    75         <td><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
     92        <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
    7693        <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
    7794        <p>
     
    87104    case 'tags':
    88105        ?>
    89         <td><?php
     106        <td <?php echo $attributes ?>><?php
    90107        $tags = get_the_tags();
    91108        if ( !empty( $tags ) ) {
     
    103120    case 'desc':
    104121        ?>
    105         <td><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
     122        <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
    106123        <?php
    107124        break;
     
    124141        }
    125142        ?>
    126         <td><?php echo $h_time ?></td>
     143        <td <?php echo $attributes ?>><?php echo $h_time ?></td>
    127144        <?php
    128145        break;
     
    137154            }
    138155            ?>
    139             <td><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
     156            <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
    140157            <?php
    141158        } else {
    142159            ?>
    143             <td>&nbsp;</td>
     160            <td <?php echo $attributes ?>>&nbsp;</td>
    144161            <?php
    145162        }
     
    148165
    149166    case 'comments':
    150         ?>
    151         <td class="num"><div class="post-com-count-wrapper">
     167        $attributes = 'class="comments column-comments num"' . $style;
     168        ?>
     169        <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
    152170        <?php
    153171        $left = get_pending_comments_num( $post->ID );
     
    165183    case 'actions':
    166184        ?>
    167         <td>
     185        <td <?php echo $attributes ?>>
    168186        <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php _e('Edit'); ?></a> |
    169187        <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
     
    174192    default:
    175193        ?>
    176         <td><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
     194        <td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
    177195        <?php
    178196        break;
Note: See TracChangeset for help on using the changeset viewer.