| | 196 | * Helper function used in the one above - get_editable_roles, as sorting |
| | 197 | * callback, in order to achieve sorted roles by capabilities. |
| | 198 | * |
| | 199 | * @param array $role_a |
| | 200 | * @param array $role_b |
| | 201 | * @return int |
| | 202 | */ |
| | 203 | function _sort_editable_roles($role_a, $role_b) { |
| | 204 | $first_cap_count = count( $role_a['capabilities'] ); |
| | 205 | $second_cap_count = count( $role_b['capabilities'] ); |
| | 206 | |
| | 207 | // The capability count is equal, sorting by name then. |
| | 208 | if ( $first_cap_count == $second_cap_count ) |
| | 209 | return strcmp ( $role_a['name'], $role_b['name'] ); |
| | 210 | |
| | 211 | // Less capabilities goes up |
| | 212 | return ( $first_cap_count > $second_cap_count ) ? 1 : -1; |
| | 213 | } |
| | 214 | |
| | 215 | /** |