Voulez-vous désactiver la liste complète des éléments de sous-menus dans l’administration de WordPress ? Bien qu’il existe probablement un plugin pour cela, nous avons créé un extrait de code rapide que vous pouvez utiliser pour supprimer tous les éléments des sous-menus de l’administration de WordPress.
Instructions:
Tout ce que vous avez à faire est d’ajouter ce code dans le fichier functions.php de votre thème ou dans un plugin spécifique à votre site:
function remove_submenus() { global $submenu; //Dashboard menu unset($submenu['index.php'][10]); // Removes Updates //Posts menu unset($submenu['edit.php'][5]); // Leads to listing of available posts to edit unset($submenu['edit.php'][10]); // Add new post unset($submenu['edit.php'][15]); // Remove categories unset($submenu['edit.php'][16]); // Removes Post Tags //Media Menu unset($submenu['upload.php'][5]); // View the Media library unset($submenu['upload.php'][10]); // Add to Media library //Links Menu unset($submenu['link-manager.php'][5]); // Link manager unset($submenu['link-manager.php'][10]); // Add new link unset($submenu['link-manager.php'][15]); // Link Categories //Pages Menu unset($submenu['edit.php?post_type=page'][5]); // The Pages listing unset($submenu['edit.php?post_type=page'][10]); // Add New page //Appearance Menu unset($submenu['themes.php'][5]); // Removes 'Themes' unset($submenu['themes.php'][7]); // Widgets unset($submenu['themes.php'][15]); // Removes Theme Installer tab //Plugins Menu unset($submenu['plugins.php'][5]); // Plugin Manager unset($submenu['plugins.php'][10]); // Add New Plugins unset($submenu['plugins.php'][15]); // Plugin Editor //Users Menu unset($submenu['users.php'][5]); // Users list unset($submenu['users.php'][10]); // Add new user unset($submenu['users.php'][15]); // Edit your profile //Tools Menu unset($submenu['tools.php'][5]); // Tools area unset($submenu['tools.php'][10]); // Import unset($submenu['tools.php'][15]); // Export unset($submenu['tools.php'][20]); // Upgrade plugins and core files //Settings Menu unset($submenu['options-general.php'][10]); // General Options unset($submenu['options-general.php'][15]); // Writing unset($submenu['options-general.php'][20]); // Reading unset($submenu['options-general.php'][25]); // Discussion unset($submenu['options-general.php'][30]); // Media unset($submenu['options-general.php'][35]); // Privacy unset($submenu['options-general.php'][40]); // Permalinks unset($submenu['options-general.php'][45]); // Misc } add_action('admin_menu', 'remove_submenus');
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez vous référer à notre guide sur comment copier/coller correctement des extraits de code dans WordPress, afin de ne pas casser accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : 30 façons de gagner de l’argent avec le blogging en ligne et comment ajouter un portfolio à votre site WordPress.
Print Form. Build-to-order Custom Manufacturing and Rapid Prototypes / Additive Manufacturing. Plastic and Metal materials. Any quantity.
Is there a way to remove items based on user role?
I needed to remove one specific sub-panel and wasnt able to find a way to access the sub-menus. Thank you so much for this script.
unset($GLOBALS[‘submenu’]);
I want to remove “My Sites” that is only ofund in WPMU but its not on the list provided. Its part of the index.php menu but I don’t know the number or where to find it so I’m stuck at….
unset($submenu[‘index.php’][??]); // Removes My Sites
Thanks Kevin.
Is possible remove this sub-menu?
– Appearence –> Sidebars
– Appearance –> Editor
Thanks Kevin. I try…but nothing changes:
// Remove all admin $submenu items function remove_submenus() { global $current_user; get_currentuserinfo(); // change users in list $users = array( “User here”, ); if (!in_array($current_user->user_login, $users)) {
unset($submenu[‘index.php’][10]); // Removes Updates unset($submenu[‘edit.php?post_type=page’][10]); // Add New page
} } add_action(‘admin_menu’, ‘remove_submenus’);
Kevin, is possible remove some submenu items based just on username?
You could do this a few ways, eg: base on user role.
if ( !current_user_can(‘author’)) {
unset($submenu[‘index.php’][10]); // Removes Updates
}
or user name
global $current_user;
get_currentuserinfo();
// change users in list
$users = array(
“ryan”,
“steven”,
“larry”,
“jerry”
);
if (!in_array($current_user->user_login, $users)) {
unset($submenu[‘index.php’][10]); // Removes Updates
}
something like this should work well for you, these of course should go inside the function.
Thank you !
But how to remove plugin settings submenu ?
By example; I have “All in one favicon” plugin submenu that I want to remove.
Regards.
Stumbled across this, very handy doing this without plugins. Cheers!
Cool glad to hear you like the snippet! Enjoy the rest of the site,