How to exclude a category returned by get_categories from function.php?


I have a plugin that create my website sitemap. It starts by getting all categories with get_categories and then gets all pages for each. However I have one category that must not be included then I did that in the plugin code:

$  args['exclude']=2; $  cats = get_categories( $  args ); 

The problem is that if the plugin replace the file my modiofication will be deleted, I tried with that:

function exclude_cat($  taxonomy, $  args) {          $  args['exclude']=2;     return $  args; }  add_filter('get_categories_taxonomy', 'exclude_cat', 10, 2); 

But then no category is returned at all, I think I’m not using it correctly but I don’t find examples.