[wp-hackers] Strange behavior in plugin with main menu and submenu
Leonid Mamchenkov
leonid at mamchenkov.net
Sun Jul 1 14:57:50 GMT 2007
Hi,
On 7/1/07, Jennifer Hodgdon <yahgrp at poplarware.com> wrote:
> Yes, I think the Codex doc is correct. But there are two differences
> between what you did and what I have seen work in a plugin:
>
> a) In a previous plugin, I put a function name in for the top-level
> menu (supposedly optional last argument to add_menu_page). That may
> not be necessary.
I don't think it's necessary, but I added in just in case now.
> b) You have set the file argument in add_submenu_page to ''. It needs
> to be set to the plugin file.
I think that if I live it as '', then current plugin file is used
anyway. But just in case, I changed these too.
> With these two changes, your calls would be:
>
> function test_menu() {
> add_submenu_page(__FILE__,'A','A',1,'__FILE__','page_a');
> add_submenu_page(__FILE__,'B','B',1,'__FILE__','page_b');
> add_menu_page('Test','Test',1,__FILE__, 'page_a');
> }
In add_submenu_page() calls you have '__FILE__', which doesn't work.
I corrected it and pasted to my plugin and it still doesn't work.
Now I see the menus OK, and I see the output of page_a(), which was
probably called by add_menu_page(). When I click on the submenu
items, nothing happens.
Suggestions/ideas? :)
--
Leonid Mamchenkov
More information about the wp-hackers
mailing list