Changes in trunk/wp-admin/users.php [15152:17439]
- File:
-
- 1 edited
-
trunk/wp-admin/users.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/users.php
r15152 r17439 8 8 9 9 /** WordPress Administration Bootstrap */ 10 require_once('./admin.php'); 11 12 /** WordPress Registration API */ 13 require_once( ABSPATH . WPINC . '/registration.php'); 14 15 if ( !current_user_can('list_users') ) 16 wp_die(__('Cheatin’ uh?')); 17 10 require_once( './admin.php' ); 11 12 if ( ! current_user_can( 'list_users' ) ) 13 wp_die( __( 'Cheatin’ uh?' ) ); 14 15 $wp_list_table = _get_list_table('WP_Users_List_Table'); 16 $pagenum = $wp_list_table->get_pagenum(); 18 17 $title = __('Users'); 19 18 $parent_file = 'users.php'; 20 19 20 add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) ); 21 21 22 // contextual help - choose Help on the top right of admin panel to preview this. 22 23 add_contextual_help($current_screen, 23 '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options when they are logged in, based on their role.') . '</p>' .24 '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '</p>' . 24 25 '<p>' . __('You can customize the display of information on this screen as you can on other screens, by using the Screen Options tab and the on-screen filters.') . '</p>' . 25 26 '<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>' . 26 27 '<p><strong>' . __('For more information:') . '</strong></p>' . 27 '<p>' . __('<a href="http://codex.wordpress.org/Users_ Authors_and_Users_SubPanel" target="_blank">Documentation on Authors andUsers</a>') . '</p>' .28 '<p>' . __('<a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank"> Roles and Capabilities Descriptions</a>') . '</p>' .28 '<p>' . __('<a href="http://codex.wordpress.org/Users_Users_SubPanel" target="_blank">Documentation on Managing Users</a>') . '</p>' . 29 '<p>' . __('<a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' . 29 30 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 30 31 ); 31 32 $update = $doaction = '';33 if ( isset($_REQUEST['action']) )34 $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];35 36 if ( empty($doaction) ) {37 if ( isset($_GET['changeit']) && !empty($_GET['new_role']) )38 $doaction = 'promote';39 }40 32 41 33 if ( empty($_REQUEST) ) { … … 49 41 } 50 42 51 switch ($doaction) { 43 $update = ''; 44 45 switch ( $wp_list_table->current_action() ) { 52 46 53 47 /* Bulk Dropdown menu Role changes */ 54 48 case 'promote': 55 49 check_admin_referer('bulk-users'); 50 51 if ( ! current_user_can( 'promote_users' ) ) 52 wp_die( __( 'You can’t edit that user.' ) ); 56 53 57 54 if ( empty($_REQUEST['users']) ) { … … 179 176 } 180 177 } 181 // @todo Delete is always for !is_multisite(). Use API.182 if ( !is_multisite() ) {183 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");184 } else {185 // WPMU only searches users of current blog186 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities' ORDER BY user_login");187 }188 $user_dropdown = '<select name="reassign_user">';189 foreach ( (array) $all_logins as $login )190 if ( $login->ID == $current_user->ID || !in_array($login->ID, $userids) )191 $user_dropdown .= "<option value=\"" . esc_attr($login->ID) . "\">{$login->user_login}</option>";192 $user_dropdown .= '</select>';193 178 ?> 194 179 </ul> … … 199 184 <?php _e('Delete all posts and links.'); ?></label></li> 200 185 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 201 <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:')."</label> $user_dropdown"; ?></li> 186 <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>'; 187 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> 202 188 </ul></fieldset> 203 189 <input type="hidden" name="action" value="dodelete" /> 204 < p class="submit"><input type="submit" name="submit" value="<?php esc_attr_e('Confirm Deletion'); ?>" class="button-secondary" /></p>190 <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?> 205 191 <?php else : ?> 206 192 <p><?php _e('There are no valid users selected for deletion.'); ?></p> … … 215 201 check_admin_referer('remove-users'); 216 202 203 if ( ! is_multisite() ) 204 wp_die( __( 'You can’t remove users.' ) ); 205 217 206 if ( empty($_REQUEST['users']) ) { 218 207 wp_redirect($redirect); … … 220 209 } 221 210 222 if ( ! current_user_can('remove_users'))223 die(__('You can’t remove users.'));211 if ( ! current_user_can( 'remove_users' ) ) 212 wp_die( __( 'You can’t remove users.' ) ); 224 213 225 214 $userids = $_REQUEST['users']; … … 248 237 249 238 check_admin_referer('bulk-users'); 239 240 if ( ! is_multisite() ) 241 wp_die( __( 'You can’t remove users.' ) ); 250 242 251 243 if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { … … 290 282 <?php if ( $go_remove ) : ?> 291 283 <input type="hidden" name="action" value="doremove" /> 292 < p class="submit"><input type="submit" name="submit" value="<?php esc_attr_e('Confirm Removal'); ?>" class="button-secondary" /></p>284 <?php submit_button( __('Confirm Removal'), 'secondary' ); ?> 293 285 <?php else : ?> 294 286 <p><?php _e('There are no valid users selected for removal.'); ?></p> … … 307 299 } 308 300 301 $wp_list_table->prepare_items(); 302 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 303 if ( $pagenum > $total_pages && $total_pages > 0 ) { 304 wp_redirect( add_query_arg( 'paged', $total_pages ) ); 305 exit; 306 } 309 307 include('./admin-header.php'); 310 311 $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null;312 $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null;313 $role = isset($_GET['role']) ? $_GET['role'] : null;314 315 // Query the user IDs for this page316 $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);317 318 // Query the post counts for this page319 $post_counts = count_many_users_posts($wp_user_search->get_results());320 321 // Query the users for this page322 cache_users($wp_user_search->get_results());323 308 324 309 $messages = array(); … … 372 357 <div class="wrap"> 373 358 <?php screen_icon(); ?> 374 <h2><?php echo esc_html( $title ); if ( current_user_can( 'create_users' ) ) { ?> <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'user'); ?></a><?php } 375 if ( isset($_GET['usersearch']) && $_GET['usersearch'] ) 376 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $_GET['usersearch'] ) ); ?> 359 <h2> 360 <?php 361 echo esc_html( $title ); 362 if ( current_user_can( 'create_users' ) ) { ?> 363 <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> 364 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 365 <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> 366 <?php } 367 368 if ( $usersearch ) 369 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?> 377 370 </h2> 378 371 379 <div class="filter"> 380 <form id="list-filter" action="" method="get"> 381 <ul class="subsubsub"> 382 <?php 383 $users_of_blog = count_users(); 384 $total_users = $users_of_blog['total_users']; 385 $avail_roles =& $users_of_blog['avail_roles']; 386 unset($users_of_blog); 387 388 $current_role = false; 389 $class = empty($role) ? ' class="current"' : ''; 390 $role_links = array(); 391 $role_links[] = "<li><a href='users.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 392 foreach ( $wp_roles->get_names() as $this_role => $name ) { 393 if ( !isset($avail_roles[$this_role]) ) 394 continue; 395 396 $class = ''; 397 398 if ( $this_role == $role ) { 399 $current_role = $role; 400 $class = ' class="current"'; 401 } 402 403 $name = translate_user_role( $name ); 404 /* translators: User role name with count */ 405 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role] ); 406 $role_links[] = "<li><a href='users.php?role=$this_role'$class>$name</a>"; 407 } 408 echo implode( " |</li>\n", $role_links) . '</li>'; 409 unset($role_links); 410 ?> 411 </ul> 372 <?php $wp_list_table->views(); ?> 373 374 <form action="" method="get"> 375 376 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> 377 378 <?php $wp_list_table->display(); ?> 412 379 </form> 413 </div>414 415 <form class="search-form" action="" method="get">416 <p class="search-box">417 <label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label>418 <input type="text" id="user-search-input" name="usersearch" value="<?php echo esc_attr($wp_user_search->search_term); ?>" />419 <input type="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" class="button" />420 </p>421 </form>422 423 <form id="posts-filter" action="" method="get">424 <div class="tablenav">425 426 <?php if ( $wp_user_search->results_are_paged() ) : ?>427 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>428 <?php endif; ?>429 430 <div class="alignleft actions">431 <select name="action">432 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>433 <?php if ( !is_multisite() && current_user_can('delete_users') ) { ?>434 <option value="delete"><?php _e('Delete'); ?></option>435 <?php } else { ?>436 <option value="remove"><?php _e('Remove'); ?></option>437 <?php } ?>438 </select>439 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />440 <label class="screen-reader-text" for="new_role"><?php _e('Change role to…') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to…') ?></option><?php wp_dropdown_roles(); ?></select>441 <input type="submit" value="<?php esc_attr_e('Change'); ?>" name="changeit" class="button-secondary" />442 <?php wp_nonce_field('bulk-users'); ?>443 </div>444 445 <br class="clear" />446 </div>447 448 <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>449 <div class="error">450 <ul>451 <?php452 foreach ( $wp_user_search->search_errors->get_error_messages() as $message )453 echo "<li>$message</li>";454 ?>455 </ul>456 </div>457 <?php endif; ?>458 459 460 <?php if ( $wp_user_search->get_results() ) : ?>461 462 <?php if ( $wp_user_search->is_search() ) : ?>463 <p><a href="users.php"><?php _e('← Back to All Users'); ?></a></p>464 <?php endif; ?>465 466 <table class="widefat fixed" cellspacing="0">467 <thead>468 <tr class="thead">469 <?php print_column_headers('users') ?>470 </tr>471 </thead>472 473 <tfoot>474 <tr class="thead">475 <?php print_column_headers('users', false) ?>476 </tr>477 </tfoot>478 479 <tbody id="users" class="list:user user-list">480 <?php481 $style = '';482 foreach ( $wp_user_search->get_results() as $userid ) {483 $user_object = new WP_User($userid);484 $roles = $user_object->roles;485 $role = array_shift($roles);486 487 if ( is_multisite() && empty( $role ) )488 continue;489 490 $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';491 echo "\n\t", user_row( $user_object, $style, $role, $post_counts[ $userid ] );492 }493 ?>494 </tbody>495 </table>496 497 <div class="tablenav">498 499 <?php if ( $wp_user_search->results_are_paged() ) : ?>500 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>501 <?php endif; ?>502 503 <div class="alignleft actions">504 <select name="action2">505 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>506 <?php if ( !is_multisite() && current_user_can('delete_users') ) { ?>507 <option value="delete"><?php _e('Delete'); ?></option>508 <?php } else { ?>509 <option value="remove"><?php _e('Remove'); ?></option>510 <?php } ?></select>511 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />512 </div>513 514 <br class="clear" />515 </div>516 517 <?php endif; ?>518 519 </form>520 </div>521 380 522 381 <?php … … 531 390 532 391 <br class="clear" /> 392 </div> 533 393 <?php 534 394 break; … … 537 397 538 398 include('./admin-footer.php'); 539 ?>
Note: See TracChangeset
for help on using the changeset viewer.