I am writing a plugin which requires exporting custom taxonomies in csv on submit button click. I am using get_terms() to export taxonomies terms. I have written a class file which handle this operation and this file is included on the top of plugin main file.
I have searched about it and found out that get_terms() doesn't work until theme function.php is not loaded. So I want to know where should I include the class file. I have checked various hooks also but problem is that if I include it on admin_menu or admin_init hooks then it also outputs some other text of wordpress in exported csv file.
So please let me know how should I include the class file.