X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/7f1521bf193b382565eb753043c161f4cb3fcda7..refs/tags/wordpress-4.7-scripts:/wp-admin/users.php?ds=sidebyside diff --git a/wp-admin/users.php b/wp-admin/users.php index 27e264ca..24367647 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -1,16 +1,22 @@ ' . __( 'Cheatin’ uh?' ) . '' . + '
' . __( 'Sorry, you are not allowed to list users.' ) . '
', + 403 + ); +} $wp_list_table = _get_list_table('WP_Users_List_Table'); $pagenum = $wp_list_table->get_pagenum(); @@ -33,7 +39,7 @@ get_current_screen()->add_help_tab( array( 'content' => '' . __('You can customize the display of this screen in a number of ways:') . '
' . '' . __('For more information:') . '
' . - '' . __('Documentation on Managing Users') . '
' . - '' . __('Descriptions of Roles and Capabilities') . '
' . - '' . __('Support Forums') . '
' + '' . __('Documentation on Managing Users') . '
' . + '' . __('Descriptions of Roles and Capabilities') . '
' . + '' . __('Support Forums') . '
' ); +get_current_screen()->set_screen_reader_content( array( + 'heading_views' => __( 'Filter users list' ), + 'heading_pagination' => __( 'Users list navigation' ), + 'heading_list' => __( 'Users list' ), +) ); + if ( empty($_REQUEST) ) { $referer = ''; } elseif ( isset($_REQUEST['wp_http_referer']) ) { @@ -75,25 +87,6 @@ if ( empty($_REQUEST) ) { $update = ''; -/** - * @since 3.5.0 - * @access private - */ -function delete_users_add_js() { ?> - -current_action() ) { /* Bulk Dropdown menu Role changes */ @@ -101,7 +94,7 @@ case 'promote': check_admin_referer('bulk-users'); if ( ! current_user_can( 'promote_users' ) ) - wp_die( __( 'You can’t edit that user.' ) ); + wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); if ( empty($_REQUEST['users']) ) { wp_redirect($redirect); @@ -109,8 +102,16 @@ case 'promote': } $editable_roles = get_editable_roles(); - if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) - wp_die(__('You can’t give users that role.')); + $role = false; + if ( ! empty( $_REQUEST['new_role2'] ) ) { + $role = $_REQUEST['new_role2']; + } elseif ( ! empty( $_REQUEST['new_role'] ) ) { + $role = $_REQUEST['new_role']; + } + + if ( ! $role || empty( $editable_roles[ $role ] ) ) { + wp_die( __( 'Sorry, you are not allowed to give users that role.' ) ); + } $userids = $_REQUEST['users']; $update = 'promote'; @@ -118,20 +119,25 @@ case 'promote': $id = (int) $id; if ( ! current_user_can('promote_user', $id) ) - wp_die(__('You can’t edit that user.')); + wp_die(__('Sorry, you are not allowed to edit this user.')); // 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[ $_REQUEST['new_role'] ]->has_cap('promote_users') + if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap('promote_users') && ! ( is_multisite() && is_super_admin() ) ) { $update = 'err_admin_role'; continue; } // If the user doesn't already belong to the blog, bail. - if ( is_multisite() && !is_user_member_of_blog( $id ) ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); + if ( is_multisite() && !is_user_member_of_blog( $id ) ) { + wp_die( + '' . __( 'One of the selected users is not a member of this site.' ) . '
', + 403 + ); + } $user = get_userdata( $id ); - $user->set_role($_REQUEST['new_role']); + $user->set_role( $role ); } wp_redirect(add_query_arg('update', $update, $redirect)); @@ -158,14 +164,14 @@ case 'dodelete': } if ( ! current_user_can( 'delete_users' ) ) - wp_die(__('You can’t delete users.')); + wp_die(__('Sorry, you are not allowed to delete users.')); $update = 'del'; $delete_count = 0; foreach ( $userids as $id ) { if ( ! current_user_can( 'delete_user', $id ) ) - wp_die(__( 'You can’t delete that user.' ) ); + wp_die(__( 'Sorry, you are not allowed to delete that user.' ) ); if ( $id == $current_user->ID ) { $update = 'err_admin_del'; @@ -198,14 +204,23 @@ case 'delete': } if ( ! current_user_can( 'delete_users' ) ) - $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); + $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); if ( empty($_REQUEST['users']) ) $userids = array( intval( $_REQUEST['user'] ) ); else $userids = array_map( 'intval', (array) $_REQUEST['users'] ); - add_action( 'admin_head', 'delete_users_add_js' ); + $users_have_content = false; + 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" ) ) { + $users_have_content = true; + } + + if ( $users_have_content ) { + add_action( 'admin_head', 'delete_users_add_js' ); + } include( ABSPATH . 'wp-admin/admin-header.php' ); ?> @@ -214,7 +229,7 @@ case 'delete':@@ -233,39 +248,51 @@ case 'delete': foreach ( $userids as $id ) { $user = get_userdata( $id ); if ( $id == $current_user->ID ) { + /* translators: 1: user id, 2: user login */ echo "