[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * User administration panel 4 * 5 * @package WordPress 6 * @subpackage Administration 7 * @since 1.0.0 8 */ 9 10 /** WordPress Administration Bootstrap */ 11 require_once __DIR__ . '/admin.php'; 12 13 if ( ! current_user_can( 'list_users' ) ) { 14 wp_die( 15 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 16 '<p>' . __( 'Sorry, you are not allowed to list users.' ) . '</p>', 17 403 18 ); 19 } 20 21 $wp_list_table = _get_list_table( 'WP_Users_List_Table' ); 22 $pagenum = $wp_list_table->get_pagenum(); 23 24 // Used in the HTML title tag. 25 $title = __( 'Users' ); 26 $parent_file = 'users.php'; 27 28 add_screen_option( 'per_page' ); 29 30 // Contextual help - choose Help on the top right of admin panel to preview this. 31 get_current_screen()->add_help_tab( 32 array( 33 'id' => 'overview', 34 'title' => __( 'Overview' ), 35 'content' => '<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>' . 36 '<p>' . __( 'To add a new user for your site, click the Add New User button at the top of the screen or Add New User in the Users menu section.' ) . '</p>', 37 ) 38 ); 39 40 get_current_screen()->add_help_tab( 41 array( 42 'id' => 'screen-content', 43 'title' => __( 'Screen Content' ), 44 'content' => '<p>' . __( 'You can customize the display of this screen in a number of ways:' ) . '</p>' . 45 '<ul>' . 46 '<li>' . __( 'You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.' ) . '</li>' . 47 '<li>' . __( 'You can filter the list of users by User Role using the text links above the users list to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.' ) . '</li>' . 48 '<li>' . __( 'You can view all posts made by a user by clicking on the number under the Posts column.' ) . '</li>' . 49 '</ul>', 50 ) 51 ); 52 53 $help = '<p>' . __( 'Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:' ) . '</p>' . 54 '<ul>' . 55 '<li>' . __( '<strong>Edit</strong> takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.' ) . '</li>'; 56 57 if ( is_multisite() ) { 58 $help .= '<li>' . __( '<strong>Remove</strong> allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using bulk actions.' ) . '</li>'; 59 } else { 60 $help .= '<li>' . __( '<strong>Delete</strong> brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using bulk actions.' ) . '</li>'; 61 } 62 63 $help .= '<li>' . __( '<strong>View</strong> takes you to a public author archive which lists all the posts published by the user.' ) . '</li>'; 64 65 if ( current_user_can( 'edit_users' ) ) { 66 $help .= '<li>' . __( '<strong>Send password reset</strong> sends the user an email with a link to set a new password.' ) . '</li>'; 67 } 68 69 $help .= '</ul>'; 70 71 get_current_screen()->add_help_tab( 72 array( 73 'id' => 'action-links', 74 'title' => __( 'Available Actions' ), 75 'content' => $help, 76 ) 77 ); 78 unset( $help ); 79 80 get_current_screen()->set_help_sidebar( 81 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 82 '<p>' . __( '<a href="https://wordpress.org/documentation/article/users-screen/">Documentation on Managing Users</a>' ) . '</p>' . 83 '<p>' . __( '<a href="https://wordpress.org/documentation/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>' ) . '</p>' . 84 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 85 ); 86 87 get_current_screen()->set_screen_reader_content( 88 array( 89 'heading_views' => __( 'Filter users list' ), 90 'heading_pagination' => __( 'Users list navigation' ), 91 'heading_list' => __( 'Users list' ), 92 ) 93 ); 94 95 if ( empty( $_REQUEST ) ) { 96 $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; 97 } elseif ( isset( $_REQUEST['wp_http_referer'] ) ) { 98 $redirect = remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), wp_unslash( $_REQUEST['wp_http_referer'] ) ); 99 $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( $redirect ) . '" />'; 100 } else { 101 $redirect = 'users.php'; 102 $referer = ''; 103 } 104 105 $update = ''; 106 107 switch ( $wp_list_table->current_action() ) { 108 109 /* Bulk Dropdown menu Role changes */ 110 case 'promote': 111 check_admin_referer( 'bulk-users' ); 112 113 if ( ! current_user_can( 'promote_users' ) ) { 114 wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); 115 } 116 117 if ( empty( $_REQUEST['users'] ) ) { 118 wp_redirect( $redirect ); 119 exit; 120 } 121 122 $editable_roles = get_editable_roles(); 123 $role = $_REQUEST['new_role']; 124 125 // Mocking the `none` role so we are able to save it to the database 126 $editable_roles['none'] = array( 127 'name' => __( '— No role for this site —' ), 128 ); 129 130 if ( ! $role || empty( $editable_roles[ $role ] ) ) { 131 wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); 132 } 133 134 if ( 'none' === $role ) { 135 $role = ''; 136 } 137 138 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 139 $update = 'promote'; 140 141 foreach ( $user_ids as $id ) { 142 if ( ! current_user_can( 'promote_user', $id ) ) { 143 wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); 144 } 145 146 // The new role of the current user must also have the promote_users cap or be a multisite super admin. 147 if ( $id === $current_user->ID 148 && ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' ) 149 && ! ( is_multisite() && current_user_can( 'manage_network_users' ) ) 150 ) { 151 $update = 'err_admin_role'; 152 continue; 153 } 154 155 // If the user doesn't already belong to the blog, bail. 156 if ( is_multisite() && ! is_user_member_of_blog( $id ) ) { 157 wp_die( 158 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . 159 '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', 160 403 161 ); 162 } 163 164 $user = get_userdata( $id ); 165 $user->set_role( $role ); 166 } 167 168 wp_redirect( add_query_arg( 'update', $update, $redirect ) ); 169 exit; 170 171 case 'dodelete': 172 if ( is_multisite() ) { 173 wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); 174 } 175 176 check_admin_referer( 'delete-users' ); 177 178 if ( empty( $_REQUEST['users'] ) ) { 179 wp_redirect( $redirect ); 180 exit; 181 } 182 183 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 184 185 if ( empty( $_REQUEST['delete_option'] ) ) { 186 $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $user_ids ) . '&error=true' ); 187 $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); 188 wp_redirect( $url ); 189 exit; 190 } 191 192 if ( ! current_user_can( 'delete_users' ) ) { 193 wp_die( __( 'Sorry, you are not allowed to delete users.' ), 403 ); 194 } 195 196 $update = 'del'; 197 $delete_count = 0; 198 199 foreach ( $user_ids as $id ) { 200 if ( ! current_user_can( 'delete_user', $id ) ) { 201 wp_die( __( 'Sorry, you are not allowed to delete that user.' ), 403 ); 202 } 203 204 if ( $id === $current_user->ID ) { 205 $update = 'err_admin_del'; 206 continue; 207 } 208 209 switch ( $_REQUEST['delete_option'] ) { 210 case 'delete': 211 wp_delete_user( $id ); 212 break; 213 case 'reassign': 214 wp_delete_user( $id, $_REQUEST['reassign_user'] ); 215 break; 216 } 217 218 ++$delete_count; 219 } 220 221 $redirect = add_query_arg( 222 array( 223 'delete_count' => $delete_count, 224 'update' => $update, 225 ), 226 $redirect 227 ); 228 wp_redirect( $redirect ); 229 exit; 230 231 case 'resetpassword': 232 check_admin_referer( 'bulk-users' ); 233 234 if ( ! current_user_can( 'edit_users' ) ) { 235 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to edit users.' ) ); 236 } 237 238 if ( empty( $_REQUEST['users'] ) ) { 239 wp_redirect( $redirect ); 240 exit(); 241 } 242 243 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 244 245 $reset_count = 0; 246 247 foreach ( $user_ids as $id ) { 248 if ( ! current_user_can( 'edit_user', $id ) ) { 249 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 250 } 251 252 if ( $id === $current_user->ID ) { 253 $update = 'err_admin_reset'; 254 continue; 255 } 256 257 // Send the password reset link. 258 $user = get_userdata( $id ); 259 if ( true === retrieve_password( $user->user_login ) ) { 260 ++$reset_count; 261 } 262 } 263 264 $redirect = add_query_arg( 265 array( 266 'reset_count' => $reset_count, 267 'update' => 'resetpassword', 268 ), 269 $redirect 270 ); 271 wp_redirect( $redirect ); 272 exit; 273 274 case 'delete': 275 if ( is_multisite() ) { 276 wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); 277 } 278 279 check_admin_referer( 'bulk-users' ); 280 281 if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { 282 wp_redirect( $redirect ); 283 exit; 284 } 285 286 if ( ! current_user_can( 'delete_users' ) ) { 287 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); 288 } 289 290 if ( empty( $_REQUEST['users'] ) ) { 291 $user_ids = array( (int) $_REQUEST['user'] ); 292 } else { 293 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 294 } 295 296 $all_user_ids = $user_ids; 297 298 if ( in_array( $current_user->ID, $user_ids, true ) ) { 299 $user_ids = array_diff( $user_ids, array( $current_user->ID ) ); 300 } 301 302 /** 303 * Filters whether the users being deleted have additional content 304 * associated with them outside of the `post_author` and `link_owner` relationships. 305 * 306 * @since 5.2.0 307 * 308 * @param bool $users_have_additional_content Whether the users have additional content. Default false. 309 * @param int[] $user_ids Array of IDs for users being deleted. 310 */ 311 $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $user_ids ); 312 313 if ( $user_ids && ! $users_have_content ) { 314 if ( $wpdb->get_var( 315 "SELECT ID FROM {$wpdb->posts} 316 WHERE post_author IN( " . implode( ',', $user_ids ) . ' ) 317 LIMIT 1' 318 ) ) { 319 $users_have_content = true; 320 } elseif ( $wpdb->get_var( 321 "SELECT link_id FROM {$wpdb->links} 322 WHERE link_owner IN( " . implode( ',', $user_ids ) . ' ) 323 LIMIT 1' 324 ) ) { 325 $users_have_content = true; 326 } 327 } 328 329 if ( $users_have_content ) { 330 add_action( 'admin_head', 'delete_users_add_js' ); 331 } 332 333 require_once ABSPATH . 'wp-admin/admin-header.php'; 334 ?> 335 <form method="post" name="updateusers" id="updateusers"> 336 <?php wp_nonce_field( 'delete-users' ); ?> 337 <?php echo $referer; ?> 338 339 <div class="wrap"> 340 <h1><?php _e( 'Delete Users' ); ?></h1> 341 342 <?php 343 if ( isset( $_REQUEST['error'] ) ) : 344 wp_admin_notice( 345 '<strong>' . __( 'Error:' ) . '</strong> ' . __( 'Please select an option.' ), 346 array( 347 'additional_classes' => array( 'error' ), 348 ) 349 ); 350 endif; 351 ?> 352 353 <?php if ( 1 === count( $all_user_ids ) ) : ?> 354 <p><?php _e( 'You have specified this user for deletion:' ); ?></p> 355 <?php else : ?> 356 <p><?php _e( 'You have specified these users for deletion:' ); ?></p> 357 <?php endif; ?> 358 359 <ul> 360 <?php 361 $go_delete = 0; 362 363 foreach ( $all_user_ids as $id ) { 364 $user = get_userdata( $id ); 365 366 if ( $id === $current_user->ID ) { 367 echo '<li>'; 368 printf( 369 /* translators: 1: User ID, 2: User login. */ 370 __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), 371 $id, 372 $user->user_login 373 ); 374 echo "</li>\n"; 375 } else { 376 echo '<li>'; 377 printf( 378 '<input type="hidden" name="users[]" value="%s" />', 379 esc_attr( $id ) 380 ); 381 printf( 382 /* translators: 1: User ID, 2: User login. */ 383 __( 'ID #%1$s: %2$s' ), 384 $id, 385 $user->user_login 386 ); 387 echo "</li>\n"; 388 389 ++$go_delete; 390 } 391 } 392 ?> 393 </ul> 394 395 <?php 396 if ( $go_delete ) : 397 398 if ( ! $users_have_content ) : 399 ?> 400 <input type="hidden" name="delete_option" value="delete" /> 401 <?php else : ?> 402 <fieldset> 403 <?php if ( 1 === $go_delete ) : ?> 404 <p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> 405 <?php else : ?> 406 <p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> 407 <?php endif; ?> 408 409 <ul style="list-style:none;"> 410 <li> 411 <input type="radio" id="delete_option0" name="delete_option" value="delete" /> 412 <label for="delete_option0"><?php _e( 'Delete all content.' ); ?></label> 413 </li> 414 <li> 415 <input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 416 <label for="delete_option1"><?php _e( 'Attribute all content to:' ); ?></label> 417 <?php 418 wp_dropdown_users( 419 array( 420 'name' => 'reassign_user', 421 'exclude' => $user_ids, 422 'show' => 'display_name_with_login', 423 ) 424 ); 425 ?> 426 </li> 427 </ul> 428 </fieldset> 429 <?php 430 endif; 431 432 /** 433 * Fires at the end of the delete users form prior to the confirm button. 434 * 435 * @since 4.0.0 436 * @since 4.5.0 The `$user_ids` parameter was added. 437 * 438 * @param WP_User $current_user WP_User object for the current user. 439 * @param int[] $user_ids Array of IDs for users being deleted. 440 */ 441 do_action( 'delete_user_form', $current_user, $user_ids ); 442 ?> 443 <input type="hidden" name="action" value="dodelete" /> 444 <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?> 445 446 <?php else : ?> 447 448 <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p> 449 450 <?php endif; ?> 451 </div><!-- .wrap --> 452 </form><!-- #updateusers --> 453 <?php 454 455 break; 456 457 case 'doremove': 458 check_admin_referer( 'remove-users' ); 459 460 if ( ! is_multisite() ) { 461 wp_die( __( 'You cannot remove users.' ), 400 ); 462 } 463 464 if ( empty( $_REQUEST['users'] ) ) { 465 wp_redirect( $redirect ); 466 exit; 467 } 468 469 if ( ! current_user_can( 'remove_users' ) ) { 470 wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 ); 471 } 472 473 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 474 $update = 'remove'; 475 476 foreach ( $user_ids as $id ) { 477 if ( ! current_user_can( 'remove_user', $id ) ) { 478 $update = 'err_admin_remove'; 479 continue; 480 } 481 482 remove_user_from_blog( $id, $blog_id ); 483 } 484 485 $redirect = add_query_arg( array( 'update' => $update ), $redirect ); 486 wp_redirect( $redirect ); 487 exit; 488 489 case 'remove': 490 check_admin_referer( 'bulk-users' ); 491 492 if ( ! is_multisite() ) { 493 wp_die( __( 'You cannot remove users.' ), 400 ); 494 } 495 496 if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { 497 wp_redirect( $redirect ); 498 exit; 499 } 500 501 if ( ! current_user_can( 'remove_users' ) ) { 502 $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) ); 503 } 504 505 if ( empty( $_REQUEST['users'] ) ) { 506 $user_ids = array( (int) $_REQUEST['user'] ); 507 } else { 508 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 509 } 510 511 require_once ABSPATH . 'wp-admin/admin-header.php'; 512 ?> 513 <form method="post" name="updateusers" id="updateusers"> 514 <?php wp_nonce_field( 'remove-users' ); ?> 515 <?php echo $referer; ?> 516 517 <div class="wrap"> 518 <h1><?php _e( 'Remove Users from Site' ); ?></h1> 519 520 <?php if ( 1 === count( $user_ids ) ) : ?> 521 <p><?php _e( 'You have specified this user for removal:' ); ?></p> 522 <?php else : ?> 523 <p><?php _e( 'You have specified these users for removal:' ); ?></p> 524 <?php endif; ?> 525 526 <ul> 527 <?php 528 $go_remove = false; 529 530 foreach ( $user_ids as $id ) { 531 $user = get_userdata( $id ); 532 533 if ( ! current_user_can( 'remove_user', $id ) ) { 534 echo '<li>'; 535 printf( 536 /* translators: 1: User ID, 2: User login. */ 537 __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), 538 $id, 539 $user->user_login 540 ); 541 echo "</li>\n"; 542 } else { 543 echo '<li>'; 544 printf( 545 '<input type="hidden" name="users[]" value="%s" />', 546 esc_attr( $id ) 547 ); 548 printf( 549 /* translators: 1: User ID, 2: User login. */ 550 __( 'ID #%1$s: %2$s' ), 551 $id, 552 $user->user_login 553 ); 554 echo "</li>\n"; 555 556 $go_remove = true; 557 } 558 } 559 ?> 560 </ul> 561 562 <?php if ( $go_remove ) : ?> 563 564 <input type="hidden" name="action" value="doremove" /> 565 <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?> 566 567 <?php else : ?> 568 569 <p><?php _e( 'There are no valid users selected for removal.' ); ?></p> 570 571 <?php endif; ?> 572 </div><!-- .wrap --> 573 </form><!-- #updateusers --> 574 <?php 575 576 break; 577 578 default: 579 if ( ! empty( $_GET['_wp_http_referer'] ) ) { 580 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); 581 exit; 582 } 583 584 if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) { 585 $screen = get_current_screen()->id; 586 $sendback = wp_get_referer(); 587 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 588 589 /** This action is documented in wp-admin/edit.php */ 590 $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $user_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 591 592 wp_safe_redirect( $sendback ); 593 exit; 594 } 595 596 $wp_list_table->prepare_items(); 597 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 598 599 if ( $pagenum > $total_pages && $total_pages > 0 ) { 600 wp_redirect( add_query_arg( 'paged', $total_pages ) ); 601 exit; 602 } 603 604 require_once ABSPATH . 'wp-admin/admin-header.php'; 605 606 $messages = array(); 607 if ( isset( $_GET['update'] ) ) : 608 switch ( $_GET['update'] ) { 609 case 'del': 610 case 'del_many': 611 $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; 612 if ( 1 === $delete_count ) { 613 $message = __( 'User deleted.' ); 614 } else { 615 /* translators: %s: Number of users. */ 616 $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); 617 } 618 $message = sprintf( $message, number_format_i18n( $delete_count ) ); 619 $messages[] = wp_get_admin_notice( 620 $message, 621 array( 622 'id' => 'message', 623 'additional_classes' => array( 'updated' ), 624 'dismissible' => true, 625 ) 626 ); 627 break; 628 case 'add': 629 $message = __( 'New user created.' ); 630 $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false; 631 if ( $user_id && current_user_can( 'edit_user', $user_id ) ) { 632 $message .= sprintf( 633 ' <a href="%1$s">%2$s</a>', 634 esc_url( 635 add_query_arg( 636 'wp_http_referer', 637 urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 638 self_admin_url( 'user-edit.php?user_id=' . $user_id ) 639 ) 640 ), 641 __( 'Edit user' ) 642 ); 643 } 644 645 $messages[] = wp_get_admin_notice( 646 $message, 647 array( 648 'id' => 'message', 649 'additional_classes' => array( 'updated' ), 650 'dismissible' => true, 651 ) 652 ); 653 break; 654 case 'resetpassword': 655 $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0; 656 if ( 1 === $reset_count ) { 657 $message = __( 'Password reset link sent.' ); 658 } else { 659 /* translators: %s: Number of users. */ 660 $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count ); 661 } 662 $message = sprintf( $message, number_format_i18n( $reset_count ) ); 663 $messages[] = wp_get_admin_notice( 664 $message, 665 array( 666 'id' => 'message', 667 'additional_classes' => array( 'updated' ), 668 'dismissible' => true, 669 ) 670 ); 671 break; 672 case 'promote': 673 $messages[] = wp_get_admin_notice( 674 __( 'Changed roles.' ), 675 array( 676 'id' => 'message', 677 'additional_classes' => array( 'updated' ), 678 'dismissible' => true, 679 ) 680 ); 681 break; 682 case 'err_admin_role': 683 $messages[] = wp_get_admin_notice( 684 __( 'The current user’s role must have user editing capabilities.' ), 685 array( 686 'id' => 'message', 687 'additional_classes' => array( 'error' ), 688 'dismissible' => true, 689 ) 690 ); 691 $messages[] = wp_get_admin_notice( 692 __( 'Other user roles have been changed.' ), 693 array( 694 'id' => 'message', 695 'additional_classes' => array( 'updated' ), 696 'dismissible' => true, 697 ) 698 ); 699 break; 700 case 'err_admin_del': 701 $messages[] = wp_get_admin_notice( 702 __( 'You cannot delete the current user.' ), 703 array( 704 'id' => 'message', 705 'additional_classes' => array( 'error' ), 706 'dismissible' => true, 707 ) 708 ); 709 $messages[] = wp_get_admin_notice( 710 __( 'Other users have been deleted.' ), 711 array( 712 'id' => 'message', 713 'additional_classes' => array( 'updated' ), 714 'dismissible' => true, 715 ) 716 ); 717 break; 718 case 'remove': 719 $messages[] = wp_get_admin_notice( 720 __( 'User removed from this site.' ), 721 array( 722 'id' => 'message', 723 'additional_classes' => array( 'updated', 'fade' ), 724 'dismissible' => true, 725 ) 726 ); 727 break; 728 case 'err_admin_remove': 729 $messages[] = wp_get_admin_notice( 730 __( 'You cannot remove the current user.' ), 731 array( 732 'id' => 'message', 733 'additional_classes' => array( 'error' ), 734 'dismissible' => true, 735 ) 736 ); 737 $messages[] = wp_get_admin_notice( 738 __( 'Other users have been removed.' ), 739 array( 740 'id' => 'message', 741 'additional_classes' => array( 'updated', 'fade' ), 742 'dismissible' => true, 743 ) 744 ); 745 break; 746 } 747 endif; 748 ?> 749 750 <?php 751 if ( isset( $errors ) && is_wp_error( $errors ) ) : 752 $error_message = ''; 753 foreach ( $errors->get_error_messages() as $err ) { 754 $error_message .= "<li>$err</li>\n"; 755 } 756 wp_admin_notice( 757 '<ul>' . $error_message . '</ul>', 758 array( 759 'additional_classes' => array( 'error' ), 760 ) 761 ); 762 endif; 763 764 if ( ! empty( $messages ) ) { 765 foreach ( $messages as $msg ) { 766 echo $msg; 767 } 768 } 769 ?> 770 771 <div class="wrap"> 772 <h1 class="wp-heading-inline"> 773 <?php echo esc_html( $title ); ?> 774 </h1> 775 776 <?php 777 if ( current_user_can( 'create_users' ) ) { 778 printf( 779 '<a href="%1$s" class="page-title-action">%2$s</a>', 780 esc_url( admin_url( 'user-new.php' ) ), 781 esc_html__( 'Add New User' ) 782 ); 783 } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { 784 printf( 785 '<a href="%1$s" class="page-title-action">%2$s</a>', 786 esc_url( admin_url( 'user-new.php' ) ), 787 esc_html__( 'Add Existing User' ) 788 ); 789 } 790 791 if ( strlen( $usersearch ) ) { 792 echo '<span class="subtitle">'; 793 printf( 794 /* translators: %s: Search query. */ 795 __( 'Search results for: %s' ), 796 '<strong>' . esc_html( $usersearch ) . '</strong>' 797 ); 798 echo '</span>'; 799 } 800 ?> 801 802 <hr class="wp-header-end"> 803 804 <?php $wp_list_table->views(); ?> 805 806 <form method="get"> 807 808 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> 809 810 <?php if ( ! empty( $_REQUEST['role'] ) ) { ?> 811 <input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" /> 812 <?php } ?> 813 814 <?php $wp_list_table->display(); ?> 815 816 </form> 817 818 <div class="clear"></div> 819 </div><!-- .wrap --> 820 <?php 821 break; 822 823 } // End of the $doaction switch. 824 825 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Nov 23 08:20:01 2024 | Cross-referenced by PHPXref |