Advertisement
Tips

Quick Tip: Customising and Simplifying the WordPress Admin for Your Clients

by

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.

Related Posts
  • Code
    Articles
    WordPress Initialization Hooks: Benefits and Common MistakesHooks
    In programming, initialization of data is important as it's where we setup the prerequisites for the application such as its attributes, its required files and data, its connection to the database, and so on. WordPress itself has a well-defined initialization procedure. Through the page life cycle, WordPress fires a number of actions many of which we've covered in previous articles. To that end, it provides a set of initialization hooks which are naturally used to initialize the application before executing its primary functionality. As plugin and theme developers, it's important to understand the use cases and common mistakes of these initialization hooks, in order to build quality applications. In this article, we are going to take a look at the importance of WordPress initialization hooks and how they are used in various scenarios.Read More…
  • Code
    Creative Coding
    Customizing the WordPress Admin: Help TextCustomize wordpress admin rachel 400
    In Part 2 of this tutorial, I showed you how to add custom metaboxes to the WordPress dashboard, which you can use to provide help text for your clients or users. But what if you want to provide help text on individual editing screens? In this tutorial, I'll show you how to do just that.Read More…
  • Code
    Creative Coding
    Customizing the WordPress Admin: Custom Admin MenusCustomize wordpress admin rachel 400
    In the first two parts of this series, I showed you how to customise the WordPress login screen and the dashboard. In this third part I'll show you how to customize the admin menus in WordPress.Read More…
  • Code
    Creative Coding
    Customizing the WordPress Admin - The DashboardCustomize wordpress admin rachel 400
    In the first part of this series, I showed you how to customize the WordPress login screen by adding a custom logo and some custom styling. The next thing your users will see after they've logged in is the Dashboard, so in this tutorial you'll learn how to customize it by removing some of the existing metaboxes, moving some around, and adding some new ones.Read More…
  • Code
    Widgets
    Building a Countdown Timer WidgetBuilding a countdown timer widget preview
    We all love a celebration, and now that Easter is over, we look forward to the next occasion. How far away is the next occasion you like to celebrate? Whatever it might be, let's build a widget plugin to add a countdown timer to our sidebar showing how long we have left to wait.Read More…
  • Code
    Widgets
    How to Build Custom Dashboard WidgetsHow to build custom dashboard widgets 400
    The WordPress Dashboard is a great place to see updates, or any kind of information related to your activity. In this tutorial, we'll see how to dispose of default widgets and how to create your own custom widgets. We are going to create a simple plugin to handle this so it can apply to any theme.Read More…