[wp-hackers] Strange behavior in plugin with main menu and submenu

Jennifer Hodgdon yahgrp at poplarware.com
Mon Jul 2 14:14:31 GMT 2007


Sorry, I forgot one thing. As noted in the codex, for a submenu, the 
"file" argument (2nd to last argument) has to be unique for each submenu:

The file that handles the display of the menu page content or a unique 
identifier for a submenu of a custom top-level menu.

I'll clarify that in the codex...

Here's some actual code from a plugin I did for a client with its own 
menu section:

   // here is another difference -- I did not pass in __FILE__
   // directly, but plugin_basename(__FILE__)

   $confmgrFileName = plugin_basename(__FILE__);
   $accessLevel = 10;

   add_menu_page( 'Conference Manager', 'Conferences', $accessLevel,
                  $confmgrFileName, 'confmgr_conference_screen' );

   add_submenu_page( $confmgrFileName,
                     'Conferences', 'Conferences',
                     $accessLevel, $confmgrFileName, 
'confmgr_conference_screen' );

   // here's the second submenu, where I chose
   // 'confmgr_sponsors' as the unique ID

   add_submenu_page( $confmgrFileName,
                     'Sponsors', 'Sponsors',
                     $accessLevel, 'confmgr_sponsors', 
'confmgr_sponsor_screen' );

       --Jennifer

-- 
Jennifer Hodgdon

Poplar ProductivityWare * www.poplarware.com
Web Databases/Scripts * Modeling/Analysis/Palm OS Software


More information about the wp-hackers mailing list