diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/users.php --- 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 @@ '
' . __( 'For more information:' ) . '
' . - '' . __( 'Documentation on Managing Users' ) . '
' . - '' . __( 'Descriptions of Roles and Capabilities' ) . '
' . + '' . __( 'Documentation on Managing Users' ) . '
' . + '' . __( 'Descriptions of Roles and Capabilities' ) . '
' . '' . __( 'Support' ) . '
' ); @@ -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'; ?>