Fix team filtering and add taxonomy links
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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' );
|
||||
|
||||
@@ -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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
@@ -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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||
@@ -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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Players', 'sportspress' ); ?></strong></p>
|
||||
|
||||
@@ -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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
@@ -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;
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
|
||||
|
||||
@@ -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( '<select name="%s" id="%s" class="postform %s">', $name, $id, $class );
|
||||
if ( $args['show_option_all'] ):
|
||||
printf( '<option value="%s" %s>%s</option>', $args['option_all_value'], selected( $args['selected'], $args['option_all_value'], false ), $args['show_option_all'] );
|
||||
printf( '<option value="%s" %s>%s</option>', $args['option_all_value'], selected( $selected, $args['option_all_value'], false ), $args['show_option_all'] );
|
||||
endif;
|
||||
if ( $args['show_option_none'] ):
|
||||
printf( '<option value="%s" %s>%s</option>', $args['option_none_value'], selected( $args['selected'], $args['option_none_value'], false ), $args['show_option_none'] );
|
||||
printf( '<option value="%s" %s>%s</option>', $args['option_none_value'], selected( $selected, $args['option_none_value'], false ), $args['show_option_none'] );
|
||||
endif;
|
||||
foreach ( $posts as $post ):
|
||||
setup_postdata( $post );
|
||||
if ( $values == 'ID' ):
|
||||
printf( '<option value="%s" %s>%s</option>', $post->ID, selected( $args['selected'], $post->ID, false ), $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) );
|
||||
printf( '<option value="%s" %s>%s</option>', $post->ID, selected( $selected, $post->ID, false ), $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) );
|
||||
else:
|
||||
printf( '<option value="%s" %s>%s</option>', $post->post_name, selected( $args['selected'], $post->post_name, false ), $post->post_title );
|
||||
printf( '<option value="%s" %s>%s</option>', $post->post_name, selected( $selected, $post->post_name, false ), $post->post_title );
|
||||
endif;
|
||||
endforeach;
|
||||
wp_reset_postdata();
|
||||
|
||||
Reference in New Issue
Block a user