public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'include'  => [],
            'exclude'  => [],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['include']  = (array) $args['include'];
        $args['exclude']  = (array) $args['exclude'];
        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total roles in the query.

        $roles = wp_roles()->roles; // All possible roles.
        $roles = $args['include'] ? array_intersect_key($roles, array_fill_keys($args['include'], true)) : $roles;
        $roles = $args['exclude'] ? array_diff_key($roles, array_fill_keys($args['exclude'], true)) : $roles;

        return $total = count($roles);
    }
public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'include'  => [],
            'exclude'  => [],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['include']  = (array) $args['include'];
        $args['exclude']  = (array) $args['exclude'];
        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total roles in the query.

        $roles = wp_roles()->roles; // All possible roles.
        $roles = $args['include'] ? array_intersect_key($roles, array_fill_keys($args['include'], true)) : $roles;
        $roles = $args['exclude'] ? array_diff_key($roles, array_fill_keys($args['exclude'], true)) : $roles;

        return $total = count($roles);
    }
public function total ( array $ args = [ ] ) : int { // Establish args. $ default_args = [ // Also used by {@link all()}. 'include' => [ ] , 'exclude' => [ ] , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'include' ] = ( array ) $ args [ 'include' ] ; $ args [ 'exclude' ] = ( array ) $ args [ 'exclude' ] ; $ args [ 'no_cache' ] = ( bool ) $ args [ 'no_cache' ] ; // Check cache; already did this query? $ cache_keys = $ args ; // Keys to consider when checking the cache. unset ( $ cache_keys [ 'no_cache' ] ) ; // Cache key exclusions. if ( ( $ total = & $ this -> cacheKey ( __FUNCTION__ , $ cache_keys ) ) !== null && ! $ args [ 'no_cache' ] ) { return $ total ; // Already cached this. } // Establish total roles in the query. $ roles = wp_roles ( ) -> roles ; // All possible roles. $ roles = $ args [ 'include' ] ? array_intersect_key ( $ roles , array_fill_keys ( $ args [ 'include' ] , true ) ) : $ roles ; $ roles = $ args [ 'exclude' ] ? array_diff_key ( $ roles , array_fill_keys ( $ args [ 'exclude' ] , true ) ) : $ roles ; return $ total = count ( $ roles ) ; }
Total roles.

@since 160524 Role utils.

@param array $args Behavioral args.

@return int Total roles.
Total roles .