2

I have a plugin that has 3 pages. One of those pages, I don't want displayed in the admin menu (working), but when a user is on that page, I want the plugin menu to be active.

I'm using the parent_file filter, but it isn't working.

I've had a look in the core, and alghouth the filter seems to be accepting the correct value ($parent_file = 'charts'), by the time the menu is being output, something else has changed it back ($parent_file = 'edit-chart').

/**
 * Highlight the 'Charts' top level menue when viewing the 'Edit Chart' page
 */
function on_menu_parent($parent_file) {

    global $current_screen;

    $base = $current_screen->base;
    if($base == 'admin_page_edit-chart') :
        $parent_file = 'charts';
    endif;

    return $parent_file;

}

The filter, called from the Plugin Class constructor is this -

add_filter('parent_file', array(&$this, 'on_menu_parent'));

Does anybody know how to get this working correctly? Thanks.

1 Answer 1

1

If written the "Current Admin Info" plugin for exactly that reason: Find what you need, when you need it. It adds a help tab with all the currently available (contextual info).

enter image description here

enter image description here

6
  • 1
    This. This is very cool. Commented Nov 22, 2012 at 18:27
  • @TheDeadMedic Thanks :) Btw: It's extensible. So if you got other classes (a.k.a. Help Tabs), you want to incorporate, feel free to send me a pull request.
    – kaiser
    Commented Nov 22, 2012 at 18:54
  • While I thank you for you answer, I don't understand how this can help me. I've tried to install it, as maybe I'm misunderstanding it's purpose, but with it active, no extra info is available in any of my help tabs?
    – David Gard
    Commented Nov 23, 2012 at 10:03
  • @DavidGard You have "tried" to install it, or did you install it? Are you saying, that you can't see the additional help tabs? Please clarify.
    – kaiser
    Commented Nov 23, 2012 at 12:56
  • Installed and cannot see any additional help tabs. Thanks.
    – David Gard
    Commented Dec 3, 2012 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.