Display all current teams in player profile
This commit is contained in:
@@ -12,6 +12,16 @@
|
||||
*/
|
||||
class SP_Player extends SP_Custom_Post {
|
||||
|
||||
/**
|
||||
* Returns current teams
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function current_teams() {
|
||||
return get_post_meta( $this->ID, 'sp_current_team', false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns past teams
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ $countries = SP()->countries->countries;
|
||||
$player = new SP_Player( $id );
|
||||
|
||||
$nationality = $player->nationality;
|
||||
$current_team = $player->current_team;
|
||||
$current_teams = $player->current_teams();
|
||||
$past_teams = $player->past_teams();
|
||||
$metrics_before = $player->metrics( true );
|
||||
$metrics_after = $player->metrics( false );
|
||||
@@ -36,8 +36,14 @@ endif;
|
||||
|
||||
$data = array_merge( $metrics_before, $common, $metrics_after );
|
||||
|
||||
if ( $current_team )
|
||||
$data[ SP()->text->string('Current Team') ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||
if ( $current_teams ):
|
||||
$teams = array();
|
||||
foreach ( $current_teams as $team ):
|
||||
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||
endforeach;
|
||||
$label = _n( 'Current Team', 'Current Teams', count( $teams ) );
|
||||
$data[ $label ] = implode( ', ', $teams );
|
||||
endif;
|
||||
|
||||
if ( $past_teams ):
|
||||
$teams = array();
|
||||
|
||||
Reference in New Issue
Block a user