public function forRole(string $role_id, bool $no_cache = false): array
    {
        if (($collection = &$this->cacheKey(__FUNCTION__, $role_id)) !== null && !$no_cache) {
            return $collection; // Already cached this.
        }
        $collection = []; // Initialize.

        if ($role_id === 'super_admin') {
            $role_id = 'administrator';

            if ($this->Wp->is_multisite) {
                $collection = array_merge($collection, [
                    'manage_network'         => 'manage_network',
                    'manage_sites'           => 'manage_sites',
                    'manage_network_users'   => 'manage_network_users',
                    'manage_network_plugins' => 'manage_network_plugins',
                    'manage_network_themes'  => 'manage_network_themes',
                    'manage_network_options' => 'manage_network_options',
                ]);
            }
        }
        $role = get_role($role_id); // If role exists.

        foreach (array_keys($role->capabilities ?? []) as $_role_cap) {
            $collection[$_role_cap] = $_role_cap;
        } // unset($_role_cap); // Housekeeping.

        asort($collection, SORT_NATURAL);

        return $collection;
    }
public function forRole(string $role_id, bool $no_cache = false): array
    {
        if (($collection = &$this->cacheKey(__FUNCTION__, $role_id)) !== null && !$no_cache) {
            return $collection; // Already cached this.
        }
        $collection = []; // Initialize.

        if ($role_id === 'super_admin') {
            $role_id = 'administrator';

            if ($this->Wp->is_multisite) {
                $collection = array_merge($collection, [
                    'manage_network'         => 'manage_network',
                    'manage_sites'           => 'manage_sites',
                    'manage_network_users'   => 'manage_network_users',
                    'manage_network_plugins' => 'manage_network_plugins',
                    'manage_network_themes'  => 'manage_network_themes',
                    'manage_network_options' => 'manage_network_options',
                ]);
            }
        }
        $role = get_role($role_id); // If role exists.

        foreach (array_keys($role->capabilities ?? []) as $_role_cap) {
            $collection[$_role_cap] = $_role_cap;
        } // unset($_role_cap); // Housekeeping.

        asort($collection, SORT_NATURAL);

        return $collection;
    }
public function forRole ( string $ role_id , bool $ no_cache = false ) : array { if ( ( $ collection = & $ this -> cacheKey ( __FUNCTION__ , $ role_id ) ) !== null && ! $ no_cache ) { return $ collection ; // Already cached this. } $ collection = [ ] ; // Initialize. if ( $ role_id === 'super_admin' ) { $ role_id = 'administrator' ; if ( $ this -> Wp -> is_multisite ) { $ collection = array_merge ( $ collection , [ 'manage_network' => 'manage_network' , 'manage_sites' => 'manage_sites' , 'manage_network_users' => 'manage_network_users' , 'manage_network_plugins' => 'manage_network_plugins' , 'manage_network_themes' => 'manage_network_themes' , 'manage_network_options' => 'manage_network_options' , ] ) ; } } $ role = get_role ( $ role_id ) ; // If role exists. foreach ( array_keys ( $ role -> capabilities ?? [ ] ) as $ _role_cap ) { $ collection [ $ _role_cap ] = $ _role_cap ; } // unset($_role_cap); // Housekeeping. asort ( $ collection , SORT_NATURAL ) ; return $ collection ; }
Collect role caps.

@since 160524 Cap utils.

@param string $role_id  Role ID.
@param bool   $no_cache Bypass cache?

@return array All role caps.
Collect role caps .