[wp-hackers] Creating an options sub-submenu

Rob Miller r at robm.me.uk
Mon Jun 25 16:56:39 GMT 2007


Alex Günsche wrote:
> On Mon, 2007-06-25 at 17:12 +0100, Rob Miller wrote:
>   
>> Or one for the "read his message" category? :P He's wanting to create 
>> sub-sub-menu entries for each of his option pages; that is, Options -> 
>> HisPlugin -> Foo, Options -> HisPlugin -> Bar, etc.
>>     
>
> I see .. sorry, Lutz. I was too fascinated by the ASCII art, and for
> some reason thought that "Options" stands for the entire menu bar. :-/
>
> However, afaik there is no official way for this. But you might try to
> create sub-sub-menus e.g. by creating one and controling the actual
> output via a GET parameter.
>
> As the page itself already is actually a GET parameter for admin.php (or
> the respective menu item), you would have to mask the parameter and
> parse the entire request URI to get your parameter. Or, you could insert
> a form with buttons and send the parameter via POST. 
>
> Alex
>
>   
Or just pass an extra parameter; the submenu is passed as "page", so the 
logical choice would probably be "subpage".

So, add an options submenu, and then in your code do something like:

switch ( $_GET['subpage'] ) {
    case 'foo':
        // display "foo" sub-sub-menu
        break;
    case 'bar':
        // display "bar" sub-sub-menu
        break;
}

Which will allow you to use options.php?page=your-plugin&subpage=foo to 
display the "foo" sub-sub-menu, options.php?page=your-plugin&subpage=bar 
to display the "bar" sub-sub-menu, etc.

But to address the original question: no, there's no official way to do 
this. Either create your own sub-sub-menu as above, or just create a new 
menu item--whichever's more logical and intuitive.

--
Rob Miller
http://robm.me.uk/


More information about the wp-hackers mailing list