Got it!
check this out:
https://pastebin.com/MR0mGF5q
The only thing now I'm trying is to validate if the endpoint coexists in a page_template, but that doesn't seem to work:
...
$menu_list = array();
$menu_list["MenuList"] = $mb_menu;
$not_available = array();
$not_available["Status"] = 'Endpoint not available';
if(get_page_template('page-menu.php')) {
return $menu_list;
} else {
return $not_available;
}
I don't know if I need to use all the PathURL for the get_template_path or is no logic to call that function for the endpoint (that I feel that is the right answer, lol).
In another case which validation you recommend guys?
Thank you