[wp-trac] [WordPress Trac] #11387: Walker Widget System
WordPress Trac
wp-trac at lists.automattic.com
Tue Dec 15 04:14:30 UTC 2009
#11387: Walker Widget System
-------------------------+--------------------------------------------------
Reporter: ShaneF | Owner: ShaneF
Type: enhancement | Status: accepted
Priority: normal | Milestone: 3.0
Component: Widgets | Version:
Severity: normal | Keywords:
-------------------------+--------------------------------------------------
Comment(by ShaneF):
In this new version I made it even easier:
{{{
$widget_design = new Widget_Basic;
$widget_array = array(
'title' => $title,
'before_output' => "<div class='textwidget'>",
'output' => $instance['filter'] ?
wpautop($text) : $text,
'after_output' => "</div>",
'style' => "none",
'design' => $widget_design
);
return array_merge($args, $widget_array);
}}}
Inside the WP_Widget class I added a new function called 'design_widget':
{{{
/** Generate the actual widget with design API.
* Do NOT over-ride this function. */
function design_widget ( $args ) {
// checking to see if the widget is going to be creating
more than one module.
if ( is_array($args[0]) ) {
foreach ($args as $widget) {
if ( empty($widget['design']) )
$widget['design'] = new
Widget_Basic;
$widget_design =
apply_filters('widget_design', $widget['design']);
echo call_user_func_array(
array(&$widget_design, 'display'), array($widget) );
}
} else {
if ( empty($args['design']) )
$args['design'] = new Widget_Basic;
$widget_design = apply_filters('widget_design',
$args['design']);
echo call_user_func_array( array(&$widget_design,
'display'), array($args) );
}
}
}}}
This way less for the widget author to convert. Everyday I come up with a
new version of the API. Code sits in my brain during the night and
process.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11387#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list