Hi I am building a plugin options page. What I’d really like to do is implement repeatable tabs (which I know is possible with the Settings API), but with a twist I haven’t seen in any options panel till now. I’d like to create new tabs on the fly, exactly like the ‘Menus’ section in the admin UI works.
Is there any standard way to do this?
WordPress Tabs are non-standard, static html markup. You can only add the markup within your
functions.php
theme file or inside your plugin.In this helper plugin (WordPress Admin Style) you’ll find the class references for the default markup of the admin area.
Full plugin snapshot. The previous snapshot is a detail located at the bottom of this one.
Click to enlarge:
Create an array of tabs you would like to create on your admin page. This would most likely contain your menu pages added by your plugin. The array keys would be the page slug, and the array values would be the tab text.
Echo the function where you want the tabs to display within your plugin.
I’ve updated Michael’s solution so that it can be used as a tab within a single page. By calling
main_function()
, you will output the tabs which will link and output the files outlined in the$my_plugin_tabs
section.For instance, by clicking on Settings you will have the tab load
settings.php
and have the tabs showing. I thought it might help to have this uploaded as well: