-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d84d940
commit 53eec18
Showing
1 changed file
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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() | ||
|
@@ -55,6 +55,11 @@ public function setup_vars() | |
); | ||
} | ||
|
||
|
||
/** | ||
* @param array $taxonomies | ||
* @return array | ||
*/ | ||
public function add_columns( $taxonomies ) | ||
{ | ||
return array_merge( | ||
|
@@ -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( ' ', 3 ) : '' | ||
,"{$taxon->name} ({$taxon->count})" | ||
,"{$term->name} ({$term->count})" | ||
); | ||
} | ||
$html .= sprintf( | ||
|
@@ -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(); | ||
|