When you're building a website for your client, sometimes there are parts of the WordPress admin that you don't need them to be able to access. In fact, if they don't need to access them, why not get them out of the way and simplify the admin for your client. Here's how...
Step 1 Setting Up Your Plugin
As per usual, you need to get your plugin setup before you can add any functionality to it. Create yourself a directory under /wp-content/plugins/ called wptuts-simple-admin. Now inside that directory, create the main PHP file for your plugoin. For the sake of standardisation, we'll call it wptuts-simple-admin.php.
Inside this file is where we put the plugin header information:
<?php /* Plugin Name: Wptuts+ Simple Admin Plugin URI: http://wp.tutsplus.com/articles/tips-articles/quick-tip-simplifying-the-wordpress-admin-for-your-clients Description: Hides parts of the WordPress admin to keep it simple. Version: 0.1 Author: Japh Author URI: http://wp.tutsplus.com/author/Japh License: GPL2 */ ?>
We're going to write this plugin with object-oriented programming, which Tom recently introduced for those who are unfamiliar, so we'll setup our class below the plugin header:
<?php class Wptuts_Simple_Admin { function __construct() { // We'll add hooks here } } $wptuts_simple_admin = new Wptuts_Simple_Admin(); ?>
At this point, you can log into your WordPress admin and see the plugin. You can also activate it now, and then go back and refresh as we add functionality.
Step 2 Hiding Menus We Don't Need
Let's say your client's site doesn't make any use of 'Links', and you don't need your client to use anything in 'Tools' or 'Settings' either (that's your job afterall, right?). So let's turn them off (highlighted lines are new code):
<?php class Wptuts_Simple_Admin { function __construct() { // Hook onto the action 'admin_menu' for our function to remove menu items add_action( 'admin_menu', array( $this, 'hide_menus' ) ); } // This function removes each menu item using the Page Hook Suffix ( http://codex.wordpress.org/Administration_Menus#Page_Hook_Suffix ) function hide_menus() { // Links page remove_menu_page( 'link-manager.php' ); // Tools page remove_menu_page( 'tools.php' ); // Settings page remove_menu_page( 'options-general.php' ); } } $wptuts_simple_admin = new Wptuts_Simple_Admin(); ?>
Step 3 Tidy Up Dashboard Widget Clutter
I don't know about you, but I find there are several dashboard widgets on every WordPress install that I simply don't need, and my clients certainly don't care about. Those are: Incoming Links, Plugins, WordPress Blog, and Other WordPress News. Admittedly it could be argued that 'Incoming Links' has a usefulness, but I prefer to hide it and save on clutter.
Now, dashboard widgets are metaboxes, so we can use the following code to get rid of them (again, highlighted lines are new code):
<?php class Wptuts_Simple_Admin { function __construct() { // Hook onto the action 'admin_menu' for our function to remove menu items add_action( 'admin_menu', array( $this, 'remove_menus' ) ); // Hook onto the action 'admin_menu' for our function to remove dashboard widgets add_action( 'admin_menu', array( $this, 'remove_dashboard_widgets' ) ); } // This function removes each menu item using the Page Hook Suffix ( http://codex.wordpress.org/Administration_Menus#Page_Hook_Suffix ) function remove_menus() { // Links page remove_menu_page( 'link-manager.php' ); // Tools page remove_menu_page( 'tools.php' ); // Settings page remove_menu_page( 'options-general.php' ); } // This function removes dashboard widgets function remove_dashboard_widgets() { // Remove each dashboard widget metabox for Incoming Links, Plugins, the WordPress Blog and Other WordPress News remove_meta_box('dashboard_incoming_links', 'dashboard', 'core'); remove_meta_box('dashboard_plugins', 'dashboard', 'core'); remove_meta_box('dashboard_primary', 'dashboard', 'core'); remove_meta_box('dashboard_secondary', 'dashboard', 'core'); } } $wptuts_simple_admin = new Wptuts_Simple_Admin(); ?>
Step 4 Simplify Post Type Columns
The last screen I'll cover for simplification in this article is the post listing screen (for both posts and pages). If your client is just one person, writing all their posts themselves, why do they need to see the author column? Sounds like wasted space to me.
<?php class Wptuts_Simple_Admin { function __construct() { // Hook onto the action 'admin_menu' for our function to remove menu items add_action( 'admin_menu', array( $this, 'remove_menus' ) ); // Hook onto the action 'admin_menu' for our function to remove dashboard widgets add_action( 'admin_menu', array( $this, 'remove_dashboard_widgets' ) ); // Hook onto the post type-specific filters to remove columns add_filter( 'manage_posts_columns', array( $this, 'remove_columns' ) ); add_filter( 'manage_pages_columns', array( $this, 'remove_columns' ) ); } // This function removes each menu item using the Page Hook Suffix ( http://codex.wordpress.org/Administration_Menus#Page_Hook_Suffix ) function remove_menus() { // Links page remove_menu_page( 'link-manager.php' ); // Tools page remove_menu_page( 'tools.php' ); // Settings page remove_menu_page( 'options-general.php' ); } // This function removes dashboard widgets function remove_dashboard_widgets() { // Remove each dashboard widget metabox for Incoming Links, Plugins, the WordPress Blog and Other WordPress News remove_meta_box('dashboard_incoming_links', 'dashboard', 'core'); remove_meta_box('dashboard_plugins', 'dashboard', 'core'); remove_meta_box('dashboard_primary', 'dashboard', 'core'); remove_meta_box('dashboard_secondary', 'dashboard', 'core'); } // This function removes post / page list columns function remove_columns( $defaults ) { unset( $defaults['author'] ); return $defaults; } } $wptuts_simple_admin = new Wptuts_Simple_Admin(); ?>
Conclusion
It's little customisations like these that allow you to make WordPress' admin feel tailored to your client's needs. There's more you can do, of course, and you'll likely vary things on a client-by-client basis. Some of these things can be done using Aaron Rutley's excellent Minimal Admin plugin.
If you wanted to take this up a notch, you could also include capability checks to disable / enable functionality based on who's logged in.
How do you like to customise WordPress for your clients? Let us know in the comments below.
Comments