Display player number in title and flag next to country name

This commit is contained in:
Brian Miyaji
2014-03-08 03:16:56 +11:00
parent 0d813cd986
commit 68ad967262
203 changed files with 16 additions and 6 deletions

11
admin/hooks/the-title.php Normal file
View 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 );

View File

@@ -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, '&mdash;' );
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;';
endif;
$data = array_merge( $common, $metrics );