PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

How to Write Your Own Easy-Administration WordPress Plugin

Note: This article was originally published at Planet PHP on 19 April 340.
Planet PHP

WordPress's popularity owes much to it's easy administration panels. Unfortunately, it can still be daunting for non-technical users such as your clients. At best they'll require a little training, hand-holding and support. At worst, they'll play around with plugin installation, edit some theme code, then expect you to clear up the mess.

I've written a number of aoMake WordPress Easier for Clientsa articles (see part 1 and part 2). In those examples, code was placed in the theme's functions.php file. That's still a viable solution if you have one WordPress installation per client or each is configured differently.

In this article, however, we'll create a plugin. Plugins have a couple of advantages:

  1. Your code resides in one file which can make maintenance easier.
  2. If you're running a WordPress network with multiple sites (previously known as WordPress MU), you can activate a single plugin across the network so it's applied to every site.

WordPress Plugin Basics

Our plugin will be contained in a single PHP file. We'll name it easy-admin.php and place it in the WordPress plugin folder (wp-content/plugins/). Ideally, the file should be UTF-8 encoded. If your text editor doesn't permit UTF-8, well, use a better editor! That said, those using English are unlikely to experience issues with ANSI-encoded files.

A PHP tag and header comments are required at the top of the file, e.g.

You can change the header details, but ensure the definition tags remain - WordPress uses them to recognize your plugin.

You can now install your plugin by activating it in the aoPluginsa section of the WordPress administration panels. Those with a WordPress network can activate it for all sites in the aoNetwork Admina section. It won't do anything yet, but you can now add whichever features you requirea

Change the WordPress Login Page Logo

The WordPress logo is lovely but few clients will care what CMS they're using. It might be more helpful to show their site name. Append the following code to easy-admin.php; it replaces the login page logo with the name and uses a pleasing CSS3-letterpress text:

// login page logo function custom_login_logo() { echo 'h1 a, h1 a:hover, h1 a:focus { font-size: 1.4em; font-weight: normal; text-align: center; text-indent: 0; line-height: 1.1em; text-decoration: none; color: #dadada; text-shadow: 0 -1px 1px #666, 0 1px 1px #fff; background-image: none !important; }'; } add_action('login_head', 'custom_login_logo');

Remove the WordPress Icon From the Administration Panel Header

The WordPress icon is shown next to the site name in the header. There's nothing wrong with it but some clients will question why there's a aW' next to their site. To remove it, append the following code to easy-admin.php:

// remove administration page header logo function remove_admin_logo() { echo 'img#header-logo { display: none; }'; } add_action('admin_head', 'remove_admin_logo');

Change the WordPress Administration Panel Footer Text

The footer provides links to WordPress, documentation and feedback. Few clients are likely to find it useful so you can replace it with your own support details. Append the following code to easy-admin.php and change the echo statement to output to a suitable message:

// change administration panel footer function change_footer_admin() { echo 'For support, please call 123456 or email mailto:support@mysite.net'; } add_filter('admin_footer_text', 'change_footer_admin');

Remove the WordPress Admin Bar

The dark-gray Admin Bar was introduced in WordPress 3.1. Personally, I don't find it particul

Truncated by Planet PHP, read more at the original (another 870 bytes)