Display multiple current teams in staff details

This commit is contained in:
Brian Miyaji
2015-07-19 13:08:38 +10:00
parent 507f13e839
commit fefc8790f7
2 changed files with 24 additions and 4 deletions

View File

@@ -12,6 +12,16 @@
*/ */
class SP_Staff extends SP_Custom_Post { class SP_Staff 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 * Returns past teams
* *

View File

@@ -15,6 +15,7 @@ if ( ! isset( $id ) )
$defaults = array( $defaults = array(
'show_nationality_flags' => get_option( 'sportspress_staff_show_flags', 'yes' ) == 'yes' ? true : false, '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 ); extract( $defaults, EXTR_SKIP );
@@ -24,7 +25,7 @@ $countries = SP()->countries->countries;
$staff = new SP_Staff( $id ); $staff = new SP_Staff( $id );
$nationality = $staff->nationality; $nationality = $staff->nationality;
$current_team = $staff->current_team; $current_teams = $staff->current_teams();
$past_teams = $staff->past_teams(); $past_teams = $staff->past_teams();
$data = array(); $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 : '&mdash;'; $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 : '&mdash;';
endif; endif;
if ( $current_team ) if ( $current_teams ):
$data[ __( 'Current Team', 'sportspress' ) ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>'; $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 ): if ( $past_teams ):
$teams = array(); $teams = array();
foreach ( $past_teams as $team ): 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; endforeach;
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams ); $data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
endif; endif;