diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php index 700cab49..b57d06f1 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php @@ -19,7 +19,37 @@ class SP_Meta_Box_List_Columns { * Output the metabox */ public static function output( $post ) { + $selected = (array)get_post_meta( $post->ID, 'sp_columns', true ); + $orderby = get_post_meta( $post->ID, 'sp_orderby', true ); ?> +

+ +

ID, 'sp_columns', true ); sp_column_checklist( $post->ID, 'sp_performance', 'block', $selected ); sp_column_checklist( $post->ID, 'sp_metric', 'none', $selected ); sp_column_checklist( $post->ID, 'sp_statistic', 'none', $selected ); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php index 4b0868dc..f78b1935 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php @@ -47,19 +47,18 @@ class SP_Meta_Box_List_Data { - + + + - - + + + + + $label ): ?> - + @@ -81,15 +80,17 @@ class SP_Meta_Box_List_Data { $default_name = get_the_title( $player_id ); ?> - + + + - + + + + $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 .= ''; 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 .= ''; + 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 .= '';
- - + + @@ -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 ); + ?> + ' . $team_name . '' . $positions . '' . sp_array_value( $row, $key, '—' ) . '