- Timestamp:
- 05/29/2015 02:40:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php
r32642 r32644 181 181 <?php 182 182 183 list( $columns, $hidden ) = $this->get_column_info();183 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 184 184 185 185 foreach ( $columns as $column_name => $column_display_name ) : 186 $class = "class='$column_name column-$column_name'"; 186 $classes = "$column_name column-$column_name"; 187 if ( $primary === $column_name || 'blogs' === $column_name ) { 188 $classes .= ' has-row-actions'; 189 } 190 191 if ( $primary === $column_name ) { 192 $classes .= ' column-primary'; 193 } 187 194 188 195 $style = ''; 189 if ( in_array( $column_name, $hidden ) ) 196 if ( in_array( $column_name, $hidden ) ) { 190 197 $style = ' style="display:none;"'; 191 192 $attributes = "$class$style"; 193 194 switch ( $column_name ) { 195 case 'cb': ?> 196 <th scope="row" class="check-column"> 197 <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label> 198 <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" /> 199 </th> 198 } 199 200 $attributes = "class='$classes'$style"; 201 202 if ( 'cb' === $column_name ){ 203 ?> 204 <th scope="row" class="check-column"> 205 <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label> 206 <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" /> 207 </th> 200 208 <?php 201 break; 202 203 case 'username': 204 $avatar = get_avatar( $user->user_email, 32 ); 205 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); 206 207 echo "<td $attributes>"; ?> 208 <?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php 209 } else { 210 echo "<td $attributes>"; 211 212 switch ( $column_name ) { 213 case 'username': 214 $avatar = get_avatar( $user->user_email, 32 ); 215 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); 216 217 echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php 209 218 if ( in_array( $user->user_login, $super_admins ) ) 210 219 echo ' - ' . __( 'Super Admin' ); 211 220 ?></strong> 212 <br/> 213 <?php 214 $actions = array(); 215 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; 216 217 if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { 218 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 219 } 220 221 /** 222 * Filter the action links displayed under each user 223 * in the Network Admin Users list table. 224 * 225 * @since 3.2.0 226 * 227 * @param array $actions An array of action links to be displayed. 228 * Default 'Edit', 'Delete'. 229 * @param WP_User $user WP_User object. 230 */ 231 $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); 232 echo $this->row_actions( $actions ); 233 ?> 234 </td> 235 <?php 236 break; 237 238 case 'name': 239 echo "<td $attributes>$user->first_name $user->last_name</td>"; 240 break; 241 242 case 'email': 243 echo "<td $attributes><a href='mailto:$user->user_email'>$user->user_email</a></td>"; 244 break; 245 246 case 'registered': 247 if ( 'list' == $mode ) 248 $date = __( 'Y/m/d' ); 249 else 250 $date = __( 'Y/m/d g:i:s a' ); 251 252 echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>"; 253 break; 254 255 case 'blogs': 256 $blogs = get_blogs_of_user( $user->ID, true ); 257 echo "<td $attributes>"; 221 <?php 222 break; 223 224 case 'name': 225 echo "$user->first_name $user->last_name"; 226 break; 227 228 case 'email': 229 echo "<a href='mailto:$user->user_email'>$user->user_email</a>"; 230 break; 231 232 case 'registered': 233 if ( 'list' == $mode ) 234 $date = __( 'Y/m/d' ); 235 else 236 $date = __( 'Y/m/d g:i:s a' ); 237 238 echo mysql2date( $date, $user->user_registered ); 239 break; 240 241 case 'blogs': 242 $blogs = get_blogs_of_user( $user->ID, true ); 258 243 if ( is_array( $blogs ) ) { 259 244 foreach ( (array) $blogs as $key => $val ) { … … 306 291 } 307 292 } 308 ?> 309 </td> 310 <?php 311 break; 312 313 default: 314 echo "<td $attributes>"; 315 /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ 316 echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); 317 echo "</td>"; 318 break; 293 break; 294 295 default: 296 /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ 297 echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); 298 break; 299 } 300 301 echo $this->handle_row_actions( $user, $column_name, $primary ); 302 echo '</td>'; 319 303 } 320 304 endforeach … … 324 308 } 325 309 } 310 311 /** 312 * Get name of default primary column 313 * 314 * @since 4.3.0 315 * @access protected 316 * 317 * @return string 318 */ 319 protected function get_default_primary_column_name() { 320 return 'username'; 321 } 322 323 /** 324 * Generate and display row actions links 325 * 326 * @since 4.3.0 327 * @access protected 328 * 329 * @param object $user User being acted upon 330 * @param string $column_name Current column name 331 * @param string $primary Primary column name 332 * 333 * @return string 334 */ 335 protected function handle_row_actions( $user, $column_name, $primary ) { 336 $super_admins = get_super_admins(); 337 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); 338 339 if ( $primary === $column_name ) { 340 $actions = array(); 341 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; 342 343 if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { 344 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 345 } 346 347 /** 348 * Filter the action links displayed under each user 349 * in the Network Admin Users list table. 350 * 351 * @since 3.2.0 352 * 353 * @param array $actions An array of action links to be displayed. 354 * Default 'Edit', 'Delete'. 355 * @param WP_User $user WP_User object. 356 */ 357 $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); 358 return $this->row_actions( $actions ); 359 } 360 } 326 361 }
Note: See TracChangeset
for help on using the changeset viewer.