diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php index 69526feb..b483c2c6 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php @@ -79,6 +79,14 @@ class SP_Meta_Box_Event_Performance { * Admin edit table */ public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $split_positions = false ) { + if ( taxonomy_exists( 'sp_position' ) ) { + $args = array( + 'hide_empty' => false, + 'parent' => 0, + 'include_children' => true, + ); + $positions = get_terms( 'sp_position', $args ); + } ?>
@@ -87,9 +95,11 @@ class SP_Meta_Box_Event_Performance { - + + + $label ): ?> - + + + $label ): $player_id = 0; $player_performance = sp_array_value( $data, $player_id, array() ); @@ -133,7 +145,7 @@ class SP_Meta_Box_Event_Performance { $player_performance ): - self::row( $labels, $player_id, $player_performance, $team_id, $data ); + self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ) ); endforeach; ?> @@ -145,7 +157,7 @@ class SP_Meta_Box_Event_Performance { /** * Admin edit table row */ - public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array() ) { + public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true ) { if ( $player_id <= 0 ) return; $number = get_post_meta( $player_id, 'sp_number', true ); @@ -157,26 +169,28 @@ class SP_Meta_Box_Event_Performance { - + + + $label ): $value = sp_array_value( $player_performance, $column, '' ); ?> diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php index 881ba86d..bcb6dfaa 100644 --- a/includes/class-sp-event.php +++ b/includes/class-sp-event.php @@ -114,7 +114,9 @@ class SP_Event extends SP_Custom_Post{ return array( $labels, $columns, $performance, $teams ); else: // Add position to performance labels - $labels = array_merge( array( 'position' => __( 'Position', 'sportspress' ) ), $labels ); + if ( taxonomy_exists( 'sp_position' ) ): + $labels = array_merge( array( 'position' => __( 'Position', 'sportspress' ) ), $labels ); + endif; if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) && is_array( $columns ) ): foreach ( $labels as $key => $label ): if ( ! in_array( $key, $columns ) ):
  # - - + + @@ -119,7 +129,9 @@ class SP_Meta_Box_Event_Performance {       
- 'sp_position', - 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]', - 'values' => 'term_id', - 'orderby' => 'slug', - 'selected' => $selected, - 'class' => 'sp-position', - 'property' => 'multiple', - 'chosen' => true, - 'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ), - ); - sp_dropdown_taxonomies( $args ); - ?> - + 'sp_position', + 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]', + 'values' => 'term_id', + 'orderby' => 'slug', + 'selected' => $selected, + 'class' => 'sp-position', + 'property' => 'multiple', + 'chosen' => true, + 'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ), + ); + sp_dropdown_taxonomies( $args ); + ?> +