From 2fb3455a530eb3fc2ef468cacb7f169e8596ec6d Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 1 May 2018 22:11:38 +1000 Subject: [PATCH] Add short name setting --- .../class-sp-meta-box-team-details.php | 5 ++++ includes/sp-api-functions.php | 27 ++++++++++++------- includes/sp-deprecated-functions.php | 17 ++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php index c9845457..c0fe4e8b 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php @@ -51,6 +51,7 @@ class SP_Meta_Box_Team_Details { endif; endif; + $short_name = get_post_meta( $post->ID, 'sp_short_name', true ); $abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true ); $redirect = get_post_meta( $post->ID, 'sp_redirect', true ); $url = get_post_meta( $post->ID, 'sp_url', true ); @@ -111,6 +112,9 @@ class SP_Meta_Box_Team_Details {

+

+

+

$post ) ); } -function sp_get_short_name( $post = 0 ) { - $abbreviation = sp_get_abbreviation( $post, 'sp_abbreviation', true ); +function sp_team_abbreviation( $post = 0 ) { + $abbreviation = get_post_meta( $post, 'sp_abbreviation', true ); if ( $abbreviation ) { return $abbreviation; + } else { + return sp_team_short_name( $post ); + } +} + +function sp_the_abbreviation( $post = 0 ) { + echo sp_team_abbreviation( $post ); +} + +function sp_team_short_name( $post = 0 ) { + $short_name = get_post_meta( $post, 'sp_short_name', true ); + if ( $short_name ) { + return $short_name; } else { return get_the_title( $post ); } } -function sp_short_name( $post = 0 ) { - echo sp_get_short_name( $post ); +function sp_the_short_name( $post = 0 ) { + echo sp_team_short_name( $post ); } function sp_get_team_name( $post = 0, $short = true ) { if ( $short ) { - return sp_get_short_name( $post ); + return sp_team_abbreviation( $post ); } else { return get_the_title( $post ); } diff --git a/includes/sp-deprecated-functions.php b/includes/sp-deprecated-functions.php index 8784bb2a..4be806a3 100644 --- a/includes/sp-deprecated-functions.php +++ b/includes/sp-deprecated-functions.php @@ -203,3 +203,20 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) { return $list->data( $admin ); } } + +if ( !function_exists( 'sp_get_short_name' ) ) { + function sp_get_short_name( $post = 0 ) { + $abbreviation = sp_get_abbreviation( $post, 'sp_abbreviation', true ); + if ( $abbreviation ) { + return $abbreviation; + } else { + return get_the_title( $post ); + } + } +} + +if ( !function_exists( 'sp_short_name' ) ) { + function sp_short_name( $post = 0 ) { + echo sp_get_short_name( $post ); + } +}