OVERVIEW
While the question was about limiting editor roles to access only Widgets, the following example shows how to limit access only to Menus. However as you will see, it can easily be changed to allow only Widgets or more!
I added Step #3 because I forgot about the Admin Bar. Oops! So now whether logged into the Dashboard or logged in and on the WP website, you have full control of what is available to an editor for the 'edit_theme_capablity' sub-menus.
If you don't have a Roles & Capabilities Plugin installed, you can do this:
(If you do, skip #1 and go to #2, then #3)
<?php
// Using jQuery: How to allow Editors to edit only Menus (or more!)
// Placed in admin-footer.php as Dashboard comes from the wp-admin files
if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
<script>
jQuery.noConflict();
jQuery(document).ready(function() {
// Comment out the line you WANT to enable, so it displays (is NOT removed).
// For example, the jQuery line for MENUS is commented out below so it's not removed.
// THEMES: If you want to allow THEMES, also comment out APPEARANCE if you want it to display Themes when clicked. (Default behaviour)
jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php"]').remove();
jQuery('li#menu-appearance.wp-has-submenu a.wp-has-submenu').removeAttr("href");
// WIDGETS:
jQuery('li#menu-appearance.wp-has-submenu li a[href="widgets.php"]').remove();
// MENUS:
// jQuery('li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"]').remove();
// BACKGROUND:
jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"]').remove();
});
</script>
<?php
} // End IF current_user_can...
} // End IF is_user_logged_in...
?>
**(3) Add this to the Theme's
footer.php
:**What this does is to allow you to choose which option you want Editors to have on their Admin Bar.
<?php
// Using jQuery: How to allow Editors to edit only Menus (or more!)
// Placed in THEME's footer.php as the Admin Bar is added when a user is logged in
if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
<script>
jQuery.noConflict();
jQuery(document).ready(function() {
// Comment out the line you WANT to enable, so it displays (is NOT removed).
// For example, the jQuery line for MENUS is commented out below so it's not removed.
// THEMES:
jQuery('li#wp-admin-bar-themes').remove();
// CUSTOMIZE:
jQuery('li#wp-admin-bar-customize').remove();
// WIDGETS:
jQuery('li#wp-admin-bar-widgets').remove();
// MENUS:
// jQuery('li#wp-admin-bar-menus').remove();
// BACKGROUND:
jQuery('li#wp-admin-bar-background').remove();
});
</script>
<?php
} // End IF current_user_can...
} // End IF is_user_logged_in...
?>