Display player number in title and flag next to country name
This commit is contained in:
11
admin/hooks/the-title.php
Normal file
11
admin/hooks/the-title.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
function sportspress_the_title( $title, $id ) {
|
||||
if ( is_singular( 'sp_player' ) && in_the_loop() && $id == get_the_ID() ):
|
||||
$number = get_post_meta( $id, 'sp_number', true );
|
||||
if ( $number != null ):
|
||||
$title = '<strong>' . $number . '</strong> ' . $title;
|
||||
endif;
|
||||
endif;
|
||||
return $title;
|
||||
}
|
||||
add_filter( 'the_title', 'sportspress_the_title', 10, 2 );
|
||||
@@ -7,18 +7,16 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) {
|
||||
|
||||
global $sportspress_countries;
|
||||
|
||||
$number = get_post_meta( $id, 'sp_number', true );
|
||||
$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 );
|
||||
$metrics = sportspress_get_player_metrics_data( $id );
|
||||
|
||||
$common = array();
|
||||
|
||||
if ( $number != null )
|
||||
$common[ __( 'Number', 'sportspress' ) ] = $number;
|
||||
if ( $nationality )
|
||||
$common[ __( 'Nationality', 'sportspress' ) ] = sportspress_array_value( $sportspress_countries, $nationality, '—' );
|
||||
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 : '—';
|
||||
endif;
|
||||
|
||||
$data = array_merge( $common, $metrics );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user