Last active
October 25, 2022 22:46
-
-
Save numediaweb/7dc94a428d0bc9d175b1 to your computer and use it in GitHub Desktop.
Revisions
-
Abdessamad Idrissi revised this gist
Jan 2, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,6 @@ function filter_admin_menues() { // Edit 'edit.php', // Media 'upload.php' -
Abdessamad Idrissi created this gist
Jan 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ function filter_admin_menues() { // If administrator then do nothing if (current_user_can('activate_plugins')) return; // Remove main menus $main_menus_to_stay = array( // Dashboard 'index.php', // Edit 'edit.php', 'post-new.php', // Media 'upload.php' ); // Remove sub menus $sub_menus_to_stay = array( // Dashboard 'index.php' => ['index.php'], // Edit 'edit.php' => ['edit.php', 'post-new.php'], // Media 'upload.php' => ['upload.php', 'media-new.php'], ); if (isset($GLOBALS['menu']) && is_array($GLOBALS['menu'])) { foreach ($GLOBALS['menu'] as $k => $main_menu_array) { // Remove main menu if (!in_array($main_menu_array[2], $main_menus_to_stay)) { remove_menu_page($main_menu_array[2]); } else { // Remove submenu foreach ($GLOBALS['submenu'][$main_menu_array[2]] as $k => $sub_menu_array) { if (!in_array($sub_menu_array[2], $sub_menus_to_stay[$main_menu_array[2]])) { remove_submenu_page($main_menu_array[2], $sub_menu_array[2]); } } } } } } // Filter admin side navigation menues add_action('admin_init', 'filter_admin_menues');