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. I run a little theme shop called DevPress and work for a startup called Cratejoy. Find me on twitter @devinsays.

14 Responses

  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. zachary

    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?

  3. […] The following solution was created gluing together two tutorials that I have read. The first is an easy to follow article by Jeff Star on Perisable Press titled How to Import and Display RSS Feeds in WordPress. Jeff walks us through using the SimplePie class. The second tutorial was written by Devin Price and focuses on controlling what is displayed on the WordPress Dashboard and is titled Dashboard Support Widgets. […]

  4. Fabio

    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

  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.

  6. Gregg

    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. 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