Client instructions through the WordPress admin
November 2, 2009So I currently have a client that – no offense to anyone, I swear it – cannot seem to handle instructions to save his life. I’ve written two PDF documents, as well as one in Word format, as well as multiple phone conversations, and having an “Active Collab” type area where your discussions are stored for future reference – and finally emails. However, I still find myself repeatedly giving him instructions, because if it’s not right in front of his face, he forgets (or doesn’t bother to go looking). It is a lesson in frustration, because I’m starting to sound like a broken record to myself.
There used to be a solution to this that I provided a long time ago to clients I had like this – before I knew better – where I would go in and edit core files to display instructions for that particular admin page. That way, it’s right there in their face, and they can’t ignore it. Of course, as soon as they upgraded, it was gone. (I’ve since learned better, and know you can usually manage this type of thing by writing a plugin (which isn’t really that hard, I swear it) or utilizing your functions.php file.)
Another alternative was this “WP Instructions” plugin, which does pretty much what I wanted it to, except for one thing: it created a new admin menu item, so all the instructions are on a separate admin page. For most clients, this would be fine. For this one (and a few others I’ve had in the past) who can’t be bothered to open a pre-written document to see if their question has already been answered, what makes me think they’d bother to click a button in the admin that plainly says “Instructions”?
They won’t. I can assure you. I needed IN YOUR FACE instructions.
This morning, I finally found a solution, and, of course, I’m going to share it with you. Now, please keep in mind, this is a plugin in the works. I’m mid-writing it, and it’s in the “infancy” stage. I haven’t finished writing it, much less checked it or made it ready for release anywhere yet. But for now, this’ll do, because it’ll give you an idea of how to go about this (and, of course, if you know of better methods, then by all means share it!)
It was actually a lot simpler than I thought it would be. I’m using just two actions, provided by WordPress: using the admin notices (admin_notice) and admin head (admin_head-XX.php) hooks. The “admin_notice” function is the type of thing you see when you publish a post or activate a plugin or whatever – that yellow bar that shows up across the top of your page to give you notification of success (or failure). I used the “admin_head” stuff to…well, basically fake conditionals, so I could serve up instructions based on what admin page they were on. The “XXX” part of this is the filename you’re on. So if you’re on the dashboard, it would be “admin_head-index.php”, and if you were on “Add New” for writing posts, it would be “admin_head-post-new.php”.
Here is the initial code:
<?php
add_action('admin_head-index.php', 'dashboard_help');
add_action('admin_head-post.php', 'post_help');
add_action('admin_head-post-new.php', 'post_new_help');
function dashboard_help() {
add_action( 'admin_notices', 'help_text');
function help_text() {
echo 'help with dashboard!';
}
}
function post_help() {
add_action( 'admin_notices', 'help_text');
function help_text() {
echo 'help with editing posts!';
}
}
function post_new_help() {
add_action( 'admin_notices', 'help_text');
function help_text() {
echo 'help with creating posts!';
}
}
?>
Of course, you can see it’s not finished yet, but the above should give you a general idea of what’s going on here. I’m going to further develop this idea and hopefully add jQuery to it (so we can easily show/hide the instructions- because I know sometimes they can go long) and make it a little neater. I know there’s a way to slim this down, too, but for right now I’m still working that out.
But there you go, hope it helps someone










P.O. Box 46
Aaaahh. Very clever.
I was just gearing up to write something like this for myself. Now I don’t have to. Although I’m going to be adding a link to a lightboxed video screencast.
I’ll let you know how it goes.
So here’s a little update (already): it doesn’t work for plugins yet. I’m still trying to figure out if I can (or if it’s even possible) to add instructions for plugins you have added in to the site.
For example, I have Userextra/Usermeta installed on the site I’m writing this for (so I can add some custom user information) and the URL for that page is “sitename/wp-admin/edit.php?page=userextra.php” Unfortunately, I can “admin_head-edit.php” but I can’t “admin_head-edit.php?page=userextra.php”, nor can I “admin_head-userextra.php”. So here’s my first conundrum. (The good news, though, is that this plugin is mega-old, and hasn’t been upgraded in forever – mainly because it doesn’t need to be, it works just fine – so I can add the stuff directly to the plugin files.) But it’s now on the list to see if I can somehow supply custom info for plugins as well.
I just wish there were some kind of conditional commenting system for the admin area – that would make it a lot easier!
Here’s another notation: for the “widgets” page, you’ll have to use “add_action(‘admin_head-widgets.php’, ‘widgets2_help’); – as it turns out, using “widgets_help’ conflicts with something else (I guess there’s already a function with this name – whoops!) so adding the “2″ helps alleviate the pain there.
Definitely bookmarked. I’m interested to see where you go with this plugin as I can certainly relate to client’s not reading anything I prepare to help them!
Screencasts seem like a great way to go, but I have a feeling that once a major version of WordPress is released I’d be updating those all over again…