Change the $parent_file of a plugin page

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.

Read More

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.

Related posts

Leave a Reply

1 comment