• I have a number of small plugins that are most useful for people to install singly. However, they can work together. My thought is that they could install a top-level options menu in the admin, to which the plugins’ settings pages could be submenus. But there is no clear idea about which plugin should be installed first. If I got the plugin to install a top-level menu options page, can subsequent installations check to see if the top-level menu already exists? If it doesn’t exist, the plugin could create it, but if it does exist, the plugin could simply install its options page as a submenu to the existing top-level menu.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Yes, your top level menu definition script could set a global variable indicating the top level menu has just been defined. Another possibility would be to simply check the global $menu for the existence of your menu in the array. I’m less than confident this would actually work, but it would be worth a try to avoid an extra global floating around.

    Thread Starter Paul Taylor

    (@pftaylor61)

    The first step has worked. I declared the top level menu, by using:

    if (!isset($glob_tlm)) {

    where $glob_tlm will contain the menu-slug of the top level menu.

    Now I need to put the same functions in the class for one of my other plugins, and then attempt to install it. I’ll post another comment if it works!

    Thanks for the help.

    Thread Starter Paul Taylor

    (@pftaylor61)

    Unfortunately, this did not work. It simply added a second top level menu with the same menu_slug, and placed both plugins menus against both the top level menus. I’ll have to look again. I need it to know if the top level menu has been produced by another.

    I’m facing the same issue. Could someone elaborate as to how to achieve the above please?

    Just to recap, what I’m trying to do is to create a suit of plugins that each add a submenu to the same top level menu. But as each plugin in the suite is optional and there is no set order to their possible installation, each plugin needs a script which does the following:

    1. check whether the top menu item exists
    2. If not exists, then create it
    3. If exists, then add another submenu item to it.

    The full code example would be appreciated, as after half a day’s searching the net, there is precious little out there that provides any successful help, but a lot of people asking for the same functionality, so this forum topic would be the sole resource on this topic.

    Many thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘General top level admin menu’ is closed to new replies.