[wp-hackers] Add_Submenu_Page Q's

Jennifer Hodgdon yahgrp at poplarware.com
Mon Sep 17 16:01:19 GMT 2007


Mike Walsh wrote:
> Does anyone have any suggestions for me or is this just broken with the
> current WP release?   There were no replies to posting of the code I am
> trying to get working.

I haven't looked at your code in detail, but I have found in the past 
that to get a stand-alone menu section to work, you need to have a 
submenu page for the main page of the submenu as well as the other 
pages. Here is some code that does work from a plugin I wrote for a 
client. You may be having trouble using just __FILE__ rather than 
plugin_basename( __FILE__ )... anyway, here is some working code:

// at global level:
$confmgrFileName = plugin_basename(__FILE__);

// the function that creates the screens:
function confmgr_admin_screens()
{
   global $confmgrFileName;

   $accessLevel = 10;

   // top-level menu
   add_menu_page( 'Conference Manager', 'Conferences', $accessLevel,
                  $confmgrFileName, 'confmgr_conference_screen' );

   // sub-menus

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

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

   add_submenu_page( $confmgrFileName,
                     'Sponsorship Levels', 'Sponsorship Levels',
                     $accessLevel, 'confmgr_sponsor_levels', 
'confmgr_sponsor_level_screen' );

// etc. continues with other pages

}

Hope this helps,
      Jennifer

-- 
Jennifer Hodgdon

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



More information about the wp-hackers mailing list