Add options to display competition and season in player details
This commit is contained in:
@@ -106,6 +106,22 @@ class SP_Settings_Players extends SP_Settings_Page {
|
|||||||
'id' => 'sportspress_player_show_past_teams',
|
'id' => 'sportspress_player_show_past_teams',
|
||||||
'default' => 'yes',
|
'default' => 'yes',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => '',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Competitions', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_player_show_leagues',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => '',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Seasons', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_player_show_seasons',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
'checkboxgroup' => 'end',
|
'checkboxgroup' => 'end',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,26 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
return get_the_terms( $this->ID, 'sp_position' );
|
return get_the_terms( $this->ID, 'sp_position' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns leagues
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function leagues() {
|
||||||
|
return get_the_terms( $this->ID, 'sp_league' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns seasons
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function seasons() {
|
||||||
|
return get_the_terms( $this->ID, 'sp_season' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns current teams
|
* Returns current teams
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ $defaults = array(
|
|||||||
'show_positions' => get_option( 'sportspress_player_show_positions', 'yes' ) == 'yes' ? true : false,
|
'show_positions' => get_option( 'sportspress_player_show_positions', 'yes' ) == 'yes' ? true : false,
|
||||||
'show_current_teams' => get_option( 'sportspress_player_show_current_teams', 'yes' ) == 'yes' ? true : false,
|
'show_current_teams' => get_option( 'sportspress_player_show_current_teams', 'yes' ) == 'yes' ? true : false,
|
||||||
'show_past_teams' => get_option( 'sportspress_player_show_past_teams', 'yes' ) == 'yes' ? true : false,
|
'show_past_teams' => get_option( 'sportspress_player_show_past_teams', 'yes' ) == 'yes' ? true : false,
|
||||||
|
'show_leagues' => get_option( 'sportspress_player_show_leagues', 'no' ) == 'yes' ? true : false,
|
||||||
|
'show_seasons' => get_option( 'sportspress_player_show_seasons', 'no' ) == 'yes' ? true : false,
|
||||||
'show_nationality_flags' => get_option( 'sportspress_player_show_flags', 'yes' ) == 'yes' ? true : false,
|
'show_nationality_flags' => get_option( 'sportspress_player_show_flags', 'yes' ) == 'yes' ? true : false,
|
||||||
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
|
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
|
||||||
);
|
);
|
||||||
@@ -32,6 +34,8 @@ $nationalities = $player->nationalities();
|
|||||||
$positions = $player->positions();
|
$positions = $player->positions();
|
||||||
$current_teams = $player->current_teams();
|
$current_teams = $player->current_teams();
|
||||||
$past_teams = $player->past_teams();
|
$past_teams = $player->past_teams();
|
||||||
|
$leagues = $player->leagues();
|
||||||
|
$seasons = $player->seasons();
|
||||||
$metrics_before = $player->metrics( true );
|
$metrics_before = $player->metrics( true );
|
||||||
$metrics_after = $player->metrics( false );
|
$metrics_after = $player->metrics( false );
|
||||||
|
|
||||||
@@ -50,7 +54,7 @@ if ( $show_nationality && $nationalities && is_array( $nationalities ) ):
|
|||||||
$common[ __( 'Nationality', 'sportspress' ) ] = implode( '<br>', $values );
|
$common[ __( 'Nationality', 'sportspress' ) ] = implode( '<br>', $values );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $show_positions && $positions ):
|
if ( $show_positions && $positions && is_array( $positions ) ):
|
||||||
$position_names = array();
|
$position_names = array();
|
||||||
foreach ( $positions as $position ):
|
foreach ( $positions as $position ):
|
||||||
$position_names[] = $position->name;
|
$position_names[] = $position->name;
|
||||||
@@ -80,6 +84,22 @@ if ( $show_past_teams && $past_teams ):
|
|||||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if ( $show_leagues && $leagues && ! is_wp_error( $leagues ) ):
|
||||||
|
$terms = array();
|
||||||
|
foreach ( $leagues as $league ) {
|
||||||
|
$terms[] = $league->name;
|
||||||
|
}
|
||||||
|
$data[ __( 'Competitions', 'sportspress' ) ] = implode( ', ', $terms );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( $show_seasons && $seasons && ! is_wp_error( $seasons ) ):
|
||||||
|
$terms = array();
|
||||||
|
foreach ( $seasons as $season ) {
|
||||||
|
$terms[] = $season->name;
|
||||||
|
}
|
||||||
|
$data[ __( 'Seasons', 'sportspress' ) ] = implode( ', ', $terms );
|
||||||
|
endif;
|
||||||
|
|
||||||
$data = apply_filters( 'sportspress_player_details', $data, $id );
|
$data = apply_filters( 'sportspress_player_details', $data, $id );
|
||||||
|
|
||||||
if ( empty( $data ) )
|
if ( empty( $data ) )
|
||||||
|
|||||||
Reference in New Issue
Block a user