As long as it gets registered before the admin_menu
hook happens, it doesn’t matter what file you put it in. The important part is what hook you call your function on. For simplicity sake you could put it in a themes functions.php
. If you want things to look a bit cleaner then put it in a php file named admin-menu.php
(or whatever explanatory name you want) and require_once
that file from functions.php
add_action('admin_menu', 'your_function_name');
function your_function_name() {
add_menu_page(...)// add your menu page here
}