From c886b143bcc6bffc4f75adcc10a57a8413ee03b3 Mon Sep 17 00:00:00 2001
From: Brian Miyaji
Date: Thu, 13 Feb 2014 17:58:47 +1100
Subject: [PATCH] Fix team filtering and add taxonomy links
---
admin/hooks/parse-query.php | 2 +-
admin/hooks/restrict-manage-posts.php | 4 ++--
admin/post-types/list.php | 12 +++++++++---
admin/post-types/table.php | 8 ++++++--
functions.php | 16 ++++++++++++----
5 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/admin/hooks/parse-query.php b/admin/hooks/parse-query.php
index b2313a2f..d02c5a00 100644
--- a/admin/hooks/parse-query.php
+++ b/admin/hooks/parse-query.php
@@ -4,7 +4,7 @@ function sportspress_parse_query( $query ) {
if ( is_admin() && $pagenow == 'edit.php' ):
- if( in_array( $typenow, array( 'sp_event', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) && isset( $_GET['team'] ) ):
+ if( in_array( $typenow, array( 'sp_event', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) && isset( $_GET['team'] ) && $_GET['team'] != null ):
$query->query_vars['meta_key'] = 'sp_team';
$query->query_vars['meta_value'] = $_GET['team'];
endif;
diff --git a/admin/hooks/restrict-manage-posts.php b/admin/hooks/restrict-manage-posts.php
index 37269768..c08d8159 100644
--- a/admin/hooks/restrict-manage-posts.php
+++ b/admin/hooks/restrict-manage-posts.php
@@ -37,11 +37,11 @@ function sportspress_restrict_manage_posts() {
$args = array(
'post_type' => 'sp_team',
'name' => 'team',
- 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
+ 'show_option_none' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
'selected' => $selected,
'values' => 'ID',
);
- sportspress_dropdown_pages( $args );
+ wp_dropdown_pages( $args );
endif;
}
add_action( 'restrict_manage_posts', 'sportspress_restrict_manage_posts' );
diff --git a/admin/post-types/list.php b/admin/post-types/list.php
index 0de2a5b5..59835600 100644
--- a/admin/post-types/list.php
+++ b/admin/post-types/list.php
@@ -64,7 +64,9 @@ function sportspress_list_player_meta( $post ) {
'selected' => $league_id,
'values' => 'term_id',
);
- sportspress_dropdown_taxonomies( $args );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_league', 'sp_team' );
+ endif;
?>
@@ -76,7 +78,9 @@ function sportspress_list_player_meta( $post ) {
'selected' => $season_id,
'values' => 'term_id',
);
- sportspress_dropdown_taxonomies( $args );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_season', 'sp_team' );
+ endif;
?>
@@ -89,7 +93,9 @@ function sportspress_list_player_meta( $post ) {
'selected' => $team_id,
'values' => 'ID',
);
- sportspress_dropdown_pages( $args );
+ if ( ! sportspress_dropdown_pages( $args ) ):
+ sportspress_post_adder( 'sp_team' );
+ endif;
?>
diff --git a/admin/post-types/table.php b/admin/post-types/table.php
index 151ab4c7..0a211822 100644
--- a/admin/post-types/table.php
+++ b/admin/post-types/table.php
@@ -62,7 +62,9 @@ function sportspress_table_team_meta( $post, $test ) {
'selected' => $league_id,
'values' => 'term_id'
);
- sportspress_dropdown_taxonomies( $args );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_league', 'sp_team' );
+ endif;
?>
@@ -74,7 +76,9 @@ function sportspress_table_team_meta( $post, $test ) {
'selected' => $season_id,
'values' => 'term_id'
);
- sportspress_dropdown_taxonomies( $args );
+ if ( ! sportspress_dropdown_taxonomies( $args ) ):
+ sportspress_taxonomy_adder( 'sp_season', 'sp_team' );
+ endif;
?>
diff --git a/functions.php b/functions.php
index ec09d7c6..7b7cc6c0 100644
--- a/functions.php
+++ b/functions.php
@@ -288,29 +288,37 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) {
'class' => null,
);
$args = array_merge( $defaults, $args );
+
$name = $args['name'];
unset( $args['name'] );
+
$id = $args['id'];
unset( $args['id'] );
+
$values = $args['values'];
unset( $args['values'] );
+
$class = $args['class'];
unset( $args['class'] );
+
+ $selected = $args['selected'];
+ unset( $args['selected'] );
+
$posts = get_posts( $args );
if ( $posts ):
printf( '