Make WordPress Core

Changeset 8888


Ignore:
Timestamp:
09/14/2008 06:51:42 AM (17 years ago)
Author:
ryan
Message:

Column hiding for links. see #7725

Location:
trunk
Files:
1 added
3 edited

Legend:

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

    r8868 r8888  
    405405
    406406    return $posts_columns;
     407}
     408
     409function wp_manage_links_columns() {
     410    $link_columns = array(
     411        'name'       => __('Name'),
     412        'url'       => __('URL'),
     413        'categories' => __('Categories'),
     414        'rel'      => __('rel'),
     415        'visible'   => __('Visible'),
     416    );
     417
     418    return apply_filters('manage_link_columns', $link_columns);
    407419}
    408420
     
    19711983    elseif ( 'page' == $page )
    19721984        $columns = wp_manage_pages_columns();
     1985    elseif ( 'link' == $page )
     1986        $columns = wp_manage_links_columns();
    19731987    elseif ( 'media' == $page )
    19741988        $columns = wp_manage_media_columns();
     
    19791993    foreach ( $columns as $column => $title ) {
    19801994        // Can't hide these
    1981         if ( 'cb' == $column || 'title' == $column )
     1995        if ( 'cb' == $column || 'title' == $column || 'name' == $column )
    19821996            continue;
    19831997        if ( 'comments' == $column )
  • trunk/wp-admin/link-manager.php

    r8867 r8888  
    3535
    3636wp_enqueue_script('admin-forms');
     37wp_enqueue_script('links');
    3738
    3839wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
     
    9596
    9697<form id="links-filter" action="" method="get">
     98
     99<div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Advanced Options') ?></a>
     100<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></a></div>
     101
     102<div id="edit-settings" class="hide-if-js hide-if-no-js">
     103<div id="edit-settings-wrap">
     104<h5><?php _e('Show on screen') ?></h5>
     105<div class="metabox-prefs">
     106<?php manage_columns_prefs('link') ?>
     107<br class="clear" />
     108</div></div>
     109</div>
     110
    97111<h2><?php printf( __('Links (<a href="%s">Add New</a>)' ), 'link-add.php' ); ?></h2>
    98112
     
    134148
    135149<br class="clear" />
    136 
    137 <?php
    138 $link_columns = array(
    139     'name'       => '<th style="width: 15%;">' . __('Name') . '</th>',
    140     'url'       => '<th>' . __('URL') . '</th>',
    141     'categories' => '<th>' . __('Categories') . '</th>',
    142     'rel'      => '<th style="text-align: center">' . __('rel') . '</th>',
    143     'visible'   => '<th style="text-align: center">' . __('Visible') . '</th>',
    144 );
    145 $link_columns = apply_filters('manage_link_columns', $link_columns);
    146 ?>
    147150
    148151<?php
     
    154157$links = get_bookmarks( $args );
    155158if ( $links ) {
     159    $link_columns = wp_manage_links_columns();
     160    $hidden = (array) get_user_option( 'manage-link-columns-hidden' );
    156161?>
    157162
     
    161166    <tr>
    162167    <th scope="col" class="check-column"><input type="checkbox" /></th>
    163 <?php foreach($link_columns as $column_display_name) {
    164     echo $column_display_name;
    165 } ?>
     168<?php foreach($link_columns as $column_name => $column_display_name) {
     169    $class = " class=\"manage-column column-$column_name\"";
     170    $style = '';
     171    if ( in_array($column_name, $hidden) )
     172        $style = ' style="display:none;"';
     173    if ( 'visible' == $column_name )
     174        $style = empty($style) ? ' style="text-align: center;"' : ' style="text-align: center; display: none;"';
     175?>
     176    <th scope="col"<?php echo "id=\"$column_name\""; echo $class; echo $style ?>><?php echo $column_display_name; ?></th>
     177<?php } ?>
    166178    </tr>
    167179    </thead>
     
    187199        echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
    188200        foreach($link_columns as $column_name=>$column_display_name) {
     201            $class = "class=\"column-$column_name\"";
     202
     203            $style = '';
     204            if ( in_array($column_name, $hidden) )
     205                $style = ' style="display:none;"';
     206            if ( 'visible' == $column_name )
     207                $style = empty($style) ? ' style="text-align: center;"' : ' style="text-align: center; display: none;"';
     208            $attributes = "$class$style";
     209
    189210            switch($column_name) {
    190211                case 'name':
    191212
    192                     echo "<td><strong><a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
     213                    echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
    193214                    $actions = array();
    194215                    $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
     
    204225                    break;
    205226                case 'url':
    206                     echo "<td><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
     227                    echo "<td $attributes><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
    207228                    break;
    208229                case 'categories':
    209                     ?><td><?php
     230                    ?><td <?php echo $attributes ?>><?php
    210231                    $cat_names = array();
    211232                    foreach ($link->link_category as $category) {
     
    222243                    break;
    223244                case 'rel':
    224                     ?><td><?php echo $link->link_rel; ?></td><?php
     245                    ?><td <?php echo $attributes ?>><?php echo $link->link_rel; ?></td><?php
    225246                    break;
    226247                case 'visible':
    227                     ?><td style='text-align: center;'><?php echo $visible; ?></td><?php
     248                    ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
    228249                    break;
    229250                default:
  • trunk/wp-includes/script-loader.php

    r8869 r8888  
    263263        $scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080910' );
    264264        $scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080910' );
     265        $scripts->add( 'links', '/wp-admin/js/links.js', array('columns'), '20080913' );
    265266
    266267        $scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' );
Note: See TracChangeset for help on using the changeset viewer.