Option to display national flag in player profile
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
<?php
|
||||
function sportspress_player_settings_nationality_callback() {
|
||||
$options = get_option( 'sportspress' );
|
||||
|
||||
$show_nationality_flag = sportspress_array_value( $options, 'player_show_nationality_flag', true );
|
||||
?>
|
||||
<fieldset>
|
||||
<label for="sportspress_player_show_nationality_flag">
|
||||
<input id="sportspress_player_show_nationality_flag_default" name="sportspress[player_show_nationality_flag]" type="hidden" value="0">
|
||||
<input id="sportspress_player_show_nationality_flag" name="sportspress[player_show_nationality_flag]" type="checkbox" value="1" <?php checked( $show_nationality_flag ); ?>>
|
||||
<?php _e( 'Display flag', 'sportspress' ); ?>
|
||||
</label>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
function sportspress_player_settings_metrics_callback() {
|
||||
$args = array(
|
||||
'post_type' => 'sp_metric',
|
||||
@@ -103,6 +118,14 @@ function sportspress_player_settings_init() {
|
||||
'sportspress_players'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'nationality',
|
||||
__( 'Nationality', 'sportspress' ),
|
||||
'sportspress_player_settings_nationality_callback',
|
||||
'sportspress_players',
|
||||
'players'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'metrics',
|
||||
__( 'Metrics', 'sportspress' ),
|
||||
|
||||
@@ -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 : '—';
|
||||
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $r['show_nationality_flag'] ? '<img src="' . SPORTSPRESS_PLUGIN_URL . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||
endif;
|
||||
|
||||
$data = array_merge( $common, $metrics );
|
||||
|
||||
Reference in New Issue
Block a user