Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#5750 closed enhancement (fixed)

New Dashboard Interface

Reported by: mdawaffe Owned by: mdawaffe
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch needs-testing
Focuses: Cc:


The attached converts the WP dashboard into a collection of widgets. These widgets are the same as "ordinary" WP widgets, but are a little bit souped up:

  1. Widget display and widget configuration are done on the same screen.
  2. Widgets can be 1/3, 1/4 1/2 or 1/1 of the dashboard width (example: all widgets in patch are 'half' width except the planet widget which is 'full' width).
  3. Widgets can be single or double high (no example, but can pass 'height' => 'double').

There is no interface for reordering widgets or adding new ones. I don't expect there to be such a UI until WP 2.6 at least. Hooks are available for plugins to register new widgets and to set/modify the order:

// Hook to register new widgets
do_action( 'wp_dashboard_setup' );

// Filter widget order
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', $dashboard_widgets );

Widgets are registered like ordinary WP widgets, but take a few more parameters (all optional):

wp_register_sidebar_widget( $widget_id, $widget_name, $widget_callback,
    'all_link'  => [full url for "See All" link],
    'feed_link' => [full url for "RSS" link],
    'width'     => 'third', 'fourth', 'HALF', 'full',
    'height'    => 'SINGLE', 'double'
  array(), // Just leave it blank: oddity in widget code
    'widget_id' => $widget_id // Yes - again.  This is required: oddity in widget code

Widgets do not need controls. Those with controls will show an "Edit" link and can be edited "in place" (new page load).

The dynamic_sidebar() function has been modified (in a backward compatible way) to handle some of the dashboard requirements:

  1. New hooks: dynamic_sidebar_params
  2. widget_id and widget_name are now passed to the widget_callback function along with before_title and friends.

Since most of the default widgets are specialized RSS widgets, the wp_widget_rss_*() functions have been broken up a bit more to accommodate the needed re-use.

Particularly hacky things are noted in the code.

Attachments (6)

5750.diff (39.9 KB) - added by mdawaffe 9 years ago.
5750b.diff (4.5 KB) - added by mdawaffe 9 years ago.
5750c.diff (9.3 KB) - added by mdawaffe 9 years ago.
style tweaks - move to separate css file
5750d.diff (1.7 KB) - added by mdawaffe 9 years ago.
fix "right now". FF, Safari, IE
5750-cache.diff (19.6 KB) - added by mdawaffe 9 years ago.
5750-ie.diff (1.8 KB) - added by mdawaffe 9 years ago.

Download all attachments as: .zip

Change History (27)

9 years ago

#1 @mdawaffe
9 years ago

  • Status changed from new to assigned

Forgot to mention: uses new cap: edit_dashboard. Upgrade function included in patch.

#2 @ryan
9 years ago

(In [6705]) New dashboard from mdawaffe. see #5750

#3 @ryan
9 years ago

My sidebar reverted to the default, it seems.

#4 @ryan
9 years ago

Visiting the dashboard causes sidebar widget configuration to be lost.

#5 @ryan
9 years ago

[02-Feb-2008 13:23:10] PHP Fatal error:  Cannot redeclare widget_gsearch() (previously declared in /Applications/MAMP/htdocs/trunk/wp-content/plugins/widgets/gsearch.php:20) in /Applications/MAMP/htdocs/trunk/wp-content/plugins/widgets/gsearch.php on line 20

I can reproduce that even after backing out the new dash changes, so I suspect it was introduced with the earlier widget admin redesign.

#6 @ryan
9 years ago

That happens when clicking "Save Changes" on the widget admin page, BTW.

#7 follow-up: @ryan
9 years ago

The call to wp_widgets_init() in the http_post case of wp-admin/widgets.php is causing this. Some widgets define their control and display functions within their init function. Lame, but it seems to be fairly common.

#8 in reply to: ↑ 7 @darkdragon
9 years ago

Replying to ryan:

Some widgets define their control and display functions within their init function. Lame, but it seems to be fairly common.

I'm going to start a campaign to stop that behavior, as it is quite annoying. I think I posted my thoughts to wp-hackers, but I doubt anyone responded.

So basically what you are saying is that when the *_init() is called more than once, PHP is trying to compile the internal functions more than once? That seems odd, PHP should realize that the functions have already been compiled and not compile them again. However, the behavior for having functions inside of functions might be undefined to the compiler, so might not realize that it already compiled the functions or doesn't need to compile them again. Or whatever.

9 years ago

#9 @mdawaffe
9 years ago


  1. Visiting dashboard no longer ruins your sidebar widgets.
  2. Better support for both new-skool "multi-widgets" and old-skool "how many X widgets do you want". Multi-widgets only need to be listed once (not once per widget instance) and their respective control callbacks only need to be called once on POST update. Each Old-skool widget needs to be listed once per instance and their respective callbacks need to be called once per instance.
  3. Old-skool widgets no longer break widgets admin page HTML.
  4. PHP warnings.

Does not fix PHP Fatal error.

#10 @ryan
9 years ago

(In [6717]) Dashboard fixes from mdawaffe. No longer stomps sidebar. see #5750

#11 @ryan
9 years ago

(In [6718]) No need to re-register widgets. see #5750

9 years ago

style tweaks - move to separate css file

#12 @ryan
9 years ago

(In [6810]) Dashboard styling from mdawaffe. see #5750

9 years ago

fix "right now". FF, Safari, IE

#13 @ryan
9 years ago

(In [6811]) Dashboard styling from mdawaffe. see #5750

#14 @_ck_
9 years ago

By the way, I've successfully tested a method to re-order these "widgets" (divs) by applying jquery.ui.sortable to them.

It's as simple as applying a class to each widget, wrapping the main wider column on the left with one div and the sidebar with another div. Needs 3 small jquery.ui libraries.

Then you can move the widgets up and down or even from the main column to the sidebar and back.

Only thing I don't have ready is a way to save the positions, which could be done via cookies like wordpress.com or via ajax as the open/closed method is currently done in the trunk. That part's a bit harder and I wanted to wait to hear if this was interesting.

#15 @mdawaffe
9 years ago

Many of these new widgets are based on RSS feeds. We know when a feed is cached.

It's silly to always do another HTTP request (via AJAX) just to load some content we already have stored in the cache.

Further more, the widgets are just big white boxes until they get AJAX populated. A "Loading..." message would be nice so that people know what's up.


  1. If the all the feeds for a widget are cached and not stale, just output the content.
  2. If feeds are not cached or cache is stale, output "Loading..." message (yes, Matt, with an ellipsis entity :) ), and AJAX load feed.
  3. light docs for dashboard widgets.

Accomplished via:

  1. wp_dashboard_cached_rss_widget()
  2. A bunch of per-widget callback functions.

9 years ago

#16 @ryan
9 years ago

(In [6958]) Dashboard widgets caching improvements from mdawaffe. see #5750

#17 @mdawaffe
9 years ago


Fixes dashboard widgets in IE6/7

Tested in FF2, FF3b3, Safari3, Opera9, IE6, IE7

9 years ago

#18 @mdawaffe
9 years ago

5750-ie.diff also contains a small IE6 fix for the Widgets page.

#19 @ryan
9 years ago

(In [7197]) Dashboard IE fixes from mdawaffe. see #5750

#20 @djr
9 years ago

May I propose looking at MyDashboard http://dev.clearskys.net/Wordpress/MyDashboard, which is based on iGoogle and has similar widgets/gadgets functionality?

#21 @mdawaffe
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed. Please open new tickets for specific bugs or enhancements.

Note: See TracTickets for help on using tickets.