[wp-trac] [WordPress Trac] #11387: Walker Widget System

WordPress Trac wp-trac at lists.automattic.com
Thu Dec 10 16:56:00 UTC 2009


#11387: Walker Widget System
-------------------------+--------------------------------------------------
 Reporter:  ShaneF       |       Owner:  azaozz
     Type:  enhancement  |      Status:  new   
 Priority:  normal       |   Milestone:  3.0   
Component:  Widgets      |     Version:        
 Severity:  normal       |    Keywords:        
-------------------------+--------------------------------------------------
 This is a new system for Widgets. The design for this system is based on
 the fact that every theme is different.

 Currently the widget system does not care about one theme. It will still
 output it's own formating structure based on it's design and then bassed
 on a messy 'register_sidebar' arguments wrap that data inside one another.

 The idea behind a Walker Widget system is that instead of the Widget
 outputing the data, it send it to a Walker where it assigns the relevant
 information and the theme's "Widget Design" class holds how Widget boxes
 are created based on the values pushed through the walker.

 For example in my theme functions.php file:

 {{{
 class Walker_Widget_Rabbit extends Walker_Widget {

         function start_widget($args, &$output) {

                 // @todo Updated with the correct vars.
                 $output .= do_action('sidebar_before_module', $id);
                 $output .= do_action('sidebar_before_module_' . $id);

                 $output .= sprintf( "<div id='%s' class='module widget
 %s'>", $args['widget_id'], $args['classname'] );
         }

         function title_widget($args, &$output) {
                 $output .= "<div class='head'><h3>" . $args['title'] .
 "</h3></div>";
                 /*
                 if ((bool) $this->get_option('scrolling') &&
 $scroll['enabled']) {
                         printf(__("navi: <a
 id=\"prev_%s\">prev</a>&nbsp;/&nbsp;<a id=\"next_%s\">next</a>"),
 $scroll['key'], $scroll['key']);
                 }
                 */
         }

         function content_widget($args, &$output) {
                 $output .= "<div class='wrap'>" .
 $this->content_style($args, $args['output']) . "</div>";
         }

         function content_style($args, $output) {

                 /*
                  * Here I am going to figure out how we are going to wrap
 most content
                  * and detirme if the information is scrolled information.
                  */

                 $style = $args['style'];
                 switch ($style) {
                         case 'none':
                                 $style = $output;
                                 break;
                         default:
                                 $style = "<ul class='dash-strip'>" .
 $output . "</ul>";
                 }
                 return $style;
         }

         function content_scroll($args, $area = 'top') {
                 //      @todo <div class="content-scroll-large"> and <div
 class="content-scroll">
         }

         function end_widget($args, &$output) {
                 $output .= "</div>";
                 // @todo Updated with the correct vars.
                 $output .= do_action('sidebar_after_module', $id);
                 $output .= do_action('sidebar_after_module_' . $id);
         }

 }
 }}}

 This also allows users to manipulate the data/design even further once
 they get it from the widget.

 I have tested this on the default theme of WordPress with the all 12 of
 the built in WordPress widgets and they act/look just like if it was
 hardcoded into the system itself.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11387>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list