Column hiding for users. see #7725
git-svn-id: https://develop.svn.wordpress.org/trunk@8936 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b614b17c96
commit
e954fdab6c
|
@ -555,6 +555,16 @@ function get_column_headers($page) {
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters('manage_link_categories_columns', $columns);
|
return apply_filters('manage_link_categories_columns', $columns);
|
||||||
|
case 'user':
|
||||||
|
$columns = array(
|
||||||
|
'cb' => '<input type="checkbox" />',
|
||||||
|
'username' => __('Username'),
|
||||||
|
'name' => __('Name'),
|
||||||
|
'email' => __('E-mail'),
|
||||||
|
'role' => __('Role'),
|
||||||
|
'posts' => __('Posts')
|
||||||
|
);
|
||||||
|
return apply_filters('manage_users_columns', $columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
|
@ -1390,21 +1400,49 @@ function user_row( $user_object, $style = '', $role = '' ) {
|
||||||
$edit = '<strong>' . $user_object->user_login . '</strong>';
|
$edit = '<strong>' . $user_object->user_login . '</strong>';
|
||||||
}
|
}
|
||||||
$role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
|
$role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
|
||||||
$r = "<tr id='user-$user_object->ID'$style>
|
$r = "<tr id='user-$user_object->ID'$style>";
|
||||||
<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>
|
$columns = get_column_headers('user');
|
||||||
<td>$edit</td>
|
$hidden = (array) get_user_option( 'manage-user-columns-hidden' );
|
||||||
<td>$user_object->first_name $user_object->last_name</td>
|
foreach ( $columns as $column_name => $column_display_name ) {
|
||||||
<td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
|
$class = "class=\"$column_name column-$column_name\"";
|
||||||
<td>$role_name</td>";
|
|
||||||
$r .= "\n\t\t<td class='num'>";
|
$style = '';
|
||||||
if ( $numposts > 0 ) {
|
if ( in_array($column_name, $hidden) )
|
||||||
$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
|
$style = ' style="display:none;"';
|
||||||
$r .= $numposts;
|
|
||||||
$r .= '</a>';
|
$attributes = "$class$style";
|
||||||
} else {
|
|
||||||
$r .= 0;
|
switch ($column_name) {
|
||||||
|
case 'cb':
|
||||||
|
$r .= "<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>";
|
||||||
|
break;
|
||||||
|
case 'username':
|
||||||
|
$r .= "<td $attributes>$edit</td>";
|
||||||
|
break;
|
||||||
|
case 'name':
|
||||||
|
$r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
|
||||||
|
break;
|
||||||
|
case 'email':
|
||||||
|
$r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
|
||||||
|
break;
|
||||||
|
case 'role':
|
||||||
|
$r .= "<td $attributes>$role_name</td>";
|
||||||
|
break;
|
||||||
|
case 'posts':
|
||||||
|
$attributes = 'class="posts column-posts num"' . $style;
|
||||||
|
$r .= "<td $attributes>";
|
||||||
|
if ( $numposts > 0 ) {
|
||||||
|
$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
|
||||||
|
$r .= $numposts;
|
||||||
|
$r .= '</a>';
|
||||||
|
} else {
|
||||||
|
$r .= 0;
|
||||||
|
}
|
||||||
|
$r .= "</td>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$r .= "</td>\n\t</tr>";
|
$r .= '</tr>';
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2181,7 +2219,7 @@ function manage_columns_prefs($page) {
|
||||||
|
|
||||||
foreach ( $columns as $column => $title ) {
|
foreach ( $columns as $column => $title ) {
|
||||||
// Can't hide these
|
// Can't hide these
|
||||||
if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'media' == $column )
|
if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column )
|
||||||
continue;
|
continue;
|
||||||
if ( empty($title) )
|
if ( empty($title) )
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1 +1,26 @@
|
||||||
jQuery( function($) { $('#users').wpList(); } );
|
jQuery( function($) {
|
||||||
|
$('#users').wpList();
|
||||||
|
|
||||||
|
columns.init('user');
|
||||||
|
|
||||||
|
// Edit Settings
|
||||||
|
$('#show-settings-link').click(function () {
|
||||||
|
$('#edit-settings').slideDown('normal', function(){
|
||||||
|
$('#show-settings-link').hide();
|
||||||
|
$('#hide-settings-link').show();
|
||||||
|
|
||||||
|
});
|
||||||
|
$('#show-settings').addClass('show-settings-opened');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#hide-settings-link').click(function () {
|
||||||
|
$('#edit-settings').slideUp('normal', function(){
|
||||||
|
$('#hide-settings-link').hide();
|
||||||
|
$('#show-settings-link').show();
|
||||||
|
$('#show-settings').removeClass('show-settings-opened');
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -261,6 +261,19 @@ if ( ! empty($messages) ) {
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
|
|
||||||
|
<div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Advanced Options') ?></a>
|
||||||
|
<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></a></div>
|
||||||
|
|
||||||
|
<div id="edit-settings" class="hide-if-js hide-if-no-js">
|
||||||
|
<div id="edit-settings-wrap">
|
||||||
|
<h5><?php _e('Show on screen') ?></h5>
|
||||||
|
<div class="metabox-prefs">
|
||||||
|
<?php manage_columns_prefs('user') ?>
|
||||||
|
<br class="clear" />
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form id="posts-filter" action="" method="get">
|
<form id="posts-filter" action="" method="get">
|
||||||
<?php if ( $wp_user_search->is_search() ) : ?>
|
<?php if ( $wp_user_search->is_search() ) : ?>
|
||||||
<h2><?php printf( current_user_can('create_users') ? __('Users Matching "%2$s" (<a href="%1$s">Add New</a>)') : __('Add New'), '#add-new-user', wp_specialchars($wp_user_search->search_term) ); ?></h2>
|
<h2><?php printf( current_user_can('create_users') ? __('Users Matching "%2$s" (<a href="%1$s">Add New</a>)') : __('Add New'), '#add-new-user', wp_specialchars($wp_user_search->search_term) ); ?></h2>
|
||||||
|
@ -350,12 +363,7 @@ unset($role_links);
|
||||||
<table class="widefat">
|
<table class="widefat">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="thead">
|
<tr class="thead">
|
||||||
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
<?php print_column_headers('user') ?>
|
||||||
<th><?php _e('Username') ?></th>
|
|
||||||
<th><?php _e('Name') ?></th>
|
|
||||||
<th><?php _e('E-mail') ?></th>
|
|
||||||
<th><?php _e('Role') ?></th>
|
|
||||||
<th class="num"><?php _e('Posts') ?></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="users" class="list:user user-list">
|
<tbody id="users" class="list:user user-list">
|
||||||
|
@ -383,7 +391,7 @@ foreach ( $wp_user_search->get_results() as $userid ) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'how' => __('Separate multiple categories with commas.')
|
'how' => __('Separate multiple categories with commas.')
|
||||||
) );
|
) );
|
||||||
$scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20071031' );
|
$scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20071031' );
|
||||||
$scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20071031' );
|
$scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20080918' );
|
||||||
$scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
|
$scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
|
||||||
$scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20080824' );
|
$scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20080824' );
|
||||||
$scripts->localize( 'password-strength-meter', 'pwsL10n', array(
|
$scripts->localize( 'password-strength-meter', 'pwsL10n', array(
|
||||||
|
@ -166,7 +166,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
|
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
|
||||||
'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
|
'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
|
||||||
) );
|
) );
|
||||||
$scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' );
|
$scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns'), '20080918' );
|
||||||
$scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729');
|
$scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729');
|
||||||
$scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
|
$scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
|
||||||
$scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
|
$scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
|
||||||
|
|
Loading…
Reference in New Issue