Excluding categories from “Manage Categories” using a get_terms filter

I’m using a filter on get_terms (see below) to remove a specified number of named categories from the “Manage Categories” listing. It works great, however, the excluded categories are still counted in the category count field that’s displayed just under the “Search Categories” button.

Is it possible that I can subtract these categories from the count?

function admin_edit_tags() {add_filter( 'get_terms', 'admin_trim_category_description', 10, 2 );}

function admin_trim_category_description( $terms, $taxonomies ){
    if( 'category' != $taxonomies[0] )return $terms;
    $my_categories = array('test1','test2','test3');
    foreach( $terms as $key => $term) 
        if(in_array($terms[$key]->name, $my_categories)) { unset($terms[$key]);}
        else
        {
        if(isset($terms[$key]->description) && $terms[$key]->description !=='') $terms[$key]->description = strip_tags(substr( $term->description, 0, 75 ))."...";
        }
        return $terms;
    }

Solutions Collecting From Web of "Excluding categories from “Manage Categories” using a get_terms filter"

I think you should use get_terms_args filter instead of get_terms and just add exclude arg, so now get_terms() function won’t retrieve those cats and you’ll get right count. Here’s code example:

add_filter( 'get_terms_args', 'mamaduka_edit_get_terms_args', 10, 2 );
/**
 * Exclude categories from "Edit Categories" screen
 *
 */
 function mamaduka_edit_get_terms_args( $args, $taxonomies ) {
    if ( is_admin() && 'category' !== $taxonomies[0] )
        return $args;

    $args['exclude'] = array( 8, 10); // Array of cat ids you want to exclude
    return $args;
}