1

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?

  • 1
    Will do. Sorry for the extra work. – David Kees Nov 5 '13 at 12:53
  • Any update on this? – Alexandre Bourlier Aug 14 '14 at 11:21
  • Nope. I never got a response. When clients have needed it, I tend to use jQuery to add the appropriate class to the menu items. And, it's usually fairly easy to add that script only on the pages which need it so I figure it's not the worst way to go. – David Kees Aug 14 '14 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.