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

        $default_args = [
            // Also used by {@link all()}.
            'taxonomy_filters'   => [],
            'taxonomies_include' => [],
            'taxonomies_exclude' => [],
            'filters'            => [
                'get'        => 'all',
                'hide_empty' => false,
                'orderby'    => 'name',
            ],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['taxonomy_filters']   = (array) $args['taxonomy_filters'];
        $args['taxonomies_include'] = (array) $args['taxonomies_include'];
        $args['taxonomies_exclude'] = (array) $args['taxonomies_exclude'];
        $args['filters']            = (array) $args['filters'];
        $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 terms in the query.

        $taxonomies = get_taxonomies($args['taxonomy_filters'], 'objects');
        $taxonomies = $args['taxonomies_include'] ? array_intersect_key($taxonomies, array_fill_keys($args['taxonomies_include'], true)) : $taxonomies;
        $taxonomies = $args['taxonomies_exclude'] ? array_diff_key($taxonomies, array_fill_keys($args['taxonomies_exclude'], true)) : $taxonomies;

        $terms = get_terms(array_merge(['taxonomy' => array_keys($taxonomies)], $args['filters'], ['fields' => 'all']));
        $terms = is_array($terms) ? $terms : []; // Force array.

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

        $default_args = [
            // Also used by {@link all()}.
            'taxonomy_filters'   => [],
            'taxonomies_include' => [],
            'taxonomies_exclude' => [],
            'filters'            => [
                'get'        => 'all',
                'hide_empty' => false,
                'orderby'    => 'name',
            ],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['taxonomy_filters']   = (array) $args['taxonomy_filters'];
        $args['taxonomies_include'] = (array) $args['taxonomies_include'];
        $args['taxonomies_exclude'] = (array) $args['taxonomies_exclude'];
        $args['filters']            = (array) $args['filters'];
        $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 terms in the query.

        $taxonomies = get_taxonomies($args['taxonomy_filters'], 'objects');
        $taxonomies = $args['taxonomies_include'] ? array_intersect_key($taxonomies, array_fill_keys($args['taxonomies_include'], true)) : $taxonomies;
        $taxonomies = $args['taxonomies_exclude'] ? array_diff_key($taxonomies, array_fill_keys($args['taxonomies_exclude'], true)) : $taxonomies;

        $terms = get_terms(array_merge(['taxonomy' => array_keys($taxonomies)], $args['filters'], ['fields' => 'all']));
        $terms = is_array($terms) ? $terms : []; // Force array.

        return $total = count($terms);
    }
public function total ( array $ args = [ ] ) : int { // Establish args. $ default_args = [ // Also used by {@link all()}. 'taxonomy_filters' => [ ] , 'taxonomies_include' => [ ] , 'taxonomies_exclude' => [ ] , 'filters' => [ 'get' => 'all' , 'hide_empty' => false , 'orderby' => 'name' , ] , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'taxonomy_filters' ] = ( array ) $ args [ 'taxonomy_filters' ] ; $ args [ 'taxonomies_include' ] = ( array ) $ args [ 'taxonomies_include' ] ; $ args [ 'taxonomies_exclude' ] = ( array ) $ args [ 'taxonomies_exclude' ] ; $ args [ 'filters' ] = ( array ) $ args [ 'filters' ] ; $ 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 terms in the query. $ taxonomies = get_taxonomies ( $ args [ 'taxonomy_filters' ] , 'objects' ) ; $ taxonomies = $ args [ 'taxonomies_include' ] ? array_intersect_key ( $ taxonomies , array_fill_keys ( $ args [ 'taxonomies_include' ] , true ) ) : $ taxonomies ; $ taxonomies = $ args [ 'taxonomies_exclude' ] ? array_diff_key ( $ taxonomies , array_fill_keys ( $ args [ 'taxonomies_exclude' ] , true ) ) : $ taxonomies ; $ terms = get_terms ( array_merge ( [ 'taxonomy' => array_keys ( $ taxonomies ) ] , $ args [ 'filters' ] , [ 'fields' => 'all' ] ) ) ; $ terms = is_array ( $ terms ) ? $ terms : [ ] ; // Force array. return $ total = count ( $ terms ) ; }
Total terms.

@since 160524 Term utils.

@param array $args Behavioral args.

@return int Total terms.
Total terms .