[wp-trac] [WordPress Trac] #24104: Remove duplicated separators in admin menu

WordPress Trac noreply at wordpress.org
Tue Apr 16 17:26:38 UTC 2013


#24104: Remove duplicated separators in admin menu
-----------------------------+--------------------------
 Reporter:  rilwis           |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Menus
  Version:  trunk            |   Severity:  normal
 Keywords:  has-patch        |
-----------------------------+--------------------------
 I'm working on WordPress admin menu, and I found that the code to remove
 duplicated separators in admin menu in `wp-admin/includes/menu.php`
 doesn't work correctly.

 Assuming we have these items in the `$menu`:


 {{{
 $menu = array(
         100 => array(
                 0 => 'Admin Style',
                 2 => 'wp-admin-style.php',
                 1 => 'read',
                 4 => 'menu-top menu-icon-generic toplevel_page_wp-admin-
 style menu-top-first menu-top-last',
                 6 => 'none',
         ),
         110 => array(
                 0 => '',
                 1 => 'read',
                 2 => 'separator1',
                 3 => '',
                 4 => 'wp-menu-separator',
         ),
         130 => array(
                 0 => '',
                 1 => 'read',
                 2 => 'separator2',
                 3 => '',
                 4 => 'wp-menu-separator',
         ),
         140 => array(
                 0 => '',
                 1 => 'read',
                 2 => 'separator-last',
                 3 => '',
                 4 => 'wp-menu-separator',
         ),
         150 => array(
                 0 => 'Hide Menu',
                 1 => 'manage_options',
                 2 => 'hide-admin-menu',
                 3 => 'Hide Admin Menu',
                 4 => 'menu-top toplevel_page_hide-admin-menu',
                 5 => 'toplevel_page_hide-admin-menu',
                 6 => 'http://localhost:8080/wp/wp-content/plugins/hide-
 admin-menu/img/icon.png',
         ),
 );
 }}}

 WordPress will remove only the 1st duplicated separator (130) and still
 keeps the 2nd one (140).

 Another problem with current code is if separator menu item has classes
 like `'wp-menu-separator woocommerce'` (WooCommerce does this), it won't
 be recognized as a separator, because the function to check separator uses
 `strcmp`.

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


More information about the wp-trac mailing list