- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-users-list-table.php
r42257 r42343 44 44 */ 45 45 public function __construct( $args = array() ) { 46 parent::__construct( array( 47 'singular' => 'user', 48 'plural' => 'users', 49 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 50 ) ); 46 parent::__construct( 47 array( 48 'singular' => 'user', 49 'plural' => 'users', 50 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 51 ) 52 ); 51 53 52 54 $this->is_site_users = 'site-users-network' === $this->screen->id; 53 55 54 if ( $this->is_site_users ) 56 if ( $this->is_site_users ) { 55 57 $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 58 } 56 59 } 57 60 … … 59 62 * Check the current user's permissions. 60 63 * 61 * @since 3.1.064 * @since 3.1.0 62 65 * 63 66 * @return bool 64 67 */ 65 68 public function ajax_user_can() { 66 if ( $this->is_site_users ) 69 if ( $this->is_site_users ) { 67 70 return current_user_can( 'manage_sites' ); 68 else71 } else { 69 72 return current_user_can( 'list_users' ); 73 } 70 74 } 71 75 … … 85 89 $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; 86 90 87 $per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';91 $per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page'; 88 92 $users_per_page = $this->get_items_per_page( $per_page ); 89 93 … … 92 96 if ( 'none' === $role ) { 93 97 $args = array( 94 'number' => $users_per_page,95 'offset' => ( $paged-1 ) * $users_per_page,98 'number' => $users_per_page, 99 'offset' => ( $paged - 1 ) * $users_per_page, 96 100 'include' => wp_get_users_with_no_role( $this->site_id ), 97 'search' => $usersearch,98 'fields' => 'all_with_meta'101 'search' => $usersearch, 102 'fields' => 'all_with_meta', 99 103 ); 100 104 } else { 101 105 $args = array( 102 106 'number' => $users_per_page, 103 'offset' => ( $paged -1 ) * $users_per_page,104 'role' => $role,107 'offset' => ( $paged - 1 ) * $users_per_page, 108 'role' => $role, 105 109 'search' => $usersearch, 106 'fields' => 'all_with_meta' 110 'fields' => 'all_with_meta', 107 111 ); 108 112 } 109 113 110 if ( '' !== $args['search'] ) 114 if ( '' !== $args['search'] ) { 111 115 $args['search'] = '*' . $args['search'] . '*'; 112 113 if ( $this->is_site_users ) 116 } 117 118 if ( $this->is_site_users ) { 114 119 $args['blog_id'] = $this->site_id; 115 116 if ( isset( $_REQUEST['orderby'] ) ) 120 } 121 122 if ( isset( $_REQUEST['orderby'] ) ) { 117 123 $args['orderby'] = $_REQUEST['orderby']; 118 119 if ( isset( $_REQUEST['order'] ) ) 124 } 125 126 if ( isset( $_REQUEST['order'] ) ) { 120 127 $args['order'] = $_REQUEST['order']; 128 } 121 129 122 130 /** … … 135 143 $this->items = $wp_user_search->get_results(); 136 144 137 $this->set_pagination_args( array( 138 'total_items' => $wp_user_search->get_total(), 139 'per_page' => $users_per_page, 140 ) ); 145 $this->set_pagination_args( 146 array( 147 'total_items' => $wp_user_search->get_total(), 148 'per_page' => $users_per_page, 149 ) 150 ); 141 151 } 142 152 … … 174 184 restore_current_blog(); 175 185 } else { 176 $url = 'users.php';186 $url = 'users.php'; 177 187 $users_of_blog = count_users(); 178 188 } … … 180 190 $total_users = $users_of_blog['total_users']; 181 191 $avail_roles =& $users_of_blog['avail_roles']; 182 unset( $users_of_blog);192 unset( $users_of_blog ); 183 193 184 194 $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; 185 195 186 $role_links = array();196 $role_links = array(); 187 197 $role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 188 198 foreach ( $wp_roles->get_names() as $this_role => $name ) { 189 if ( ! isset($avail_roles[$this_role]) )199 if ( ! isset( $avail_roles[ $this_role ] ) ) { 190 200 continue; 201 } 191 202 192 203 $current_link_attributes = ''; … … 198 209 $name = translate_user_role( $name ); 199 210 /* translators: User role name with count */ 200 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );201 $role_links[ $this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";202 } 203 204 if ( ! empty( $avail_roles['none' ] ) ) {211 $name = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) ); 212 $role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>"; 213 } 214 215 if ( ! empty( $avail_roles['none'] ) ) { 205 216 206 217 $current_link_attributes = ''; … … 212 223 $name = __( 'No role' ); 213 224 /* translators: User role name with count */ 214 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none'] ) );225 $name = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles['none'] ) ); 215 226 $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>"; 216 227 … … 231 242 232 243 if ( is_multisite() ) { 233 if ( current_user_can( 'remove_users' ) ) 244 if ( current_user_can( 'remove_users' ) ) { 234 245 $actions['remove'] = __( 'Remove' ); 246 } 235 247 } else { 236 if ( current_user_can( 'delete_users' ) ) 248 if ( current_user_can( 'delete_users' ) ) { 237 249 $actions['delete'] = __( 'Delete' ); 250 } 238 251 } 239 252 … … 250 263 */ 251 264 protected function extra_tablenav( $which ) { 252 $id = 'bottom' === $which ? 'new_role2' : 'new_role';265 $id = 'bottom' === $which ? 'new_role2' : 'new_role'; 253 266 $button_id = 'bottom' === $which ? 'changeit2' : 'changeit'; 254 267 ?> 255 268 <div class="alignleft actions"> 256 269 <?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?> 257 <label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Change role to…' )?></label>258 <select name="<?php echo $id ?>" id="<?php echo $id?>">259 <option value=""><?php _e( 'Change role to…' ) ?></option>270 <label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to…' ); ?></label> 271 <select name="<?php echo $id; ?>" id="<?php echo $id; ?>"> 272 <option value=""><?php _e( 'Change role to…' ); ?></option> 260 273 <?php wp_dropdown_roles(); ?> 261 274 </select> … … 322 335 'email' => __( 'Email' ), 323 336 'role' => __( 'Role' ), 324 'posts' => __( 'Posts' ) 337 'posts' => __( 'Posts' ), 325 338 ); 326 339 327 if ( $this->is_site_users ) 340 if ( $this->is_site_users ) { 328 341 unset( $c['posts'] ); 342 } 329 343 330 344 return $c; … … 354 368 public function display_rows() { 355 369 // Query the post counts for this page 356 if ( ! $this->is_site_users ) 370 if ( ! $this->is_site_users ) { 357 371 $post_counts = count_many_users_posts( array_keys( $this->items ) ); 372 } 358 373 359 374 foreach ( $this->items as $userid => $user_object ) { … … 381 396 } 382 397 $user_object->filter = 'display'; 383 $email = $user_object->user_email;384 385 if ( $this->is_site_users ) 398 $email = $user_object->user_email; 399 400 if ( $this->is_site_users ) { 386 401 $url = "site-users.php?id={$this->site_id}&"; 387 else402 } else { 388 403 $url = 'users.php?'; 404 } 389 405 390 406 $user_roles = $this->get_role_list( $user_object ); 391 407 392 408 // Set up the hover actions for this user 393 $actions = array();394 $checkbox = '';409 $actions = array(); 410 $checkbox = ''; 395 411 $super_admin = ''; 396 412 … … 406 422 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) ); 407 423 408 if ( current_user_can( 'edit_user', $user_object->ID ) ) {409 $edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";424 if ( current_user_can( 'edit_user', $user_object->ID ) ) { 425 $edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />"; 410 426 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; 411 427 } else { … … 413 429 } 414 430 415 if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) 416 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>"; 417 if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) 418 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>"; 431 if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) { 432 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>'; 433 } 434 if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) { 435 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>'; 436 } 419 437 420 438 // Add a link to the user's author archive, if not empty. … … 529 547 $r .= $this->row_actions( $actions ); 530 548 } 531 $r .= "</td>";549 $r .= '</td>'; 532 550 } 533 551 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)