[wp-trac] [WordPress Trac] #21424: Adding an Admin Page Slug without and Admin Menu Link

WordPress Trac wp-trac at lists.automattic.com
Mon Jul 30 15:55:38 UTC 2012


#21424: Adding an Admin Page Slug without and Admin Menu Link
-----------------------------+-----------------------------
 Reporter:  joe.woidpress    |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:  3.4.1
 Severity:  normal           |   Keywords:
-----------------------------+-----------------------------
 I'd like to be able to add an admin page slug that runs a function but
 does not appear in the admin menu.

 For instance, if I create a custom object in a plugin managed in a custom
 database table, I'd like to be able to bring up an edit page for that
 plugin using a page slug and query var like:

 ?page=my-plugin-edit-object&object-id=6

 ...which could help simplify the plugin's architecture into something more
 pseudo-MVC like rather that having to find some sort of twisted PHP
 control flow.

 I can currently get this functionality by using add_submenu_page with the
 $parent_slug parameter set to another submenu (since WordPress doesn't
 support more than one level of submenu nesting).

 For example, in my plugin I'd do something like:

 {{{
 add_menu_page( 'My Plugin', 'My Plugin', 'manage_options', 'my-plugin',
 array( $this, 'my_plugin_main_page' ) );
 add_submenu_page( 'my-plugin', 'My Plugin: Objects', 'objects',
 'manage_options', 'my-plugin-objects', array( $this,
 'my_plugin_objects_page' ) );
 add_submenu_page( 'my-plugin-objects', 'My Plugin: Edit Object', 'edit
 object', 'manage_options', 'my-plugin-edit-object', array( $this,
 'edit_object_page' ) );
 }}}

 ...yet this is sort of in hack territory.

 The idea here is that the admin page with the slug 'my-plugin-edit-object'
 shouldn't be in the main admin menu since it would be accessed only from
 the 'my-plugin-objects' page with a query var for the id of the object in
 the database (e.g. ?page=my-plugin-edit-object&object-id=6 as I have
 above).

 Would it be possible to add some kind of "add_action_page" function to the
 API so that we could create plugins which have admin menu slugs which
 aren't designed to show up as a link in the main admin menu?

 This could be quite useful and make it far easier to architect plugins in
 a sort of "pseudo-MVC" fashion...

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21424>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list