Customizing Your WordPress Admin

The backend of WordPress is one of the better ones out there. However, depending on your needs, the menu can be a little crowded with fluff that you just don't want or need there.
In this tutorial, I am going to show you how to tame your admin menu. I will show you how to rename menus, reorder the menus, or just plain eliminate them without touching core. Because touching core is bad.
At times you may want to rename one of the admin menus. For example, you are running a recipe site, and you are using "Posts" to list recipes rather than for a blog.
To do this, you will need to use the admin_menu action hook. It is used for adding submenus to the admin menu, or other miscellaneous options having to do the with the menu.
First, you need to create a function and then attach it to the action hook inside thefunctions.php of your theme.
The WordPress admin menu is actually stored in an array ($menu). So first as you see, edit_admin_menus uses $menu global to get the array. Now you will need to pinpoint the key associated with the menu you want to rename. A list of all menus and submenus will be provided at the end of this tutorial.
Since we wanted to change the "Posts" menu to "Recipes", we know that we need to target "5":
Believe it or not, that's all there is to it. Save functions.php, and refresh the admin page. But now the submenus don't match the new name.
Renaming submenus is almost the same process, except that you need to add the $submenu global, and you will be targeting the link URI as well. So for example, changing "All Posts" to "All Recipes" would look something like this:
You can do this for every submenu item. All together, edit_admin_menus would look something like this
The posts menu has now been transformed to a recipe menu. This process works for all the menus from the Dashboard to Settings as well as their sub menus.
Now I am going to show you how to change the order of the menus, including the separators. I usually prefer Media and Links to be more towards the bottom since I don't use them nearly as much as Pages and Comments.
Ordering the admin menu requires using the menu_order filter. However, the menu_order filter requires that you first activate custom_menu_order. So first, you will want to put this code into your functions.php.
The order of the menus is top to bottom, so which ever menu you put at the top of the array, will be the first menu. If you do not put one of the standard menu items in the array, it will simply fall to the end of the list, it will not remove it from the menu.
You have renamed some menus and you have ordered them how you like. But what if you don't use pages or the link manager at all? You can just remove them.
Removing admin menus is very easy to do. WordPress has a built in function just for removing menus:
All remove_menu_page needs is the slug of the menu you are removing (also at the end of this tutorial).
So, for example, if you wanted to remove the Tools menu, you would use:
When removing a menu, you can just reuse the same function you created to rename menus. Here is an example of the function you used at the beginning of this tutorial where you renamed the Posts menu, but now it is also removing the Tools menu as well.
Removing a submenu is just as easy, it uses a very similar function that removing a top level menu does. Here it is hiding the Theme Editor from the Appearance menu:
The only difference in the arguments is that you must provide the slug of the submenu's parent, and then the slug for the submenu itself. In a final example, here is the code hiding the entire Tools menu and the Theme Editor submenu:
As you can see, doing some basic customization to the backend of WordPress is nice and easy, and even though many might not see what you have done, in the end it can (and will) help you greatly. Organization is never a bad thing. You do it on the front end of your theme, why not do it on the backend too?
This is also great if you are running a site for a client. Hiding menus that they could use to cause potential unintended harm to their site is always a huge plus! In future tutorials I will go over more of the customizations that are possible, from using CSS to change the overall look and feel of the backend, to having the customizations only affect certain users.
As promised, I have included a chart that will give you all of the menus and submenus name, key, and slug.









Source: http://code.tutsplus.com/articles/customizing-your-wordpress-admin--wp-24941


Hi,
You need to figure out the index for Suburbs:
function change_post_menu_label() {
    global $menu;
    global $submenu;
    echo "<pre>";
    print_r($menu);
    print_r($submenu);
    echo "</pre>";
    $submenu['edit.php'][15][0] = 'Status'; // Change name for categories
    $submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
}
For that you need to print the $menu array and $submenu. after you get the index, replace the index 15 and 16 in above code to rename the category and label.
Source: https://wordpress.org/support/topic/how-to-rename-the-admin-sub-menu-name-of-a-custom-post-category-or-tag

No comments:

Post a Comment