I'm a newbie plugin developer, and I've had an idea for what I though would be a simple to build debut plugin, but I seem to have reached a brick wall with it and wonder if anyone can suggest some alternative approaches or even tell me whether it's even possible.

The aim of the plugin was this: to create tool tips showing the plugin name, for any menu items in the Admin pages that were created by plugins (i.e. not part of the default WP install). So for example you might see the menu item: Users/Roles, and think 'where does that Roles item come from?' You'd then hover over the item, and a tool tip would pop up saying "Added by Members plugin", so you know that item was added by the Members plugin.

So at first I explored the Walker class, but this didn't seem to apply to menus in the admin. Next I looked for filters for the admin menu, to try and add an HTML title attribute into menu items created by plugins, but I didn't seem to be able to find any suitable filters.

I looked at the $menu and $submenu global variables in WP, but for some reason, some menu items that were present in the page weren't in these collections, in particular those created by the aforementioned Members plugin.

So finally I thought I would grab the array of plugins using the get_plugins() function, I then extracted the name of each plugin folder from this and guessed this would be the name of the plugin. I then passed this list of plugin names and their diplay names into javascript parameters for use by a jquery function, to see if it could find any of these plugin names in any of the html links or class names in the admin menus. It then added an html title attribute to any matched links and displayed it with the jquery tooltip() funtionality.

This worked partially, but since many of the plugin names do not appear in the links they create or even the titles of the menus they create, it's incomplete and so not very useful.

So I wonder if there's anything I've overlooked that could be a way to achieve this functionality more robustly?

Thanks for any help/suggestions.

  • 1
    this sounds like an impossible task as WP is too flexible to actually follow any specific pattern, especially using names as they can be translated, but I wonder what exactly is the use case for such a functionality? Commented May 5, 2016 at 14:43
  • to clarify it is possible, but for general solution you might need to parse the plugin's php files and or used backtrace to figure out which file added a menu and then try to guess the plugin. both can be done, but do they worth the effort? Commented May 5, 2016 at 14:47
  • Thanks for your input @MarkKaplun. The use case has been my own frustration when I have installed many plugins to a WP site and then want to remove some I don't use. After a while I find I can forget which plugin is responsilble for which menu item, especially when a setting is not even in a menu but in a property page. So it would be handy to see exactly how a plugin has changed the mens etc. to quickly see if it's something I use or not.
    – Jelnet
    Commented May 6, 2016 at 17:38

1 Answer 1


Plugins generate menu items by calling add_management_page(). Here they insert the slug that ends up in the menu. Usually this slug is the same as the plugin slug, but this is not mandatory. Hence your partial result when you tried this. You would have to scavenge all plugin files to find the slugs as @Mark Kaplun suggested.

Or you could override add_management_page(). Make sure your plugin is loaded as early as possible (use add_action('muplugins_loaded', 'your_plugin_name',0);), so all other plugins will use your version of add_management_page().

Using PHP's debug_backtrace you can find the function that called your version of add_management_page(). Next you can find the path where that calling function originates with PHP's ReflectionFunction. Then you match the path with the list of plugins you got using get_plugins(). This gives you all the information you need for your tooltip.

So, it's a hell of a job and I certainly didn't try it out.

  • Edited just to correct a word
    – cjbj
    Commented May 6, 2016 at 13:11
  • Thanks @cjbj that's very helpful I shall take a look at trying that.
    – Jelnet
    Commented May 6, 2016 at 17:43
  • Quick question @cjbj - you mentioned overriding add_management_page() - however if I try and redefine that function I get a PHP error. I looked into the PHP override_function but that seems to require a PECL extension which I'm not sure can be packed into a plugin. Is that what you meant or maybe I misunderstood something? Ta for any help.
    – Jelnet
    Commented May 19, 2016 at 12:59
  • @Jelnet Perhaps you should look deeper, see which functions are called by add_management_page. Maybe there's a hook there which you can use. Perhaps even something that operates directly on the datastructure. As I said: this really is very complex stuff that I didn't try. I can point in a gerenal direction, but there's no guarantee for success.
    – cjbj
    Commented May 19, 2016 at 13:19

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.