#5750 closed enhancement (fixed)
New Dashboard Interface
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
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:
- Widget display and widget configuration are done on the same screen.
- 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). - 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, array( 'all_link' => [full url for "See All" link], 'feed_link' => [full url for "RSS" link], 'width' => 'third', 'fourth', 'HALF', 'full', 'height' => 'SINGLE', 'double' ) ); wp_register_widget_control( $widget_id, $widget_control_name, $widget_control_callback, array(), // Just leave it blank: oddity in widget code array( '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:
- New hooks:
dynamic_sidebar_params
widget_id
andwidget_name
are now passed to thewidget_callback
function along withbefore_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)
Change History (27)
#5
@
15 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.
#7
follow-up:
↓ 8
@
15 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
@
15 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
@
15 years ago
5750b.diff
- Visiting dashboard no longer ruins your sidebar widgets.
- 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.
- Old-skool widgets no longer break widgets admin page HTML.
- PHP warnings.
Does not fix PHP Fatal error.
#14
@
15 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
@
15 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.
Attached:
- If the all the feeds for a widget are cached and not stale, just output the content.
- If feeds are not cached or cache is stale, output "Loading..." message (yes, Matt, with an ellipsis entity :) ), and AJAX load feed.
- light docs for dashboard widgets.
Accomplished via:
wp_dashboard_cached_rss_widget()
- A bunch of per-widget callback functions.
#17
@
15 years ago
5750-ie.diff
Fixes dashboard widgets in IE6/7
Tested in FF2, FF3b3, Safari3, Opera9, IE6, IE7
#20
@
15 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?
Forgot to mention: uses new cap:
edit_dashboard
. Upgrade function included in patch.