Ticket #11387: walker_widget.3.patch

File walker_widget.3.patch, 42.5 KB (added by ShaneF, 3 years ago)
  • wp-content/themes/classic/functions.php

     
    77automatic_feed_links(); 
    88 
    99if ( function_exists('register_sidebar') ) 
    10         register_sidebar(array( 
    11                 'before_widget' => '<li id="%1$s" class="widget %2$s">', 
    12                 'after_widget' => '</li>', 
    13                 'before_title' => '', 
    14                 'after_title' => '', 
    15         )); 
     10        register_sidebar(); 
    1611 
    1712?> 
  • wp-content/themes/default/functions.php

     
    99automatic_feed_links(); 
    1010 
    1111if ( function_exists('register_sidebar') ) { 
    12         register_sidebar(array( 
    13                 'before_widget' => '<li id="%1$s" class="widget %2$s">', 
    14                 'after_widget' => '</li>', 
    15                 'before_title' => '<h2 class="widgettitle">', 
    16                 'after_title' => '</h2>', 
    17         )); 
     12        register_sidebar(); 
    1813} 
    1914 
    2015/** @ignore */ 
  • wp-includes/bookmark-template.php

     
    251251        echo $output; 
    252252} 
    253253 
     254/** 
     255 *  
     256 * @param $args 
     257 * @return unknown_type 
     258 */ 
     259function wp_list_bookmarks_widget($args = '') { 
     260        $defaults = array( 
     261                'orderby' => 'name', 'order' => 'ASC', 
     262                'limit' => -1, 'category' => '', 'exclude_category' => '', 
     263                'category_name' => '', 'hide_invisible' => 1, 
     264                'show_updated' => 0, 'echo' => 1, 
     265                'categorize' => 1, 'title_li' => __('Bookmarks'), 
     266                'title_before' => '<h2>', 'title_after' => '</h2>', 
     267                'category_orderby' => 'name', 'category_order' => 'ASC', 
     268                'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">', 
     269                'category_after' => '</li>' 
     270        ); 
     271 
     272        $r = wp_parse_args( $args, $defaults ); 
     273        extract( $r, EXTR_SKIP ); 
     274 
     275        $output = ''; 
     276 
     277        if ( $categorize ) { 
     278                $cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0)); 
     279 
     280                foreach ( (array) $cats as $cat ) { 
     281                        $params = array_merge($r, array('category' => $cat->term_id)); 
     282                        $bookmarks = get_bookmarks($params); 
     283                        if ( empty($bookmarks) ) 
     284                                continue; 
     285                         
     286                        $bookmarks_output[] = array(  
     287                                'title' => apply_filters( "link_category", $cat->name ), 
     288                                'output' => _walk_bookmarks($bookmarks, $r) 
     289                        ); 
     290                         
     291                } 
     292                 
     293        } else { 
     294                $bookmarks = get_bookmarks($r); 
     295                if ( !empty($bookmarks) ) { 
     296                        $bookmarks_output[] = array(  
     297                                'title' => apply_filters( "link_category", $cat->name ),  
     298                                'output' => _walk_bookmarks($bookmarks, $r) 
     299                        ); 
     300                } 
     301        } 
     302         
     303        return $bookmarks_output; 
     304} 
     305 
    254306?> 
  • wp-includes/default-widgets.php

     
    2121 
    2222        function widget( $args, $instance ) { 
    2323                extract( $args ); 
    24  
     24                 
    2525                $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title']); 
    2626                $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 
     27                $walker = empty( $instance['walker'] ) ? '' : $instance['walker']; 
    2728                $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 
    2829 
    2930                if ( $sortby == 'menu_order' ) 
    3031                        $sortby = 'menu_order, post_title'; 
    31  
    32                 $out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) ); 
    33  
    34                 if ( !empty( $out ) ) { 
    35                         echo $before_widget; 
    36                         if ( $title) 
    37                                 echo $before_title . $title . $after_title; 
    38                 ?> 
    39                 <ul> 
    40                         <?php echo $out; ?> 
    41                 </ul> 
    42                 <?php 
    43                         echo $after_widget; 
    44                 } 
     32                 
     33                if (  !empty( $walker ) ) 
     34                        $page_walker = new $walker; 
     35                         
     36                $pages_array = array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude, 'walker' => $page_walker); 
     37                $output = wp_list_pages( apply_filters('widget_pages_args', $pages_array ) ); 
     38                 
     39                $widget_design = new Widget_Basic; 
     40                $widget_array = array( 
     41                        'title'                 => apply_filters('widget_title', $title, $args), 
     42                        'before_output' => "<ul>", 
     43                        'output'                => $output, 
     44                        'after_output'  => "</ul>", 
     45                        'style'                 => "li", 
     46                        'design'                => $widget_design 
     47                ); 
     48                return array_merge($args, $widget_array);        
    4549        } 
    4650 
    4751        function update( $new_instance, $old_instance ) { 
     
    5256                } else { 
    5357                        $instance['sortby'] = 'menu_order'; 
    5458                } 
    55  
     59                 
     60                $instance['walker'] = strip_tags( $new_instance['walker'] ); 
    5661                $instance['exclude'] = strip_tags( $new_instance['exclude'] ); 
    5762 
    5863                return $instance; 
     
    6065 
    6166        function form( $instance ) { 
    6267                //Defaults 
    63                 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') ); 
     68                $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'walker' => '', 'exclude' => '') ); 
    6469                $title = esc_attr( $instance['title'] ); 
     70                $walker = esc_attr( $instance['walker'] ); 
    6571                $exclude = esc_attr( $instance['exclude'] ); 
    6672        ?> 
    6773                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p> 
     
    7480                        </select> 
    7581                </p> 
    7682                <p> 
     83                        <label for="<?php echo $this->get_field_id('walker'); ?>"><?php _e( 'Walker:' ); ?></label> <input type="text" value="<?php echo $walker; ?>" name="<?php echo $this->get_field_name('walker'); ?>" id="<?php echo $this->get_field_id('walker'); ?>" class="widefat" /> 
     84                        <br /> 
     85                        <small><?php _e( 'Customer Walker' ); ?></small> 
    7786                        <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" /> 
    7887                        <br /> 
    7988                        <small><?php _e( 'Page IDs, separated by commas.' ); ?></small> 
     
    109118                        echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget; 
    110119                        return; 
    111120                } 
    112  
    113                 $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget); 
    114                 wp_list_bookmarks(apply_filters('widget_links_args', array( 
    115                         'title_before' => $before_title, 'title_after' => $after_title, 
    116                         'category_before' => $before_widget, 'category_after' => $after_widget, 
     121                 
     122                $links_data = wp_list_bookmarks_widget(apply_filters('widget_links_args', array( 
     123                        'title_before' => '', 'title_after' => '', 'category_before' => '', 'category_after' => '', 
    117124                        'show_images' => $show_images, 'show_description' => $show_description, 
    118125                        'show_name' => $show_name, 'show_rating' => $show_rating, 
    119126                        'category' => $category, 'class' => 'linkcat widget' 
    120127                ))); 
     128                $widget_design = new Widget_Basic; 
     129                $widget_default_array = array('design' => $widget_design, 'style' => 'li', 'before_output' => '<ul class="xoxo blogroll">', 'after_output' => '</ul>'); 
     130                 
     131                foreach ($links_data as $links) { 
     132                        $widget_array[] = array_merge($links, $widget_default_array); 
     133                } 
     134                 
     135                return $widget_array; 
     136                 
    121137        } 
    122138 
    123139        function update( $new_instance, $old_instance ) { 
     
    178194 
    179195        function widget( $args, $instance ) { 
    180196                extract($args); 
    181                 $title = apply_filters('widget_title', $instance['title']); 
     197                $title = apply_filters( 'widget_title', $instance['title'], $args); 
    182198 
    183                 echo $before_widget; 
    184                 if ( $title ) 
    185                         echo $before_title . $title . $after_title; 
    186  
    187                 // Use current theme search form if it exists 
    188                 get_search_form(); 
    189  
    190                 echo $after_widget; 
     199                $widget_design = new Widget_Search; 
     200                $widget_array = array( 
     201                        'title'                 => $title, 
     202                        'output'                => get_search_form(false), 
     203                        'style'                 => "none", 
     204                        'design'                => $widget_design 
     205                ); 
     206                return array_merge($args, $widget_array); 
    191207        } 
    192208 
    193209        function form( $instance ) { 
     
    213229 * @since 2.8.0 
    214230 */ 
    215231class WP_Widget_Archives extends WP_Widget { 
    216  
     232         
     233        // @todo Add other options, day(s), month,  
     234         
    217235        function WP_Widget_Archives() { 
    218236                $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your blog&#8217;s posts') ); 
    219237                $this->WP_Widget('archives', __('Archives'), $widget_ops); 
     
    223241                extract($args); 
    224242                $c = $instance['count'] ? '1' : '0'; 
    225243                $d = $instance['dropdown'] ? '1' : '0'; 
    226                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title']); 
    227  
    228                 echo $before_widget; 
    229                 if ( $title ) 
    230                         echo $before_title . $title . $after_title; 
    231  
     244                $t = isset($instance['type']) ? $instance['type'] : 'monthly'; 
     245                $l = ( (int) $instance['limit'] > 0) ? (int) $instance['limit'] : ''; 
     246                $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $args); 
     247                 
    232248                if ( $d ) { 
    233 ?> 
    234                 <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo esc_attr(__('Select Month')); ?></option> <?php wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c))); ?> </select> 
    235 <?php 
     249                        $wp_widget_archives_dropdown_options = array( 
     250                                'monthly' => __("Select Month"), 
     251                                'yearly' => __("Select Year"), 
     252                                'daily' => __("Select Day"), 
     253                                'weekly' => __("Select Week"), 
     254                                'postbypost' => __("Select Post") 
     255                        ); 
     256                        $output = "<select name=\"archive-dropdown\" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\">". esc_attr($wp_widget_archives_dropdown_options[$t]) . "</option>" . wp_get_archives(apply_filters('widget_archives_dropdown_args', array('echo' => 0, 'type' => $t, 'format' => 'option', 'show_post_count' => $c, 'limit' => $l))) . "</select>"; 
    236257                } else { 
    237 ?> 
    238                 <ul> 
    239                 <?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?> 
    240                 </ul> 
    241 <?php 
     258                        $output = wp_get_archives(apply_filters('widget_archives_args', array('echo' => 0, 'type' => $t, 'show_post_count' => $c, 'limit' => $l))); 
    242259                } 
    243  
    244                 echo $after_widget; 
     260                 
     261                $widget_design = new Widget_Basic; 
     262                $widget_array = array( 
     263                        'title'                 => $title, 
     264                        'before_output' => "<ul>", 
     265                        'output'                => $output, 
     266                        'after_output'  => "</ul>", 
     267                        'style'                 => "li", 
     268                        'design'                => $widget_design 
     269                ); 
     270                return array_merge($args, $widget_array);                
    245271        } 
    246272 
    247273        function update( $new_instance, $old_instance ) { 
    248274                $instance = $old_instance; 
    249                 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); 
     275                $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'type' => '', 'limit' => '', 'dropdown' => '') ); 
    250276                $instance['title'] = strip_tags($new_instance['title']); 
     277                $instance['type'] = $new_instance['type']; 
    251278                $instance['count'] = $new_instance['count'] ? 1 : 0; 
     279                $instance['limit'] = ( (int) $new_instance['limit'] > 0) ? $new_instance['limit'] : ''; 
    252280                $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 
    253  
    254281                return $instance; 
    255282        } 
    256283 
    257284        function form( $instance ) { 
    258                 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); 
     285                $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'type' => '', 'count' => 0, 'limit' => '', 'dropdown' => '') ); 
    259286                $title = strip_tags($instance['title']); 
     287                $limit = $instance['limit']; 
    260288                $count = $instance['count'] ? 'checked="checked"' : ''; 
    261289                $dropdown = $instance['dropdown'] ? 'checked="checked"' : ''; 
    262 ?> 
     290                $_widget_archives_options = array('monthly' => _("Monthly"), 'yearly' => _("Yearly"), 'daily' => _("Daily"), 'weekly' => _("Weekly"), 'postbypost' => _("Post by Post")); 
     291                ?> 
    263292                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> 
     293                <p><label for="<?php echo $this->get_field_id('type'); ?>" class="screen-reader-text"><?php _e('Type:'); ?></label> 
     294                <select class="widefat" id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>"> 
     295                        <?php 
     296                                foreach ( $_widget_archives_options as $key => $value) { 
     297                                        $selected = ($key == $instance['type']) ? 'selected="selected"' : ''; 
     298                                        echo "<option value=\"$key\" $selected />" . $value . "</option>"; 
     299                                } 
     300                        ?>                       
     301                </select></p> 
    264302                <p> 
    265303                        <input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label> 
    266304                        <br /> 
    267305                        <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as a drop down'); ?></label> 
    268306                </p> 
     307                <p><label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e('Limit:'); ?></label> 
     308                <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit; ?>" size="3" /><br /> 
     309                </p> 
    269310<?php 
    270311        } 
    271312} 
     
    286327 
    287328        function widget( $args, $instance ) { 
    288329                extract($args); 
    289                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title']); 
    290  
    291                 echo $before_widget; 
    292                 if ( $title ) 
    293                         echo $before_title . $title . $after_title; 
    294 ?> 
    295                         <ul> 
    296                         <?php wp_register(); ?> 
    297                         <li><?php wp_loginout(); ?></li> 
    298                         <li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> 
    299                         <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> 
    300                         <li><a href="http://wordpress.org/" title="<?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li> 
    301                         <?php wp_meta(); ?> 
    302                         </ul> 
    303 <?php 
    304                 echo $after_widget; 
     330                $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $args); 
     331                 
     332                $widget_design = new Widget_Basic; 
     333                $widget_array = array( 
     334                        'title'                 => $title, 
     335                        'before_output' => "<ul>", 
     336                        'output'                => "<li>" . wp_register('', '', false) . "</li><li>" . wp_loginout('', false) . "</li><li><a href='". get_bloginfo('rss2_url') . "' title='". __('Syndicate this site using RSS 2.0') . "'>" . __('Entries <abbr title="Really Simple Syndication">RSS</abbr>') . "</a></li><li><a href='" . get_bloginfo('comments_rss2_url') . "' title='" . __('The latest comments to all posts in RSS') . "'>" . __('Comments <abbr title="Really Simple Syndication">RSS</abbr>') . "</a></li><li><a href='http://wordpress.org/' title='" . __('Powered by WordPress, state-of-the-art semantic personal publishing platform.') . "'>WordPress.org</a></li>" . wp_meta(), 
     337                        'after_output'  => "</ul>", 
     338                        'design'                => $widget_design 
     339                ); 
     340                return array_merge($args, $widget_array);        
    305341        } 
    306342 
    307343        function update( $new_instance, $old_instance ) { 
     
    334370 
    335371        function widget( $args, $instance ) { 
    336372                extract($args); 
    337                 $title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title']); 
    338                 echo $before_widget; 
    339                 if ( $title ) 
    340                         echo $before_title . $title . $after_title; 
    341                 echo '<div id="calendar_wrap">'; 
    342                 get_calendar(); 
    343                 echo '</div>'; 
    344                 echo $after_widget; 
     373                $title = apply_filters('widget_title', empty($instance['title']) ? __('Calendar') : $instance['title'], $args); 
     374                 
     375                $widget_design = new Widget_Basic; 
     376                $widget_array = array( 
     377                        'title'                 => $title, 
     378                        'before_output' => "<div id='calendar_wrap'>", 
     379                        'output'                => get_calendar(true, false), 
     380                        'after_output'  => "</div>", 
     381                        'style'                 => "none", 
     382                        'design'                => $widget_design 
     383                ); 
     384                return array_merge($args, $widget_array); 
    345385        } 
    346386 
    347387        function update( $new_instance, $old_instance ) { 
     
    378418                extract($args); 
    379419                $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance ); 
    380420                $text = apply_filters( 'widget_text', $instance['text'], $instance ); 
    381                 echo $before_widget; 
    382                 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> 
    383                         <div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div> 
    384                 <?php 
    385                 echo $after_widget; 
     421                 
     422                $widget_design = new Widget_Basic; 
     423                $widget_array = array( 
     424                        'title'                 => $title, 
     425                        'before_output' => "<div class='textwidget'>", 
     426                        'output'                => $instance['filter'] ? wpautop($text) : $text, 
     427                        'after_output'  => "</div>", 
     428                        'style'                 => "none", 
     429                        'design'                => $widget_design 
     430                ); 
     431                return array_merge($args, $widget_array); 
    386432        } 
    387433 
    388434        function update( $new_instance, $old_instance ) { 
     
    426472        function widget( $args, $instance ) { 
    427473                extract( $args ); 
    428474 
    429                 $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title']); 
     475                $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $args); 
    430476                $c = $instance['count'] ? '1' : '0'; 
    431477                $h = $instance['hierarchical'] ? '1' : '0'; 
    432478                $d = $instance['dropdown'] ? '1' : '0'; 
     479                $walker = empty( $instance['walker'] ) ? '' : $instance['walker']; 
     480                 
     481                if (  !empty( $walker ) ) 
     482                        $cat_walker = new $walker; 
     483                 
     484                $cat_args = array('echo' => 0, 'orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'walker' => $cat_walker); 
    433485 
    434                 echo $before_widget; 
    435                 if ( $title ) 
    436                         echo $before_title . $title . $after_title; 
    437  
    438                 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 
    439  
    440486                if ( $d ) { 
    441487                        $cat_args['show_option_none'] = __('Select Category'); 
    442                         wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); 
    443 ?> 
    444  
    445 <script type='text/javascript'> 
    446 /* <![CDATA[ */ 
    447         var dropdown = document.getElementById("cat"); 
    448         function onCatChange() { 
    449                 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 
    450                         location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; 
    451                 } 
    452         } 
    453         dropdown.onchange = onCatChange; 
    454 /* ]]> */ 
    455 </script> 
    456  
    457 <?php 
     488                        $widget_opt_array = array('style' => "none"); 
     489                        $output .= wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); 
     490                        $output .= "<script type='text/javascript'> 
     491                        /* <![CDATA[ */ 
     492                                var dropdown = document.getElementById(\"cat\"); 
     493                                function onCatChange() { 
     494                                        if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 
     495                                                location.href = \"" . get_option('home') . "/?cat=\"+dropdown.options[dropdown.selectedIndex].value; 
     496                                        } 
     497                                } 
     498                                dropdown.onchange = onCatChange; 
     499                        /* ]]> */ 
     500                        </script>"; 
    458501                } else { 
    459 ?> 
    460                 <ul> 
    461 <?php 
    462                 $cat_args['title_li'] = ''; 
    463                 wp_list_categories(apply_filters('widget_categories_args', $cat_args)); 
    464 ?> 
    465                 </ul> 
    466 <?php 
     502                        $cat_args['title_li'] = ''; 
     503                        $widget_opt_array = array('before_output' => "<ul>", 'after_output' => "</ul>", 'style' => "li"); 
     504                        $output = wp_list_categories(apply_filters('widget_categories_args', $cat_args)); 
    467505                } 
    468506 
    469                 echo $after_widget; 
     507                $widget_design = new Widget_Basic; 
     508                $widget_array = array( 
     509                        'title'                 => $title, 
     510                        'output'                => $output, 
     511                        'design'                => $widget_design 
     512                ); 
     513                return array(array_merge($args, array_merge($widget_array, $widget_opt_array)));         
    470514        } 
    471515 
    472516        function update( $new_instance, $old_instance ) { 
     
    475519                $instance['count'] = $new_instance['count'] ? 1 : 0; 
    476520                $instance['hierarchical'] = $new_instance['hierarchical'] ? 1 : 0; 
    477521                $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 
     522                $instance['walker'] = strip_tags( $new_instance['walker'] ); 
    478523 
    479524                return $instance; 
    480525        } 
    481526 
    482527        function form( $instance ) { 
    483528                //Defaults 
    484                 $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 
     529                $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'walker' => '') ); 
    485530                $title = esc_attr( $instance['title'] ); 
    486531                $count = isset($instance['count']) ? (bool) $instance['count'] :false; 
    487532                $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 
    488533                $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 
     534                $walker = esc_attr( $instance['walker'] ); 
    489535?> 
    490536                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> 
    491537                <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p> 
     
    497543                <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br /> 
    498544 
    499545                <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> /> 
    500                 <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p> 
     546                <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label> 
     547                 
     548                <br /><br /> 
     549                <label for="<?php echo $this->get_field_id('walker'); ?>"><?php _e( 'Walker:' ); ?></label> <input type="text" value="<?php echo $walker; ?>" name="<?php echo $this->get_field_name('walker'); ?>" id="<?php echo $this->get_field_id('walker'); ?>" class="widefat" /> 
     550                <br /> 
     551                <small><?php _e( 'Customer Walker' ); ?></small></p> 
    501552<?php 
    502553        } 
    503554 
     
    534585                ob_start(); 
    535586                extract($args); 
    536587 
    537                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); 
     588                $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $args); 
    538589                if ( !$number = (int) $instance['number'] ) 
    539590                        $number = 10; 
    540591                else if ( $number < 1 ) 
     
    543594                        $number = 15; 
    544595 
    545596                $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); 
     597                 
    546598                if ($r->have_posts()) : 
    547 ?> 
    548                 <?php echo $before_widget; ?> 
    549                 <?php if ( $title ) echo $before_title . $title . $after_title; ?> 
    550                 <ul> 
    551                 <?php  while ($r->have_posts()) : $r->the_post(); ?> 
    552                 <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li> 
    553                 <?php endwhile; ?> 
    554                 </ul> 
    555                 <?php echo $after_widget; ?> 
    556 <?php 
     599                 
     600                        while ($r->have_posts()) { 
     601                                $r->the_post(); 
     602                                $posts_output .= "<li><a href='" . get_permalink() . "' title='" . esc_attr(get_the_title() ? get_the_title() : get_the_ID()) . "'>" .  ( ( get_the_title() ) ? get_the_title() : the_ID() ) . "</a></li>"; 
     603                        } 
     604                         
    557605                        wp_reset_query();  // Restore global post data stomped by the_post(). 
     606                 
    558607                endif; 
    559608 
     609                $widget_design = new Widget_Basic; 
     610                $widget_array = array( 
     611                        'title'                 => $title, 
     612                        'before_output' => "<ul>", 
     613                        'output'                => $posts_output, 
     614                        'after_output'  => "</ul>", 
     615                        'style'                 => "li", 
     616                        'design'                => $widget_design 
     617                ); 
     618                                 
    560619                $cache[$args['widget_id']] = ob_get_flush(); 
    561620                wp_cache_add('widget_recent_posts', $cache, 'widget'); 
     621 
     622                return array_merge($args, $widget_array); 
     623                 
    562624        } 
    563625 
    564626        function update( $new_instance, $old_instance ) { 
     
    625687                global $wpdb, $comments, $comment; 
    626688 
    627689                extract($args, EXTR_SKIP); 
    628                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']); 
     690                $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title'], $args); 
    629691                if ( !$number = (int) $instance['number'] ) 
    630692                        $number = 5; 
    631693                else if ( $number < 1 ) 
     
    639701                } 
    640702 
    641703                $comments = array_slice( (array) $comments, 0, $number ); 
    642 ?> 
    643                 <?php echo $before_widget; ?> 
    644                         <?php if ( $title ) echo $before_title . $title . $after_title; ?> 
    645                         <ul id="recentcomments"><?php 
    646                         if ( $comments ) : foreach ( (array) $comments as $comment) : 
    647                         echo  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>'; 
    648                         endforeach; endif;?></ul> 
    649                 <?php echo $after_widget; ?> 
    650 <?php 
     704                 
     705                if ( $comments ) : foreach ( (array) $comments as $comment) : 
     706                        $comments_output .=  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>'; 
     707                endforeach; endif; 
     708                 
     709                $widget_design = new Widget_Basic; 
     710                $widget_array = array( 
     711                        'title'                 => $title, 
     712                        'before_output' => "<ul id='recentcomments'>", 
     713                        'output'                => $comments_output, 
     714                        'after_output'  => "</ul>", 
     715                        'style'                 => "li", 
     716                        'design'                => $widget_design 
     717                ); 
     718 
     719                return array_merge($args, $widget_array); 
    651720        } 
    652721 
    653722        function update( $new_instance, $old_instance ) { 
     
    720789 
    721790                if ( empty($title) ) 
    722791                        $title = empty($desc) ? __('Unknown Feed') : $desc; 
    723  
    724                 $title = apply_filters('widget_title', $title ); 
     792                 
     793                $title = apply_filters('widget_title', $title, $args ); 
    725794                $url = esc_url(strip_tags($url)); 
    726795                $icon = includes_url('images/rss.png'); 
    727796                if ( $title ) 
    728797                        $title = "<a class='rsswidget' href='$url' title='" . esc_attr(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>"; 
    729  
    730                 echo $before_widget; 
    731                 if ( $title ) 
    732                         echo $before_title . $title . $after_title; 
    733                 wp_widget_rss_output( $rss, $instance ); 
    734                 echo $after_widget; 
     798                 
     799                $widget_design = new Widget_Basic; 
     800                $widget_func_array = array_merge($instance, array('echo' => 0)); 
     801                $widget_array = array( 
     802                        'title'                 => $title, 
     803                        'before_output' => "<ul>", 
     804                        'output'                => wp_widget_rss_output( $rss, $widget_func_array ), 
     805                        'after_output'  => "</ul>", 
     806                        'style'                 => "li", 
     807                        'design'                => $widget_design 
     808                ); 
    735809                $rss->__destruct();  
    736810                unset($rss); 
     811 
     812                return array_merge($args, $widget_array); 
    737813        } 
    738814 
    739815        function update($new_instance, $old_instance) { 
     
    760836 * @param array $args Widget arguments. 
    761837 */ 
    762838function wp_widget_rss_output( $rss, $args = array() ) { 
     839         
     840        $rss_items = ''; 
     841         
    763842        if ( is_string( $rss ) ) { 
    764843                $rss = fetch_feed($rss); 
    765844        } elseif ( is_array($rss) && isset($rss['url']) ) { 
     
    771850 
    772851        if ( is_wp_error($rss) ) { 
    773852                if ( is_admin() || current_user_can('manage_options') ) 
    774                         echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>'; 
     853                        $rss_items .= '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>'; 
    775854                return; 
    776855        } 
    777856 
    778         $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 ); 
     857        $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'echo' => 1 ); 
    779858        $args = wp_parse_args( $args, $default_args ); 
    780859        extract( $args, EXTR_SKIP ); 
    781860 
     
    787866        $show_date     = (int) $show_date; 
    788867 
    789868        if ( !$rss->get_item_quantity() ) { 
    790                 echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>'; 
     869                $rss_items .= '<li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li>'; 
    791870                $rss->__destruct();  
    792871                unset($rss); 
    793872                return; 
    794873        } 
    795874 
    796         echo '<ul>'; 
    797875        foreach ( $rss->get_items(0, $items) as $item ) { 
    798876                $link = $item->get_link(); 
    799877                while ( stristr($link, 'http') != $link ) 
     
    835913                } 
    836914 
    837915                if ( $link == '' ) { 
    838                         echo "<li>$title{$date}{$summary}{$author}</li>"; 
     916                        $rss_items .= "<li>$title{$date}{$summary}{$author}</li>"; 
    839917                } else { 
    840                         echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>"; 
     918                        $rss_items .= "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>"; 
    841919                } 
    842920        } 
    843         echo '</ul>'; 
     921         
     922        if ( $echo ) 
     923                echo $rss_items; 
     924        else 
     925                return $rss_items; 
     926         
    844927        $rss->__destruct();  
    845928        unset($rss); 
    846929} 
     
    9741057 
    9751058        function widget( $args, $instance ) { 
    9761059                extract($args); 
    977                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title']); 
     1060                $title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title'], $args); 
    9781061 
    979                 echo $before_widget; 
    980                 if ( $title ) 
    981                         echo $before_title . $title . $after_title; 
    982                 echo '<div>'; 
    983                 wp_tag_cloud(apply_filters('widget_tag_cloud_args', array())); 
    984                 echo "</div>\n"; 
    985                 echo $after_widget; 
     1062                $widget_design = new Widget_Basic; 
     1063                $widget_array = array( 
     1064                        'title'                 => $title, 
     1065                        'before_output' => "<div>", 
     1066                        'output'                => wp_tag_cloud(apply_filters('widget_tag_cloud_args', array('echo' => 0))), 
     1067                        'after_output'  => "</div>", 
     1068                        'style'                 => "none", 
     1069                        'design'                => $widget_design 
     1070                ); 
     1071                return array_merge($args, $widget_array); 
    9861072        } 
    9871073 
    9881074        function update( $new_instance, $old_instance ) { 
     
    9981084        } 
    9991085} 
    10001086 
     1087class Walker_Widget { 
     1088         
     1089        function start_widget($args, &$output)  {} 
     1090         
     1091        function end_widget($args, &$output)            {} 
     1092         
     1093        function title_widget($args, &$output)  {} 
     1094         
     1095        function content_widget($args, &$output)        {} 
     1096 
     1097        function display( $args = array() ) { 
     1098                $output = ''; 
     1099                call_user_func_array( array(&$this, 'start_widget'),    array($args, &$output) ); 
     1100                call_user_func_array( array(&$this, 'title_widget'),    array($args, &$output) ); 
     1101                call_user_func_array( array(&$this, 'content_widget'),  array($args, &$output) ); 
     1102                call_user_func_array( array(&$this, 'end_widget'),              array($args, &$output) ); 
     1103                return $output; 
     1104        } 
     1105         
     1106} 
     1107 
     1108class Widget_Basic extends Walker_Widget { 
     1109         
     1110        function start_widget($args, &$output) { 
     1111                $output .= sprintf( __("<li id='%s' class='widget %s'>"), $args['widget_id'], $args['classname'] );      
     1112        } 
     1113         
     1114        function title_widget($args, &$output) { 
     1115                $output .= "<h2>" . $args['title'] . "</h2>"; 
     1116        } 
     1117                 
     1118        function content_widget($args, &$output) { 
     1119                $output .= $args['before_output'] . $args['output'] . $args['after_output']; 
     1120        } 
     1121         
     1122        function end_widget($args, &$output) { 
     1123                $output .= "</li>"; 
     1124        } 
     1125         
     1126} 
     1127 
     1128class Widget_Tag_Cloud extends Walker_Widget { 
     1129         
     1130        function title_widget($args, &$output) { 
     1131                $output .= "<h2>" . $args['title'] . "</h2>"; 
     1132        } 
     1133                 
     1134        function content_widget($args, &$output) { 
     1135                $output .= $args['before_output'] . $args['output'] . $args['after_output']; 
     1136        } 
     1137         
     1138} 
     1139 
     1140class Widget_Search extends Walker_Widget { 
     1141 
     1142        function title_widget($args, &$output) { 
     1143                $output .= $args['title']; 
     1144        } 
     1145                 
     1146        function content_widget($args, &$output) { 
     1147                $output .= $args['output']; 
     1148        } 
     1149         
     1150} 
     1151 
    10011152/** 
    10021153 * Register all of the default WordPress widgets on startup. 
    10031154 * 
  • wp-includes/general-template.php

     
    112112 * 
    113113 * @since 2.7.0 
    114114 */ 
    115 function get_search_form() { 
     115function get_search_form($echo = true) { 
    116116        do_action( 'get_search_form' ); 
    117117 
    118118        $search_form_template = locate_template(array('searchform.php')); 
     
    128128        </div> 
    129129        </form>'; 
    130130 
    131         echo apply_filters('get_search_form', $form); 
     131        if ( $echo ) 
     132                echo apply_filters('get_search_form', $form); 
     133        else 
     134                return apply_filters('get_search_form', $form); 
    132135} 
    133136 
    134137/** 
     
    141144 * @uses apply_filters() Calls 'loginout' hook on HTML link content. 
    142145 * 
    143146 * @param string $redirect Optional path to redirect to on login/logout. 
     147 * @param boolean $echo Default to echo and not return the link. 
    144148 */ 
    145 function wp_loginout($redirect = '') { 
     149function wp_loginout($redirect = '', $echo = true) { 
    146150        if ( ! is_user_logged_in() ) 
    147151                $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>'; 
    148152        else 
    149153                $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>'; 
    150  
    151         echo apply_filters('loginout', $link); 
     154         
     155        if ( $echo ) 
     156                echo apply_filters('loginout', $link); 
     157        else 
     158                return apply_filters('loginout', $link); 
    152159} 
    153160 
    154161/** 
     
    228235 * 
    229236 * @param string $before Text to output before the link (defaults to <li>). 
    230237 * @param string $after Text to output after the link (defaults to </li>). 
     238 * @param boolean $echo Default to echo and not return the link. 
    231239 */ 
    232 function wp_register( $before = '<li>', $after = '</li>' ) { 
     240function wp_register( $before = '<li>', $after = '</li>', $echo = true ) { 
    233241 
    234242        if ( ! is_user_logged_in() ) { 
    235243                if ( get_option('users_can_register') ) 
     
    239247        } else { 
    240248                $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after; 
    241249        } 
    242  
    243         echo apply_filters('register', $link); 
     250         
     251        if ( $echo ) 
     252                echo apply_filters('register', $link); 
     253        else 
     254                return apply_filters('register', $link); 
    244255} 
    245256 
    246257/** 
     
    952963 * @since 1.0.0 
    953964 * 
    954965 * @param bool $initial Optional, default is true. Use initial calendar names. 
     966 * @param bool $echo Optional, default is true. Set to false for return. 
    955967 */ 
    956 function get_calendar($initial = true) { 
     968function get_calendar($initial = true, $echo = true) { 
    957969        global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 
    958970 
    959971        $cache = array(); 
     
    10241036 
    10251037        /* translators: Calendar caption: 1: month name, 2: 4-digit year */ 
    10261038        $calendar_caption = _x('%1$s %2$s', 'calendar caption'); 
    1027         echo '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> 
     1039        $calendar_output .= '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> 
    10281040        <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> 
    10291041        <thead> 
    10301042        <tr>'; 
     
    10381050        foreach ( $myweek as $wd ) { 
    10391051                $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 
    10401052                $wd = esc_attr($wd); 
    1041                 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 
     1053                $calendar_output .= "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 
    10421054        } 
    10431055 
    1044         echo ' 
     1056        $calendar_output .= ' 
    10451057        </tr> 
    10461058        </thead> 
    10471059 
     
    10491061        <tr>'; 
    10501062 
    10511063        if ( $previous ) { 
    1052                 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 
     1064                $calendar_output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 
    10531065                get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 
    10541066                        date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 
    10551067        } else { 
    1056                 echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>'; 
     1068                $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>'; 
    10571069        } 
    10581070 
    1059         echo "\n\t\t".'<td class="pad">&nbsp;</td>'; 
     1071        $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>'; 
    10601072 
    10611073        if ( $next ) { 
    1062                 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 
     1074                $calendar_output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 
    10631075                get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month) , 
    10641076                        date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>'; 
    10651077        } else { 
    1066                 echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>'; 
     1078                $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>'; 
    10671079        } 
    10681080 
    1069         echo ' 
     1081        $calendar_output .= ' 
    10701082        </tr> 
    10711083        </tfoot> 
    10721084 
     
    11181130        // See how much we should pad in the beginning 
    11191131        $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); 
    11201132        if ( 0 != $pad ) 
    1121                 echo "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>'; 
     1133                $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>'; 
    11221134 
    11231135        $daysinmonth = intval(date('t', $unixmonth)); 
    11241136        for ( $day = 1; $day <= $daysinmonth; ++$day ) { 
    11251137                if ( isset($newrow) && $newrow ) 
    1126                         echo "\n\t</tr>\n\t<tr>\n\t\t"; 
     1138                        $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; 
    11271139                $newrow = false; 
    11281140 
    11291141                if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) 
    1130                         echo '<td id="today">'; 
     1142                        $calendar_output .= '<td id="today">'; 
    11311143                else 
    1132                         echo '<td>'; 
     1144                        $calendar_output .= '<td>'; 
    11331145 
    11341146                if ( in_array($day, $daywithpost) ) // any posts today? 
    1135                                 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>"; 
     1147                                $calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>"; 
    11361148                else 
    1137                         echo $day; 
    1138                 echo '</td>'; 
     1149                        $calendar_output .= $day; 
     1150                $calendar_output .= '</td>'; 
    11391151 
    11401152                if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) 
    11411153                        $newrow = true; 
     
    11431155 
    11441156        $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); 
    11451157        if ( $pad != 0 && $pad != 7 ) 
    1146                 echo "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>'; 
     1158                $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>'; 
    11471159 
    1148         echo "\n\t</tr>\n\t</tbody>\n\t</table>"; 
     1160        $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; 
    11491161 
    11501162        $output = ob_get_contents(); 
    11511163        ob_end_clean(); 
    1152         echo $output; 
    11531164        $cache[ $key ] = $output; 
    11541165        wp_cache_set( 'get_calendar', $cache, 'calendar' ); 
     1166 
     1167        if ( $echo ) 
     1168                echo $calendar_output; 
     1169        else 
     1170                return $calendar_output; 
     1171 
    11551172} 
    11561173 
    11571174/** 
  • wp-includes/widgets.php

     
    3838         * 
    3939         * Subclasses should over-ride this function to generate their widget code. 
    4040         * 
    41          * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. 
    4241         * @param array $instance The settings for the particular instance of the widget 
    4342         */ 
    44         function widget($args, $instance) { 
     43        function widget($args, $instance, &$design) { 
    4544                die('function WP_Widget::widget() must be over-ridden in a sub-class.'); 
    4645        } 
    4746 
     
    178177                        $instance = $instance[$this->number]; 
    179178                        // filters the widget's settings, return false to stop displaying the widget 
    180179                        $instance = apply_filters('widget_display_callback', $instance, $this, $args); 
    181                         if ( false !== $instance ) 
    182                                 $this->widget($args, $instance); 
     180                        if ( false !== $instance ) { 
     181                                $widget_design = $this->widget($args, $instance); 
     182                                call_user_func_array( array(&$this, 'design_widget'), array($widget_design) ); 
     183                        } 
    183184                } 
    184185        } 
    185186 
     187        /** Generate the actual widget with design API. 
     188         *      Do NOT over-ride this function. */ 
     189        function design_widget ( $args ) { 
     190                // checking to see if the widget is going to be creating more than one module. 
     191                if ( is_array($args[0]) ) { 
     192                        foreach ($args as $widget) { 
     193                                if ( empty($widget['design']) ) 
     194                                        $widget['design'] = new Widget_Basic; 
     195                                $widget_design = apply_filters('widget_design', $widget['design']); 
     196                                echo call_user_func_array( array(&$widget_design, 'display'), array($widget) ); 
     197                        } 
     198                } else { 
     199                        if ( empty($args['design']) ) 
     200                                $args['design'] = new Widget_Basic; 
     201                        $widget_design = apply_filters('widget_design', $args['design']); 
     202                        echo call_user_func_array( array(&$widget_design, 'display'), array($args) ); 
     203                } 
     204        } 
     205         
    186206        /** Deal with changed settings. 
    187207         *      Do NOT over-ride this function. */ 
    188208        function update_callback( $widget_args = 1 ) { 
     
    274294                } 
    275295                return $return; 
    276296        } 
    277  
     297         
    278298        /** Helper function: Registers a single instance. */ 
    279299        function _register_one($number = -1) { 
    280300                wp_register_sidebar_widget(     $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) ); 
     
    519539 * name - The name of the sidebar, which presumably the title which will be 
    520540 *     displayed. 
    521541 * id - The unique identifier by which the sidebar will be called by. 
    522  * before_widget - The content that will prepended to the widgets when they are 
    523  *     displayed. 
    524  * after_widget - The content that will be appended to the widgets when they are 
    525  *     displayed. 
    526  * before_title - The content that will be prepended to the title when displayed. 
    527  * after_title - the content that will be appended to the title when displayed. 
    528542 * 
    529543 * <em>Content</em> is assumed to be HTML and should be formatted as such, but 
    530544 * doesn't have to be. 
     
    548562        $defaults = array( 
    549563                'name' => sprintf(__('Sidebar %d'), $i ), 
    550564                'id' => "sidebar-$i", 
    551                 'description' => '', 
    552                 'before_widget' => '<li id="%1$s" class="widget %2$s">', 
    553                 'after_widget' => "</li>\n", 
    554                 'before_title' => '<h2 class="widgettitle">', 
    555                 'after_title' => "</h2>\n", 
     565                'description' => '' 
    556566        ); 
    557567 
    558568        $sidebar = array_merge($defaults, (array) $args); 
     
    873883                                $classname_ .= '_' . get_class($cn); 
    874884                } 
    875885                $classname_ = ltrim($classname_, '_'); 
    876                 $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_); 
     886                $params[0]['classname'] = $classname_; 
    877887 
    878888                $params = apply_filters( 'dynamic_sidebar_params', $params ); 
    879889 
     
    12911301        $widget_obj = $wp_widget_factory->widgets[$widget]; 
    12921302        if ( !is_a($widget_obj, 'WP_Widget') ) 
    12931303                return; 
    1294  
    1295         $before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname']); 
    1296         $default_args = array('before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'); 
    1297  
    1298         $args = wp_parse_args($args, $default_args); 
     1304         
     1305        echo "when do we run?"; 
     1306                 
    12991307        $instance = wp_parse_args($instance); 
    13001308 
    13011309        $widget_obj->_set(-1);