wpnoviceuser
Member
Posted 16 years ago #
How can I remove or hide the Widgets submenu from the Presentations menu in my admin panel?
I've searched for days trying to remove this with no luck.
I've been able to edit lots of other admin menu items by editing menu.php, but the Widgets submenu isn't there. I've used Crimson editor and searched all files in WP, but can't find where to remove this. I thought maybe it would be in widgets.php, but no luck there. I've even searched the database and can't find a field there that controls this. I can disable widgets by editing functions.php in my theme, but since I use several I really want to simply remove/hide the Widgets submenu under Presentation. I don't really mind if the widgets functionality is not disabled...just removing or hiding that submenu would be great. Any tips would be greatly appreciated.
Thanks in advance.
File wp-includes\functions.php
From line 1416
I use Windows Grep to search through files, it's faster it's great, you can use regular expression or not and other tons of feature, a must have tools:
http://www.wingrep.com
wpnoviceuser
Member
Posted 16 years ago #
Great...thank you. And thanks for the wingrep tip.
@SteveAgl
Thanks for the Wingrep tip! I had been searching for something like this!
Mu-Plugin Option?
add to mu-plugins
<?php
add_action('admin_menu', 'remove_widgets_menu_item');
function remove_widgets_menu_item(){
global $submenu;
$submenu['themes.php'][7] = ''; //replace it with your own
// unset( $submenu['themes.php'][7] ); //remove it altogether
}
?>
cafespain
Member
Posted 15 years ago #
Replace the lines under global $submenu; with:
foreach($submenu['themes.php'] as $key => $sm) {
if(__($sm[0]) == "Widgets" || $sm[2] = "widgets.php") {
unset($submenu['themes.php'][$key];
break;
}
}
And then you will be more bullet-proof if other plugins (ahem) mess around with the admin menus before yours is run.