Skip to content

Commit

Permalink
improved code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
franz-josef-kaiser committed Jan 28, 2013
1 parent d84d940 commit 53eec18
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions filterama.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: (WCM) Filterama
* Plugin URI: http://example.com
* Description: Adds one taxonomy filter/drop-down/select box for each taxonomy attached to a (custom) post types list in the admin post list page.
* Version: 0.3
* Version: 0.3.2
* Author: Franz Josef Kaiser <[email protected]>
* Author URI: http://example.com
* Contributors: userabuser, kai-ser
Expand Down Expand Up @@ -41,7 +41,7 @@ public function setup()

// ALL or ANY
add_action( 'restrict_manage_posts', array( $this, 'get_markup_match' ) );
add_filter( 'posts_where' , array( $this, 'sql_match' ) );
add_filter( 'posts_where' , array( $this, 'sql_where_match' ) );
}

public function setup_vars()
Expand All @@ -55,6 +55,11 @@ public function setup_vars()
);
}


/**
* @param array $taxonomies
* @return array
*/
public function add_columns( $taxonomies )
{
return array_merge(
Expand All @@ -77,20 +82,20 @@ public function get_markup_tax_select()
,__( 'View All' )
,get_taxonomy( $tax )->label
);
foreach ( get_terms( $tax ) as $taxon )
foreach ( get_terms( $tax ) as $term )
{
$selected = isset( $_GET[ $tax ] )
? selected( $taxon->slug, $_GET[ $tax ], false )
? selected( $term->slug, $_GET[ $tax ], false )
: ''
;
$parent = '0' !== $taxon->parent ?: true;
$parent = '0' !== $term->parent ?: true;
$options .= sprintf(
'<option class="level-%s" value="%s" %s>%s%s</option>'
,! $parent ? '1' : '0'
,$taxon->slug
,$term->slug
,$selected
,! $parent ? str_repeat( '&nbsp;', 3 ) : ''
,"{$taxon->name} ({$taxon->count})"
,"{$term->name} ({$term->count})"
);
}
$html .= sprintf(
Expand Down Expand Up @@ -124,7 +129,7 @@ public function get_markup_match()
* @param string $where WHERE SQL clause
* @return string SQL
*/
public function sql_match( $where )
public function sql_where_match( $where )
{
global $wpdb;
$tt_ids = $this->get_tax_ids();
Expand Down

0 comments on commit 53eec18

Please sign in to comment.