From 00d6c1873b31ebeddda1caf6d41cc61fe4d5e603 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sun, 27 Sep 2015 11:54:39 +1000 Subject: [PATCH] Add player number and name API functions --- includes/sp-api-functions.php | 14 ++++++++++++++ includes/sp-core-functions.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/sp-api-functions.php b/includes/sp-api-functions.php index a45f0dd5..81ac95b5 100644 --- a/includes/sp-api-functions.php +++ b/includes/sp-api-functions.php @@ -230,6 +230,20 @@ function sp_league_table( $post = 0 ) { * Player functions */ +function sp_get_player_number( $post = 0 ) { + $player = new SP_Player( $post ); + return $player->number; +} + +function sp_get_player_name_with_number( $post = 0, $prepend = '', $append = '. ' ) { + $number = sp_get_player_number( $post ); + if ( isset( $number ) && '' !== $number ) { + return $prepend . $number . $append . get_the_title( $post ); + } else { + return get_the_title( $post ); + } +} + function sp_player_details( $post = 0 ) { sp_get_template( 'player-details.php', array( 'id' => $post ) ); } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index a7a1d892..57334afe 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -838,7 +838,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
  • ', sizeof( $parents ) ); ?> ', sizeof( $parents ) ); ?>