In `WP_MS_Users_List_Table::display_rows()`:

* Move the giant `switch` statement into methods
* Call `->single_row_columns()`, which we now override - there is a small amount of logic that requires overriding, otherwise it is largely the same as the parent method

See #29881.

Built from https://develop.svn.wordpress.org/trunk@32757


git-svn-id: http://core.svn.wordpress.org/trunk@32728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-06-13 17:11:26 +00:00
parent 3855cfbffd
commit 4348074f3a
2 changed files with 187 additions and 128 deletions

View File

@ -175,90 +175,87 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
/**
* @since 4.3.0
*
* @global string $mode
* @param object $user
*/
public function display_rows() {
global $mode;
$super_admins = get_super_admins();
foreach ( $this->items as $user ) {
$class = '';
$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
foreach ( $status_list as $status => $col ) {
if ( $user->$status )
$class .= " $col";
}
public function column_cb( $user ) {
?>
<tr class="<?php echo trim( $class ); ?>">
<?php
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) :
$classes = "$column_name column-$column_name";
if ( $primary === $column_name || 'blogs' === $column_name ) {
$classes .= ' has-row-actions';
}
if ( $primary === $column_name ) {
$classes .= ' column-primary';
}
if ( in_array( $column_name, $hidden ) ) {
$classes .= ' hidden';
}
$attributes = "class='$classes'";
if ( 'cb' === $column_name ){
?>
<th scope="row" class="check-column">
<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
</th>
<?php
} else {
echo "<td $attributes>";
}
switch ( $column_name ) {
case 'username':
/**
* @since 4.3.0
*
* @param object $user
*/
public function column_username( $user ) {
$super_admins = get_super_admins();
$avatar = get_avatar( $user->user_email, 32 );
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
if ( in_array( $user->user_login, $super_admins ) )
echo $avatar;
?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
if ( in_array( $user->user_login, $super_admins ) ) {
echo ' - ' . __( 'Super Admin' );
}
?></strong>
<?php
break;
}
case 'name':
/**
* @since 4.3.0
*
* @param object $user
*/
public function column_name( $user ) {
echo "$user->first_name $user->last_name";
break;
}
case 'email':
/**
* @since 4.3.0
*
* @param object $user
*/
public function column_email( $user ) {
echo "<a href='mailto:$user->user_email'>$user->user_email</a>";
break;
}
case 'registered':
if ( 'list' == $mode )
/**
* @since 4.3.0
*
* @global string $mode
*
* @param object $user
*/
public function column_registered( $user ) {
global $mode;
if ( 'list' == $mode ) {
$date = __( 'Y/m/d' );
else
} else {
$date = __( 'Y/m/d g:i:s a' );
}
echo mysql2date( $date, $user->user_registered );
break;
}
case 'blogs':
/**
* @since 4.3.0
*
* @param object $user
*/
public function column_blogs( $user ) {
$blogs = get_blogs_of_user( $user->ID, true );
if ( is_array( $blogs ) ) {
foreach ( (array) $blogs as $key => $val ) {
if ( !can_edit_network( $val->site_id ) )
if ( ! is_array( $blogs ) ) {
return;
}
foreach ( $blogs as $val ) {
if ( ! can_edit_network( $val->site_id ) ) {
continue;
}
$path = ( $val->path == '/' ) ? '' : $val->path;
echo '<span class="site-' . $val->site_id . '" >';
@ -299,25 +296,87 @@ class WP_MS_Users_List_Table extends WP_List_Table {
$action_count = count( $actions );
foreach ( $actions as $action => $link ) {
++$i;
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
$sep = ( $i == $action_count ) ? '' : ' | ';
echo "<span class='$action'>$link$sep</span>";
}
echo '</small></span><br/>';
}
}
break;
default:
/**
* @since 4.3.0
*
* @param object $user
* @param string $column_name
*/
public function column_default( $user, $column_name ) {
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
break;
}
echo $this->handle_row_actions( $user, $column_name, $primary );
echo '</td>';
/**
* @since 4.3.0
*
* @param object $item
*/
public function single_row_columns( $item ) {
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$classes = "$column_name column-$column_name";
if ( $primary === $column_name || 'blogs' === $column_name ) {
$classes .= ' has-row-actions';
}
endforeach
if ( $primary === $column_name ) {
$classes .= ' column-primary';
}
if ( in_array( $column_name, $hidden ) ) {
$classes .= ' hidden';
}
$attributes = "class='$classes'";
if ( 'cb' === $column_name ) {
echo '<th scope="row" class="check-column">';
$this->column_cb( $item );
echo '</th>';
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
echo "<td $attributes>";
call_user_func( array( $this, 'column_' . $column_name ), $item );
echo $this->handle_row_actions( $item, $column_name, $primary );
echo "</td>";
} else {
echo "<td $attributes>";
$this->column_default( $item, $column_name );
echo $this->handle_row_actions( $item, $column_name, $primary );
echo "</td>";
}
}
}
public function display_rows() {
foreach ( $this->items as $user ) {
$class = '';
$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
foreach ( $status_list as $status => $col ) {
if ( $user->$status ) {
$class .= " $col";
}
}
?>
<tr class="<?php echo trim( $class ); ?>">
<?php $this->single_row_columns( $user ); ?>
</tr>
<?php
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32756';
$wp_version = '4.3-alpha-32757';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.