--- a/wp/wp-admin/users.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/users.php Tue Dec 15 13:49:49 2020 +0100
@@ -8,7 +8,7 @@
*/
/** WordPress Administration Bootstrap */
-require_once( dirname( __FILE__ ) . '/admin.php' );
+require_once __DIR__ . '/admin.php';
if ( ! current_user_can( 'list_users' ) ) {
wp_die(
@@ -25,7 +25,7 @@
add_screen_option( 'per_page' );
-// contextual help - choose Help on the top right of admin panel to preview this.
+// Contextual help - choose Help on the top right of admin panel to preview this.
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
@@ -53,9 +53,9 @@
'<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>';
if ( is_multisite() ) {
- $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>';
+ $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>';
} else {
- $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>';
+ $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>';
}
$help .= '</ul>';
@@ -71,8 +71,8 @@
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Users_Screen">Documentation on Managing Users</a>' ) . '</p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Roles_and_Capabilities">Descriptions of Roles and Capabilities</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/users-screen/">Documentation on Managing Users</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
@@ -108,7 +108,7 @@
if ( empty( $_REQUEST['users'] ) ) {
wp_redirect( $redirect );
- exit();
+ exit;
}
$editable_roles = get_editable_roles();
@@ -131,7 +131,8 @@
if ( ! current_user_can( 'promote_user', $id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
}
- // The new role of the current user must also have the promote_users cap or be a multisite super admin
+
+ // The new role of the current user must also have the promote_users cap or be a multisite super admin.
if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' )
&& ! ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) {
$update = 'err_admin_role';
@@ -152,7 +153,7 @@
}
wp_redirect( add_query_arg( 'update', $update, $redirect ) );
- exit();
+ exit;
case 'dodelete':
if ( is_multisite() ) {
@@ -163,7 +164,7 @@
if ( empty( $_REQUEST['users'] ) ) {
wp_redirect( $redirect );
- exit();
+ exit;
}
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
@@ -210,7 +211,7 @@
$redirect
);
wp_redirect( $redirect );
- exit();
+ exit;
case 'delete':
if ( is_multisite() ) {
@@ -221,7 +222,7 @@
if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) {
wp_redirect( $redirect );
- exit();
+ exit;
}
if ( ! current_user_can( 'delete_users' ) ) {
@@ -234,18 +235,24 @@
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
}
+ $all_userids = $userids;
+
+ if ( in_array( $current_user->ID, $userids, true ) ) {
+ $userids = array_diff( $userids, array( $current_user->ID ) );
+ }
+
/**
* Filters whether the users being deleted have additional content
* associated with them outside of the `post_author` and `link_owner` relationships.
*
* @since 5.2.0
*
- * @param boolean $users_have_additional_content Whether the users have additional content. Default false.
- * @param int[] $userids Array of IDs for users being deleted.
+ * @param bool $users_have_additional_content Whether the users have additional content. Default false.
+ * @param int[] $userids Array of IDs for users being deleted.
*/
$users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
- if ( ! $users_have_content ) {
+ if ( $userids && ! $users_have_content ) {
if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
$users_have_content = true;
} elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
@@ -257,7 +264,7 @@
add_action( 'admin_head', 'delete_users_add_js' );
}
- include( ABSPATH . 'wp-admin/admin-header.php' );
+ require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<form method="post" name="updateusers" id="updateusers">
<?php wp_nonce_field( 'delete-users' ); ?>
@@ -267,11 +274,11 @@
<h1><?php _e( 'Delete Users' ); ?></h1>
<?php if ( isset( $_REQUEST['error'] ) ) : ?>
<div class="error">
- <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
+ <p><strong><?php _e( 'Error:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
</div>
<?php endif; ?>
- <?php if ( 1 == count( $userids ) ) : ?>
+ <?php if ( 1 === count( $all_userids ) ) : ?>
<p><?php _e( 'You have specified this user for deletion:' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have specified these users for deletion:' ); ?></p>
@@ -280,13 +287,13 @@
<ul>
<?php
$go_delete = 0;
- foreach ( $userids as $id ) {
+ foreach ( $all_userids as $id ) {
$user = get_userdata( $id );
if ( $id == $current_user->ID ) {
- /* translators: 1: user id, 2: user login */
+ /* translators: 1: User ID, 2: User login. */
echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n";
} else {
- /* translators: 1: user id, 2: user login */
+ /* translators: 1: User ID, 2: User login. */
echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
$go_delete++;
}
@@ -314,7 +321,7 @@
wp_dropdown_users(
array(
'name' => 'reassign_user',
- 'exclude' => array_diff( $userids, array( $current_user->ID ) ),
+ 'exclude' => $userids,
'show' => 'display_name_with_login',
)
);
@@ -386,7 +393,7 @@
if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) {
wp_redirect( $redirect );
- exit();
+ exit;
}
if ( ! current_user_can( 'remove_users' ) ) {
@@ -399,7 +406,7 @@
$userids = $_REQUEST['users'];
}
- include( ABSPATH . 'wp-admin/admin-header.php' );
+ require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<form method="post" name="updateusers" id="updateusers">
<?php wp_nonce_field( 'remove-users' ); ?>
@@ -408,7 +415,7 @@
<div class="wrap">
<h1><?php _e( 'Remove Users from Site' ); ?></h1>
- <?php if ( 1 == count( $userids ) ) : ?>
+ <?php if ( 1 === count( $userids ) ) : ?>
<p><?php _e( 'You have specified this user for removal:' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have specified these users for removal:' ); ?></p>
@@ -421,10 +428,10 @@
$id = (int) $id;
$user = get_userdata( $id );
if ( ! current_user_can( 'remove_user', $id ) ) {
- /* translators: 1: user id, 2: user login */
+ /* translators: 1: User ID, 2: User login. */
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";
} else {
- /* translators: 1: user id, 2: user login */
+ /* translators: 1: User ID, 2: User login. */
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
$go_remove = true;
}
@@ -450,11 +457,12 @@
}
if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) {
+ $screen = get_current_screen()->id;
+ $sendback = wp_get_referer();
$userids = $_REQUEST['users'];
- $sendback = wp_get_referer();
- /** This action is documented in wp-admin/edit-comments.php */
- $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $wp_list_table->current_action(), $userids );
+ /** This action is documented in wp-admin/edit.php */
+ $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $userids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
wp_safe_redirect( $sendback );
exit;
@@ -467,7 +475,7 @@
exit;
}
- include( ABSPATH . 'wp-admin/admin-header.php' );
+ require_once ABSPATH . 'wp-admin/admin-header.php';
$messages = array();
if ( isset( $_GET['update'] ) ) :
@@ -478,26 +486,30 @@
if ( 1 == $delete_count ) {
$message = __( 'User deleted.' );
} else {
+ /* translators: %s: Number of users. */
$message = _n( '%s user deleted.', '%s users deleted.', $delete_count );
}
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>';
break;
case 'add':
- if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) {
- /* translators: %s: edit page url */
- $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(
- __( 'New user created. <a href="%s">Edit user</a>' ),
+ $message = __( 'New user created.' );
+
+ $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false;
+ if ( $user_id && current_user_can( 'edit_user', $user_id ) ) {
+ $message .= sprintf(
+ ' <a href="%s">%s</a>',
esc_url(
add_query_arg(
'wp_http_referer',
urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
self_admin_url( 'user-edit.php?user_id=' . $user_id )
)
- )
- ) . '</p></div>';
- } else {
- $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>';
+ ),
+ __( 'Edit user' )
+ );
}
+
+ $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>';
break;
case 'promote':
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>';
@@ -558,7 +570,7 @@
}
if ( strlen( $usersearch ) ) {
- /* translators: %s: search keywords */
+ /* translators: %s: Search query. */
printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) );
}
?>
@@ -583,6 +595,6 @@
<?php
break;
-} // end of the $doaction switch
+} // End of the $doaction switch.
-include( ABSPATH . 'wp-admin/admin-footer.php' );
+require_once ABSPATH . 'wp-admin/admin-footer.php';