Dashboard Support Widgets

WordPress loads a number of dashboard widgets by default when an admin logs into the site. Some of these are incredibly useful, like the comments widget and incoming links. But others aren’t really necessary for the standard user, such as the WordPress News and Development Blog feeds. For the majority of my clients it just clutters up the dashboard and slows down the page load.

On WordPress Weekly a few weeks back, Jacob Goldman mentioned that he removes all these unnecessary widgets on his client’s sites and replaces them with the contact information for his company in case people need support. I thought this was a brilliant idea, but didn’t realize how easy it was until I read an article on dashboard hacks by Cats Who Code.

So, this is my first ever attempt at a plug-in. I relied heavily on the WordPress Codex post about dashboard widgets and altered an rss feed plug-in that was hiding in the repository. I’m not sure I got everything right, especially on the feed end, but I thought I’d share the code for anyone who’s interested.

This plug-in will add a widget that displays the contact information for my company and an rss feed from my blog. It’s well commented and should be fairly straight forward to alter for your own purposes. You can download the plug-in here.

<?php
/*
Plugin Name: Dashboard Support Widgets
Plugin URI: http://www.wordpresstheming.com
Description: Add support and rss widgets to dashboard
Version: 1.0
Author: Devin Price
Author URI: http://www.wordpresstheming.com
*/
// Remove Some of the Standard Widgets
function remove_dashboard_widgets() {
	// Globalize the metaboxes array, this holds all the widgets for wp-admin
 	global $wp_meta_boxes;
	// Remove the following dashboard widgets
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
// Hook into the 'wp_dashboard_setup' action to register our function
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
// Register New Dashboard Widgets
function wpt_register_dashboard_widget() {
	wp_add_dashboard_widget('wpt_rss_dashboard_widget', 'WordPress Theming Feed', 'wpt_rss_dashboard_widget');
	wp_add_dashboard_widget('support_dashboard_widget', 'WordPress Theming Support', 'support_dashboard_widget');
}
// Hook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'wpt_register_dashboard_widget');
//Support Dashboard Widget
function support_dashboard_widget() {
	// Displays contact and support info in the widget box
	echo "<p>Please contact <a href=\"mailto:devin@wordpresstheming.com\">devin@wordpresstheming.com</a> if you have questions or need updates for your website.  The <a href=\"http://wordpress.org/codex/\">WordPress Codex</a> and <a href=\"http://wordpress.org/support/\">Support Forums</a> are also great places to find answers to your questions.</p>";
}
// Print Dashboard Widget
function wpt_rss_dashboard_widget($sidebar_args) {
	global $wpdb;
	include_once(ABSPATH . WPINC . '/rss.php');
	$rss_feed = "http://feeds.feedburner.com/wordpress-theming";
	echo "<div id='identity'></div>";
	echo "<ul>";
	$rss = fetch_rss($rss_feed);
	$rss->items = array_slice($rss->items, 0, 6);
	$channel = $rss->channel;
	foreach ($rss->items as $item ) {
		$parsed_url = parse_url(wp_filter_kses($item['link']));
		echo "<li><b><a href=" . wp_filter_kses($item['link']) . ">" . wptexturize(wp_specialchars($item['title'])) . "</a></b></li>";
	}
	echo "</ul>";
}
?>

About Devin

I'm a WordPress developer based in Austin, Texas. Follow my projects on GitHub, or more general WordPress ramblings as @devinsays on twitter.
Categorized: Plug-ins

14 comments on “Dashboard Support Widgets

  1. Sweet! Thanks for writing about this – it has always been one of those things that I was interested in knowing about, but somehow I never have found the time to research. Now I don’t have to :) Looks really easy, can’t wait to try it out.

  2. i try to install and it says “Plugin could not be activated because it triggered a fatal error”

    does this not work for WPMU possibly?

    • Possibly. This was more of a tutorial than a fully supported plug-in. The RSS feed sometimes causes me issues when it can’t load immediately. I haven’t had a chance to look at how WordPress core does it- but that would be the guideline to follow.

      However, I haven’t encountered any problems just using the text box with company info (minus the RSS feed). I’d try hacking it a bit and see what you can do.

      When I get some spare time, I will make some updates to this plug-in and perhaps do an official release.

  3. Pingback: WordPress Plugin Support Aggregator | Michael Fields: WordPress Development

  4. Hey, this is a great, I was just searching how to disable some wp admin panels, and add my custom panels because some panels aren’t needed for final users that only publish content in wordpress.
    Thanks

    • There’s also “screen options” on the dashboard if just want to quickly change the panels around- but this is a more permanent solution and affects all users. I’d be careful about using the RSS code as I still need to update that so it caches correcty- but you should be fine on regular text.

  5. Hi Devin – Congrats on taking the plunge and coming up with a plugin! Did you ever do an official release of this or make any other modifications? I’m thinking about giving it a go but I’ve upgraded to WP 3.01 and wondered if there was anything I should be aware of before diving in.

    • No, I never did an official release- still on the list. It does work but I’d warn you that the RSS feeds are not cached properly, I’d just use this code to add the static text.

  6. Devin, If I wanted to add more customization to the widget HTML via CSS. How can I add new CSS without touching the core admin css files? I would like to show examples of the shortcodes I have added for support. I am wondering if there is away to add CSS to the admin area CSS via the function.php file. Thanks for your help!

  7. Pingback: How to create a wordpress dashboard widget | tutorials blogs

  8. Hey!, nice plugin and code.

    I try to used in functions.php and works perfectly, but I have a question about rss feed, what happend when the blog feed is privacy settings where only registered user can see it? I add the feed but no post show it. Any idea ?

    Much thanx :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>