Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. function remove_menus(){
  2.  
  3. //Find admin...
  4. $admin_url = get_admin_url();
  5.  
  6. //Find php-files in admin path
  7. //and create an array of them
  8. $admin_files = array();
  9. foreach (glob("*.php") as $file) {
  10. if($file == '.' || $file == '..') continue;
  11. $admin_files[] = $file;
  12. }
  13.  
  14. //Remove all menupages for all files in wp-admin folder
  15. foreach($admin_files as $af) {
  16. remove_menu_page( $af );
  17. }
  18.  
  19. //Get all registered post types
  20. // types will be a list of the post type names
  21. $types = get_post_types();
  22.  
  23. //Remove pages for all registered post types as well
  24. foreach( $types as $type ) {
  25. remove_menu_page( 'edit.php?post_type=' . $type);
  26. }
  27.  
  28. //Get plugins and remove them from menu
  29. $plugins = get_plugins();
  30. foreach($plugins as $p) {
  31. remove_menu_page( strtolower($p['Name'] ) );
  32. }
  33.  
  34. }
  35. add_action( 'admin_init', 'remove_menus' ,99);
  36.  
  37. //Get plugins
  38. $plugins = get_plugins();
  39. foreach($plugins as $p) {
  40. remove_menu_page( strtolower($p['Name'] ) );
  41. }
  42.  
  43. remove_menu_page('wpseo_dashboard');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement