Skip to content

Commit

Permalink
switched to a custom walker
Browse files Browse the repository at this point in the history
  • Loading branch information
franz-josef-kaiser committed Feb 1, 2013
1 parent a41cc6e commit b0c7375
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 12 deletions.
31 changes: 19 additions & 12 deletions inc/filter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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
) );
}
}
}
41 changes: 41 additions & 0 deletions inc/walker_tax.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
defined( 'ABSPATH' ) OR exit;

class WCMF_walker extends Walker_CategoryDropdown
{
var $tree_type = 'category';
var $db_fields = array(
'parent' => '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( '&nbsp;', $depth * 3 );
$cat_name = apply_filters( 'list_cats', $term->name, $term );
$output .= sprintf(
'<option class="level-%s" value="%s" %s>%s%s</option>'
,$depth
,$term->slug
,selected(
$args['selected']
,$term->slug
,false
)
,"{$pad}{$cat_name}"
,$args['show_count']
? "&nbsp;&nbsp;({$term->count})"
: ''
);
}
}

0 comments on commit b0c7375

Please sign in to comment.