Make WordPress Core

Changeset 8936


Ignore:
Timestamp:
09/19/2008 05:31:00 AM (18 years ago)
Author:
ryan
Message:

Column hiding for users. see #7725

Location:
trunk
Files:
4 edited

Legend:

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

    r8933 r8936  
    556556
    557557                        return apply_filters('manage_link_categories_columns', $columns);
     558                case 'user':
     559                        $columns = array(
     560                                'cb' => '<input type="checkbox" />',
     561                                'username' => __('Username'),
     562                                'name' => __('Name'),
     563                                'email' => __('E-mail'),
     564                                'role' => __('Role'),
     565                                'posts' => __('Posts')
     566                        );
     567                        return apply_filters('manage_users_columns', $columns);
    558568        }
    559569
    … …  
    13911401        }
    13921402        $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
    1393         $r = "<tr id='user-$user_object->ID'$style>
    1394                 <th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>
    1395                 <td>$edit</td>
    1396                 <td>$user_object->first_name $user_object->last_name</td>
    1397                 <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
    1398                 <td>$role_name</td>";
    1399         $r .= "\n\t\t<td class='num'>";
    1400         if ( $numposts > 0 ) {
    1401                 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
    1402                 $r .= $numposts;
    1403                 $r .= '</a>';
    1404         } else {
    1405                 $r .= 0;
    1406         }
    1407         $r .= "</td>\n\t</tr>";
     1403        $r = "<tr id='user-$user_object->ID'$style>";
     1404        $columns = get_column_headers('user');
     1405        $hidden = (array) get_user_option( 'manage-user-columns-hidden' );
     1406        foreach ( $columns as $column_name => $column_display_name ) {
     1407                $class = "class=\"$column_name column-$column_name\"";
     1408
     1409                $style = '';
     1410                if ( in_array($column_name, $hidden) )
     1411                        $style = ' style="display:none;"';
     1412
     1413                $attributes = "$class$style";
     1414
     1415                switch ($column_name) {
     1416                        case 'cb':
     1417                                $r .= "<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>";
     1418                                break;
     1419                        case 'username':
     1420                                $r .= "<td $attributes>$edit</td>";
     1421                                break;
     1422                        case 'name':
     1423                                $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
     1424                                break;
     1425                        case 'email':
     1426                                $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
     1427                                break;
     1428                        case 'role':
     1429                                $r .= "<td $attributes>$role_name</td>";
     1430                                break;
     1431                        case 'posts':
     1432                                $attributes = 'class="posts column-posts num"' . $style;
     1433                                $r .= "<td $attributes>";
     1434                                if ( $numposts > 0 ) {
     1435                                        $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
     1436                                        $r .= $numposts;
     1437                                        $r .= '</a>';
     1438                                } else {
     1439                                        $r .= 0;
     1440                                }
     1441                                $r .= "</td>";
     1442                }
     1443        }
     1444        $r .= '</tr>';
     1445
    14081446        return $r;
    14091447}
    … …  
    21822220        foreach ( $columns as $column => $title ) {
    21832221                // Can't hide these
    2184                 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'media' == $column )
     2222                if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column )
    21852223                        continue;
    21862224                if ( empty($title) )
  • trunk/wp-admin/js/users.js

    r7131 r8936  
    1 jQuery( function($) { $('#users').wpList(); } );
     1jQuery( function($) {
     2        $('#users').wpList();
     3
     4        columns.init('user');
     5
     6        // Edit Settings
     7        $('#show-settings-link').click(function () {
     8                $('#edit-settings').slideDown('normal', function(){
     9                        $('#show-settings-link').hide();
     10                        $('#hide-settings-link').show();
     11                       
     12                });
     13                $('#show-settings').addClass('show-settings-opened');
     14                return false;
     15        });
     16       
     17        $('#hide-settings-link').click(function () {
     18                $('#edit-settings').slideUp('normal', function(){
     19                        $('#hide-settings-link').hide();
     20                        $('#show-settings-link').show();
     21                        $('#show-settings').removeClass('show-settings-opened');
     22                });
     23               
     24                return false;
     25        });
     26});
  • trunk/wp-admin/users.php

    r8916 r8936  
    262262
    263263<div class="wrap">
     264
     265<div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Advanced Options') ?></a>
     266<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></a></div>
     267
     268<div id="edit-settings" class="hide-if-js hide-if-no-js">
     269<div id="edit-settings-wrap">
     270<h5><?php _e('Show on screen') ?></h5>
     271<div class="metabox-prefs">
     272<?php manage_columns_prefs('user') ?>
     273<br class="clear" />
     274</div></div>
     275</div>
     276
    264277<form id="posts-filter" action="" method="get">
    265278        <?php if ( $wp_user_search->is_search() ) : ?>
    … …  
    351364<thead>
    352365<tr class="thead">
    353         <th scope="col" class="check-column"><input type="checkbox" /></th>
    354         <th><?php _e('Username') ?></th>
    355         <th><?php _e('Name') ?></th>
    356         <th><?php _e('E-mail') ?></th>
    357         <th><?php _e('Role') ?></th>
    358         <th class="num"><?php _e('Posts') ?></th>
     366<?php print_column_headers('user') ?>
    359367</tr>
    360368</thead>
    … …  
    384392
    385393<?php endif; ?>
    386 
     394<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
    387395</form>
    388396</div>
  • trunk/wp-includes/script-loader.php

    r8923 r8936  
    151151                ) );
    152152                $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20071031' );
    153                 $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20071031' );
     153                $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20080918' );
    154154                $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
    155155                $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20080824' );
    … …  
    167167                        'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
    168168                ) );
    169                 $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' );
     169                $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns'), '20080918' );
    170170                $scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729');
    171171                $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
Note: See TracChangeset for help on using the changeset viewer.