diff --git a/inc/filter.class.php b/inc/filter.class.php index 79a178f..3da6fe8 100644 --- a/inc/filter.class.php +++ b/inc/filter.class.php @@ -18,7 +18,10 @@ public static function init() public function setup_actions() { - add_filter( "manage_taxonomies_for_{$this->post_type}_columns", array( $this, 'add_columns' ) ); + add_filter( + "manage_taxonomies_for_{$this->post_type}_columns" + ,array( $this, 'add_columns' ) + ); } public function add_columns( $taxonomies ) @@ -31,22 +34,26 @@ public function add_columns( $taxonomies ) public function get_markup() { + $walker = new WCMF_walker; foreach ( $this->taxonomies as $tax ) { - $options = array( + wp_dropdown_categories( array( 'taxonomy' => $tax + ,'hide_if_empty' => true ,'show_option_all' => sprintf( - '%s %s' - ,__( 'View All', 'filterama' ) - ,get_taxonomy( $tax )->label + get_taxonomy( $tax )->labels->all_items ) - ,'hide_empty' => 0 - ,'hierarchical' => is_taxonomy_hierarchical( $tax ) - ,'show_count' => 1 - ,'orderby' => 'name' - ,'selected' => $tax - ); - wp_dropdown_categories( $options ); + ,'hide_empty' => true + ,'hierarchical' => is_taxonomy_hierarchical( $tax ) + ,'show_count' => true + ,'orderby' => 'name' + ,'selected' => '0' !== get_query_var( $tax ) + ? get_query_var( $tax ) + : false + ,'name' => $tax + ,'id' => $tax + ,'walker' => $walker + ) ); } } } \ No newline at end of file diff --git a/inc/walker_tax.class.php b/inc/walker_tax.class.php new file mode 100644 index 0000000..0bcd2ae --- /dev/null +++ b/inc/walker_tax.class.php @@ -0,0 +1,41 @@ + 'parent' + ,'id' => 'term_id' + ); + public $tax_name; + + /** + * @see Walker::start_el() + * @param string $output Passed by reference. Used to append additional content. + * @param object $term Taxonomy term data object. + * @param int $depth Depth of category. Used for padding. + * @param array $args Uses 'selected' and 'show_count' keys, if they exist. + * @param int $id + * @return void + */ + function start_el( &$output, $term, $depth, $args, $id = 0 ) + { + $pad = str_repeat( ' ', $depth * 3 ); + $cat_name = apply_filters( 'list_cats', $term->name, $term ); + $output .= sprintf( + '' + ,$depth + ,$term->slug + ,selected( + $args['selected'] + ,$term->slug + ,false + ) + ,"{$pad}{$cat_name}" + ,$args['show_count'] + ? "  ({$term->count})" + : '' + ); + } +} \ No newline at end of file