Make WordPress Core

Opened 6 years ago

Closed 6 months ago

Last modified 6 months ago

#44460 closed defect (bug) (worksforme)

Menu Items Conflict

Reported by: wlpdrpat's profile wlpdrpat Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-screenshots reporter-feedback
Focuses: Cc:

Description

This issue was fixed in version 4.4 per https://core.trac.wordpress.org/ticket/23316

The latest version of WP the issue resurfaced.

function add_menu_page position values that conflict will either hide primary side menu items or the side menu items will hide the new menu pages:

Defining the position value as 0 or 1 causes the new menu item to hide the Dashboard menu item.

Defining the position value as 2 causes the Dashboard menu item to hide the new menu item.

Defining the position value as 3 or 4 causes the new menu item to hide the Posts menu item.

Defining the position value as 5 causes the Posts menu item to hide the new menu item.

I didn't research it any further but there is definitely a reintroduction of the bug that was previously resolved.

There is no method of defining position to display a new menu item above Dashboard or between Dashboard and Posts. If 2 menu items are created with defined position values between 0-4 then both the Dashboard and Posts menu item are hidden or hide the new menu items depending on the defined values.

Attachments (2)

menu-items-by-positions.png (15.1 KB) - added by subrataemfluence 6 years ago.
admin-menu-extra100.png (54.4 KB) - added by sabernhardt 6 months ago.

Download all attachments as: .zip

Change History (6)

#1 @wlpdrpat
6 years ago

This bug also breaks the functionality of this plugin: https://wordpress.org/plugins/link-manager/

The plugin is supposed to display the Link Manager menu item.

If an additional add_menu_page is defined with position 0-5 then the Links Manager menu item displays but the Media menu item is not displayed. If no add_menu_page is defined with position 0-5 then Media menu item is displayed and Links Manager is not displayed.

#2 @subrataemfluence
6 years ago

  • Component changed from General to Menus
  • Keywords has-screenshots reporter-feedback added

I could not reproduce the error.

The following code in my theme's functions.php generated 6 menu items but no existing item or new item got hidden by one another.

<?php
function add_menu_item(){
   $position_arr = array( 0, 1, 2, 3, 4, 5 );
   foreach ( $position_arr as $item ) {
        add_menu_page(
                'Item-' . $item,
                'ITEM-' . $item,
                'manage_options',
                'item-' . $item,
                '',
                'dashicons-wordpress-alt',
                $item
        );
   }
}

add_action('admin_menu', 'add_menu_item');

I have attached a screenshot of my admin page with all existing and new menu items visible.

Do I need anything else to reproduce the error?

Project configuration:

  • WordPress version: 5.0-alpha-43320
  • Theme: twentyseventeen
  • Installation type: Single site
Version 0, edited 6 years ago by subrataemfluence (next)

#3 @rodrigosprimo
6 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Closing as there has been no feedback in a few years and @subrataemfluence was not able to reproduce the problem. Feel free to reopen with more information if there's still an issue.

#4 @sabernhardt
6 months ago

  • Component changed from Menus to Administration
  • Milestone Awaiting Review deleted

It seems to work properly now.

I tried similar code in a custom plugin (like the function in comment:2, but I extended the position array from 0 to 100 and replaced the icon). The custom top-level links were added below the links from Core and from Link Manager at the same position number.

Last edited 6 months ago by sabernhardt (previous) (diff)
Note: See TracTickets for help on using tickets.