Make WordPress Core

Ticket #31178: menu.php.patch

File menu.php.patch, 2.1 KB (added by pbearne, 10 years ago)

concept patch

  • src/wp-admin/menu.php

     
    2222 * @var array
    2323 */
    2424
    25 $menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' );
    2625
     26function get_safe_index( $target_index, $target_array ){
     27        if( ! array_key_exists( $target_index, $target_array ) ){
     28                return $target_index;
     29        }
     30        while( array_key_exists( $target_index, $target_array ) ){
     31                $target_index = $target_index . '.' . rand( 1, 1000 );
     32        }
     33        return $target_index;
     34}
     35
     36
     37$menu[ get_safe_index( 2, $menu ) ] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' );
     38
    2739$submenu[ 'index.php' ][0] = array( __('Home'), 'read', 'index.php' );
    2840
    2941if ( is_multisite() ) {
     
    126138         * by a hard-coded value below, increment the position.
    127139         */
    128140        $core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99);
    129         while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
     141        while ( isset( $menu[$ptype_menu_position] ) || in_array( $ptype_menu_position, $core_menu_positions ) ){
    130142                $ptype_menu_position++;
     143        }
    131144
    132         $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon );
     145
     146        $menu[get_safe_index( $ptype_menu_position, $menu )] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon );
    133147        $submenu["edit.php?post_type=$ptype"][5]  = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts,  "edit.php?post_type=$ptype");
    134148        $submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" );
    135149