WordPress.org

Make WordPress Core

Ticket #12951: menu_overwrite_fix.diff

File menu_overwrite_fix.diff, 1.1 KB (added by blepoxp, 8 years ago)

fixes admin menu items from being overwritten

  • wp-admin/menu.php

     
    119119        $ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : $_wp_last_object_menu;
    120120        $menu_icon = is_string($ptype_obj->menu_icon) ? esc_url($ptype_obj->menu_icon) : 'div';
    121121       
     122        // if $ptype_menu_position is already populated or it is equal to core menu_position loaded below, recurssivly increment
     123        $core_menu_positions = array(59,60,65,70,75,80,85,99);
     124        while( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position , $core_menu_positions) ){
     125                $ptype_menu_position++;
     126        }
     127       
    122128        $menu[$ptype_menu_position] = array(esc_attr($ptype_obj->label), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-posts', 'menu-' . sanitize_html_class($ptype), $menu_icon);
    123129        $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), $ptype_obj->edit_type_cap,  "edit.php?post_type=$ptype");
    124130        /* translators: add new custom post type */