I’ve used add_menu_page()
to create a top-level dashboard menu item for a custom taxonomy. This is due to some specific needs with respect to this plugin. The menu item works fine, but when you click it, the Posts menu opens. I’ve tried to hook the parent_file
filter to change that and the best I’ve been able to accomplish is to ensure that no menu appears.
add_action("admin_menu", "add_bureau_menu_item");
add_filter("parent_file", "fix_bureau_tax_parent");
public function add_bureau_menu_item() {
$tax = get_taxonomy("bureau");
add_menu_page("Bureaus", "Bureaus", "read", "edit-tags.php?taxonomy=" . $tax->name, "", "", 20);
}
public function fix_bureau_tax_parent($parent="") {
global $pagenow;
$tax = get_taxonomy("bureau");
if(!empty($_GET["taxonomy"]) && $_GET["taxonomy"]==$tax->name && $pagenow=="edit-tags.php") $parent = "edit-tags.php?taxonomy=" . $tax->name;
return $parent;
}
So, here’s the question: is there a way to highlight a menu item created with add_menu_page()
using the parent_file
filter?