Advertisement
TheMightyAnt

WP Rearrange admin menu & Rename posts & Remove menu items

Mar 6th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. /* RENAME POSTS & REARRANGE THE ADMIN MENU & REMOVE ITEMS */
  2.  
  3. // Change Posts name
  4. function change_post_menu_label() {
  5. global $menu;
  6. global $submenu;
  7. $menu[5][0] = 'Blog';
  8. $submenu['edit.php'][5][0] = 'Blog Articles';
  9. $submenu['edit.php'][10][0] = 'Add Blog Article';
  10. //$submenu['edit.php'][15][0] = 'Status'; // Change name for categories
  11. //$submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
  12. echo '';
  13. }
  14.  
  15. function change_post_object_label() {
  16. global $wp_post_types;
  17. $labels = &$wp_post_types['post']->labels;
  18. $labels->name = 'Blog Articles';
  19. $labels->singular_name = 'Blog Article';
  20. $labels->add_new = 'Add Article';
  21. $labels->add_new_item = 'Add Article';
  22. $labels->edit_item = 'Edit Articles';
  23. $labels->new_item = 'Blog Article';
  24. $labels->view_item = 'View Article';
  25. $labels->search_items = 'Search Articles';
  26. $labels->not_found = 'No Articles found';
  27. $labels->not_found_in_trash = 'No Articles found in Trash';
  28. }
  29. add_action( 'init', 'change_post_object_label' );
  30. add_action( 'admin_menu', 'change_post_menu_label' );
  31.  
  32. // Rearrange the admin menu
  33. function custom_menu_order($menu_ord) {
  34. if (!$menu_ord) return true;
  35. return array(
  36. 'index.php', // Dashboard
  37. 'edit.php?post_type=page', // Pages
  38. 'edit.php?post_type=events', // Custom type one
  39. 'edit.php?post_type=galleries', // Custom type two
  40. 'edit.php', // Posts
  41. 'separator1', // First separator
  42.  
  43. 'upload.php', // Media
  44. 'link-manager.php', // Links
  45. 'edit-comments.php', // Comments
  46. //'separator2', // Second separator
  47. 'themes.php', // Appearance
  48. 'plugins.php', // Plugins
  49. 'users.php', // Users
  50. 'tools.php', // Tools
  51. 'options-general.php', // Settings
  52. 'separator-last', // Last separator
  53. );
  54. }
  55. add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order
  56. add_filter('menu_order', 'custom_menu_order');
  57.  
  58. // Remove admin menu items
  59. function remove_menus () {
  60. global $menu;
  61. $restricted = array(__('Comments'), __('Media'));
  62. end ($menu);
  63. while (prev($menu)){
  64. $value = explode(' ',$menu[key($menu)][0]);
  65. if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
  66. }
  67. }
  68. add_action('admin_menu', 'remove_menus');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement