WordPress 3.3 is planned for November this year and we published the scope a while ago here on Theme.fm. As mentioned in that post, 3.3 will get a series of UI improvements, one of which is Pointers (or Admin Pointers). We learned about pointers in WordPress a few hours ago from one of Daryl Koopersmith’s changesets so we decided to give it a spin ourselves.
What are Admin Pointers?
Here’s what Jane wrote in the trac ticket for WordPress pointers:
When a new user-facing feature is included in a core update, display a new feature pointer that highlights the new feature a la Facebook, Gmail, etc.
Core features are cool, but the exciting thing about pointers is that plugin and theme developers will (hopefully) be able to use them as well. The API at it’s current stage looks quite simple. It’s basically a jQuery widget which you can stick to things like buttons, menus, links and any other elements in the DOM.
The source code is located in wp-includes/js/wp-pointer.js which suggests that pointers could be used outside of the admin panel, which is great. There are not too much details about that yet though, and before the actual 3.3 release, the script may be moved somewhere else, unlike the pointers script and style handle which is probably final: wp-pointer.
Note that WordPress pointers are not available on any stable versions of WordPress yet and is planned for 3.3. You can access the development copy of WordPress via Subversion but you shouldn’t use that in any live environment.
Using Pointers in Your Themes and Plugins
For experimental purposes we decided to give pointers a spin in Twenty Eleven by creating a child theme. Let’s start off by creating a functions.php file for your child theme and adding the following code to include the pointer scripts and styles:
add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' );
function my_admin_enqueue_scripts() {
// Using Pointers
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
// Register our action
add_action( 'admin_print_footer_scripts', 'my_admin_print_footer_scripts' );
}
function my_admin_print_footer_scripts() {
// This will run during footer scripts, use jQuery to show the pointer here.
}
This simply tells WordPress to enqueue the pointers script and stylesheet in the admin panel, as well as registers an action that runs during admin_print_footer_scripts — that’s where we’re going to use jQuery to actually show the pointer, let’s do that:
function my_admin_print_footer_scripts() {
$pointer_content = '<h3>Welcome to Twenty Eleven!</h3>';
$pointer_content .= '<p>Lorem Ipsum is simply dummy text of the printing <br /> and typesetting industry. Lorem Ipsum has been the <br /> industrys standard dummy text ever since the 1500s!';
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function($) {
$('#menu-appearance').pointer({
content: '<?php echo $pointer_content; ?>',
position: 'left',
close: function() {
// Once the close button is hit
}
}).pointer('open');
});
//]]>
</script>
<?php
}
The usage is not too straightforward. Basically we set a variable to contain our pointer content, that’s the place where you’ll have to localize your strings if you need to. Note that $pointer_content is used inside the javascript block, so make sure you escape/quote the string and we’ll leave that out for brevity.
After the php chunk you’ll see that we’re calling the pointer function in jQuery while providing it with a selector — this is the object in the DOM that you want to apply the pointer to. In our case it’s #menu-appearance which is the id of the Appearance section in the admin menu (you can use Firebug or Chrome’s developer tools to find other elements).
The pointer function is passed a few arguments. You’ll find all of them in the wp-pointer.js file, they’ll hopefully get some inline code comments while being self-explanatory. Anyway, we set the position of our pointer with the position argument and the position of the arrow of our pointer with the .arrow argument
Also note that close argument which is given a function that runs when the close button is hit. We’ll talk about this in a while. The call to .pointer('open') is appended at the end of it all, this will display the pointer on screen.
So now you should end up with something like this:
Sweet, eh? But there’s a problem. The close button works, but as soon as you refresh the page or visit any other section in your admin panel, the annoying pointer pops up again. This is where user settings come in.
Closing Pointers
Daryl’s initial commit suggested using so-called user settings to handle pointer data, which is a mix of cookies and options on a per-user basis in WordPress. The most recent changes though suggest using the user meta table and AJAX calls to close events.
The API for pointers usage in themes and plugins has been postponed to WordPress 3.4 but there’s quite a lot we can learn from how the core implements the “close” feature. Here’s the changeset by Andrew Nacin which shows how AJAX is used and attached to the pointer’s close event.
Conclusion
This post is intended to give you a quick and rough overview of pointers in WordPress 3.3. As already mentioned, you shouldn’t use the trunk version of WordPress in production (on your live websites) and there’s no guarantee that the functionality or API will not changed before the final 3.3 release.
We’ll keep up to date with that ticket and revisit this post with an update as soon as 3.3 is released. Meanwhile you can play around with what we have. I bet that it’ll be quite simple to create a live tour of themes, plugins and WordPress itself by using pointers. What do you think?
Update 22.09.2011: We’ll keep this post updated until the 3.3 release so don’t get used to the API just yet. It seems like user settings wasn’t the best option after all because of the cookie size restrictions. Here’s what we got from Andrew Nacin:
I had a conversation with koopersmith and we plan to switch closing to an XHR call and avoid the user settings API … We don’t want the user settings API to start getting used all over the place. User settings are cool and simple, but bad for one-off features like this, especially when plugins may then extend it. The issue is that the cookie holding that data can only hold so much data (4kb). It’s also why we kept the setting name so short (“p0″).
And here’s also what John O’Nolan from the Core UI team suggested as an alternative color implementation which makes the pointers stand out a little more.
We also went ahead with that tour idea and created this: Theme.fm Experiments: Admin Tour with WordPress Pointers. Quite some good feedback there ;)
Update: as shown in this diff, this changeset and pointed out earlier by Andrew Nacin, dismissed pointers are kept in user meta (in the database) rather than user settings (cookies) and the mentioned code illustrate an elegant way of doing so. The code in this post has been modified to work with the recent changes to the API.
Thank you so much for reading. Leave your thoughts on WordPress Pointers in the comments section below an thank you for staying tuned!






That’s pretty cool, I just saw the pointer in my latest 3.3 update.
I was thinking in implementing something like this for my plugins, to point out to users new features and options. Good thing to see this as a core feature.
That’s right. I think that with these new pointers, upon activation, plugins can guide the users through the plugin usage and settings, maybe with a “take the tour” trigger or somehow integrated with the contextual help drop-down ( which we all tend to forget about ;). And it could be fantastic for themes as well, like a guide through the Theme Options panel and especially through custom post types if present. Thanks for your comment Milan!
Now this is a really nice add-on which I can see becoming quite useful. Thanks for the writeup.
You’re welcome Shawn, thanks for your comment!
With this feature, wordpress becomes even easier! Thank you, Kostya. I like it)
You’re welcome Anvar, let’s see how the feature and the API evolves before the actual 3.3 release :)
From a developer perspective this is indeed a great tool! But I cannot help but think, what about clients’ sites? To give clients a walk-through of their new WordPress site seems very nice indeed, but I wouldn’t want these pointers to pop up their heads every time I update a plugin for them.
Hopefully things like this will be taken into consideration when developing the pointer further towards the 3.3 release.
Thanks for the very informing article, Konstantin!
Developers sometimes overuse notification boxes, the admin menu, the dashboard widgets, meta boxes in edit post and page screens, so yes, pointers will be overused too but it’s a matter of being polite, like showing them only if the user clicks the “what’s new in this plugin” link or visits the plugin options page :)
Thanks for your comment!
waw, this is pretty cool! I have multi-author community blog, so this’ll make easier for new users to get used to my site..
but if pointers implemented in core, it will make core ‘heavier’, won’t it? as long as I read from the core dev team, they want to make WP core as light as possible..
is this that ‘important’ to include in core? what do you think?
Hi Ilman. Do you mean heavy as in the WordPress zip file or heavy as in too much actions and filters, etc? If it’s the size of the installation archive then I wouldn’t bother, Internet is getting cheaper and faster every year. If you’re concerned about performance issues then note that pointers are included only when they’re used, besides, some of the changes in 3.2 and commits in 3.3 made a huge improvement of the admin panel performance, plus there’s a major CSS cleanup planned, so I don’t think performance will suffer :)
Thanks for your comment!
My only concern is about the database. If I understand things well, every pointer will add a line in the database, won’t it ? On websites with may users, this might become a problem …
Diije I don’t think so, admin pointers us the user settings API ( wp-includes/functions.php ) which stores interface settings in user options in the database and/or cookies, having one row for one user. Screen options like number of columns, positioning of meta boxes, etc are already stored there for each and every user so I don’t think that pointer data would be a problem. Thanks for your comment!
Diije, turns out the user settings themselves are stored completely in cookies, hence the 4kb restriction and why the initial setting was named so short (p0). The whole scenario will probably be moved to the database via an XHR call, not sure what the implementation is going to be there but stay tuned :)
Thanks for the input :)
Pingback: WordPress gets admin pointers for fancy guides
Pingback: New Feature Pointers Slated For WordPress 3.3
Pingback: Theme.fm demo what can be done with Pointers, new for WordPress 3.3 | WPCandy
Thanks for the code sample. I thought this would be an easy and straight forward process, but it looks like you have to write everything yourself. In this case it’s as _easy_ as using jQuery tooltip or whatever other plugin. Not kool.
Kaiser, do note that the API is going to change so hopefully we’ll see some improvements there usage-wise :) Thanks for your comment!
Wow, nice new feature, specially for wp newbies … it reminds me of the way Facebook points out their updates …
Also thank you for the source code ;)
You’re welcome :) Note that the API may (and probably will) change so don’t rely on the source code too much!
i copied code above and everything works great, except my pointer has no arrow. did i made some mistake?
i use nightly build of wordpress, maybe they changed the way to show arrow?
Maybe, I’ll edit this article when 3.3 hits the shelves but as far as I can see it going, usage in themes and plugins won’t be supported for 3.3. Of course we can always hack our way through ;)
Konradk look at how the code above has changed. Positioning has been simplified and arrow positioning has been removed. Tested on today’s nightly build, works like a charm :) I like the new shadowy style too!
Hey Konstantin,
Great write-up. Are you planning an update to this as I believe the beta 2 has ‘finished’ the implementation of the pointers and it is a fair bit different to what you have above. It’d be great to see how to ‘do it properly’ :)
Hey there RT, no update yet but we’re watching with what’s happening on the dev side so we’ll make sure to update you as soon as 3.3 hits the shelves :)
I love Admin Pointers. We’re definitely going to integrate them with WP e-Commerce Plugin… :)
Too bad they’re not rolling out support for plugins and themes in 3.3, but we could still “hack” our way through. Seems like an API is arriving with 3.4 though ;) Thanks for your comment Dan!
Yah. So in the meantime I was thinking we’ll just do what Joost did in his Plugins… we’re still looking for a developer to do this with us. Anybody?
Thanks for the writeup. I’ve spent a ton of time looking for a codex page on this – does it exist (yet)?
Will help me in my latest plugins !
Pingback: WordPress 3.3: New Features | Learning from Lorelle