*/ public function offered(): array { $names = wp_roles()->role_names; $offered = []; foreach ($names as $slug => $name) { $offered[(string) $slug] = (string) $name; } return $offered; } /** * @return list */ public function held(): array { // Asked before `wp_get_current_user()`, because it is the cheap // question and the answer for most page views: a signed-out visitor // holds no role, and there is nothing here to build a user object for. if (!is_user_logged_in()) { return []; } return array_values(array_map('strval', (array) wp_get_current_user()->roles)); } }