[wp-hackers] Add_Submenu_Page Q's

Mike Walsh mike_walsh at mindspring.com
Tue Sep 18 03:50:04 GMT 2007


Thank you very much for this example, it helped me quite a bit.  It turns
out my code wasn't much different than what is posted below BUT my code also
included calls to add_options_page(), add_management_page(), and
add_theme_page().  If these calls happen prior to calling add_menu_page()
and/or add_submenu_page(), the creation of the custom sub menus fails.

I have re-posted my code for a single file Menu Tester plugin which now
works.  Hopefully someone else will find this useful.

http://www.onefishtwofish.net/menutester.txt (change the file extension to
.php)

Mike


--
Mike Walsh -- mike_walsh at mindspring dot com



-----Original Message-----

   5. Re: Add_Submenu_Page Q's (Jennifer Hodgdon)


----------------------------------------------------------------------

Message: 5
Date: Mon, 17 Sep 2007 09:01:19 -0700
From: Jennifer Hodgdon <yahgrp at poplarware.com>
Subject: Re: [wp-hackers] Add_Submenu_Page Q's
To: wp-hackers at lists.automattic.com
Message-ID: <46EEA4CF.20007 at poplarware.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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