Make WordPress Core

Opened 6 weeks ago

Last modified 4 weeks ago

#42486 new defect (bug)

The Tools screen is blank for users who cannot manage categories or tags

Reported by: johnbillion Owned by:
Milestone: 4.9.2 Priority: normal
Severity: normal Version: 4.9
Component: Administration Keywords: has-patch
Focuses: Cc:


Since Press This was removed in #41689, the Tools screen is only composed of the Categories and Tags Converter.

For users who can't manage categories or tags (Authors and Contributors), the Tools screen is now completely empty. Subscribers currently don't see the Tools admin menu item.

The Tools admin menu item should be removed if there's nothing to display on it.

Attachments (4)

42486-menu.php.patch (1.1 KB) - added by janak007 5 weeks ago.
42486-tools.php.patch (856 bytes) - added by janak007 5 weeks ago.
42486.patch (2.8 KB) - added by janak007 5 weeks ago.
Merged file patch
42486.diff (1.2 KB) - added by dd32 4 weeks ago.

Download all attachments as: .zip

Change History (8)

#1 @janak007
5 weeks ago

  • Keywords has-patch added; needs-patch removed

This would need workaround in two files.
1) menu.php for hiding the tools from admin menu.
2) tools.php for preventing users to access the page from by entering direct URL.

I have added patch for two files. After applying these patches only user with import capability can access to tools page.

#2 @ocean90
5 weeks ago

  • Version changed from trunk to 4.9

5 weeks ago

Merged file patch

#3 @johnbillion
4 weeks ago

  • Milestone changed from 4.9.1 to 4.9.2

4 weeks ago

#4 @dd32
4 weeks ago

A use-case to consider here is when a plugin has added something to the tools page, such as the press this plugin.

I don't think we need to worry about blocking direct access to the page.

The attachments so far on this ticket don't really seem like good solutions, consider these use-cases:

  • User can't import, but can export
  • User can't export, but can import
  • Multisite network has Import/Export disabled, but can access Delete Site
  • Plugin has added submenus to the Tools menu
  • A plugin is adding extra things on the tools page.

To fix this, it's going to need to be some code in wp-admin/includes/menu.php around line 180 which checks that

  • Tools.php doesn't have any sub child nodes
  • !has_action( 'tool_box' ) (to detect custom output on that page) and only then remove the menu from the menu.

42486.diff does just this, and I think this covers enough of the edge cases here.
As mentioned in the patch, it's still possible to hit a blank page when the user can import, but can't modify tags/cats, the menu will have subpages of importers/etc in that case.
Maybe we could increase the amount of text on the page, showing a description of the page & a "Sorry, nothing you can access right now" message when no tools on offer?

Note: See TracTickets for help on using tickets.