Add national flag option to player list
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||
endforeach;
|
||||
|
||||
@@ -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 = '<span class="player-flag"><img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"></span>' . $name;
|
||||
endforeach;
|
||||
$name_class .= ' has-photo';
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $link_posts ):
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||
|
||||
Reference in New Issue
Block a user