$before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title, 'limit' => $limit, 'flatten' => $flatten, )); } function wp_widget_recent_by_category_control() { $options = $newoptions = get_option('widget_recent_by_category'); if ( $_POST['recent_by_category-submit'] ) { $newoptions['limit'] = $_POST['recent_by_category-limit']; $newoptions['flatten'] = isset($_POST['recent_by_category-flatten']); $newoptions['title'] = strip_tags(stripslashes($_POST['recent_by_category-title'])); } if ( $options != $newoptions ) { $options = $newoptions; update_option('widget_recent_by_category', $options); } $limit = $options['limit']; $flatten = $options['flatten'] ? 'checked="checked"' : ''; $title = attribute_escape($options['title']); ?>
1, 'exclude' => '', 'hdr_level' => '3', 'feed' => '', 'feed_image' => '', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', 'limit' => 5, 'hierarchical' => 1, ); $r = array_merge($defaults, $r); extract($r); $categories = get_categories($r); $output = ''; if ( empty($categories) ) { $output .= $before_widget . __("No categories") . $after_widget; } else { global $wp_query; if( !empty($show_option_all) ) $output .= '' . $show_option_all . ''; if ( is_category() ) $r['current_category'] = $wp_query->get_queried_object_id(); if ( $hierarchical ) $depth = 0; // Walk the full depth. else $depth = -1; // Flat. $output .= rpbc_walk_category_tree($categories, $depth, $r); } return apply_filters('rpbc_recent_posts', $output); } function rpbc_walk_category_tree() { $walker = new Walker_RecentByCategory; $args = func_get_args(); return call_user_func_array(array(&$walker, 'walk'), $args); } class Walker_RecentByCategory extends Walker { var $tree_type = 'category'; var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this public $activecats; function start_lvl($output, $depth, $args) { return $output; } function end_lvl($output, $depth, $args) { return $output; } function start_el($output, $category, $depth, $args) { extract($args); if (0 == $depth || ! $flatten) { $output .= $before_widget; $cat_name = attribute_escape( $category->cat_name); $cat_name = apply_filters( 'rpbc_list_cats', $cat_name, $category ); $link = $before_title; $link .= 'category_description) ) $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"'; else $link .= 'title="' . attribute_escape( apply_filters( 'category_description', $category->category_description, $category )) . '"'; $link .= '>'; $link .= $cat_name . ""; $link .= $after_title; if ( (! empty($feed_image)) || (! empty($feed)) ) { $link .= ' '; if ( empty($feed_image) ) $link .= '('; $link .= ''; $link .= ''; if ( empty($feed_image) ) $link .= ')'; } if ( $current_category ) $_current_category = get_category( $current_category ); $output .= "\t$link\n"; $output .= "