- |
-
- |
+
+
+
+ |
+
@@ -102,7 +103,7 @@ class SP_Meta_Box_List_Data {
|
-
+
|
+
+
+ 'sp_position',
+ 'name' => 'sp_players[' . $player_id . '][position]',
+ 'show_option_blank' => __( '(Auto)', 'sportspress' ),
+ 'values' => 'term_id',
+ 'orderby' => 'slug',
+ 'selected' => $selected,
+ 'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
+ );
+ sp_dropdown_taxonomies( $args );
+ ?>
+ |
+
$label ):
- if ( in_array( $column, array( 'number', 'team' ) ) ) continue;
+ if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
$value = sp_array_value( $player_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
?>
diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php
index 3f4761be..e1ae632d 100644
--- a/includes/class-sp-player-list.php
+++ b/includes/class-sp-player-list.php
@@ -491,9 +491,19 @@ class SP_Player_List extends SP_Custom_Post {
// Add player number and name to row
$merged[ $player_id ] = array();
- $player_data['number'] = get_post_meta( $player_id, 'sp_number', true );
+ if ( in_array( 'number', $this->columns ) ):
+ $player_data['number'] = get_post_meta( $player_id, 'sp_number', true );
+ endif;
+
$player_data['name'] = get_the_title( $player_id );
- $player_data['team'] = get_post_meta( $player_id, 'sp_team', true );
+
+ if ( in_array( 'team', $this->columns ) ):
+ $player_data['team'] = get_post_meta( $player_id, 'sp_team', true );
+ endif;
+
+ if ( in_array( 'position', $this->columns ) ):
+ $player_data['position'] = null;
+ endif;
foreach( $player_data as $key => $value ):
@@ -530,6 +540,8 @@ class SP_Player_List extends SP_Custom_Post {
$labels[ $key ] = '#';
elseif ( $key == 'team' && apply_filters( 'sportspress_has_teams', true ) ):
$labels[ $key ] = __( 'Team', 'sportspress' );
+ elseif ( $key == 'position' ):
+ $labels[ $key ] = __( 'Position', 'sportspress' );
elseif ( array_key_exists( $key, $columns ) ):
$labels[ $key ] = $columns[ $key ];
endif;
@@ -548,6 +560,7 @@ class SP_Player_List extends SP_Custom_Post {
if ( in_array( 'number', $this->columns ) ) $labels['number'] = '#';
$labels['name'] = __( 'Player', 'sportspress' );
if ( in_array( 'team', $this->columns ) && apply_filters( 'sportspress_has_teams', true ) ) $labels['team'] = __( 'Team', 'sportspress' );
+ if ( in_array( 'position', $this->columns ) ) $labels['position'] = __( 'Position', 'sportspress' );
$merged[0] = array_merge( $labels, $columns );
return $merged;
diff --git a/templates/player-list.php b/templates/player-list.php
index 4ddf5baf..753dabe0 100644
--- a/templates/player-list.php
+++ b/templates/player-list.php
@@ -176,9 +176,20 @@ foreach ( $groups as $group ):
endif;
$output .= '' . $team_name . ' | ';
endif;
+
+ if ( array_key_exists( 'position', $labels ) ):
+ $position = sp_array_value( $row, 'position', null );
+ if ( null === $position || ! $position ):
+ $positions = wp_strip_all_tags( get_the_term_list( $player_id, 'sp_position', '', ', ' ) );
+ else:
+ $position_term = get_term_by( 'id', $position, 'sp_position', ARRAY_A );
+ $positions = sp_array_value( $position_term, 'name', '—' );
+ endif;
+ $output .= '' . $positions . ' | ';
+ endif;
foreach( $labels as $key => $value ):
- if ( in_array( $key, array( 'number', 'name', 'team' ) ) )
+ if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) )
continue;
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
$output .= '' . sp_array_value( $row, $key, '—' ) . ' | ';