[wp-trac] [WordPress Trac] #19085: Deleting First Submenu Page in Admin Menu breaks URL for Menu Page

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 29 18:44:20 UTC 2011


#19085: Deleting First Submenu Page in Admin Menu breaks URL for Menu Page
----------------------------+-----------------------------
 Reporter:  mikeschinkel    |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  3.3
 Severity:  major           |   Keywords:  needs-patch
----------------------------+-----------------------------
 If you attempt to remove the Post Type Submenu Page in the Admin it breaks
 the Menu Page URL; it causes the Menu Page URL to be the same as the new
 first Submenu Page URL:

 [[Image(http://screenshots.newclarity.net/skitched-20111029-142108.png)]]

 Here is a simple class you can drop into the theme's `functions.php` file
 to experience this bug. This example is a minimum to trigger the error
 ''(I simplified the `register_post_type()` call so the example code would
 have fewer lines):''

 {{{
 <?php

 class Trigger_Admin_Menu_Bug {
   static function on_load() {
     add_action( 'init', array( __CLASS__, 'init' ) );
     add_action( 'parent_file', array( __CLASS__, 'parent_file' ) );
   }
   static function init() {
     global $wpdb;
     register_post_type( 'test-cpt', array(
       'label'   => 'Test CPT',
       'show_ui' => true,
     ));
   }
   static function parent_file( $parent_file ) {
     remove_submenu_page( 'edit.php?post_type=test-cpt',
                          'edit.php?post_type=test-cpt' );
     return $parent_file;
   }
 }
 Trigger_Admin_Menu_Bug::on_load();
 }}}

 I'd provide a patch but the admin menu code is more complex than I can
 fully understand.  Maybe the person who originally wrote it could fix it?

 Note: Sadly, this is a blocker for one of my client projects.  The client
 wants the admin menus simplified to reduce the conceptual load on their
 end users because we are adding many other submenu pages.  Plus I've
 traced through the core WP code with a debugger for many hours looking for
 hooks that would allow me to get around this issue, but there simply are
 no hooks where it would be needed to hack a fix for this.

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


More information about the wp-trac mailing list