/**
* -------------------------------------------------------------------------
* Add capability for editors to edit menus
* -------------------------------------------------------------------------
*/
/*function add_theme_caps(){
global $pagenow;
// gets the author role
$role = get_role('editor');
if ('themes.php' == $pagenow && isset($_GET['activated'])) {
// Test if theme is activated
// Theme is activated
// This only works, because it accesses the class instance.
// would allow the editor to edit the theme options
$role->add_cap('edit_theme_options');
} else {
// Theme is deactivated
// Remove the capability when theme is deactivated
$role->remove_cap('edit_theme_options');
}
}
add_action( 'load-themes.php', 'add_theme_caps' );
*/
function hide_menu() {
if (current_user_can('editor')) {
$role = get_role('editor');
if (!$role->has_cap( 'edit_theme_options' ) ) {
$role->add_cap('edit_theme_options');
}
remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
remove_submenu_page( 'themes.php', 'customize.php?return=%2Fwp-admin%2Fthemes.php' ); // hide the customizer submenu
remove_submenu_page( 'themes.php', 'customize.php?return=%2Fwp-admin%2Fprofile.php' );
remove_submenu_page( 'themes.php', 'customize.php?return=%2Fwp-admin%2Fnav-menus.php' );
}
}
add_action('admin_head', 'hide_menu');
Författare: Erik
Erik har jobbat med webb professionellt sedan 2008. Från 2005 till 2008 studerades webb på ING/JTH och dessförinnan skapades webb på all fritid. Första sajten byggdes någon gång mellan 1996-1998.
Visa alla inlägg av Erik