WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 15 months ago

#32785 new enhancement

Removing admin submenu items lack consistency

Reported by: paaljoachim Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords: needs-patch
Focuses: administration Cc:

Description (last modified by ocean90)

An easy to understand example to remove a admin submenu item is :

remove_submenu_page( 'plugins.php', 'plugin-install.php' );      
remove_submenu_page( 'plugins.php', 'plugin-editor.php' );       		    

Using the add_action admin init one can remove all submenu pages except:

Appearance -> Customize, Header and Background.

I found the following code to remove these sections.

//Remove the custom options provided by the default twentyeleven theme. https://wordpress.org/support/topic/remove-header-and-background-option-pages-in-twenty-eleven-child-theme?replies=11
add_action( 'after_setup_theme','remove_header_background', 100 );
function remove_header_background() {
	remove_custom_background();
	remove_custom_image_header();
}
function remove_customize_page(){
	global $submenu;
	unset($submenu['themes.php'][6]); // remove customize link
}
add_action( 'admin_menu', 'remove_customize_page');

Having to add extra code shows lack of consistency. Removing Customize, Header and Background should be just as simple as:

remove_submenu_page( 'themes.php', 'customize.php' );    	     		 
remove_submenu_page( 'themes.php', 'customize-header.php' );    	     
remove_submenu_page( 'themes.php', 'custom-background.php' );  

Change History (6)

#2 @ocean90
2 years ago

  • Description modified (diff)

#3 @paaljoachim
2 years ago

Thank you for adjusting the description ocean90..:)

#4 @welcher
15 months ago

  • Keywords needs-patch added

#5 @welcher
15 months ago

@paaljoachim did you want to try adding a patch for this?

#6 @paaljoachim
15 months ago

I will look into it.

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