WordPress 2.7 introduced Dashboard Widgets, which are the widgets displayed on the main Dashboard of your WordPress installation. Along with these new widgets came the Dashboard Widgets API, which allows you to create any custom Dashboard Widget that you would like.
To create a custom Dashboard Widget you’ll be using the wp_add_ dashboard_widget function as shown here:
add_action('wp_dashboard_setup', 'mypaaji_add_dashboard_widget' );
// call function to create our dashboard widget
function mypaaji_add_dashboard_widget() {
wp_add_dashboard_widget('mypaaji_dashboard_widget', __('MyPaaji Dashboard Widget','mypaaji-dashboard-plugin'), 'mypaaji_create_dashboard_widget');
}
// function to display our dashboard widget content
function mypaaji_create_dashboard_widget() {
_e('Hello World! This is my Dashboard Widget','mypaaji-dashboard-plugin');
}

First you call the wp_dashboard_setup Action hook to execute the function to build your custom Dashboard Widget. This hook is triggered after all of the default Dashboard Widgets have been built.
Next you execute the wp_add_dashboard_widget function to create your Dashboard Widget. The first parameter is the widget ID slug. This is used for the CSS classname and the key in the array of widgets. The next parameter is the display name for your widget. The final parameter you send is your custom function name to display your widget contents. An optional fourth parameter can be sent for a control callback function. This function would be used to process any form elements that might exist in your Dashboard Widget.
After executing the wp_add_dashboard_widget function your custom function is called to display your widget contents. In this example you display a simple string, with internationalization support, of course.
Share Some Love