Dashboard Widgets – Add Admin Page With Same Functionality

I have a plugin that has its own dashboard with basically quick-views of relevant data and I wanted to know if there was an “easy” way to mimic the functionality of the admin dashboard where you can move/minimize/maximize the widgets?

UPDATE:
I am assuming I would have to add metaboxes similar to when you add metaboxes to a custom post type…is this the direction I should go in?

Related posts

1 comment

  1. I guess “easy” is a relative term. Yes, you can create your own.

    For adding an admin page there are a glut of tutorials out there. This one works (and has some other info you might need) http://wp.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/. Search for “Add Your Own Settings Page or Admin Menu” on the page.

    jQuery UI is loaded in the WordPress admin. You can use http://jqueryui.com/sortable/#portlets as a starting guide for how to make the dragging/sorting/collapsing happen.

    Then, when someone moves or collapses a panel, you’ll need to store that change in the database and read it the next time the page loads to reload the configuration.


    EDIT

    Try to reverse engineer the actual WP dashboard code first and you may indeed get a lot of the functionality for free.

    /wp-admin/includes/dashboard.php has the widget code (or view source on the dashboard and go from there). Also code for saving/loading settings.

    wp-admin/js/common.js has the javascript that enables the widget behavior.

    The jQuery.UI stuff isn’t autoloaded by default so you’ll need to wp_enqueue_script what you need.

    Alternatively
    You can skip making your own and simply add custom widgets to the default dashboard. http://codex.wordpress.org/Dashboard_Widgets_API

Comments are closed.