Option to display national flag in player profile

This commit is contained in:
Brian Miyaji
2014-03-08 03:34:43 +11:00
parent 68ad967262
commit ff10e0c0af
2 changed files with 33 additions and 2 deletions

View File

@@ -1,12 +1,20 @@
<?php
if ( !function_exists( 'sportspress_player_metrics' ) ) {
function sportspress_player_metrics( $id = null ) {
function sportspress_player_metrics( $id = null, $args = '' ) {
if ( ! $id )
$id = get_the_ID();
global $sportspress_countries;
$options = get_option( 'sportspress' );
$defaults = array(
'show_nationality_flag' => sportspress_array_value( $options, 'player_show_nationality_flag', true ),
);
$r = wp_parse_args( $args, $defaults );
$nationality = get_post_meta( $id, 'sp_nationality', true );
$current_team = get_post_meta( $id, 'sp_current_team', true );
$past_teams = get_post_meta( $id, 'sp_past_team', false );
@@ -15,7 +23,7 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) {
$common = array();
if ( $nationality ):
$country_name = sportspress_array_value( $sportspress_countries, $nationality, null );
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? '<img src="' . SPORTSPRESS_PLUGIN_URL . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' . $country_name : '&mdash;';
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $r['show_nationality_flag'] ? '<img src="' . SPORTSPRESS_PLUGIN_URL . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '&mdash;';
endif;
$data = array_merge( $common, $metrics );