diff --git a/assets/css/sportspress-rtl.css b/assets/css/sportspress-rtl.css
index 0517de48..92fd9c7d 100644
--- a/assets/css/sportspress-rtl.css
+++ b/assets/css/sportspress-rtl.css
@@ -22,7 +22,8 @@
/* League Table and Player List */
.sp-league-table .data-name .team-logo,
-.sp-player-list .data-name .player-photo {
+.sp-player-list .data-name .player-photo,
+.sp-player-list .data-name .player-flag {
margin-right: 0;
margin-left: 0.25em;
float: right;
diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css
index e1dbbac8..9f640c1e 100644
--- a/assets/css/sportspress.css
+++ b/assets/css/sportspress.css
@@ -158,7 +158,8 @@
.sp-player-list td {
line-height: 2em;
}
-.sp-player-list .data-name .player-photo {
+.sp-player-list .data-name .player-photo,
+.sp-player-list .data-name .player-flag {
width: 2em;
height: 2em;
margin-right: 0.25em;
@@ -166,7 +167,8 @@
float: left;
text-align: center;
}
-.sp-player-list .data-name .player-photo img {
+.sp-player-list .data-name .player-photo img,
+.sp-player-list .data-name .player-flag img {
width: auto;
height: auto;
max-width: 2em;
diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php
index e281a40d..bb790ae7 100644
--- a/includes/class-sp-player.php
+++ b/includes/class-sp-player.php
@@ -69,7 +69,16 @@ class SP_Player extends SP_Custom_Post {
* @return array
*/
public function nationalities() {
- return get_post_meta( $this->ID, 'sp_nationality', false );
+ $nationalities = get_post_meta( $this->ID, 'sp_nationality', false );
+ if ( empty ( $nationalities ) ) return array();
+ foreach ( $nationalities as $nationality ):
+ if ( 2 == strlen( $nationality ) ):
+ $legacy = SP()->countries->legacy;
+ $nationality = strtolower( $nationality );
+ $nationality = sp_array_value( $legacy, $nationality, null );
+ endif;
+ endforeach;
+ return $nationalities;
}
/**
diff --git a/modules/sportspress-player-lists.php b/modules/sportspress-player-lists.php
index 009d6571..35da77b1 100644
--- a/modules/sportspress-player-lists.php
+++ b/modules/sportspress-player-lists.php
@@ -210,6 +210,15 @@ class SportsPress_Player_Lists {
'id' => 'sportspress_list_show_photos',
'default' => 'no',
'type' => 'checkbox',
+ 'checkboxgroup' => 'start',
+ ),
+
+ array(
+ 'desc' => __( 'Display national flags', 'sportspress' ),
+ 'id' => 'sportspress_list_show_flags',
+ 'default' => 'no',
+ 'type' => 'checkbox',
+ 'checkboxgroup' => 'end',
),
array(
diff --git a/templates/player-details.php b/templates/player-details.php
index a8b18d03..36c0bcca 100644
--- a/templates/player-details.php
+++ b/templates/player-details.php
@@ -43,11 +43,6 @@ $common = array();
if ( $show_nationality && $nationalities && is_array( $nationalities ) ):
$values = array();
foreach ( $nationalities as $nationality ):
- if ( 2 == strlen( $nationality ) ):
- $legacy = SP()->countries->legacy;
- $nationality = strtolower( $nationality );
- $nationality = sp_array_value( $legacy, $nationality, null );
- endif;
$country_name = sp_array_value( $countries, $nationality, null );
$values[] = $country_name ? ( $show_nationality_flags ? '
' : '' ) . $country_name : '—';
endforeach;
diff --git a/templates/player-list.php b/templates/player-list.php
index 6c721eea..96083bc5 100644
--- a/templates/player-list.php
+++ b/templates/player-list.php
@@ -20,7 +20,8 @@ $defaults = array(
'order' => 'ASC',
'show_all_players_link' => false,
'show_title' => get_option( 'sportspress_list_show_title', 'yes' ) == 'yes' ? true : false,
- 'show_player_photo' => get_option( 'sportspress_list_show_photos', 'yes' ) == 'yes' ? true : false,
+ 'show_player_photo' => get_option( 'sportspress_list_show_photos', 'no' ) == 'yes' ? true : false,
+ 'show_player_flag' => get_option( 'sportspress_list_show_flags', 'no' ) == 'yes' ? true : false,
'link_posts' => get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
@@ -144,6 +145,17 @@ foreach ( $groups as $group ):
endif;
endif;
+ if ( $show_player_flag ):
+ $player = new SP_Player( $player_id );
+ $nationalities = $player->nationalities();
+ if ( ! empty( $nationalities ) ):
+ foreach ( $nationalities as $nationality ):
+ $name = '
' . $name;
+ endforeach;
+ $name_class .= ' has-photo';
+ endif;
+ endif;
+
if ( $link_posts ):
$permalink = get_post_permalink( $player_id );
$name = '' . $name . '';