Dashboard Widget (Without Controls) Sample Plugin

WordPress 2.5 has the ability to customize your administration dashboard with the help of widgets.

After poking around WordPress 2.5 codes, I have come out with this Dashboard Widget Sample Plugin. BUT do note that this plugin does not include Dashboard Widget Controls. If I have the time, I will add that in or perhaps I will create another plugin called “Dashboard Widget (With Controls) Sample Plugin”.

To get a clearer picture of what this sample plugin does, here is a screenshot of the Dashboard Widget (Without Controls) Sample in action.

Here comes the code:

 'Full URL For "See All" link', // Example: 'index.php?page=wp-useronline/wp-useronline.php'
		'feed_link' => 'Full URL For "RSS" link', // Example: 'index.php?page=wp-useronline/wp-useronline-rss.php'
		'width' => 'half', // OR 'fourth', 'third', 'half', 'full' (Default: 'half')
		'height' => 'single', // OR 'single', 'double' (Default: 'single')
		)
	);
}

### Function: Add Dashboard Widget
add_filter('wp_dashboard_widgets', 'PLUGINNAME_add_dashboard_widget');
function PLUGINNAME_add_dashboard_widget($widgets) {
	global $wp_registered_widgets;
	if (!isset($wp_registered_widgets['dashboard_PLUGINNAME'])) {
		return $widgets;
	}
	array_splice($widgets, sizeof($widgets)-1, 0, 'dashboard_PLUGINNAME');
	return $widgets;
}

### Function: Print Dashboard Widget
function dashboard_PLUGINNAME($sidebar_args) {
	global $wpdb;
	extract($sidebar_args, EXTR_SKIP);
	echo $before_widget;
	echo $before_title;
	echo $widget_name;
	echo $after_title;
	echo 'YOUR CONTENT GOES IN HERE';
	echo $after_widget;
}
?>

Hope this helps some of you guys. =)

1 Star2 Stars3 Stars4 Stars5 Stars (33 votes, average: 3.91 out of 5)

4 thoughts on “Dashboard Widget (Without Controls) Sample Plugin”

  1. Oh man…

    Sorry, didn’t read your article properly 🙂 Nice stuff and very useful!

    please, tell me how you insert colorized php code in your post?

Comments are closed.