Display multiple current teams in staff details
This commit is contained in:
@@ -15,6 +15,7 @@ if ( ! isset( $id ) )
|
||||
|
||||
$defaults = array(
|
||||
'show_nationality_flags' => get_option( 'sportspress_staff_show_flags', 'yes' ) == 'yes' ? true : false,
|
||||
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
@@ -24,7 +25,7 @@ $countries = SP()->countries->countries;
|
||||
$staff = new SP_Staff( $id );
|
||||
|
||||
$nationality = $staff->nationality;
|
||||
$current_team = $staff->current_team;
|
||||
$current_teams = $staff->current_teams();
|
||||
$past_teams = $staff->past_teams();
|
||||
|
||||
$data = array();
|
||||
@@ -38,13 +39,22 @@ if ( $nationality ):
|
||||
$data[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flags ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||
endif;
|
||||
|
||||
if ( $current_team )
|
||||
$data[ __( 'Current Team', 'sportspress' ) ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||
if ( $current_teams ):
|
||||
$teams = array();
|
||||
foreach ( $current_teams as $team ):
|
||||
$team_name = get_the_title( $team );
|
||||
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||
$teams[] = $team_name;
|
||||
endforeach;
|
||||
$data[ __( 'Current Team', 'sportspress' ) ] = implode( ', ', $teams );
|
||||
endif;
|
||||
|
||||
if ( $past_teams ):
|
||||
$teams = array();
|
||||
foreach ( $past_teams as $team ):
|
||||
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||
$team_name = get_the_title( $team );
|
||||
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||
$teams[] = $team_name;
|
||||
endforeach;
|
||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
||||
endif;
|
||||
|
||||
Reference in New Issue
Block a user