1

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?

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

  • Thanks so much for the kickstart. This will get me on my way. I figured there wasn't an API I could tap into, but doesn't hurt to ask. The jQuery UI will get me there...just a lot of manual coding. Thanks again! – clockwiseq Jan 15 '14 at 3:41
  • There is the WP Settings API but it doesn't offer the portlets stuff out of the box. codex.wordpress.org/Settings_API You may be able to dig around in the code that drives the main WP dashboard and take what you need. – Will Jan 15 '14 at 3:44
  • I'll definitely take a look at that. Thanks for the added info. If I could double-bump up the answer, I would. :-) – clockwiseq Jan 15 '14 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.