WordPress.org

Make WordPress Core

Opened 7 weeks ago

#54073 new defect (bug)

Plugin removes menu items with no submenu page

Reported by: samperrow Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 5.8
Component: Administration Keywords:
Focuses: Cc:

Description

I have a plugin which adds a menu page with the update_plugins capability. There is another plugin I noticed which removes the plugin icon from the menu bar, but the plugin page can still be accessed directly via URL. Instead of the plugin icon, there is only a black void (see image).

Workarounds:
1) When I change the update_plugins capability in the add_menu_page method to activate_plugins, the problem is resolved.
2) If I were to have submenu pages for the plugin, the problem is resolved and the plugin icon is visible as it should be.

To reproduce:
1) add menu page:

<?php
$settings_page = \add_menu_page(
    'Plugin Page Title',
    'Menu title',
    'update_plugins',
     'menu_slug',
     array( $this, 'callback_fn' ),
     'images/icon.png'
);

2) Remove update_plugins option from bulk operations select list (from a separate plugin):

<?php
global $current_user;
$current_user->allcaps['update_plugins'] = 0;

I have using WP 5.8, PHP 8.0.8, non-multisite install (locally and on prod). I have noticed this happens for other matching capabilities too (activate_plugins) for example.
Screenshot: https://imgur.com/LlXaxPl

The two conflicting plugins I am using are “Pre Party Browser Hints” (adds submenu page) and “Disable All WordPress Updates (removes update_plugins operation). I suspect this could be an issue with WP core code, because it does not seem like an intentional feature.

Attachments (1)

Screen Shot 2021-09-03 at 9.57.44 AM.png (44.8 KB) - added by samperrow 7 weeks ago.
screenshot

Download all attachments as: .zip

Change History (1)

Note: See TracTickets for help on using tickets.