Ticket #22993: 22993.2.diff
File 22993.2.diff, 2.6 KB (added by , 11 years ago) |
---|
-
wp-includes/user.php
1077 1077 // 1078 1078 1079 1079 /** 1080 * Get array of user IDs that have no role 1081 */ 1082 function wp_get_norole_users() { 1083 global $wpdb, $wp_roles; 1084 $id = get_current_blog_id(); 1085 $blog_prefix = $wpdb->get_blog_prefix($id); 1086 if ( ! isset( $wp_roles ) ) 1087 $wp_roles = new WP_Roles(); 1088 $role_keys = array_keys( $wp_roles->get_names() ); 1089 $norole_regexp = implode( "|", $role_keys ); 1090 $norole_users = $wpdb->get_col( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities' AND meta_value NOT REGEXP '{$norole_regexp}'" ); 1091 return $norole_users; 1092 } 1093 1094 /** 1080 1095 * Set up global user vars. 1081 1096 * 1082 1097 * Used by wp_set_current_user() for back compat. Might be deprecated in the future. -
wp-admin/includes/class-wp-users-list-table.php
44 44 45 45 $paged = $this->get_pagenum(); 46 46 47 $args = array( 48 'number' => $users_per_page, 49 'offset' => ( $paged-1 ) * $users_per_page, 50 'role' => $role, 51 'search' => $usersearch, 52 'fields' => 'all_with_meta' 53 ); 47 if ( ( 'none' == $role ) && ( $norole_users = wp_get_norole_users() ) ) { 48 $args = array( 49 'number' => $users_per_page, 50 'offset' => ( $paged-1 ) * $users_per_page, 51 'include' => $norole_users, 52 'search' => $usersearch, 53 'fields' => 'all_with_meta' 54 ); 55 } else { 56 $args = array( 57 'number' => $users_per_page, 58 'offset' => ( $paged-1 ) * $users_per_page, 59 'role' => $role, 60 'search' => $usersearch, 61 'fields' => 'all_with_meta' 62 ); 63 } 54 64 55 65 if ( '' !== $args['search'] ) 56 66 $args['search'] = '*' . $args['search'] . '*'; … … 116 126 $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>"; 117 127 } 118 128 129 if ( $norole_users = wp_get_norole_users() ) { 130 $class = ( isset( $_REQUEST['role'] ) && ( 'none' == $_REQUEST['role'] ) ) ? ' class="current"' : ''; 131 $norole_user_count = count( $norole_users ); 132 $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$class>" . sprintf( _nx( 'None <span class="count">(%s)</span>', 'None <span class="count">(%s)</span>', $norole_user_count, 'users' ), number_format_i18n( $norole_user_count ) ) . '</a>'; 133 } 134 119 135 return $role_links; 120 136 } 121 137