• Resolved geoffe

    (@geoffe)


    I’ve read that

    It is also possible, but strongly discouraged, to create top-level menus in the admin console.

    I’m not creating a plugin for general release, but would like some explanation of how this trick is done. I’ve got a plugin that I want to add submenu functions for it, but can’t get the menu to behave properly.

    Creating the top-level menu item is simple enough, and I can create sub-level menu items, but I’m learning that navigating between each is not simple enough. Each menu item has a different GET variable added to the URI and that doesn’t seem to distinguish whether it is highlighted or not.

    I’ve read the codex pages and looked through menu.php and admin.php. It seems there is a confusion with filenames. Is it not possible to have submenu items called from the same file as the top level item? Is there someplace to modify the code so that it will recognize pages with different GET variables attached as unique?

Viewing 1 replies (of 1 total)
  • Thread Starter geoffe

    (@geoffe)

    I came up with the solution, and indeed it was necessary to create separate files for the navigation to work.

    So I created two ‘dummy’ files that pointed to the necessary function in my plugin class using this code and putting into a file named contacts.php in this example:

    <?php
    require_once (‘admin.php’);
    $title = __(‘Contacts’);
    $parent_file = ‘contacts.php’;
    require_once (‘admin-header.php’);
    $cmanager->admin_menu();
    $cmanager->admin_training_page(‘contacts’);
    include (‘admin-footer.php’);
    ?>

    admin_menu() is used to call the add_submenu_page and add_menu_page functions

Viewing 1 replies (of 1 total)
  • The topic ‘top level menu item’ is closed to new replies.