Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#32784 closed defect (bug) (worksforme)

Admin_init removes theme editor - admin_menu does not.

Reported by: paaljoachim Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: close 2nd-opinion
Focuses: administration Cc:


I am creating a tutorial with removing all the submenu pages in the left admin menu.

remove_submenu_page( 'themes.php', 'theme-editor.php' );
with add_action( 'admin_menu', 'remove_admin_submenus' );

Does not remove the theme editor.

Switching out admin_menu with admin_init the theme editor is also removed.

I am also hoping that there is some simple code to add a custom user role to the adjusted admin menu code.
As well as removing customize, header and background from the themes.php subpage menu.

Change History (3)

#1 @jasonlcrane
6 years ago

  • Keywords close 2nd-opinion added

Take a look at the Notes section on the remove_submenu_page Codex page here: https://codex.wordpress.org/Function_Reference/remove_submenu_page#notes

I can confirm that giving admin_menu a priority of 110 solves this issue. This may be beyond the scope of your tutorial, but I think it's also worth noting that removing the item from the menu doesn't prevent a user from accessing theme-editor.php directly. For that situation specifically, it may better to disable editing from the dashboard completely with

define('DISALLOW_FILE_EDIT', true);

in the wp-config file, as noted here: http://codex.wordpress.org/Hardening_WordPress#Disable_File_Editing

#2 @SergeyBiryukov
6 years ago

  • Component changed from Menus to Administration

#3 @wonderboymusic
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.