diff --git a/includes/admin/post-types/class-sp-admin-cpt-player.php b/includes/admin/post-types/class-sp-admin-cpt-player.php
index 6c19b57e..cad164ac 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-player.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-player.php
@@ -90,34 +90,15 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
if ( empty( $teams ) ):
echo '—';
else:
- $results = get_post_meta( $post_id, 'sp_results', true );
- $main_result = get_option( 'sportspress_primary_result', null );
+ $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
foreach( $teams as $team_id ):
if ( ! $team_id ) continue;
$team = get_post( $team_id );
-
if ( $team ):
- $team_results = sp_array_value( $results, $team_id, null );
-
- if ( $main_result ):
- $team_result = sp_array_value( $team_results, $main_result, null );
- else:
- if ( is_array( $team_results ) ):
- end( $team_results );
- $team_result = prev( $team_results );
- else:
- $team_result = null;
- endif;
- endif;
-
- if ( $team_result != null ):
- unset( $team_results['outcome'] );
- $team_results = implode( ' | ', $team_results );
- echo '' . $team_result . ' ';
- endif;
-
echo $team->post_title;
-
+ if ( in_array( $team_id, $current_teams ) ):
+ echo '';
+ endif;
echo '
';
endif;
endforeach;
diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php
index 58838e6d..3519d766 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-staff.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php
@@ -87,13 +87,13 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
if ( empty( $teams ) ):
echo '—';
else:
- $current_team = get_post_meta( $post_id, 'sp_current_team', true );
+ $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
foreach( $teams as $team_id ):
if ( ! $team_id ) continue;
$team = get_post( $team_id );
if ( $team ):
echo $team->post_title;
- if ( $team_id == $current_team ):
+ if ( in_array( $team_id, $current_teams ) ):
echo '';
endif;
echo '
';
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-details.php
index fb3fb57b..79d41d73 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-player-details.php
@@ -51,7 +51,7 @@ class SP_Meta_Box_Player_Details {
$teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) );
$past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) );
- $current_team = get_post_meta( $post->ID, 'sp_current_team', true );
+ $current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
?>
@@ -83,16 +83,16 @@ class SP_Meta_Box_Player_Details { sp_dropdown_taxonomies( $args ); ?> -
+
'sp_team', - 'name' => 'sp_current_team', - 'show_option_blank' => true, - 'selected' => $current_team, + 'name' => 'sp_current_team[]', + 'selected' => $current_teams, 'values' => 'ID', - 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ), - 'class' => 'sp-current-team widefat', + 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), + 'class' => 'sp-current-teams widefat', + 'property' => 'multiple', 'chosen' => true, ); sp_dropdown_pages( $args ); @@ -151,8 +151,8 @@ class SP_Meta_Box_Player_Details { public static function save( $post_id, $post ) { update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) ); update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) ); - update_post_meta( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', null ) ); + sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) ); - sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', null ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) ); + sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) ); } } \ No newline at end of file diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php index 6f0fcfee..31db8972 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php @@ -43,7 +43,7 @@ class SP_Meta_Box_Staff_Details { $teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) ); $past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) ); - $current_team = get_post_meta( $post->ID, 'sp_current_team', true ); + $current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) ); ?>
@@ -60,16 +60,16 @@ class SP_Meta_Box_Staff_Details { -
+
'sp_team', - 'name' => 'sp_current_team', - 'show_option_blank' => true, - 'selected' => $current_team, + 'name' => 'sp_current_team[]', + 'selected' => $current_teams, 'values' => 'ID', - 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ), - 'class' => 'sp-current-team widefat', + 'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), + 'class' => 'sp-current-teams widefat', + 'property' => 'multiple', 'chosen' => true, ); sp_dropdown_pages( $args ); @@ -128,8 +128,8 @@ class SP_Meta_Box_Staff_Details { public static function save( $post_id, $post ) { update_post_meta( $post_id, 'sp_role', sp_array_value( $_POST, 'sp_role', '' ) ); update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) ); - update_post_meta( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', null ) ); + sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) ); sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) ); - sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', null ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) ); + sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) ); } } \ No newline at end of file