274 if ( ! current_user_can( 'delete_users' ) ) { |
286 if ( ! current_user_can( 'delete_users' ) ) { |
275 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); |
287 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); |
276 } |
288 } |
277 |
289 |
278 if ( empty( $_REQUEST['users'] ) ) { |
290 if ( empty( $_REQUEST['users'] ) ) { |
279 $userids = array( (int) $_REQUEST['user'] ); |
291 $user_ids = array( (int) $_REQUEST['user'] ); |
280 } else { |
292 } else { |
281 $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
293 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); |
282 } |
294 } |
283 |
295 |
284 $all_userids = $userids; |
296 $all_user_ids = $user_ids; |
285 |
297 |
286 if ( in_array( $current_user->ID, $userids, true ) ) { |
298 if ( in_array( $current_user->ID, $user_ids, true ) ) { |
287 $userids = array_diff( $userids, array( $current_user->ID ) ); |
299 $user_ids = array_diff( $user_ids, array( $current_user->ID ) ); |
288 } |
300 } |
289 |
301 |
290 /** |
302 /** |
291 * Filters whether the users being deleted have additional content |
303 * Filters whether the users being deleted have additional content |
292 * associated with them outside of the `post_author` and `link_owner` relationships. |
304 * associated with them outside of the `post_author` and `link_owner` relationships. |
293 * |
305 * |
294 * @since 5.2.0 |
306 * @since 5.2.0 |
295 * |
307 * |
296 * @param bool $users_have_additional_content Whether the users have additional content. Default false. |
308 * @param bool $users_have_additional_content Whether the users have additional content. Default false. |
297 * @param int[] $userids Array of IDs for users being deleted. |
309 * @param int[] $user_ids Array of IDs for users being deleted. |
298 */ |
310 */ |
299 $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids ); |
311 $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $user_ids ); |
300 |
312 |
301 if ( $userids && ! $users_have_content ) { |
313 if ( $user_ids && ! $users_have_content ) { |
302 if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { |
314 if ( $wpdb->get_var( |
|
315 "SELECT ID FROM {$wpdb->posts} |
|
316 WHERE post_author IN( " . implode( ',', $user_ids ) . ' ) |
|
317 LIMIT 1' |
|
318 ) ) { |
303 $users_have_content = true; |
319 $users_have_content = true; |
304 } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { |
320 } elseif ( $wpdb->get_var( |
|
321 "SELECT link_id FROM {$wpdb->links} |
|
322 WHERE link_owner IN( " . implode( ',', $user_ids ) . ' ) |
|
323 LIMIT 1' |
|
324 ) ) { |
305 $users_have_content = true; |
325 $users_have_content = true; |
306 } |
326 } |
307 } |
327 } |
308 |
328 |
309 if ( $users_have_content ) { |
329 if ( $users_have_content ) { |
310 add_action( 'admin_head', 'delete_users_add_js' ); |
330 add_action( 'admin_head', 'delete_users_add_js' ); |
311 } |
331 } |
312 |
332 |
313 require_once ABSPATH . 'wp-admin/admin-header.php'; |
333 require_once ABSPATH . 'wp-admin/admin-header.php'; |
314 ?> |
334 ?> |
315 <form method="post" name="updateusers" id="updateusers"> |
335 <form method="post" name="updateusers" id="updateusers"> |
316 <?php wp_nonce_field( 'delete-users' ); ?> |
336 <?php wp_nonce_field( 'delete-users' ); ?> |
317 <?php echo $referer; ?> |
337 <?php echo $referer; ?> |
318 |
338 |
319 <div class="wrap"> |
339 <div class="wrap"> |
320 <h1><?php _e( 'Delete Users' ); ?></h1> |
340 <h1><?php _e( 'Delete Users' ); ?></h1> |
321 <?php if ( isset( $_REQUEST['error'] ) ) : ?> |
341 |
322 <div class="error"> |
342 <?php |
323 <p><strong><?php _e( 'Error:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> |
343 if ( isset( $_REQUEST['error'] ) ) : |
324 </div> |
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> |
325 <?php endif; ?> |
357 <?php endif; ?> |
326 |
358 |
327 <?php if ( 1 === count( $all_userids ) ) : ?> |
359 <ul> |
328 <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
329 <?php else : ?> |
|
330 <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
331 <?php endif; ?> |
|
332 |
|
333 <ul> |
|
334 <?php |
360 <?php |
335 $go_delete = 0; |
361 $go_delete = 0; |
336 foreach ( $all_userids as $id ) { |
362 |
|
363 foreach ( $all_user_ids as $id ) { |
337 $user = get_userdata( $id ); |
364 $user = get_userdata( $id ); |
338 if ( $id == $current_user->ID ) { |
365 |
339 /* translators: 1: User ID, 2: User login. */ |
366 if ( $id === $current_user->ID ) { |
340 echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n"; |
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"; |
341 } else { |
375 } else { |
342 /* translators: 1: User ID, 2: User login. */ |
376 echo '<li>'; |
343 echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n"; |
377 printf( |
344 $go_delete++; |
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; |
345 } |
390 } |
346 } |
391 } |
347 ?> |
392 ?> |
348 </ul> |
393 </ul> |
|
394 |
349 <?php |
395 <?php |
350 if ( $go_delete ) : |
396 if ( $go_delete ) : |
351 |
397 |
352 if ( ! $users_have_content ) : |
398 if ( ! $users_have_content ) : |
353 ?> |
399 ?> |
354 <input type="hidden" name="delete_option" value="delete" /> |
400 <input type="hidden" name="delete_option" value="delete" /> |
355 <?php else : ?> |
401 <?php else : ?> |
356 <?php if ( 1 == $go_delete ) : ?> |
402 <fieldset> |
357 <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
403 <?php if ( 1 === $go_delete ) : ?> |
358 <?php else : ?> |
404 <p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
359 <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
405 <?php else : ?> |
360 <?php endif; ?> |
406 <p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
361 <ul style="list-style:none;"> |
407 <?php endif; ?> |
362 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> |
408 |
363 <?php _e( 'Delete all content.' ); ?></label></li> |
409 <ul style="list-style:none;"> |
364 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> |
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> |
365 <?php |
429 <?php |
366 echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; |
430 endif; |
367 wp_dropdown_users( |
431 |
368 array( |
|
369 'name' => 'reassign_user', |
|
370 'exclude' => $userids, |
|
371 'show' => 'display_name_with_login', |
|
372 ) |
|
373 ); |
|
374 ?> |
|
375 </li> |
|
376 </ul></fieldset> |
|
377 <?php |
|
378 endif; |
|
379 /** |
432 /** |
380 * Fires at the end of the delete users form prior to the confirm button. |
433 * Fires at the end of the delete users form prior to the confirm button. |
381 * |
434 * |
382 * @since 4.0.0 |
435 * @since 4.0.0 |
383 * @since 4.5.0 The `$userids` parameter was added. |
436 * @since 4.5.0 The `$user_ids` parameter was added. |
384 * |
437 * |
385 * @param WP_User $current_user WP_User object for the current user. |
438 * @param WP_User $current_user WP_User object for the current user. |
386 * @param int[] $userids Array of IDs for users being deleted. |
439 * @param int[] $user_ids Array of IDs for users being deleted. |
387 */ |
440 */ |
388 do_action( 'delete_user_form', $current_user, $userids ); |
441 do_action( 'delete_user_form', $current_user, $user_ids ); |
389 ?> |
442 ?> |
390 <input type="hidden" name="action" value="dodelete" /> |
443 <input type="hidden" name="action" value="dodelete" /> |
391 <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?> |
444 <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?> |
392 <?php else : ?> |
445 |
393 <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p> |
446 <?php else : ?> |
394 <?php endif; ?> |
447 |
395 </div> |
448 <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p> |
396 </form> |
449 |
|
450 <?php endif; ?> |
|
451 </div><!-- .wrap --> |
|
452 </form><!-- #updateusers --> |
397 <?php |
453 <?php |
398 |
454 |
399 break; |
455 break; |
400 |
456 |
401 case 'doremove': |
457 case 'doremove': |
445 if ( ! current_user_can( 'remove_users' ) ) { |
501 if ( ! current_user_can( 'remove_users' ) ) { |
446 $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) ); |
502 $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) ); |
447 } |
503 } |
448 |
504 |
449 if ( empty( $_REQUEST['users'] ) ) { |
505 if ( empty( $_REQUEST['users'] ) ) { |
450 $userids = array( (int) $_REQUEST['user'] ); |
506 $user_ids = array( (int) $_REQUEST['user'] ); |
451 } else { |
507 } else { |
452 $userids = $_REQUEST['users']; |
508 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); |
453 } |
509 } |
454 |
510 |
455 require_once ABSPATH . 'wp-admin/admin-header.php'; |
511 require_once ABSPATH . 'wp-admin/admin-header.php'; |
456 ?> |
512 ?> |
457 <form method="post" name="updateusers" id="updateusers"> |
513 <form method="post" name="updateusers" id="updateusers"> |
458 <?php wp_nonce_field( 'remove-users' ); ?> |
514 <?php wp_nonce_field( 'remove-users' ); ?> |
459 <?php echo $referer; ?> |
515 <?php echo $referer; ?> |
460 |
516 |
461 <div class="wrap"> |
517 <div class="wrap"> |
462 <h1><?php _e( 'Remove Users from Site' ); ?></h1> |
518 <h1><?php _e( 'Remove Users from Site' ); ?></h1> |
463 |
519 |
464 <?php if ( 1 === count( $userids ) ) : ?> |
520 <?php if ( 1 === count( $user_ids ) ) : ?> |
465 <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
521 <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
466 <?php else : ?> |
522 <?php else : ?> |
467 <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
523 <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
468 <?php endif; ?> |
524 <?php endif; ?> |
469 |
525 |
470 <ul> |
526 <ul> |
471 <?php |
527 <?php |
472 $go_remove = false; |
528 $go_remove = false; |
473 foreach ( $userids as $id ) { |
529 |
474 $id = (int) $id; |
530 foreach ( $user_ids as $id ) { |
475 $user = get_userdata( $id ); |
531 $user = get_userdata( $id ); |
|
532 |
476 if ( ! current_user_can( 'remove_user', $id ) ) { |
533 if ( ! current_user_can( 'remove_user', $id ) ) { |
477 /* translators: 1: User ID, 2: User login. */ |
534 echo '<li>'; |
478 echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), $id, $user->user_login ) . "</li>\n"; |
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"; |
479 } else { |
542 } else { |
480 /* translators: 1: User ID, 2: User login. */ |
543 echo '<li>'; |
481 echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n"; |
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 |
482 $go_remove = true; |
556 $go_remove = true; |
483 } |
557 } |
484 } |
558 } |
485 ?> |
559 ?> |
486 </ul> |
560 </ul> |
|
561 |
487 <?php if ( $go_remove ) : ?> |
562 <?php if ( $go_remove ) : ?> |
488 <input type="hidden" name="action" value="doremove" /> |
563 |
|
564 <input type="hidden" name="action" value="doremove" /> |
489 <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?> |
565 <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?> |
490 <?php else : ?> |
566 |
491 <p><?php _e( 'There are no valid users selected for removal.' ); ?></p> |
567 <?php else : ?> |
492 <?php endif; ?> |
568 |
493 </div> |
569 <p><?php _e( 'There are no valid users selected for removal.' ); ?></p> |
494 </form> |
570 |
|
571 <?php endif; ?> |
|
572 </div><!-- .wrap --> |
|
573 </form><!-- #updateusers --> |
495 <?php |
574 <?php |
496 |
575 |
497 break; |
576 break; |
498 |
577 |
499 default: |
578 default: |
527 if ( isset( $_GET['update'] ) ) : |
607 if ( isset( $_GET['update'] ) ) : |
528 switch ( $_GET['update'] ) { |
608 switch ( $_GET['update'] ) { |
529 case 'del': |
609 case 'del': |
530 case 'del_many': |
610 case 'del_many': |
531 $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; |
611 $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; |
532 if ( 1 == $delete_count ) { |
612 if ( 1 === $delete_count ) { |
533 $message = __( 'User deleted.' ); |
613 $message = __( 'User deleted.' ); |
534 } else { |
614 } else { |
535 /* translators: %s: Number of users. */ |
615 /* translators: %s: Number of users. */ |
536 $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
616 $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
537 } |
617 } |
538 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
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 ); |
539 break; |
627 break; |
540 case 'add': |
628 case 'add': |
541 $message = __( 'New user created.' ); |
629 $message = __( 'New user created.' ); |
542 |
|
543 $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false; |
630 $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false; |
544 if ( $user_id && current_user_can( 'edit_user', $user_id ) ) { |
631 if ( $user_id && current_user_can( 'edit_user', $user_id ) ) { |
545 $message .= sprintf( |
632 $message .= sprintf( |
546 ' <a href="%s">%s</a>', |
633 ' <a href="%1$s">%2$s</a>', |
547 esc_url( |
634 esc_url( |
548 add_query_arg( |
635 add_query_arg( |
549 'wp_http_referer', |
636 'wp_http_referer', |
550 urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
637 urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
551 self_admin_url( 'user-edit.php?user_id=' . $user_id ) |
638 self_admin_url( 'user-edit.php?user_id=' . $user_id ) |
553 ), |
640 ), |
554 __( 'Edit user' ) |
641 __( 'Edit user' ) |
555 ); |
642 ); |
556 } |
643 } |
557 |
644 |
558 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>'; |
645 $messages[] = wp_get_admin_notice( |
|
646 $message, |
|
647 array( |
|
648 'id' => 'message', |
|
649 'additional_classes' => array( 'updated' ), |
|
650 'dismissible' => true, |
|
651 ) |
|
652 ); |
559 break; |
653 break; |
560 case 'resetpassword': |
654 case 'resetpassword': |
561 $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0; |
655 $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0; |
562 if ( 1 === $reset_count ) { |
656 if ( 1 === $reset_count ) { |
563 $message = __( 'Password reset link sent.' ); |
657 $message = __( 'Password reset link sent.' ); |
564 } else { |
658 } else { |
565 /* translators: %s: Number of users. */ |
659 /* translators: %s: Number of users. */ |
566 $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count ); |
660 $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count ); |
567 } |
661 } |
568 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $reset_count ) ) . '</p></div>'; |
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 ); |
569 break; |
671 break; |
570 case 'promote': |
672 case 'promote': |
571 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>'; |
673 $messages[] = wp_get_admin_notice( |
|
674 __( 'Changed roles.' ), |
|
675 array( |
|
676 'id' => 'message', |
|
677 'additional_classes' => array( 'updated' ), |
|
678 'dismissible' => true, |
|
679 ) |
|
680 ); |
572 break; |
681 break; |
573 case 'err_admin_role': |
682 case 'err_admin_role': |
574 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'The current user’s role must have user editing capabilities.' ) . '</p></div>'; |
683 $messages[] = wp_get_admin_notice( |
575 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Other user roles have been changed.' ) . '</p></div>'; |
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 ); |
576 break; |
699 break; |
577 case 'err_admin_del': |
700 case 'err_admin_del': |
578 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'You cannot delete the current user.' ) . '</p></div>'; |
701 $messages[] = wp_get_admin_notice( |
579 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Other users have been deleted.' ) . '</p></div>'; |
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 ); |
580 break; |
717 break; |
581 case 'remove': |
718 case 'remove': |
582 $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __( 'User removed from this site.' ) . '</p></div>'; |
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 ); |
583 break; |
727 break; |
584 case 'err_admin_remove': |
728 case 'err_admin_remove': |
585 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'You cannot remove the current user.' ) . '</p></div>'; |
729 $messages[] = wp_get_admin_notice( |
586 $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __( 'Other users have been removed.' ) . '</p></div>'; |
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 ); |
587 break; |
745 break; |
588 } |
746 } |
589 endif; |
747 endif; |
590 ?> |
748 ?> |
591 |
749 |
592 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> |
750 <?php |
593 <div class="error"> |
751 if ( isset( $errors ) && is_wp_error( $errors ) ) : |
594 <ul> |
752 $error_message = ''; |
595 <?php |
|
596 foreach ( $errors->get_error_messages() as $err ) { |
753 foreach ( $errors->get_error_messages() as $err ) { |
597 echo "<li>$err</li>\n"; |
754 $error_message .= "<li>$err</li>\n"; |
598 } |
755 } |
599 ?> |
756 wp_admin_notice( |
600 </ul> |
757 '<ul>' . $error_message . '</ul>', |
601 </div> |
758 array( |
602 <?php |
759 'additional_classes' => array( 'error' ), |
603 endif; |
760 ) |
|
761 ); |
|
762 endif; |
604 |
763 |
605 if ( ! empty( $messages ) ) { |
764 if ( ! empty( $messages ) ) { |
606 foreach ( $messages as $msg ) { |
765 foreach ( $messages as $msg ) { |
607 echo $msg; |
766 echo $msg; |
608 } |
767 } |
609 } |
768 } |
610 ?> |
769 ?> |
611 |
770 |
612 <div class="wrap"> |
771 <div class="wrap"> |
613 <h1 class="wp-heading-inline"> |
772 <h1 class="wp-heading-inline"> |
614 <?php |
773 <?php echo esc_html( $title ); ?> |
615 echo esc_html( $title ); |
774 </h1> |
616 ?> |
|
617 </h1> |
|
618 |
775 |
619 <?php |
776 <?php |
620 if ( current_user_can( 'create_users' ) ) { |
777 if ( current_user_can( 'create_users' ) ) { |
621 ?> |
778 printf( |
622 <a href="<?php echo esc_url( admin_url( 'user-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> |
779 '<a href="%1$s" class="page-title-action">%2$s</a>', |
623 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
780 esc_url( admin_url( 'user-new.php' ) ), |
624 <a href="<?php echo esc_url( admin_url( 'user-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
781 esc_html__( 'Add New User' ) |
625 <?php |
782 ); |
626 } |
783 } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { |
627 |
784 printf( |
628 if ( strlen( $usersearch ) ) { |
785 '<a href="%1$s" class="page-title-action">%2$s</a>', |
629 echo '<span class="subtitle">'; |
786 esc_url( admin_url( 'user-new.php' ) ), |
630 printf( |
787 esc_html__( 'Add Existing User' ) |
631 /* translators: %s: Search query. */ |
788 ); |
632 __( 'Search results for: %s' ), |
789 } |
633 '<strong>' . esc_html( $usersearch ) . '</strong>' |
790 |
634 ); |
791 if ( strlen( $usersearch ) ) { |
635 echo '</span>'; |
792 echo '<span class="subtitle">'; |
636 } |
793 printf( |
637 ?> |
794 /* translators: %s: Search query. */ |
638 |
795 __( 'Search results for: %s' ), |
639 <hr class="wp-header-end"> |
796 '<strong>' . esc_html( $usersearch ) . '</strong>' |
|
797 ); |
|
798 echo '</span>'; |
|
799 } |
|
800 ?> |
|
801 |
|
802 <hr class="wp-header-end"> |
640 |
803 |
641 <?php $wp_list_table->views(); ?> |
804 <?php $wp_list_table->views(); ?> |
642 |
805 |
643 <form method="get"> |
806 <form method="get"> |
644 |
807 |
645 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> |
808 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> |
646 |
809 |
647 <?php if ( ! empty( $_REQUEST['role'] ) ) { ?> |
810 <?php if ( ! empty( $_REQUEST['role'] ) ) { ?> |
648 <input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" /> |
811 <input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" /> |
649 <?php } ?> |
812 <?php } ?> |
650 |
813 |
651 <?php $wp_list_table->display(); ?> |
814 <?php $wp_list_table->display(); ?> |
652 </form> |
815 |
653 |
816 </form> |
654 <div class="clear"></div> |
817 |
655 </div> |
818 <div class="clear"></div> |
|
819 </div><!-- .wrap --> |
656 <?php |
820 <?php |
657 break; |
821 break; |
658 |
822 |
659 } // End of the $doaction switch. |
823 } // End of the $doaction switch. |
660 |
824 |