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

        foreach (wp_roles()->roles as $_role_id => $_role) {
            foreach (array_keys($_role['capabilities'] ?? []) as $_role_cap) {
                $collection[$_role_cap] = $_role_cap;
            }
        } // unset($_role_id, $_role, $_role_cap); // Housekeeping.

        $collection = array_merge($collection, $this->forRole('super_admin', $no_cache));

        foreach (get_post_types([], 'objects') as $_post_type => $_post_type_object) {
            foreach ($_post_type_object->cap ?? [] as $_core_cap => $_post_type_cap) {
                if (!in_array($_core_cap, ['read_post', 'edit_post', 'delete_post'], true)) {
                    // ↑ Do not include post meta caps; see: <http://jas.xyz/1XN7IKd>
                    $collection[$_core_cap]      = $_core_cap;
                    $collection[$_post_type_cap] = $_post_type_cap;
                }
            } // unset($_core_cap, $_post_type_cap);
        } // unset($_post_type, $_post_type_object); // Housekeeping.

        foreach (get_taxonomies([], 'objects') as $_taxonomy => $_taxonomy_object) {
            foreach ($_taxonomy_object->cap ?? [] as $_core_cap => $_taxonomy_cap) {
                $collection[$_core_cap]     = $_core_cap;
                $collection[$_taxonomy_cap] = $_taxonomy_cap;
            } // unset($_core_cap, $_taxonomy_cap);
        } // unset($_taxonomy, $_taxonomy_object); // Housekeeping.

        asort($collection, SORT_NATURAL);

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

        foreach (wp_roles()->roles as $_role_id => $_role) {
            foreach (array_keys($_role['capabilities'] ?? []) as $_role_cap) {
                $collection[$_role_cap] = $_role_cap;
            }
        } // unset($_role_id, $_role, $_role_cap); // Housekeeping.

        $collection = array_merge($collection, $this->forRole('super_admin', $no_cache));

        foreach (get_post_types([], 'objects') as $_post_type => $_post_type_object) {
            foreach ($_post_type_object->cap ?? [] as $_core_cap => $_post_type_cap) {
                if (!in_array($_core_cap, ['read_post', 'edit_post', 'delete_post'], true)) {
                    // ↑ Do not include post meta caps; see: <http://jas.xyz/1XN7IKd>
                    $collection[$_core_cap]      = $_core_cap;
                    $collection[$_post_type_cap] = $_post_type_cap;
                }
            } // unset($_core_cap, $_post_type_cap);
        } // unset($_post_type, $_post_type_object); // Housekeeping.

        foreach (get_taxonomies([], 'objects') as $_taxonomy => $_taxonomy_object) {
            foreach ($_taxonomy_object->cap ?? [] as $_core_cap => $_taxonomy_cap) {
                $collection[$_core_cap]     = $_core_cap;
                $collection[$_taxonomy_cap] = $_taxonomy_cap;
            } // unset($_core_cap, $_taxonomy_cap);
        } // unset($_taxonomy, $_taxonomy_object); // Housekeeping.

        asort($collection, SORT_NATURAL);

        return $collection;
    }
public function collectAll ( bool $ no_cache = false ) : array { if ( ( $ collection = & $ this -> cacheKey ( __FUNCTION__ ) ) !== null && ! $ no_cache ) { return $ collection ; // Already cached this. } $ collection = [ ] ; // Initialize. foreach ( wp_roles ( ) -> roles as $ _role_id => $ _role ) { foreach ( array_keys ( $ _role [ 'capabilities' ] ?? [ ] ) as $ _role_cap ) { $ collection [ $ _role_cap ] = $ _role_cap ; } } // unset($_role_id, $_role, $_role_cap); // Housekeeping. $ collection = array_merge ( $ collection , $ this -> forRole ( 'super_admin' , $ no_cache ) ) ; foreach ( get_post_types ( [ ] , 'objects' ) as $ _post_type => $ _post_type_object ) { foreach ( $ _post_type_object -> cap ?? [ ] as $ _core_cap => $ _post_type_cap ) { if ( ! in_array ( $ _core_cap , [ 'read_post' , 'edit_post' , 'delete_post' ] , true ) ) { // ↑ Do not include post meta caps; see: <http://jas.xyz/1XN7IKd> $ collection [ $ _core_cap ] = $ _core_cap ; $ collection [ $ _post_type_cap ] = $ _post_type_cap ; } } // unset($_core_cap, $_post_type_cap); } // unset($_post_type, $_post_type_object); // Housekeeping. foreach ( get_taxonomies ( [ ] , 'objects' ) as $ _taxonomy => $ _taxonomy_object ) { foreach ( $ _taxonomy_object -> cap ?? [ ] as $ _core_cap => $ _taxonomy_cap ) { $ collection [ $ _core_cap ] = $ _core_cap ; $ collection [ $ _taxonomy_cap ] = $ _taxonomy_cap ; } // unset($_core_cap, $_taxonomy_cap); } // unset($_taxonomy, $_taxonomy_object); // Housekeeping. asort ( $ collection , SORT_NATURAL ) ; return $ collection ; }
Collect caps.

@since 160524 Cap utils.

@param bool $no_cache Bypass cache?

@return array All collected caps.
Collect caps .